OSDN Git Service

More encryption-aware triaging.
authorJeff Sharkey <jsharkey@android.com>
Tue, 9 Feb 2016 22:56:11 +0000 (15:56 -0700)
committerJeff Sharkey <jsharkey@android.com>
Tue, 9 Feb 2016 22:56:13 +0000 (15:56 -0700)
Most of these callers are okay having results omitted when a package
is uninstalled or encryption unaware.  For example, jobs and
notifications can only be enqueued by already running apps.

When clearing zen rules, keep around rules inserted by apps on
ejected external storage devices.

Make ServiceWatcher stricter by requiring that the matching package
be in the system image.

Bug: 2647120527105254
Change-Id: Ie41ea8042ac1a54e9cbe0c35cec89e70521e9bed

core/java/android/app/LoadedApk.java
core/java/android/app/SearchableInfo.java
services/core/java/com/android/server/ServiceWatcher.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/job/JobSchedulerService.java
services/core/java/com/android/server/notification/NotificationManagerService.java
services/core/java/com/android/server/notification/ZenModeHelper.java

index da52c1e..8717353 100644 (file)
@@ -447,7 +447,8 @@ public final class LoadedApk {
         IPackageManager pm = ActivityThread.getPackageManager();
         android.content.pm.PackageInfo pi;
         try {
-            pi = pm.getPackageInfo(mPackageName, 0, UserHandle.myUserId());
+            pi = pm.getPackageInfo(mPackageName, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
+                    UserHandle.myUserId());
         } catch (RemoteException e) {
             throw new IllegalStateException("Unable to get package info for "
                     + mPackageName + "; is system dying?", e);
index c7d2140..a952915 100644 (file)
@@ -363,7 +363,8 @@ public final class SearchableInfo implements Parcelable {
         String suggestProviderPackage = null;
         if (mSuggestAuthority != null) {
             PackageManager pm = activityContext.getPackageManager();
-            ProviderInfo pi = pm.resolveContentProvider(mSuggestAuthority, 0);
+            ProviderInfo pi = pm.resolveContentProvider(mSuggestAuthority,
+                    PackageManager.MATCH_DEBUG_TRIAGED_MISSING);
             if (pi != null) {
                 suggestProviderPackage = pi.packageName;
             }
index 9a773f2..383e25a 100644 (file)
@@ -92,9 +92,8 @@ public class ServiceWatcher implements ServiceConnection {
             String pkg = initialPackageNames.get(i);
             try {
                 HashSet<Signature> set = new HashSet<Signature>();
-                Signature[] sigs = pm.getPackageInfo(pkg,
-                        PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE
-                                | PackageManager.GET_SIGNATURES).signatures;
+                Signature[] sigs = pm.getPackageInfo(pkg, PackageManager.MATCH_SYSTEM_ONLY
+                        | PackageManager.GET_SIGNATURES).signatures;
                 set.addAll(Arrays.asList(sigs));
                 sigSets.add(set);
             } catch (NameNotFoundException e) {
index 9dae740..002feef 100644 (file)
@@ -10722,6 +10722,12 @@ public final class ActivityManagerService extends ActivityManagerNative
             return;
         }
 
+        // We're only interested in providers that are encryption unaware, and
+        // we don't care about uninstalled apps, since there's no way they're
+        // running at this point.
+        final int matchFlags = GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE
+                | MATCH_DEBUG_TRIAGED_MISSING;
+
         synchronized (this) {
             final int NP = mProcessNames.getMap().size();
             for (int ip = 0; ip < NP; ip++) {
@@ -10736,8 +10742,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                         try {
                             final String pkgName = app.pkgList.keyAt(ig);
                             final PackageInfo pkgInfo = AppGlobals.getPackageManager()
-                                    .getPackageInfo(pkgName,
-                                            GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE, userId);
+                                    .getPackageInfo(pkgName, matchFlags, userId);
                             if (pkgInfo != null && !ArrayUtils.isEmpty(pkgInfo.providers)) {
                                 for (ProviderInfo provInfo : pkgInfo.providers) {
                                     Log.v(TAG, "Installing " + provInfo);
index 4c26998..e5e86ac 100644 (file)
@@ -1024,7 +1024,8 @@ public class JobSchedulerService extends com.android.server.SystemService
             final IPackageManager pm = AppGlobals.getPackageManager();
             final ComponentName service = job.getService();
             try {
-                ServiceInfo si = pm.getServiceInfo(service, 0, UserHandle.getUserId(uid));
+                ServiceInfo si = pm.getServiceInfo(service,
+                        PackageManager.MATCH_DEBUG_TRIAGED_MISSING, UserHandle.getUserId(uid));
                 if (si == null) {
                     throw new IllegalArgumentException("No such service " + service);
                 }
index bf8e8fb..ba4547c 100644 (file)
@@ -3480,7 +3480,8 @@ public class NotificationManagerService extends SystemService {
         try {
             // TODO: it might be faster to return a boolean from package manager rather than the
             // whole application info. Revisit and make the API change.
-            ai = AppGlobals.getPackageManager().getApplicationInfo(pkg, 0, userId);
+            ai = AppGlobals.getPackageManager().getApplicationInfo(pkg,
+                    PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId);
             if (ai == null) {
                 Slog.w(TAG, "No application info for package " + pkg + " and user " + userId);
                 return false;
index bba0d40..383c1ab 100644 (file)
@@ -578,7 +578,8 @@ public class ZenModeHelper {
                     ZenRule rule = newConfig.automaticRules.get(newConfig.automaticRules.keyAt(i));
                     if (RULE_INSTANCE_GRACE_PERIOD < (currentTime - rule.creationTime)) {
                         try {
-                            mPm.getPackageInfo(rule.component.getPackageName(), 0);
+                            mPm.getPackageInfo(rule.component.getPackageName(),
+                                    PackageManager.MATCH_UNINSTALLED_PACKAGES);
                         } catch (PackageManager.NameNotFoundException e) {
                             newConfig.automaticRules.removeAt(i);
                         }