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

Commit 00edb0c4 authored by wilsonshih's avatar wilsonshih
Browse files

Do not remove the snapshot starting window immediately...

...after the IME reports that it has finished drawing.
The IME could draw before the application window gains focus after the
device is unlocked. Therefore, treat the IME window's "drawn" state as
a condition for removal, rather than directly removing the snapshot
starting window.

Bug: 429531321
Flag: EXEMPT bugfix
Test: Verify that, following a screen off/on cycle and device unlock,
the snapshot starting window should not disappear immediately when the
IME is drawn, but rather wait for the app window drawn.

Change-Id: Idb730c8471518b51bf8c1c80a013954eceae7857
parent 904b96b1
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());
        }
    }