PackageManager#queryIntentServices breaks its contract.
PackageManager#queryIntentServices javadoc contract states that this
method (and the like) never returns null, rather an empty list if
no result is found. However, there is a path in the PackageManagerService
that returns null, thus breaking the contract. Handling the null list
explicitly.
bug:10930560
Change-Id: I708c51b8b7075e529145c8b0bf159efd6b697532
diff --git a/services/java/com/android/server/print/PrintManagerService.java b/services/java/com/android/server/print/PrintManagerService.java
index 5f8708a..9810bf0 100644
--- a/services/java/com/android/server/print/PrintManagerService.java
+++ b/services/java/com/android/server/print/PrintManagerService.java
@@ -413,6 +413,10 @@
.queryIntentServicesAsUser(intent, PackageManager.GET_SERVICES,
getChangingUserId());
+ if (installedServices == null) {
+ return;
+ }
+
final int installedServiceCount = installedServices.size();
for (int i = 0; i < installedServiceCount; i++) {
ServiceInfo serviceInfo = installedServices.get(i).serviceInfo;