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

Commit 3c1c2542 authored by Eric Lok's avatar Eric Lok Committed by Android (Google) Code Review
Browse files

Merge "Implement perceptible tasks" into main

parents 8b2f2bc0 289d36c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ interface IActivityTaskManager {
    int getFrontActivityScreenCompatMode();
    void setFrontActivityScreenCompatMode(int mode);
    void setFocusedTask(int taskId);
    boolean setTaskIsPerceptible(int taskId, boolean isPerceptible);
    boolean removeTask(int taskId);
    void removeAllVisibleRecentTasks();
    List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents,
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ android_library {
        "//frameworks/libs/systemui:com_android_systemui_shared_flags_lib",
        "//frameworks/libs/systemui:msdl",
        "//frameworks/libs/systemui:view_capture",
        "am_flags_lib",
    ],
    resource_dirs: [
        "res",
+4 −1
Original line number Diff line number Diff line
@@ -22,4 +22,7 @@
<resources>
    <!-- Whether to add padding at the bottom of the complication clock -->
    <bool name="dream_overlay_complication_clock_bottom_padding">false</bool>

    <!-- Whether to mark tasks that are present in the UI as perceptible tasks. -->
    <bool name="config_usePerceptibleTasks">false</bool>
</resources>
+21 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import android.view.Display;
import android.window.TaskSnapshot;

import com.android.internal.app.IVoiceInteractionManagerService;
import com.android.server.am.Flags;
import com.android.systemui.shared.R;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;

@@ -226,6 +228,17 @@ public class ActivityManagerWrapper {
        }
    }

    /**
     * Sets whether or not the specified task is perceptible.
     */
    public boolean setTaskIsPerceptible(int taskId, boolean isPerceptible) {
        try {
            return getService().setTaskIsPerceptible(taskId, isPerceptible);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Removes a task by id.
     */
@@ -310,6 +323,14 @@ public class ActivityManagerWrapper {
                || freeformDevOption);
    }

    /**
     * Returns true if tasks with a presence in the UI should be marked as perceptible tasks.
     */
    public static boolean usePerceptibleTasks(Context context) {
        return Flags.perceptibleTasks()
                && context.getResources().getBoolean(R.bool.config_usePerceptibleTasks);
    }

    /**
     * Returns true if the running task represents the home task
     */
+25 −1
Original line number Diff line number Diff line
@@ -446,6 +446,8 @@ public class OomAdjuster {
    private static final int CACHING_UI_SERVICE_CLIENT_ADJ_THRESHOLD =
            Flags.raiseBoundUiServiceThreshold() ? SERVICE_ADJ : PERCEPTIBLE_APP_ADJ;

    static final long PERCEPTIBLE_TASK_TIMEOUT_MILLIS = 5 * 60 * 1000;

    @VisibleForTesting
    public static class Injector {
        boolean isChangeEnabled(@CachedCompatChangeId int cachedCompatChangeId,
@@ -1847,7 +1849,7 @@ public class OomAdjuster {
            mHasVisibleActivities = false;
        }

        void onOtherActivity() {
        void onOtherActivity(long perceptibleTaskStoppedTimeMillis) {
            if (procState > PROCESS_STATE_CACHED_ACTIVITY) {
                procState = PROCESS_STATE_CACHED_ACTIVITY;
                mAdjType = "cch-act";
@@ -1856,6 +1858,28 @@ public class OomAdjuster {
                            "Raise procstate to cached activity: " + app);
                }
            }
            if (Flags.perceptibleTasks() && adj > PERCEPTIBLE_MEDIUM_APP_ADJ) {
                if (perceptibleTaskStoppedTimeMillis >= 0) {
                    final long now = mInjector.getUptimeMillis();
                    if (now - perceptibleTaskStoppedTimeMillis < PERCEPTIBLE_TASK_TIMEOUT_MILLIS) {
                        adj = PERCEPTIBLE_MEDIUM_APP_ADJ;
                        mAdjType = "perceptible-act";
                        if (procState > PROCESS_STATE_IMPORTANT_BACKGROUND) {
                            procState = PROCESS_STATE_IMPORTANT_BACKGROUND;
                        }

                        maybeSetProcessFollowUpUpdateLocked(app,
                                perceptibleTaskStoppedTimeMillis + PERCEPTIBLE_TASK_TIMEOUT_MILLIS,
                                now);
                    } else if (adj > PREVIOUS_APP_ADJ) {
                        adj = PREVIOUS_APP_ADJ;
                        mAdjType = "stale-perceptible-act";
                        if (procState > PROCESS_STATE_LAST_ACTIVITY) {
                            procState = PROCESS_STATE_LAST_ACTIVITY;
                        }
                    }
                }
            }
            mHasVisibleActivities = false;
        }
    }
Loading