diff options
| author | Derek Sollenberger <djsollen@google.com> | 2010-08-23 14:51:41 -0400 |
|---|---|---|
| committer | Derek Sollenberger <djsollen@google.com> | 2010-08-24 09:31:59 -0400 |
| commit | 41d5e93bbdff5dc6383ebd9391e3f1c492dee215 (patch) | |
| tree | 9c0dfd37243eddb4ef6c98c682cb06ae42d5bda8 /core/java/android/webkit/PluginManager.java | |
| parent | f52435569c15d6c8c09a6bc95fca27139359f5cb (diff) | |
Move APK monitoring into WebView.
This CL adds the monitoring logic that was removed from the Browser
in a companion CL. This allows applications other than the Browser
to use special features offered by YouTube and plugins. Additionally,
the pluginManager was refactored to prevent code duplication between
the manager and WebView.
Change-Id: Ie37f248c8edd9d06ae1fd6675dd5f06f04774b09
http://b/2834603
Diffstat (limited to 'core/java/android/webkit/PluginManager.java')
| -rw-r--r-- | core/java/android/webkit/PluginManager.java | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/core/java/android/webkit/PluginManager.java b/core/java/android/webkit/PluginManager.java index cdcb662e057c..f7d1134d94d6 100644 --- a/core/java/android/webkit/PluginManager.java +++ b/core/java/android/webkit/PluginManager.java @@ -149,41 +149,11 @@ public class PluginManager { continue; } - // check if the plugin has the required permissions - String permissions[] = pkgInfo.requestedPermissions; - if (permissions == null) { + // check if the plugin has the required permissions and + // signatures + if (!containsPluginPermissionAndSignatures(pkgInfo)) { continue; } - boolean permissionOk = false; - for (String permit : permissions) { - if (PLUGIN_PERMISSION.equals(permit)) { - permissionOk = true; - break; - } - } - if (!permissionOk) { - continue; - } - - // check to ensure the plugin is properly signed - Signature signatures[] = pkgInfo.signatures; - if (signatures == null) { - continue; - } - if (SystemProperties.getBoolean("ro.secure", false)) { - boolean signatureMatch = false; - for (Signature signature : signatures) { - for (int i = 0; i < SIGNATURES.length; i++) { - if (SIGNATURES[i].equals(signature)) { - signatureMatch = true; - break; - } - } - } - if (!signatureMatch) { - continue; - } - } // determine the type of plugin from the manifest if (serviceInfo.metaData == null) { @@ -226,6 +196,64 @@ public class PluginManager { } /* package */ + boolean containsPluginPermissionAndSignatures(String pluginAPKName) { + PackageManager pm = mContext.getPackageManager(); + + // retrieve information from the plugin's manifest + try { + PackageInfo pkgInfo = pm.getPackageInfo(pluginAPKName, PackageManager.GET_PERMISSIONS + | PackageManager.GET_SIGNATURES); + if (pkgInfo != null) { + return containsPluginPermissionAndSignatures(pkgInfo); + } + } catch (NameNotFoundException e) { + Log.w(LOGTAG, "Can't find plugin: " + pluginAPKName); + } + return false; + } + + private static boolean containsPluginPermissionAndSignatures(PackageInfo pkgInfo) { + + // check if the plugin has the required permissions + String permissions[] = pkgInfo.requestedPermissions; + if (permissions == null) { + return false; + } + boolean permissionOk = false; + for (String permit : permissions) { + if (PLUGIN_PERMISSION.equals(permit)) { + permissionOk = true; + break; + } + } + if (!permissionOk) { + return false; + } + + // check to ensure the plugin is properly signed + Signature signatures[] = pkgInfo.signatures; + if (signatures == null) { + return false; + } + if (SystemProperties.getBoolean("ro.secure", false)) { + boolean signatureMatch = false; + for (Signature signature : signatures) { + for (int i = 0; i < SIGNATURES.length; i++) { + if (SIGNATURES[i].equals(signature)) { + signatureMatch = true; + break; + } + } + } + if (!signatureMatch) { + return false; + } + } + + return true; + } + + /* package */ String getPluginsAPKName(String pluginLib) { // basic error checking on input params |
