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

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

Call new user requested profiling triggers

Call the newly added triggers for force stop, kill recents, and kill task manager.

Test: trigger each kill scenario, observe trigger called and trace result
Bug: 406809160
Flag: android.os.profiling.profiling_25q4
Change-Id: Ic621cd89552bc254ed4791d167b10997f47f94eb
parent 193932a1
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -4267,6 +4267,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                        "fully stop " + packageName + "/" + userId + " by user request");
            }
            if (android.os.profiling.Flags.profiling25q4()
                    && packageName != null) {
                sendProfilingTrigger(
                        uid,
                        packageName,
                        ProfilingTrigger.TRIGGER_TYPE_KILL_TASK_MANAGER);
            }
            mServices.bringDownDisabledPackageServicesLocked(
                    packageName, null, userId, false, true, true);
            mServices.onUidRemovedLocked(uid);
@@ -4357,6 +4365,15 @@ public class ActivityManagerService extends IActivityManager.Stub
                    subReason,
                    (packageName == null ? ("stop user " + userId) : ("stop " + packageName))
                    + " due to " + reasonString);
            if (didSomething && subReason == ApplicationExitInfo.SUBREASON_FORCE_STOP
                    && android.os.profiling.Flags.profiling25q4()
                    && packageName != null) {
                sendProfilingTrigger(
                        uid,
                        packageName,
                        ProfilingTrigger.TRIGGER_TYPE_KILL_FORCE_STOP);
            }
        }
        if (mServices.bringDownDisabledPackageServicesLocked(
@@ -17122,6 +17139,19 @@ public class ActivityManagerService extends IActivityManager.Stub
                        // receiver.
                        pr.setWaitingToKill("remove task");
                    }
                    // Send the profiling trigger. This is done both in cases where we kill
                    // immediately and where we delay the kill, as the user has already requested
                    // the kill and the longer we wait the lower the chance the events of interest
                    // will still be in the buffer.
                    if (android.os.profiling.Flags.profiling25q4()
                            && pr.info != null
                            && pr.info.packageName != null) {
                        sendProfilingTrigger(
                                pr.uid,
                                pr.info.packageName,
                                ProfilingTrigger.TRIGGER_TYPE_KILL_RECENTS);
                    }
                }
            }
        }
@@ -19615,4 +19645,14 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        return token;
    }
    /** Helper method for sending profiling triggers asynchronously. */
    private void sendProfilingTrigger(int uid, @NonNull String packageName, int triggerType) {
        mHandler.post(new Runnable() {
            @Override public void run() {
                ProfilingServiceHelper.getInstance().onProfilingTriggerOccurred(
                        uid, packageName, triggerType);
            }
        });
    }
}