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

Commit 6324f804 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Reduce spurious noteUidProcessState triggers

ActivityManagerService.noteUidProcessState is triggered on both
ProcessState and Capability changes, but only AppOpsService cares about
the Capability chage. Seperating out the method to handle just
ProcessState and ProcessState+Capability changes will reduce unnecessary
calls for the rest of the listeners.

Flag:EXEMPTED_bugfix
Fix: 392706859
Test: manual (Perfetto trace of a fixed workload will see a reduction in
binder calls to netd from MobileDataStats)

Change-Id: I65e81d3fb26e3682efce89c9d9bbe7989bf680cd
parent 6c118a5b
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -15113,10 +15113,24 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    void noteUidProcessState(final int uid, final int state,
    /**
     * Called by {@link OomAdjuster} whenever either the ProcessState or Capability of a uid has
     * changed.
     * NOTE: Use {@link #noteUidProcessState(int, int)} instead of this method for listeners
     * interested in only ProcessState changes.
     */
    void noteUidProcessStateAndCapability(final int uid, final int state,
            final @ProcessCapability int capability) {
        mBatteryStatsService.noteUidProcessState(uid, state);
        mAppOpsService.updateUidProcState(uid, state, capability);
    }
    /**
     * Called by {@link OomAdjuster} whenever either the ProcessState of a uid has changed.
     * NOTE: Use {@link #noteUidProcessStateAndCapability(int, int, int)} instead of this method
     * for listeners interested in both ProcessState and Capability changes.
     */
    void noteUidProcessState(final int uid, final int state) {
        mBatteryStatsService.noteUidProcessState(uid, state);
        if (StatsPullAtomService.ENABLE_MOBILE_DATA_STATS_AGGREGATED_PULLER) {
            try {
                if (mStatsPullAtomServiceInternal == null) {
+5 −2
Original line number Diff line number Diff line
@@ -1681,8 +1681,11 @@ public class OomAdjuster {
                    }
                    if ((uidChange & UidRecord.CHANGE_PROCSTATE) != 0
                            || (uidChange & UidRecord.CHANGE_CAPABILITY) != 0) {
                        mService.noteUidProcessState(uidRec.getUid(), uidRec.getCurProcState(),
                                uidRec.getCurCapability());
                        mService.noteUidProcessStateAndCapability(uidRec.getUid(),
                                uidRec.getCurProcState(), uidRec.getCurCapability());
                    }
                    if ((uidChange & UidRecord.CHANGE_PROCSTATE) != 0) {
                        mService.noteUidProcessState(uidRec.getUid(), uidRec.getCurProcState());
                    }
                    if (uidRec.hasForegroundServices()) {
                        mService.mServices.foregroundServiceProcStateChangedLocked(uidRec);
+6 −2
Original line number Diff line number Diff line
@@ -3286,8 +3286,9 @@ public final class ProcessList {
                uidRec.updateHasInternetPermission();
                mActiveUids.put(proc.uid, uidRec);
                EventLogTags.writeAmUidRunning(uidRec.getUid());
                mService.noteUidProcessState(uidRec.getUid(), uidRec.getCurProcState(),
                mService.noteUidProcessStateAndCapability(uidRec.getUid(), uidRec.getCurProcState(),
                        uidRec.getCurCapability());
                mService.noteUidProcessState(uidRec.getUid(), uidRec.getCurProcState());
            }
            proc.setUidRecord(uidRec);
            uidRec.addProcess(proc);
@@ -3489,8 +3490,11 @@ public final class ProcessList {
                        EventLogTags.writeAmUidStopped(uid);
                        mActiveUids.remove(uid);
                        mService.mFgsStartTempAllowList.removeUid(record.info.uid);
                        mService.noteUidProcessState(uid, ActivityManager.PROCESS_STATE_NONEXISTENT,
                        mService.noteUidProcessStateAndCapability(uid,
                                ActivityManager.PROCESS_STATE_NONEXISTENT,
                                ActivityManager.PROCESS_CAPABILITY_NONE);
                        mService.noteUidProcessState(uid, ActivityManager.PROCESS_STATE_NONEXISTENT
                        );
                    }
                    record.setUidRecord(null);
                }