diff options
| author | 2024-11-14 12:31:36 +0000 | |
|---|---|---|
| committer | 2024-11-15 10:03:56 +0000 | |
| commit | 4faf0ca3bb80f104614e6280f1933d8ff1ce689c (patch) | |
| tree | a3a21197ac6ec5d88ddfa63e69458d0f71a56bd5 | |
| parent | 261caa809debb19c7be8a70594da50c52efbe583 (diff) | |
Fix start info handling of isolated processes
Currently isolated process uids are stored in their own container.
This results in storing a large number of records that are not reasonable accessible.
As an initial remedy, simply discard the records for isolated processes.
This is done both when added, and when restored from disk so that old ones don't linger.
In the future, we may want to store these under the parent UID.
Bug: 374032823
Test: trigger isolated process start, confirm no record.
Flag: com.android.server.am.app_start_info_isolated_process
Change-Id: Icaeec18fb679c1e71ec9a0b250af7f5f4e18d87e
| -rw-r--r-- | services/core/java/com/android/server/am/AppStartInfoTracker.java | 25 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/flags.aconfig | 10 |
2 files changed, 32 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/AppStartInfoTracker.java b/services/core/java/com/android/server/am/AppStartInfoTracker.java index 3913d2f2ea92..961022b7231b 100644 --- a/services/core/java/com/android/server/am/AppStartInfoTracker.java +++ b/services/core/java/com/android/server/am/AppStartInfoTracker.java @@ -634,12 +634,20 @@ public final class AppStartInfoTracker { } final ApplicationStartInfo info = new ApplicationStartInfo(raw); + int uid = raw.getRealUid(); - AppStartInfoContainer container = mData.get(raw.getPackageName(), raw.getRealUid()); + // Isolated process starts won't be reasonably accessible if stored by their uid, don't + // store them. + if (com.android.server.am.Flags.appStartInfoIsolatedProcess() + && UserHandle.isIsolated(uid)) { + return null; + } + + AppStartInfoContainer container = mData.get(raw.getPackageName(), uid); if (container == null) { container = new AppStartInfoContainer(mAppStartInfoHistoryListSize); - container.mUid = info.getRealUid(); - mData.put(raw.getPackageName(), raw.getRealUid(), container); + container.mUid = uid; + mData.put(raw.getPackageName(), uid, container); } container.addStartInfoLocked(info); @@ -1010,6 +1018,17 @@ public final class AppStartInfoTracker { new AppStartInfoContainer(mAppStartInfoHistoryListSize); int uid = container.readFromProto(proto, AppsStartInfoProto.Package.USERS, pkgName); + + // If the isolated process flag is enabled and the uid is that of an isolated + // process, then break early so that the container will not be added to mData. + // This is expected only as a one time mitigation, records added after this flag + // is enabled should always return false for isIsolated and thereby always + // continue on. + if (com.android.server.am.Flags.appStartInfoIsolatedProcess() + && UserHandle.isIsolated(uid)) { + break; + } + synchronized (mLock) { mData.put(pkgName, uid, container); } diff --git a/services/core/java/com/android/server/am/flags.aconfig b/services/core/java/com/android/server/am/flags.aconfig index c59c40fc9cd8..6d247d227774 100644 --- a/services/core/java/com/android/server/am/flags.aconfig +++ b/services/core/java/com/android/server/am/flags.aconfig @@ -270,3 +270,13 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "app_start_info_isolated_process" + namespace: "system_performance" + description: "Adjust handling of isolated process records to be discarded." + bug: "374032823" + metadata { + purpose: PURPOSE_BUGFIX + } +} |