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

Commit 2040088a authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added activity cmd to display current process state of an app." into nyc-dev

parents 26acf086 2f1b2272
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -7221,6 +7221,15 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    // NOTE: this is an internal method used by the OnShellCommand implementation only and should
    // be guarded by permission checking.
    int getUidState(int uid) {
        synchronized (this) {
            UidRecord uidRec = mActiveUids.get(uid);
            return uidRec == null ? ActivityManager.PROCESS_STATE_NONEXISTENT : uidRec.curProcState;
        }
    }
    @Override
    public boolean inMultiWindow(IBinder token) {
        final long origId = Binder.clearCallingIdentity();
@@ -13244,6 +13253,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState() {
        enforceNotIsolatedCaller("getProcessesInErrorState");
        // assume our apps are happy - lazy create the list
@@ -13320,6 +13330,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        outInfo.processState = app.curProcState;
    }
    @Override
    public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() {
        enforceNotIsolatedCaller("getRunningAppProcesses");
@@ -13371,6 +13382,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        return runList;
    }
    @Override
    public List<ApplicationInfo> getRunningExternalApplications() {
        enforceNotIsolatedCaller("getRunningExternalApplications");
        List<ActivityManager.RunningAppProcessInfo> runningApps = getRunningAppProcesses();
+20 −3
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.server.am;

import android.app.ActivityManager;
import android.app.IActivityManager;
import android.os.RemoteException;
import android.os.ShellCommand;
import android.os.UserHandle;
import android.util.DebugUtils;

import com.android.internal.util.ArrayUtils;

@@ -64,6 +66,8 @@ class ActivityManagerShellCommand extends ShellCommand {
                    return runIsUserStopped(pw);
                case "lenient-background-check":
                    return runLenientBackgroundCheck(pw);
                case "get-uid-state":
                    return getUidState(pw);
                default:
                    return handleDefaultCommands(cmd);
            }
@@ -170,6 +174,17 @@ class ActivityManagerShellCommand extends ShellCommand {
        return 0;
    }

    int getUidState(PrintWriter pw) throws RemoteException {
        mInternal.enforceCallingPermission(android.Manifest.permission.DUMP,
                "getUidState()");
        int state = mInternal.getUidState(Integer.parseInt(getNextArgRequired()));
        pw.print(state);
        pw.print(" (");
        pw.printf(DebugUtils.valueToString(ActivityManager.class, "PROCESS_STATE_", state));
        pw.println(")");
        return 0;
    }

    @Override
    public void onHelp() {
        PrintWriter pw = getOutPrintWriter();
@@ -212,7 +227,7 @@ class ActivityManagerShellCommand extends ShellCommand {
            pw.println("  kill [--user <USER_ID> | all | current] <PACKAGE>");
            pw.println("    Kill all processes associated with the given application.");
            pw.println("  kill-all");
            pw.println("    Kill all processes that are safe to kill (cached, etc)");
            pw.println("    Kill all processes that are safe to kill (cached, etc).");
            pw.println("  write");
            pw.println("    Write all pending state to storage.");
            pw.println("  track-associations");
@@ -220,9 +235,11 @@ class ActivityManagerShellCommand extends ShellCommand {
            pw.println("  untrack-associations");
            pw.println("    Disable and clear association tracking.");
            pw.println("  is-user-stopped <USER_ID>");
            pw.println("    returns whether <USER_ID> has been stopped or not");
            pw.println("    Returns whether <USER_ID> has been stopped or not.");
            pw.println("  lenient-background-check [<true|false>]");
            pw.println("    optionally controls lenient background check mode, returns current mode.");
            pw.println("    Optionally controls lenient background check mode, returns current mode.");
            pw.println("  get-uid-state <UID>");
            pw.println("    Gets the process state of an app given its <UID>.");
        }
    }
}