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

Commit 3fbfac64 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Do not remove the snapshot starting window immediately..." into main

parents e93dcc71 00edb0c4
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -194,8 +194,8 @@ public class StartingSurfaceDrawer {
                records.getRecord(taskId);
        final SnapshotRecord record = sRecord instanceof SnapshotRecord
                ? (SnapshotRecord) sRecord : null;
        if (record != null && record.hasImeSurface()) {
            records.removeWindow(taskId);
        if (record != null) {
            record.onImeWindowDrawn();
        }
    }

@@ -265,6 +265,7 @@ public class StartingSurfaceDrawer {
        protected final ShellExecutor mRemoveExecutor;
        private final int mTaskId;
        private final StartingWindowRecordManager mRecordManager;
        private boolean mImeWindowDrawn;

        SnapshotRecord(int activityType, ShellExecutor removeExecutor, int taskId,
                StartingWindowRecordManager recordManager) {
@@ -279,7 +280,8 @@ public class StartingSurfaceDrawer {
            if (immediately
                    // Show the latest content as soon as possible for unlocking to home.
                    || mActivityType == ACTIVITY_TYPE_HOME
                    || info.deferRemoveMode == DEFER_MODE_NONE) {
                    || info.deferRemoveMode == DEFER_MODE_NONE
                    || mImeWindowDrawn) {
                removeImmediately();
                return true;
            }
@@ -312,6 +314,16 @@ public class StartingSurfaceDrawer {
            mRemoveExecutor.removeCallbacks(mScheduledRunnable);
            mRecordManager.onRecordRemoved(this, mTaskId);
        }

        void onImeWindowDrawn() {
            if (!hasImeSurface()) {
                return;
            }
            mImeWindowDrawn = true;
            if (mRemoveExecutor.hasCallback(mScheduledRunnable)) {
                removeImmediately();
            }
        }
    }

    static class StartingWindowRecordManager {
+12 −8
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@ import static com.android.wm.shell.startingsurface.SplashscreenContentDrawer.MIN
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -237,14 +239,16 @@ public class StartingSurfaceDrawerTests extends ShellTestCase {
            // Simulate a task snapshot window created with hasImeSurface.
            mStartingSurfaceDrawer.makeTaskSnapshotWindow(windowInfo, snapshot);
            waitHandlerIdle(mTestHandler);

            // Verify the task snapshot with hasImeSurface will be removed when receiving the
            // callback that the real IME was drawn.
            // makeTaskSnapshotWindow shall call removeWindowSynced before there add a new
            // StartingWindowRecord for the task.
            reset(mStartingSurfaceDrawer.mWindowRecords);
            // Verify the task snapshot with hasImeSurface will not be removed immediately when
            // receiving the callback that the real IME was drawn.
            mStartingSurfaceDrawer.onImeDrawnOnTask(1);
            verify(mStartingSurfaceDrawer.mWindowRecords, times(2))
                    .removeWindow(any(), eq(true));
            verify(mStartingSurfaceDrawer.mWindowRecords, never())
                    .removeWindow(any(), anyBoolean());
            final StartingWindowRemovalInfo removalInfo = new StartingWindowRemovalInfo();
            removalInfo.taskId = windowInfo.taskInfo.taskId;
            mStartingSurfaceDrawer.removeStartingWindow(removalInfo);
            verify(mStartingSurfaceDrawer.mWindowRecords).removeWindow(any(), anyBoolean());
        }
    }