Loading libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +15 −3 Original line number Diff line number Diff line Loading @@ -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(); } } Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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 { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +12 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +15 −3 Original line number Diff line number Diff line Loading @@ -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(); } } Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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 { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +12 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } Loading