[PackageUsage] fix NPE
This is called by `mPm.getPackageUsage().maybeWriteAsync(mPm.mSettings.getPackagesLocked())` under `mPm.mLock` so it's unclear why any pkgSetting would be null. Perhaps there are other usages not shown in the stack trace. Adding null pointer checks to avoid crashes. BUG: 229823551 Test: builds Change-Id: Ia33bb59824e774b02249a1e9872bc6e418dec658
This commit is contained in:
@@ -66,7 +66,8 @@ class PackageUsage extends AbstractStatsBase<Map<String, PackageSetting>> {
|
||||
out.write(sb.toString().getBytes(StandardCharsets.US_ASCII));
|
||||
|
||||
for (PackageSetting pkgSetting : pkgSettings.values()) {
|
||||
if (pkgSetting.getPkgState().getLatestPackageUseTimeInMills() == 0L) {
|
||||
if (pkgSetting == null || pkgSetting.getPkgState() == null
|
||||
|| pkgSetting.getPkgState().getLatestPackageUseTimeInMills() == 0L) {
|
||||
continue;
|
||||
}
|
||||
sb.setLength(0);
|
||||
|
||||
Reference in New Issue
Block a user