OSDN Git Service

Crashing the system process is inadvisable
authorChristopher Tate <ctate@google.com>
Fri, 28 Aug 2015 17:55:14 +0000 (10:55 -0700)
committerChristopher Tate <ctate@google.com>
Fri, 28 Aug 2015 17:59:25 +0000 (10:59 -0700)
When asking for the set of services published by a package, it's
quite possible that there are none, in which case the returned List<>
is null rather than valid-but-empty.  Don't bother looking at it
when it's null.

Bug 23614440

Change-Id: Ibebb26b9c3f75ec810a95f1b9d2663e884cb98bc

services/backup/java/com/android/server/backup/BackupManagerService.java

index 7c74a30..12003e2 100644 (file)
@@ -1955,10 +1955,12 @@ public class BackupManagerService {
                 .setPackage(pkgInfo.packageName);
         List<ResolveInfo> hosts = mPackageManager.queryIntentServicesAsUser(
                 intent, 0, UserHandle.USER_OWNER);
-        final int N = hosts.size();
-        for (int i = 0; i < N; i++) {
-            final ServiceInfo info = hosts.get(i).serviceInfo;
-            tryBindTransport(info);
+        if (hosts != null) {
+            final int N = hosts.size();
+            for (int i = 0; i < N; i++) {
+                final ServiceInfo info = hosts.get(i).serviceInfo;
+                tryBindTransport(info);
+            }
         }
     }