summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/PluginUtil.java
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-11-09 14:45:58 -0500
committerDerek Sollenberger <djsollen@google.com>2009-11-09 14:45:58 -0500
commit9e28c4ce666f1b8c5e5355d739e37480856ef509 (patch)
treeba5b9139d7ed17941421255b5577835fb0371da8 /core/java/android/webkit/PluginUtil.java
parent0e983864fca215513de9664573dcc3bbadf41e79 (diff)
downloadframeworks_base-9e28c4ce666f1b8c5e5355d739e37480856ef509.zip
frameworks_base-9e28c4ce666f1b8c5e5355d739e37480856ef509.tar.gz
frameworks_base-9e28c4ce666f1b8c5e5355d739e37480856ef509.tar.bz2
Allow plugins to load java classes from their apk.
Provide the functions to be called from native code that take the plugin's location and desired class name and then load that class from the plugin's apk if it is available. see http://b/2215696
Diffstat (limited to 'core/java/android/webkit/PluginUtil.java')
-rw-r--r--core/java/android/webkit/PluginUtil.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/java/android/webkit/PluginUtil.java b/core/java/android/webkit/PluginUtil.java
index 8fdbd67..33ccf9d 100644
--- a/core/java/android/webkit/PluginUtil.java
+++ b/core/java/android/webkit/PluginUtil.java
@@ -19,9 +19,6 @@ import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
class PluginUtil {
private static final String LOGTAG = "PluginUtil";
@@ -35,12 +32,7 @@ class PluginUtil {
static PluginStub getPluginStub(Context context, String packageName,
String className) {
try {
- Context pluginContext = context.createPackageContext(packageName,
- Context.CONTEXT_INCLUDE_CODE |
- Context.CONTEXT_IGNORE_SECURITY);
- ClassLoader pluginCL = pluginContext.getClassLoader();
-
- Class<?> stubClass = pluginCL.loadClass(className);
+ Class<?> stubClass = getPluginClass(context, packageName, className);
Object stubObject = stubClass.newInstance();
if (stubObject instanceof PluginStub) {
@@ -56,4 +48,14 @@ class PluginUtil {
}
return null;
}
+
+ /* package */
+ static Class<?> getPluginClass(Context context, String packageName,
+ String className) throws NameNotFoundException, ClassNotFoundException {
+ Context pluginContext = context.createPackageContext(packageName,
+ Context.CONTEXT_INCLUDE_CODE |
+ Context.CONTEXT_IGNORE_SECURITY);
+ ClassLoader pluginCL = pluginContext.getClassLoader();
+ return pluginCL.loadClass(className);
+ }
}