summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/PackageManagerInternal.java5
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java6
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java21
3 files changed, 23 insertions, 9 deletions
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java
index e8bade9b2c94..4c981cdb2511 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -378,4 +378,9 @@ public abstract class PackageManagerInternal {
* associated with an instant app. It may be kept after the instant app has been uninstalled.
*/
public abstract boolean hasInstantApplicationMetadata(String packageName, int userId);
+
+ /**
+ * Updates a package last used time.
+ */
+ public abstract void notifyPackageUse(String packageName, int reason);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 810a6bfd89a3..ae0910ce716b 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3588,10 +3588,8 @@ public class ActivityManagerService extends IActivityManager.Stub
}
void notifyPackageUse(String packageName, int reason) {
- IPackageManager pm = AppGlobals.getPackageManager();
- try {
- pm.notifyPackageUse(packageName, reason);
- } catch (RemoteException e) {
+ synchronized(this) {
+ getPackageManagerInternalLocked().notifyPackageUse(packageName, reason);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index bafcad4b775f..20fb3501031a 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -9844,12 +9844,16 @@ public class PackageManagerService extends IPackageManager.Stub
return;
}
}
- final PackageParser.Package p = mPackages.get(packageName);
- if (p == null) {
- return;
- }
- p.mLastPackageUsageTimeInMills[reason] = System.currentTimeMillis();
+ notifyPackageUseLocked(packageName, reason);
+ }
+ }
+
+ private void notifyPackageUseLocked(String packageName, int reason) {
+ final PackageParser.Package p = mPackages.get(packageName);
+ if (p == null) {
+ return;
}
+ p.mLastPackageUsageTimeInMills[reason] = System.currentTimeMillis();
}
@Override
@@ -25502,6 +25506,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
return mInstantAppRegistry.hasInstantApplicationMetadataLPr(packageName, userId);
}
}
+
+ @Override
+ public void notifyPackageUse(String packageName, int reason) {
+ synchronized (mPackages) {
+ PackageManagerService.this.notifyPackageUseLocked(packageName, reason);
+ }
+ }
}
@Override