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

Commit 6cc5e383 authored by Edgar Arriaga's avatar Edgar Arriaga Committed by Cherrypicker Worker
Browse files

Simplify debug command to force compactions

This removes the need to specify the UID as part of the command

Bug: 262442634
Test: am compact full <package_name>
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:94ea572a57d4d5328d2e4b53582a7ea692a39a79)
Merged-In: I3fa2d9bcc14e4ce31e8825d5a029f5768553f4fc
Change-Id: I3fa2d9bcc14e4ce31e8825d5a029f5768553f4fc
parent 29a79cf7
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -1066,16 +1066,26 @@ final class ActivityManagerShellCommand extends ShellCommand {
    }

    @NeverCompile
    int runCompact(PrintWriter pw) {
    int runCompact(PrintWriter pw) throws RemoteException {
        ProcessRecord app;
        String op = getNextArgRequired();
        boolean isFullCompact = op.equals("full");
        boolean isSomeCompact = op.equals("some");
        if (isFullCompact || isSomeCompact) {
            String processName = getNextArgRequired();
            String uid = getNextArgRequired();
            synchronized (mInternal.mProcLock) {
                app = mInternal.getProcessRecordLocked(processName, Integer.parseInt(uid));
                // Default to current user
                int userId = mInterface.getCurrentUserId();
                String userOpt = getNextOption();
                if (userOpt != null && "--user".equals(userOpt)) {
                    int inputUserId = UserHandle.parseUserArg(getNextArgRequired());
                    if (inputUserId != UserHandle.USER_CURRENT) {
                        userId = inputUserId;
                    }
                }
                final int uid =
                        mInternal.getPackageManagerInternal().getPackageUid(processName, 0, userId);
                app = mInternal.getProcessRecordLocked(processName, uid);
            }
            pw.println("Process record found pid: " + app.mPid);
            if (isFullCompact) {
@@ -4018,7 +4028,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
            pw.println("      --allow-background-activity-starts: The receiver may start activities");
            pw.println("          even if in the background.");
            pw.println("      --async: Send without waiting for the completion of the receiver.");
            pw.println("  compact [some|full|system] <process_name> <Package UID>");
            pw.println("  compact [some|full|system] <process_name> [--user <USER_ID>]");
            pw.println("      Force process compaction.");
            pw.println("      some: execute file compaction.");
            pw.println("      full: execute anon + file compaction.");