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

Commit 9b9497d8 authored by Louis Chang's avatar Louis Chang Committed by Automerger Merge Worker
Browse files

Merge "Fix the hidden task was removed before starting home" into udc-dev am:...

Merge "Fix the hidden task was removed before starting home" into udc-dev am: d4ef43a7 am: e2e8289b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21918744



Change-Id: If3912a9e59e68028fc7bae4c91c5e1df84842df5
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3829e330 e2e8289b
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -2098,7 +2098,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mTaskSupervisor = supervisor;

        info.taskAffinity = computeTaskAffinity(info.taskAffinity, info.applicationInfo.uid,
                launchMode);
                info.launchMode, mActivityComponent);
        taskAffinity = info.taskAffinity;
        final String uid = Integer.toString(info.applicationInfo.uid);
        if (info.windowLayout != null && info.windowLayout.windowLayoutAffinity != null
@@ -2199,12 +2199,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * @param affinity The affinity of the activity.
     * @param uid The user-ID that has been assigned to this application.
     * @param launchMode The activity launch mode
     * @param componentName The activity component name. This is only useful when the given
     *                      launchMode is {@link ActivityInfo#LAUNCH_SINGLE_INSTANCE}
     * @return The task affinity
     */
    static String computeTaskAffinity(String affinity, int uid, int launchMode) {
    static String computeTaskAffinity(String affinity, int uid, int launchMode,
            ComponentName componentName) {
        final String uidStr = Integer.toString(uid);
        if (affinity != null && !affinity.startsWith(uidStr)) {
            affinity = uidStr + (launchMode == LAUNCH_SINGLE_INSTANCE ? "-si:" : ":") + affinity;
            affinity = uidStr + ":" + affinity;
            if (launchMode == LAUNCH_SINGLE_INSTANCE && componentName != null) {
                affinity += ":" + componentName.hashCode();
            }
        }
        return affinity;
    }
+2 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_TASKS;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RECENTS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RECENTS_TRIM_TASKS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_RECENTS;
@@ -1221,7 +1222,7 @@ class RecentTasks {
    void onActivityIdle(ActivityRecord r) {
        // Clean up the hidden tasks when going to home because the user may not be unable to return
        // to the task from recents.
        if (!mHiddenTasks.isEmpty() && r.isActivityTypeHome()) {
        if (!mHiddenTasks.isEmpty() && r.isActivityTypeHome() && r.isState(RESUMED)) {
            removeUnreachableHiddenTasks(r.getWindowingMode());
        }
        if (mCheckTrimmableTasksOnIdle) {
+1 −1
Original line number Diff line number Diff line
@@ -5332,7 +5332,7 @@ class Task extends TaskFragment {
        // the task if the affinity has changed.

        final String affinity = ActivityRecord.computeTaskAffinity(destAffinity, srec.getUid(),
                srec.launchMode);
                srec.launchMode, srec.mActivityComponent);
        if (srec == null || srec.getTask().affinity == null
                || !srec.getTask().affinity.equals(affinity)) {
            return true;
+3 −3
Original line number Diff line number Diff line
@@ -1728,7 +1728,7 @@ public class ActivityStarterTests extends WindowTestsBase {
        final ActivityInfo info = new ActivityInfo();
        info.applicationInfo = new ApplicationInfo();
        info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
                0 /* launchMode */);
                0 /* launchMode */, null /* componentName */);
        info.requiredDisplayCategory = "automotive";
        final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
                .build();
@@ -1754,7 +1754,7 @@ public class ActivityStarterTests extends WindowTestsBase {
        final ActivityInfo info = new ActivityInfo();
        info.applicationInfo = new ApplicationInfo();
        info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
                0 /* launchMode */);
                0 /* launchMode */, null /* componentName */);
        info.requiredDisplayCategory = "automotive";
        final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
                .build();
@@ -1780,7 +1780,7 @@ public class ActivityStarterTests extends WindowTestsBase {
        final ActivityInfo info = new ActivityInfo();
        info.applicationInfo = new ApplicationInfo();
        info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
                0 /* launchMode */);
                0 /* launchMode */, null /* componentName */);
        info.requiredDisplayCategory = "automotive";
        final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
                .build();
+6 −3
Original line number Diff line number Diff line
@@ -448,12 +448,15 @@ public class RecentTasksTest extends WindowTestsBase {
        final String taskAffinity = "affinity";
        final int uid = 10123;
        final Task task1 = createTaskBuilder(".Task1").build();
        task1.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE);
        final ComponentName componentName = getUniqueComponentName();
        task1.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE,
                componentName);
        mRecentTasks.add(task1);

        // Add another task to recents, and make sure the previous task was removed.
        final Task task2 = createTaskBuilder(".Task2").build();
        task2.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE);
        task2.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE,
                componentName);
        mRecentTasks.add(task2);
        assertEquals(1, mRecentTasks.getRecentTasks(MAX_VALUE, 0 /* flags */,
                true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());
@@ -461,7 +464,7 @@ public class RecentTasksTest extends WindowTestsBase {
        // Add another single-instance task to recents, and make sure no task is removed.
        final Task task3 = createTaskBuilder(".Task3").build();
        task3.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid,
                LAUNCH_SINGLE_INSTANCE);
                LAUNCH_SINGLE_INSTANCE, componentName);
        mRecentTasks.add(task3);
        assertEquals(2, mRecentTasks.getRecentTasks(MAX_VALUE, 0 /* flags */,
                true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());