OSDN Git Service

Make Context.getClassLoader() work. [DO NOT MERGE]
authorDeepanshu Gupta <deepanshu@google.com>
Tue, 19 May 2015 01:47:07 +0000 (18:47 -0700)
committerDeepanshu Gupta <deepanshu@google.com>
Tue, 25 Aug 2015 19:06:43 +0000 (12:06 -0700)
commitafedbc47b3c8f3fa9955496e6ceb7f5702dd90a3
tree2046fbcf31f9c9747959f9d303d76c9f3317cf8e
parent92480a9ad89a813bdf36185fa8c4d227d8415b4c
Make Context.getClassLoader() work. [DO NOT MERGE]

Context.getClassLoader() is used by the LayoutInflater and can be used
by custom views. However, when called from the LayoutInflater, this
needs to return only the Framework classes. This is so that the IDE gets
a chance to instantiate the custom views, which helps in better error
reporting and better fallback in case of exceptions, like MockView.

To workaround this need of the same method returning different results
based on where it's called from, the method call in LayoutInflater is
renamed to getFrameworkClassLoader() and the new method is injected in
Context. The implementation of getFrameworkClassLoader() maintains the
existing behaviour of getClassLoader().

Context.getClassLoader() is now modified to return classes from both
Framework and the app namespace.

Also, update the list of packages to search for Framework views.

Change-Id: I1a6be4aa1fc5c1c5520b5440a348a52f10b6eb3b
(cherry picked from commit f8ea750455eec81e4e6d877b3e18e29a86d4ec95)
tools/layoutlib/bridge/src/android/view/BridgeInflater.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/InjectMethodRunnables.java [new file with mode: 0644]
tools/layoutlib/create/src/com/android/tools/layoutlib/create/InjectMethodsAdapter.java [new file with mode: 0644]
tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java