Merge "Inject back key event if focused window didn't be drawn"

This commit is contained in:
Arthur Hung
2022-12-06 01:51:18 +00:00
committed by Android (Google) Code Review
3 changed files with 30 additions and 0 deletions

View File

@@ -4171,6 +4171,12 @@
"group": "WM_DEBUG_REMOTE_ANIMATIONS",
"at": "com\/android\/server\/wm\/RemoteAnimationController.java"
},
"1945495497": {
"message": "Focused window didn't have a valid surface drawn.",
"level": "DEBUG",
"group": "WM_DEBUG_BACK_PREVIEW",
"at": "com\/android\/server\/wm\/BackNavigationController.java"
},
"1947239194": {
"message": "Deferring rotation, still finishing previous rotation",
"level": "VERBOSE",

View File

@@ -168,6 +168,12 @@ class BackNavigationController {
+ "recents. Overriding back callback to recents controller callback.");
return null;
}
if (!window.isDrawn()) {
ProtoLog.d(WM_DEBUG_BACK_PREVIEW,
"Focused window didn't have a valid surface drawn.");
return null;
}
}
if (window == null) {

View File

@@ -150,6 +150,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
WindowState window = createWindow(null, WindowManager.LayoutParams.TYPE_WALLPAPER,
"Wallpaper");
addToWindowMap(window, true);
makeWindowVisibleAndDrawn(window);
IOnBackInvokedCallback callback = createOnBackInvokedCallback();
window.setOnBackInvokedCallbackInfo(
@@ -236,6 +237,20 @@ public class BackNavigationControllerTests extends WindowTestsBase {
1, appLatch.getCount());
}
@Test
public void backInfoWindowWithoutDrawn() {
WindowState window = createWindow(null, WindowManager.LayoutParams.TYPE_APPLICATION,
"TestWindow");
addToWindowMap(window, true);
IOnBackInvokedCallback callback = createOnBackInvokedCallback();
window.setOnBackInvokedCallbackInfo(
new OnBackInvokedCallbackInfo(callback, OnBackInvokedDispatcher.PRIORITY_DEFAULT));
BackNavigationInfo backNavigationInfo = startBackNavigation();
assertThat(backNavigationInfo).isNull();
}
private IOnBackInvokedCallback withSystemCallback(Task task) {
IOnBackInvokedCallback callback = createOnBackInvokedCallback();
task.getTopMostActivity().getTopChild().setOnBackInvokedCallbackInfo(
@@ -309,6 +324,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
Mockito.doNothing().when(task).reparentSurfaceControl(any(), any());
mAtm.setFocusedTask(task.mTaskId, record);
addToWindowMap(window, true);
makeWindowVisibleAndDrawn(window);
return task;
}
@@ -333,6 +349,8 @@ public class BackNavigationControllerTests extends WindowTestsBase {
addToWindowMap(window1, true);
addToWindowMap(window2, true);
makeWindowVisibleAndDrawn(window2);
CrossActivityTestCase testCase = new CrossActivityTestCase();
testCase.task = task;
testCase.recordBack = record1;