From 0b8ada648e11ddc80b8203a9afbb79482fd7c7ff Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Thu, 1 Dec 2022 15:06:22 -0500 Subject: Fix screenshot back key recognition We were only requesting focus once, on screenshot view inflation, and the focus got reset when window.setContentView was called, causing us to no longer receive key events. This change moves the setContentView call to only happen once, and requests focus explicitly for each screenshot. Test: manual -- took two screenshots in succession and verified that back gesture worked to dismiss screenshot Bug: 259490332 Fix: 259490332 Change-Id: Ia0dd38b32f7986088b87f3838bcb05dbbb02238d --- .../com/android/systemui/screenshot/ScreenshotController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/SystemUI') diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java index d94c8277b82c..4a6df76bd8a0 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java @@ -513,6 +513,10 @@ public class ScreenshotController { Log.d(TAG, "adding OnComputeInternalInsetsListener"); } mScreenshotView.getViewTreeObserver().addOnComputeInternalInsetsListener(mScreenshotView); + if (DEBUG_WINDOW) { + Log.d(TAG, "setContentView: " + mScreenshotView); + } + setContentView(mScreenshotView); } /** @@ -587,6 +591,7 @@ public class ScreenshotController { // The window is focusable by default setWindowFocusable(true); + mScreenshotView.requestFocus(); // Wait until this window is attached to request because it is // the reference used to locate the target window (below). @@ -645,10 +650,7 @@ public class ScreenshotController { mContext.getPackageManager().getUserBadgeForDensity(owner, 0)); } mScreenshotView.setScreenshot(mScreenBitmap, screenInsets); - if (DEBUG_WINDOW) { - Log.d(TAG, "setContentView: " + mScreenshotView); - } - setContentView(mScreenshotView); + // ignore system bar insets for the purpose of window layout mWindow.getDecorView().setOnApplyWindowInsetsListener( (v, insets) -> WindowInsets.CONSUMED); -- cgit v1.2.3-59-g8ed1b