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

Commit 21d73a78 authored by wilsonshih's avatar wilsonshih
Browse files

Fixes start new showWhenLocked activity will stuck on DreamActivity.

1. Update the isTopNonPinnedStack when check visibility for next
activity, otherwise even when DreamActivity is finishing but still on
top, there would still though next activity is not top non-pinned
stack.

2. If we start next activity while isDreaming, we will set
launchTaskBehind for the next activity, which will cause the new
activity stay in unknown apps because client will go through onStart ->
onResume -> onPaused directly, in this case ATMS will receive relayout
before activityResumed. To prevent the app transition hanging there, go
to waiting for relayout directly if we know that activity was set
launchTaskBehind.

Bug: 162190413
Test: atest PinnedStackTests ActivityLifecyclePipTests
Test: atest UnknownAppVisibilityControllerTest
Test: Set crediential and alarm, enable dream, wait to see that alarm
activity should unlock DreamActivity before transition timeout.

Change-Id: I8ef5c5e0424c925fdaccda6baff496302a0ff3ba
parent 51929385
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4664,7 +4664,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // case where this is the top activity in a pinned stack.
        final boolean isTop = this == stack.getTopNonFinishingActivity();
        final boolean isTopNotPinnedStack = stack.isAttached()
                && stack.getDisplayArea().isTopNotPinnedStack(stack);
                && stack.getDisplayArea().isTopNotFinishNotPinnedStack(stack);
        final boolean visibleIgnoringDisplayStatus = stack.checkKeyguardVisibility(this,
                visibleIgnoringKeyguard, isTop && isTopNotPinnedStack);

+5 −1
Original line number Diff line number Diff line
@@ -1489,9 +1489,13 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        return stack == getTopStack();
    }

    boolean isTopNotPinnedStack(Task stack) {
    boolean isTopNotFinishNotPinnedStack(Task stack) {
        for (int i = getStackCount() - 1; i >= 0; --i) {
            final Task current = getStackAt(i);
            final ActivityRecord topAct = current.getTopNonFinishingActivity();
            if (topAct == null) {
                continue;
            }
            if (!current.inPinnedWindowingMode()) {
                return current == stack;
            }
+7 −3
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import android.annotation.NonNull;
import android.util.ArrayMap;
import android.util.Slog;

import com.android.server.wm.WindowManagerService.H;

import java.io.PrintWriter;

/**
@@ -102,7 +100,13 @@ class UnknownAppVisibilityController {
        if (DEBUG_UNKNOWN_APP_VISIBILITY) {
            Slog.d(TAG, "App launched activity=" + activity);
        }
        // If the activity was started with launchTaskBehind, the lifecycle will goes to paused
        // directly, and the process will pass onResume, so we don't need to waiting resume for it.
        if (!activity.mLaunchTaskBehind) {
            mUnknownApps.put(activity, UNKNOWN_STATE_WAITING_RESUME);
        } else {
            mUnknownApps.put(activity, UNKNOWN_STATE_WAITING_RELAYOUT);
        }
    }

    /**
+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,18 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase {
        assertTrue(mDisplayContent.mUnknownAppVisibilityController.allResolved());
    }

    @Test
    public void testSkipResume() {
        final ActivityRecord activity = createTestActivityRecord(mDisplayContent);
        activity.mLaunchTaskBehind = true;
        mDisplayContent.mUnknownAppVisibilityController.notifyLaunched(activity);
        mDisplayContent.mUnknownAppVisibilityController.notifyRelayouted(activity);

        // Make sure our handler processed the message.
        waitHandlerIdle(mWm.mH);
        assertTrue(mDisplayContent.mUnknownAppVisibilityController.allResolved());
    }

    @Test
    public void testMultiple() {
        final ActivityRecord activity1 = createTestActivityRecord(mDisplayContent);