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

Commit dfc4ce14 authored by Arthur Hung's avatar Arthur Hung Committed by Android (Google) Code Review
Browse files

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

parents 226fc413 a13a07e3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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",
+6 −0
Original line number Diff line number Diff line
@@ -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) {
+18 −0
Original line number Diff line number Diff line
@@ -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;