Don't crash in AccountManagerService if a uid has no packages
PackageManagerService.getPackagesForUid() may return null
BUG:31544109
Change-Id: I8ce45b5462154ac53cf5930e1889cf5d2fa486f4
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 48e9ac7..b152372 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -928,14 +928,16 @@
String interestedPackages = null;
try {
String[] allPackages = mPackageManager.getPackagesForUid(uid);
- for(String aPackage : allPackages) {
- ApplicationInfo ai = mPackageManager.getApplicationInfo(aPackage,
- PackageManager.GET_META_DATA);
- Bundle b = ai.metaData;
- if(b == null) {
- return;
+ if (allPackages != null) {
+ for(String aPackage : allPackages) {
+ ApplicationInfo ai = mPackageManager.getApplicationInfo(aPackage,
+ PackageManager.GET_META_DATA);
+ Bundle b = ai.metaData;
+ if(b == null) {
+ return;
+ }
+ interestedPackages = b.getString("android.accounts.SupportedLoginTypes");
}
- interestedPackages = b.getString("android.accounts.SupportedLoginTypes");
}
} catch (PackageManager.NameNotFoundException e) {
Log.d("NameNotFoundException", e.getMessage());