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

Commit c69ea31c authored by Jing Ji's avatar Jing Ji
Browse files

Don't reset the reported proc state while cleaning up the process

It'll be used to feed into the app kill stats.

Meanwhile, use the real process UID instead of the package UID for
indexing the app kill stats container internally, it'll be better
in terms of aligning with the caller UID in queries.

Bug: 194364213
Test: atest ApplicationExitInfoTest
Test: atest CtsAppExitTestCases:ActivityManagerAppExitInfoTest
Test: Manual - dumpsys activity exit-info
Change-Id: I5c966086bb90675294b5dfc1c5cdb0c163f05170
parent 61d71cca
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -430,7 +430,13 @@ public final class AppExitInfoTracker {

        final ApplicationExitInfo info = new ApplicationExitInfo(raw);
        final String[] packages = raw.getPackageList();
        final int uid = raw.getPackageUid();
        int uid = raw.getRealUid();
        if (UserHandle.isIsolated(uid)) {
            Integer k = mIsolatedUidRecords.getUidByIsolatedUid(uid);
            if (k != null) {
                uid = k;
            }
        }
        for (int i = 0; i < packages.length; i++) {
            addExitInfoInnerLocked(packages[i], uid, info);
        }
@@ -833,14 +839,14 @@ public final class AppExitInfoTracker {
        pw.println(prefix + "package: " + packageName);
        int size = array.size();
        for (int i = 0; i < size; i++) {
            pw.println(prefix + "  Historical Process Exit for userId=" + array.keyAt(i));
            pw.println(prefix + "  Historical Process Exit for uid=" + array.keyAt(i));
            array.valueAt(i).dumpLocked(pw, prefix + "    ", sdf);
        }
    }

    @GuardedBy("mLock")
    private void addExitInfoInnerLocked(String packageName, int userId, ApplicationExitInfo info) {
        AppExitInfoContainer container = mData.get(packageName, userId);
    private void addExitInfoInnerLocked(String packageName, int uid, ApplicationExitInfo info) {
        AppExitInfoContainer container = mData.get(packageName, uid);
        if (container == null) {
            container = new AppExitInfoContainer(mAppExitInfoHistoryListSize);
            if (UserHandle.isIsolated(info.getRealUid())) {
@@ -851,7 +857,7 @@ public final class AppExitInfoTracker {
            } else {
                container.mUid = info.getRealUid();
            }
            mData.put(packageName, userId, container);
            mData.put(packageName, uid, container);
        }
        container.addExitInfoLocked(info);
    }
@@ -997,7 +1003,7 @@ public final class AppExitInfoTracker {
            info.setPackageList(app.getPackageList());
            info.setReason(ApplicationExitInfo.REASON_UNKNOWN);
            info.setStatus(0);
            info.setImportance(procStateToImportance(app.mState.getSetProcState()));
            info.setImportance(procStateToImportance(app.mState.getReportedProcState()));
            info.setPss(app.mProfile.getLastPss());
            info.setRss(app.mProfile.getLastRss());
            info.setTimestamp(timestamp);
+1 −1
Original line number Diff line number Diff line
@@ -1086,7 +1086,7 @@ final class ProcessStateRecord {
        mCurRawAdj = mSetRawAdj = mCurAdj = mSetAdj = mVerifiedAdj = ProcessList.INVALID_ADJ;
        mCurCapability = mSetCapability = PROCESS_CAPABILITY_NONE;
        mCurSchedGroup = mSetSchedGroup = ProcessList.SCHED_GROUP_BACKGROUND;
        mCurProcState = mRepProcState = mCurRawProcState = mSetProcState = mAllowStartFgsState =
        mCurProcState = mCurRawProcState = mSetProcState = mAllowStartFgsState =
                PROCESS_STATE_NONEXISTENT;
    }

+1 −1
Original line number Diff line number Diff line
@@ -1003,7 +1003,7 @@ public class ApplicationExitInfoTest {
                    dummyPackageName, dummyClassName), "", definingUid));
        }
        app.mServices.setConnectionGroup(connectionGroup);
        app.mState.setSetProcState(procState);
        app.mState.setReportedProcState(procState);
        app.mProfile.setLastMemInfo(spy(new Debug.MemoryInfo()));
        app.mProfile.setLastPss(pss);
        app.mProfile.setLastRss(rss);