From 425fa132e78cc1dfa70e824b9ca0432fdf60920f Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Mon, 24 Feb 2025 22:39:44 +0000 Subject: Expose stopAppForUser in ActivityManger Adding wrapper function to call stopAppForUser from ActivityManagerService. It can be used stop app when full scale 'force stop' is not required. Flag: EXEMPT bug_fix Test: m && boot device Test: m Settings && adb install -r $ANDROID_PRODUCT_OUT/system_ext/priv-app/Settings/Settings.apk Bug: 389696304 Change-Id: I34e8720e2f227c7f93e2e9e1df7db993aa81c607 --- core/java/android/app/ActivityManager.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 69d3e8d4c0d2..a6e603042416 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -4974,6 +4974,25 @@ public class ActivityManager { } } + /** + * Fully stop the given app's processes without restoring service starts or + * bindings, but without the other durable effects of the full-scale + * "force stop" intervention. + * + * @param packageName The name of the package to be stopped. + * + * @hide This is not available to third party applications due to + * it allowing them to break other applications by stopping their + * services. + */ + public void stopPackageForUser(String packageName) { + try { + getService().stopAppForUser(packageName, mContext.getUserId()); + } 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 -- cgit v1.2.3-59-g8ed1b