diff options
author | Alex Klyubin <klyubin@google.com> | 2013-06-06 14:56:24 -0700 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2013-06-06 14:56:24 -0700 |
commit | 29de9d5153075b33717ba18a0c13c84ea4ba34f3 (patch) | |
tree | 76365d4104d6a7735822cf9491c4b003e09814c1 /src/com/android/settings/DeviceAdminAdd.java | |
parent | d60861258169083f3174734af821fc8078ec5d2f (diff) | |
download | packages_apps_Settings-29de9d5153075b33717ba18a0c13c84ea4ba34f3.zip packages_apps_Settings-29de9d5153075b33717ba18a0c13c84ea4ba34f3.tar.gz packages_apps_Settings-29de9d5153075b33717ba18a0c13c84ea4ba34f3.tar.bz2 |
Permit deactivation of malformed Device Admins.
Bug: 9074296
Change-Id: I4a3b2f972cb297b9f985a762219c8d67d8e3a425
Diffstat (limited to 'src/com/android/settings/DeviceAdminAdd.java')
-rw-r--r-- | src/com/android/settings/DeviceAdminAdd.java | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index c0d615c..f668a63 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -116,34 +116,38 @@ public class DeviceAdminAdd extends Activity { return; } - // Make sure the given component name is actually a valid device admin. - List<ResolveInfo> avail = getPackageManager().queryBroadcastReceivers( - new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED), - 0); - int count = avail == null ? 0 : avail.size(); - boolean found = false; - for (int i=0; i<count; i++) { - ResolveInfo ri = avail.get(i); - if (ai.packageName.equals(ri.activityInfo.packageName) - && ai.name.equals(ri.activityInfo.name)) { - try { - // We didn't retrieve the meta data for all possible matches, so - // need to use the activity info of this specific one that was retrieved. - ri.activityInfo = ai; - DeviceAdminInfo dpi = new DeviceAdminInfo(this, ri); - found = true; - } catch (XmlPullParserException e) { - Log.w(TAG, "Bad " + ri.activityInfo, e); - } catch (IOException e) { - Log.w(TAG, "Bad " + ri.activityInfo, e); + // When activating, make sure the given component name is actually a valid device admin. + // No need to check this when deactivating, because it is safe to deactivate an active + // invalid device admin. + if (!mDPM.isAdminActive(cn)) { + List<ResolveInfo> avail = getPackageManager().queryBroadcastReceivers( + new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED), + 0); + int count = avail == null ? 0 : avail.size(); + boolean found = false; + for (int i=0; i<count; i++) { + ResolveInfo ri = avail.get(i); + if (ai.packageName.equals(ri.activityInfo.packageName) + && ai.name.equals(ri.activityInfo.name)) { + try { + // We didn't retrieve the meta data for all possible matches, so + // need to use the activity info of this specific one that was retrieved. + ri.activityInfo = ai; + DeviceAdminInfo dpi = new DeviceAdminInfo(this, ri); + found = true; + } catch (XmlPullParserException e) { + Log.w(TAG, "Bad " + ri.activityInfo, e); + } catch (IOException e) { + Log.w(TAG, "Bad " + ri.activityInfo, e); + } + break; } - break; } - } - if (!found) { - Log.w(TAG, "Request to add invalid device admin: " + cn); - finish(); - return; + if (!found) { + Log.w(TAG, "Request to add invalid device admin: " + cn); + finish(); + return; + } } ResolveInfo ri = new ResolveInfo(); |