Fixed NPE in ActivityManager's launch count service.
Bug: 3497127
Change-Id: I38661fb0654e807f05cc57e43cff912de8d39096
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 77dc084..930c6b0 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -1253,8 +1253,13 @@
return new HashMap<String, Integer>();
}
+ PkgUsageStats[] allPkgUsageStats = usageStatsService.getAllPkgUsageStats();
+ if (allPkgUsageStats == null) {
+ return new HashMap<String, Integer>();
+ }
+
Map<String, Integer> launchCounts = new HashMap<String, Integer>();
- for (PkgUsageStats pkgUsageStats : usageStatsService.getAllPkgUsageStats()) {
+ for (PkgUsageStats pkgUsageStats : allPkgUsageStats) {
launchCounts.put(pkgUsageStats.packageName, pkgUsageStats.launchCount);
}