From cb247866acf10b039e02b600f8471b4a508f0ce8 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Wed, 25 Sep 2013 23:52:36 -0700 Subject: [PATCH] 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 --- .../java/com/android/server/print/PrintManagerService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/java/com/android/server/print/PrintManagerService.java b/services/java/com/android/server/print/PrintManagerService.java index 5f8708acb3973..9810bf0d99086 100644 --- a/services/java/com/android/server/print/PrintManagerService.java +++ b/services/java/com/android/server/print/PrintManagerService.java @@ -413,6 +413,10 @@ public final class PrintManagerService extends IPrintManager.Stub { .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;