summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DeviceAdminSettings.java
diff options
context:
space:
mode:
authorAlex Klyubin <klyubin@google.com>2013-05-22 09:06:35 -0700
committerAlex Klyubin <klyubin@google.com>2013-05-22 09:08:53 -0700
commitd14258e50efc3677abef3cd204b67e7f26e47b56 (patch)
tree522c23af24276d2704505c315d17972e1381f0ba /src/com/android/settings/DeviceAdminSettings.java
parent0b2781ae537e6d3d27863080eea0a0a5fa6c83b8 (diff)
downloadpackages_apps_Settings-d14258e50efc3677abef3cd204b67e7f26e47b56.tar.gz
packages_apps_Settings-d14258e50efc3677abef3cd204b67e7f26e47b56.tar.bz2
packages_apps_Settings-d14258e50efc3677abef3cd204b67e7f26e47b56.zip
Ensure all active Device Admins are listed.
Bug: 9074296 Change-Id: Ifb70c12ccea6628042b98a18186816887cb4477b
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);