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

Commit e8979d4c authored by Jing Ji's avatar Jing Ji
Browse files

ActivityManager#killBackgroundProcesses can kill caller's own app only

unless it has the privileged permission KILL_ALL_BACKGROUND_PROCESSES.

Bug: 239423414
Test: atest CtsAppTestCases:ActivityManagerTest
Change-Id: I35d20539ffac055a6d61260445620f45584bd9c5
parent 7c067f9e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ package android {
    field public static final String INTERACT_ACROSS_USERS_FULL = "android.permission.INTERACT_ACROSS_USERS_FULL";
    field public static final String INTERNAL_SYSTEM_WINDOW = "android.permission.INTERNAL_SYSTEM_WINDOW";
    field public static final String INVOKE_CARRIER_SETUP = "android.permission.INVOKE_CARRIER_SETUP";
    field public static final String KILL_ALL_BACKGROUND_PROCESSES = "android.permission.KILL_ALL_BACKGROUND_PROCESSES";
    field public static final String KILL_UID = "android.permission.KILL_UID";
    field public static final String LAUNCH_DEVICE_MANAGER_SETUP = "android.permission.LAUNCH_DEVICE_MANAGER_SETUP";
    field public static final String LOCAL_MAC_ADDRESS = "android.permission.LOCAL_MAC_ADDRESS";
+4 −0
Original line number Diff line number Diff line
@@ -3953,6 +3953,10 @@ public class ActivityManager {
     * processes to reclaim memory; the system will take care of restarting
     * these processes in the future as needed.
     *
     * <p>On devices with a {@link Build.VERSION#SECURITY_PATCH} of 2022-12-01 or greater,
     * third party applications can only use this API to kill their own processes.
     * </p>
     *
     * @param packageName The name of the package whose processes are to
     * be killed.
     */
+17 −0
Original line number Diff line number Diff line
@@ -3139,6 +3139,13 @@

    <!-- Allows an application to call
        {@link android.app.ActivityManager#killBackgroundProcesses}.
        <p>As of Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
        the {@link android.app.ActivityManager#killBackgroundProcesses} is no longer available to
        third party applications. For backwards compatibility, the background processes of the
        caller's own package will still be killed when calling this API. If the caller has
        the system permission {@code KILL_ALL_BACKGROUND_PROCESSES}, other processes will be
        killed too.

         <p>Protection level: normal
    -->
    <permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"
@@ -3146,6 +3153,16 @@
        android:description="@string/permdesc_killBackgroundProcesses"
        android:protectionLevel="normal" />

    <!-- @SystemApi @hide Allows an application to call
        {@link android.app.ActivityManager#killBackgroundProcesses}
        to kill background processes of other apps.
         <p>Not for use by third-party applications.
    -->
    <permission android:name="android.permission.KILL_ALL_BACKGROUND_PROCESSES"
        android:label="@string/permlab_killBackgroundProcesses"
        android:description="@string/permdesc_killBackgroundProcesses"
        android:protectionLevel="signature|privileged" />

    <!-- @SystemApi @hide Allows an application to query process states and current
         OOM adjustment scores.
         <p>Not for use by third-party applications. -->
+1 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ applications that come with the platform
        <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
        <permission name="android.permission.INSTALL_PACKAGES"/>
        <permission name="android.permission.INSTALL_PACKAGE_UPDATES"/>
        <permission name="android.permission.KILL_ALL_BACKGROUND_PROCESSES"/>
        <!-- Needed for test only -->
        <permission name="android.permission.ACCESS_MTP"/>
        <!-- Needed for test only -->
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@
    <uses-permission android:name="android.permission.CONTROL_UI_TRACING" />
    <uses-permission android:name="android.permission.SIGNAL_PERSISTENT_PROCESSES" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <uses-permission android:name="android.permission.KILL_ALL_BACKGROUND_PROCESSES" />
    <!-- Internal permissions granted to the shell. -->
    <uses-permission android:name="android.permission.FORCE_BACK" />
    <uses-permission android:name="android.permission.BATTERY_STATS" />
Loading