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

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

Add an api to schedule app killings on imperceptible.

Bug: 142676371
Test: atest CtsAppTestCases:ActivityManagerTest
Change-Id: Ibf515ddcf384bc643c568243b675efb61f0bbd66
parent 4a9cddd4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@ package android.app {
    method @NonNull public java.util.Collection<java.util.Locale> getSupportedLocales();
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, "android.permission.CREATE_USERS"}) public boolean isProfileForeground(@NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void killProcessesWhenImperceptible(@NonNull int[], @NonNull String);
    method @RequiresPermission(android.Manifest.permission.KILL_UID) public void killUid(int, String);
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
    method public void setDeviceLocales(@NonNull android.os.LocaleList);
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ package android.app {
    method public long getTotalRam();
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getUidImportance(int);
    method public static boolean isHighEndGfx();
    method @RequiresPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) public void killProcessesWhenImperceptible(@NonNull int[], @NonNull String);
    method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
    method public static void resumeAppSwitches() throws android.os.RemoteException;
    method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public void scheduleApplicationInfoChanged(java.util.List<java.lang.String>, int);
+24 −0
Original line number Diff line number Diff line
@@ -4531,6 +4531,30 @@ public class ActivityManager {
        return false;
    }

    /**
     * Kill the given PIDs, but the killing will be delayed until the device is idle
     * and the given process is imperceptible.
     *
     * <p>You must hold the permission
     * {@link android.Manifest.permission#FORCE_STOP_PACKAGES} to be able to
     * call this method.
     * </p>
     *
     * @param pids The list of the pids to be killed
     * @pram reason The reason of the kill
     *
     * @hide
     */
    @SystemApi @TestApi
    @RequiresPermission(Manifest.permission.FORCE_STOP_PACKAGES)
    public void killProcessesWhenImperceptible(@NonNull int[] pids, @NonNull String reason) {
        try {
            getService().killProcessesWhenImperceptible(pids, reason);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * The AppTask allows you to manage your own application's tasks.
     * See {@link android.app.ActivityManager#getAppTasks()}
+6 −0
Original line number Diff line number Diff line
@@ -631,4 +631,10 @@ interface IActivityManager {
     */
    ParceledListSlice<ApplicationExitInfo> getHistoricalProcessExitReasons(String packageName,
            int pid, int maxNum, int userId);

    /*
     * Kill the given PIDs, but the killing will be delayed until the device is idle
     * and the given process is imperceptible.
     */
    void killProcessesWhenImperceptible(in int[] pids, String reason);
}
+12 −0
Original line number Diff line number Diff line
@@ -4306,4 +4306,16 @@

    <!-- Retention policy: number of records to kept for the historical exit info per package. -->
    <integer name="config_app_exit_info_history_list_size">16</integer>

    <!-- Packages that can't be killed even if it's requested to be killed on imperceptible -->
    <string-array name="config_defaultImperceptibleKillingExemptionPkgs" translatable="false" />

    <!-- Proc States that can't be killed even if it's requested to be killed on imperceptible -->
    <integer-array name="config_defaultImperceptibleKillingExemptionProcStates">
      <item>0</item> <!-- PROCESS_STATE_PERSISTENT -->
      <item>1</item> <!-- PROCESS_STATE_PERSISTENT_UI -->
      <item>2</item> <!-- PROCESS_STATE_TOP -->
      <item>4</item> <!-- PROCESS_STATE_FOREGROUND_SERVICE -->
      <item>12</item> <!-- PROCESS_STATE_TOP_SLEEPING -->
    </integer-array>
</resources>
Loading