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

Commit c1b5ff04 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Invalidate home task snapshot onWakeAndUnlock.

Also, add ability to pass in null to invalidateHomeTaskSnapshot
if the correct permissions are held, so that System UI does not
need to IPC to Launcher to ask it to invalidate itself.

Fixes: 229191103
Test: atest SystemUITests
Test: wake and unlock, note no double launcher
Change-Id: I0c547639979460b3a85b0ef0a8bbf760d60054cb
parent e1edc97d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -454,7 +454,13 @@ public class ActivityClient {
        }
    }

    /** Removes the snapshot of home task. */
    /**
     * Removes the outdated snapshot of the home task.
     *
     * @param homeToken The token of the home task, or null if you have the
     *                  {@link android.Manifest.permission#MANAGE_ACTIVITY_TASKS} permission and
     *                  want us to find the home task token for you.
     */
    public void invalidateHomeTaskSnapshot(IBinder homeToken) {
        try {
            getActivityClientController().invalidateHomeTaskSnapshot(homeToken);
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
import static android.app.ActivityTaskManager.getService;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityClient;
import android.app.ActivityManager;
@@ -154,11 +155,15 @@ public class ActivityManagerWrapper {

    /**
     * Removes the outdated snapshot of home task.
     *
     * @param homeActivity The home task activity, or null if you have the
     *                     {@link android.Manifest.permission#MANAGE_ACTIVITY_TASKS} permission and
     *                     want us to find the home task for you.
     */
    public void invalidateHomeTaskSnapshot(final Activity homeActivity) {
    public void invalidateHomeTaskSnapshot(@Nullable final Activity homeActivity) {
        try {
            ActivityClient.getInstance().invalidateHomeTaskSnapshot(
                    homeActivity.getActivityToken());
                    homeActivity == null ? null : homeActivity.getActivityToken());
        } catch (Throwable e) {
            Log.w(TAG, "Failed to invalidate home snapshot", e);
        }
+8 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.dagger.KeyguardModule;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationShadeDepthController;
@@ -2780,6 +2781,13 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
    public void onWakeAndUnlocking() {
        Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking");
        mWakeAndUnlocking = true;

        // We're going to animate in the Launcher, so ask WM to clear the task snapshot so we don't
        // initially display an old snapshot with all of the icons visible. We're System UI, so
        // we're allowed to pass in null to ask WM to find the home activity for us to prevent
        // needing to IPC to Launcher.
        ActivityManagerWrapper.getInstance().invalidateHomeTaskSnapshot(null /* homeActivity */);

        keyguardDone();
        Trace.endSection();
    }
+20 −1
Original line number Diff line number Diff line
@@ -1190,10 +1190,29 @@ class ActivityClientController extends IActivityClientController.Stub {
        }
    }

    /**
     * Removes the outdated home task snapshot.
     *
     * @param token The token of the home task, or null if you have the
     *              {@link android.Manifest.permission#MANAGE_ACTIVITY_TASKS}
     *              permission and want us to find the home task token for you.
     */
    @Override
    public void invalidateHomeTaskSnapshot(IBinder token) {
        if (token == null) {
            ActivityTaskManagerService.enforceTaskPermission("invalidateHomeTaskSnapshot");
        }

        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
            final ActivityRecord r;
            if (token == null) {
                final Task rootTask =
                        mService.mRootWindowContainer.getDefaultTaskDisplayArea().getRootHomeTask();
                r = rootTask != null ? rootTask.topRunningActivity() : null;
            } else {
                r = ActivityRecord.isInRootTaskLocked(token);
            }

            if (r != null && r.isActivityTypeHome()) {
                mService.mWindowManager.mTaskSnapshotController.removeSnapshotCache(
                        r.getTask().mTaskId);