Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4faf0ca3 authored by Yisroel Forta's avatar Yisroel Forta
Browse files

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
parent 261caa80
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -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);
                    }
+10 −0
Original line number Diff line number Diff line
@@ -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
    }
}