Merge "Add AM#forceStopPackageAsUserEvenWhenStopping" into udc-dev am: a701b0f9cf
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22751755 Change-Id: I9e43245203371d7826d971707e15ec918bd8cd15 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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="
|
||||
@@ -3776,7 +3785,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
final long callingId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
IPackageManager pm = AppGlobals.getPackageManager();
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
int[] users = userId == UserHandle.USER_ALL
|
||||
? mUserController.getUsers() : new int[] { userId };
|
||||
for (int user : users) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user