summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DeviceAdminAdd.java
diff options
context:
space:
mode:
authorAlex Klyubin <klyubin@google.com>2013-06-06 15:45:23 -0700
committerAlex Klyubin <klyubin@google.com>2013-06-06 15:45:23 -0700
commit681b21f3e4ef0a63d982eca0e9d1896422bc30ff (patch)
tree7d7dd36c3522ac19a9f9f9fa114268aa0de8a3e4 /src/com/android/settings/DeviceAdminAdd.java
parent56604046c5c46087aa5320d7c6aa6eb49c313637 (diff)
parent5d21820a979cac6d9a7426b5a5aed4b65e3cc67b (diff)
downloadpackages_apps_Settings-681b21f3e4ef0a63d982eca0e9d1896422bc30ff.zip
packages_apps_Settings-681b21f3e4ef0a63d982eca0e9d1896422bc30ff.tar.gz
packages_apps_Settings-681b21f3e4ef0a63d982eca0e9d1896422bc30ff.tar.bz2
resolved conflicts for merge of 5d21820a to jb-mr2-dev
Change-Id: If371a4571c5440ce2a0b4339f97893bf78832b31
Diffstat (limited to 'src/com/android/settings/DeviceAdminAdd.java')
-rw-r--r--src/com/android/settings/DeviceAdminAdd.java56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 27e7a54..6234038 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),
- PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
- 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),
+ PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
+ 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();