diff options
author | Adam Lesinski <adamlesinski@google.com> | 2014-08-11 15:03:32 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2014-08-12 20:25:37 +0000 |
commit | 9a0b289f060e68e42d3db0b843d55cf920f3da12 (patch) | |
tree | d4859fad956007459e0263aa9045b870ade4609c /services/usage/java/com/android/server | |
parent | 02b25e9ba6b5c15c3af08bf74ad70519fcbcd8ce (diff) | |
download | frameworks_base-9a0b289f060e68e42d3db0b843d55cf920f3da12.zip frameworks_base-9a0b289f060e68e42d3db0b843d55cf920f3da12.tar.gz frameworks_base-9a0b289f060e68e42d3db0b843d55cf920f3da12.tar.bz2 |
Fix NPE in UsageStats for new User
Bug:16946585
Change-Id: Ibd0d674681f3f49087305cea33ce7292f5d2229d
Diffstat (limited to 'services/usage/java/com/android/server')
-rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsService.java | 8 | ||||
-rw-r--r-- | services/usage/java/com/android/server/usage/UserUsageStatsService.java | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index c38391a..82e837d 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -311,11 +311,15 @@ public class UsageStatsService extends SystemService implements final int userId = UserHandle.getCallingUserId(); final long token = Binder.clearCallingIdentity(); try { - return new ParceledListSlice<>(UsageStatsService.this.queryUsageStats( - userId, bucketType, beginTime, endTime)); + final List<UsageStats> results = UsageStatsService.this.queryUsageStats( + userId, bucketType, beginTime, endTime); + if (results != null) { + return new ParceledListSlice<>(results); + } } finally { Binder.restoreCallingIdentity(token); } + return null; } @Override diff --git a/services/usage/java/com/android/server/usage/UserUsageStatsService.java b/services/usage/java/com/android/server/usage/UserUsageStatsService.java index 2dfd0f6..e489fb3 100644 --- a/services/usage/java/com/android/server/usage/UserUsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UserUsageStatsService.java @@ -181,7 +181,7 @@ class UserUsageStatsService { final List<UsageStats> results = mDatabase.queryUsageStats(bucketType, beginTime, endTime); if (DEBUG) { - Slog.d(TAG, mLogPrefix + "Results: " + results.size()); + Slog.d(TAG, mLogPrefix + "Results: " + (results == null ? 0 : results.size())); } return results; } |