summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DeviceAdminSettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/DeviceAdminSettings.java')
-rw-r--r--src/com/android/settings/DeviceAdminSettings.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 9cfb44d9d..fa1c7f464 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -43,8 +43,10 @@ import android.widget.TextView;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
public class DeviceAdminSettings extends ListFragment {
static final String TAG = "DeviceAdminSettings";
@@ -91,8 +93,33 @@ public class DeviceAdminSettings extends ListFragment {
List<ResolveInfo> avail = getActivity().getPackageManager().queryBroadcastReceivers(
new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED),
PackageManager.GET_META_DATA | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
- int count = avail == null ? 0 : avail.size();
- for (int i=0; i<count; i++) {
+ if (avail == null) {
+ avail = Collections.emptyList();
+ }
+
+ // Some admins listed in mActiveAdmins may not have been found by the above query.
+ // We thus add them separately.
+ Set<ComponentName> activeAdminsNotInAvail = new HashSet<ComponentName>(mActiveAdmins);
+ for (ResolveInfo ri : avail) {
+ ComponentName riComponentName =
+ new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
+ activeAdminsNotInAvail.remove(riComponentName);
+ }
+ if (!activeAdminsNotInAvail.isEmpty()) {
+ avail = new ArrayList<ResolveInfo>(avail);
+ PackageManager packageManager = getActivity().getPackageManager();
+ for (ComponentName unlistedActiveAdmin : activeAdminsNotInAvail) {
+ List<ResolveInfo> resolved = packageManager.queryBroadcastReceivers(
+ new Intent().setComponent(unlistedActiveAdmin),
+ PackageManager.GET_META_DATA
+ | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
+ if (resolved != null) {
+ avail.addAll(resolved);
+ }
+ }
+ }
+
+ for (int i = 0, count = avail.size(); i < count; i++) {
ResolveInfo ri = avail.get(i);
try {
DeviceAdminInfo dpi = new DeviceAdminInfo(getActivity(), ri);