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

Commit ef439b26 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Add sub-reasons for the killings from task manager and force-stop" into tm-dev

parents 83645e6d 9edb86c9
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -360,6 +360,53 @@ public final class ApplicationExitInfo implements Parcelable {
     */
    public static final int SUBREASON_FREEZER_BINDER_TRANSACTION = 20;

    /**
     * The process was killed because of force-stop, it could be due to that
     * the user clicked the "Force stop" button of the application in the Settings;
     * this would be set only when the reason is {@link #REASON_USER_REQUESTED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_FORCE_STOP = 21;

    /**
     * The process was killed because the user removed the application away from Recents;
     * this would be set only when the reason is {@link #REASON_USER_REQUESTED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_REMOVE_TASK = 22;

    /**
     * The process was killed because the user stopped the application from the task manager;
     * this would be set only when the reason is {@link #REASON_USER_REQUESTED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_STOP_APP = 23;

    /**
     * The process was killed because the user stopped the application from developer options,
     * or via the adb shell commmand interface; this would be set only when the reason is
     * {@link #REASON_USER_REQUESTED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_KILL_BACKGROUND = 24;

    /**
     * The process was killed because of package update; this would be set only when the reason is
     * {@link #REASON_USER_REQUESTED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_PACKAGE_UPDATE = 25;

    // If there is any OEM code which involves additional app kill reasons, it should
    // be categorized in {@link #REASON_OTHER}, with subreason code starting from 1000.

@@ -520,6 +567,11 @@ public final class ApplicationExitInfo implements Parcelable {
        SUBREASON_ISOLATED_NOT_NEEDED,
        SUBREASON_FREEZER_BINDER_IOCTL,
        SUBREASON_FREEZER_BINDER_TRANSACTION,
        SUBREASON_FORCE_STOP,
        SUBREASON_REMOVE_TASK,
        SUBREASON_STOP_APP,
        SUBREASON_KILL_BACKGROUND,
        SUBREASON_PACKAGE_UPDATE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SubReason {}
@@ -1193,6 +1245,16 @@ public final class ApplicationExitInfo implements Parcelable {
                return "FREEZER BINDER IOCTL";
            case SUBREASON_FREEZER_BINDER_TRANSACTION:
                return "FREEZER BINDER TRANSACTION";
            case SUBREASON_FORCE_STOP:
                return "FORCE STOP";
            case SUBREASON_REMOVE_TASK:
                return "REMOVE TASK";
            case SUBREASON_STOP_APP:
                return "STOP APP";
            case SUBREASON_KILL_BACKGROUND:
                return "KILL BACKGROUND";
            case SUBREASON_PACKAGE_UPDATE:
                return "PACKAGE UPDATE";
            default:
                return "UNKNOWN";
        }
+6 −6
Original line number Diff line number Diff line
@@ -3780,7 +3780,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    synchronized (mProcLock) {
                        mProcessList.killPackageProcessesLSP(packageName, appId, targetUserId,
                                ProcessList.SERVICE_ADJ, ApplicationExitInfo.REASON_USER_REQUESTED,
                                ApplicationExitInfo.SUBREASON_UNKNOWN, "kill background");
                                ApplicationExitInfo.SUBREASON_KILL_BACKGROUND, "kill background");
                    }
                }
            }
@@ -3810,7 +3810,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    mProcessList.killPackageProcessesLSP(null /* packageName */, -1 /* appId */,
                            UserHandle.USER_ALL, ProcessList.CACHED_APP_MIN_ADJ,
                            ApplicationExitInfo.REASON_USER_REQUESTED,
                            ApplicationExitInfo.SUBREASON_UNKNOWN,
                            ApplicationExitInfo.SUBREASON_KILL_BACKGROUND,
                            "kill all background");
                }
@@ -4352,7 +4352,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        ProcessList.INVALID_ADJ, true, false, true,
                        false, true /* setRemoved */, false,
                        ApplicationExitInfo.REASON_USER_REQUESTED,
                        ApplicationExitInfo.SUBREASON_UNKNOWN,
                        ApplicationExitInfo.SUBREASON_STOP_APP,
                        "fully stop " + packageName + "/" + userId + " by user request");
            }
@@ -4404,7 +4404,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    evenPersistent, true /* setRemoved */, uninstalling,
                    packageName == null ? ApplicationExitInfo.REASON_USER_STOPPED
                    : ApplicationExitInfo.REASON_USER_REQUESTED,
                    ApplicationExitInfo.SUBREASON_UNKNOWN,
                    ApplicationExitInfo.SUBREASON_FORCE_STOP,
                    (packageName == null ? ("stop user " + userId) : ("stop " + packageName))
                    + " due to " + reason);
        }
@@ -13636,7 +13636,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                                    UserHandle.getAppId(extraUid),
                                                    userId, ProcessList.INVALID_ADJ,
                                                    ApplicationExitInfo.REASON_USER_REQUESTED,
                                                    ApplicationExitInfo.SUBREASON_UNKNOWN,
                                                    ApplicationExitInfo.SUBREASON_PACKAGE_UPDATE,
                                                    "change " + ssp);
                                        }
                                    }
@@ -16365,7 +16365,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    if (pr.mState.getSetSchedGroup() == ProcessList.SCHED_GROUP_BACKGROUND
                            && pr.mReceivers.numberOfCurReceivers() == 0) {
                        pr.killLocked("remove task", ApplicationExitInfo.REASON_USER_REQUESTED,
                                ApplicationExitInfo.SUBREASON_UNKNOWN, true);
                                ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
                    } else {
                        // We delay killing processes that are not in the background or running a
                        // receiver.
+1 −1
Original line number Diff line number Diff line
@@ -2561,7 +2561,7 @@ public class OomAdjuster {
            if (app.getWaitingToKill() != null && app.mReceivers.numberOfCurReceivers() == 0
                    && state.getSetSchedGroup() == ProcessList.SCHED_GROUP_BACKGROUND) {
                app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED,
                        ApplicationExitInfo.SUBREASON_UNKNOWN, true);
                        ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
                success = false;
            } else {
                int processGroup;