OSDN Git Service

Fix: handle null value for packageUsageInfo while deciding unused apps
authorShubham Ajmera <shubhamajmera@google.com>
Tue, 18 Jul 2017 22:04:28 +0000 (15:04 -0700)
committerShubham Ajmera <shubhamajmera@google.com>
Tue, 18 Jul 2017 22:26:39 +0000 (15:26 -0700)
Bug: 36598475
Test: Verified for AOSP calculator
Change-Id: I86633a729ae34c621f9026fcf0486f2c0a5c7e4c

services/core/java/com/android/server/pm/PackageManagerServiceUtils.java

index 9211af6..a7031c9 100644 (file)
@@ -209,10 +209,12 @@ public class PackageManagerServiceUtils {
 
         // If the app was active in background during the threshold period and was used
         // by other packages.
+        // If packageUseInfo is null, it can be said that the package was not used by other
+        // packages.
         boolean isActiveInBackgroundAndUsedByOtherPackages = ((currentTimeInMillis
                 - latestPackageUseTimeInMillis)
                 < thresholdTimeinMillis)
-                && packageUseInfo.isUsedByOtherApps();
+                && (packageUseInfo != null && packageUseInfo.isUsedByOtherApps());
 
         return !isActiveInBackgroundAndUsedByOtherPackages;
     }