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

Commit a701b0f9 authored by Xiang Wang's avatar Xiang Wang Committed by Android (Google) Code Review
Browse files

Merge "Add AM#forceStopPackageAsUserEvenWhenStopping" into udc-dev

parents eb6d0c35 14129746
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -4432,6 +4432,21 @@ public class ActivityManager {
        forceStopPackageAsUser(packageName, mContext.getUserId());
    }

    /**
     * Similar to {@link #forceStopPackageAsUser(String, int)} but will also stop the package even
     * when the user is in the stopping state.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.FORCE_STOP_PACKAGES)
    public void forceStopPackageAsUserEvenWhenStopping(String packageName, @UserIdInt int userId) {
        try {
            getService().forceStopPackageEvenWhenStopping(packageName, userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Sets the current locales of the device. Calling app must have the permission
     * {@code android.permission.CHANGE_CONFIGURATION} and
+1 −0
Original line number Diff line number Diff line
@@ -336,6 +336,7 @@ interface IActivityManager {
    boolean registerForegroundServiceObserver(in IForegroundServiceObserver callback);
    @UnsupportedAppUsage
    void forceStopPackage(in String packageName, int userId);
    void forceStopPackageEvenWhenStopping(in String packageName, int userId);
    boolean killPids(in int[] pids, in String reason, boolean secure);
    @UnsupportedAppUsage
    List<ActivityManager.RunningServiceInfo> getServices(int maxNum, int flags);
+11 −2
Original line number Diff line number Diff line
@@ -3761,6 +3761,15 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void forceStopPackage(final String packageName, int userId) {
        forceStopPackage(packageName, userId, /*flags=*/ 0);
    }
    @Override
    public void forceStopPackageEvenWhenStopping(final String packageName, int userId) {
        forceStopPackage(packageName, userId, ActivityManager.FLAG_OR_STOPPED);
    }
    private void forceStopPackage(final String packageName, int userId, int userRunningFlags) {
        if (checkCallingPermission(android.Manifest.permission.FORCE_STOP_PACKAGES)
                != PackageManager.PERMISSION_GRANTED) {
            String msg = "Permission Denial: forceStopPackage() from pid="
@@ -3804,7 +3813,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        Slog.w(TAG, "Failed trying to unstop package "
                                + packageName + ": " + e);
                    }
                    if (mUserController.isUserRunning(user, 0)) {
                    if (mUserController.isUserRunning(user, userRunningFlags)) {
                        forceStopPackageLocked(packageName, pkgUid, "from pid " + callingPid);
                        finishForceStopPackageLocked(packageName, pkgUid);
                    }