diff options
| author | 2024-03-26 22:18:09 +0000 | |
|---|---|---|
| committer | 2024-04-11 21:13:50 +0000 | |
| commit | b4fd5ab3e0246d008159e7a0bbda36812e65572c (patch) | |
| tree | 3e67f9b1248725376e18596e9b55060be0094e0c | |
| parent | a90f38ae6d720e8da87cf81b925b6fd3ec51eda8 (diff) | |
Hook up AppStartInfo app provided timestamps
Complete passing from AMS to tracker
Also add cross user check for other AppStartInfo methods
Bug: 325776365
Test: new cts tests
Change-Id: Ied7430051461990ef3737ac5aa7ceb9809f7ead2
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 27 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/AppStartInfoTracker.java | 2 |
2 files changed, 25 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8022eb37fce7..73ce47c9536f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -10167,7 +10167,11 @@ public class ActivityManagerService extends IActivityManager.Stub } final int callingUid = Binder.getCallingUid(); - mProcessList.getAppStartInfoTracker().addStartInfoCompleteListener(listener, callingUid); + mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId, true, + ALLOW_NON_FULL, "addApplicationStartInfoCompleteListener", null); + + mProcessList.getAppStartInfoTracker().addStartInfoCompleteListener(listener, + UserHandle.getUid(userId, UserHandle.getAppId(callingUid))); } @@ -10182,13 +10186,30 @@ public class ActivityManagerService extends IActivityManager.Stub } final int callingUid = Binder.getCallingUid(); - mProcessList.getAppStartInfoTracker().removeStartInfoCompleteListener(listener, callingUid, - true); + mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId, true, + ALLOW_NON_FULL, "removeApplicationStartInfoCompleteListener", null); + + mProcessList.getAppStartInfoTracker().removeStartInfoCompleteListener(listener, + UserHandle.getUid(userId, UserHandle.getAppId(callingUid)), true); } @Override public void addStartInfoTimestamp(int key, long timestampNs, int userId) { enforceNotIsolatedCaller("addStartInfoTimestamp"); + + // For the simplification, we don't support USER_ALL nor USER_CURRENT here. + if (userId == UserHandle.USER_ALL || userId == UserHandle.USER_CURRENT) { + throw new IllegalArgumentException("Unsupported userId"); + } + + final int callingUid = Binder.getCallingUid(); + mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId, true, + ALLOW_NON_FULL, "addStartInfoTimestamp", null); + + final String packageName = Settings.getPackageNameForUid(mContext, callingUid); + + mProcessList.getAppStartInfoTracker().addTimestampToStart(packageName, + UserHandle.getUid(userId, UserHandle.getAppId(callingUid)), timestampNs, key); } @Override diff --git a/services/core/java/com/android/server/am/AppStartInfoTracker.java b/services/core/java/com/android/server/am/AppStartInfoTracker.java index ddf1d5f5ab71..0728ea8e5604 100644 --- a/services/core/java/com/android/server/am/AppStartInfoTracker.java +++ b/services/core/java/com/android/server/am/AppStartInfoTracker.java @@ -464,7 +464,7 @@ public final class AppStartInfoTracker { addTimestampToStart(app.info.packageName, app.uid, timeNs, key); } - private void addTimestampToStart(String packageName, int uid, long timeNs, int key) { + void addTimestampToStart(String packageName, int uid, long timeNs, int key) { synchronized (mLock) { AppStartInfoContainer container = mData.get(packageName, uid); if (container == null) { |