diff options
| author | 2025-03-10 23:39:52 +0000 | |
|---|---|---|
| committer | 2025-03-11 02:33:15 +0000 | |
| commit | 5728aca73697fa5ec5e29a37ef80ea35d7aeeb8a (patch) | |
| tree | da5088751ebd2d4b80f7d632f5c74fc405520247 | |
| parent | fedfa7913018180ad37f22ebbc7ffe773331ecdb (diff) | |
Ignore focus change when in RDMV2
In RDMV2, if the device receives a pointer event outside of the
current focused display, the device should not change focus. This
is because the inner display is displaying only a system dialog, and
any interactions with the inner display should not take focus away
from whatever is on the main (outer) display.
In the case of rear camera selfie, changing focus causes the volume
buttons to no longer be sent to the camera app for the shutter action.
Fixes: 398500791
Flag: EXEMPT bugfix
Test: manual test
Test: atest WindowManagerServiceTests
Change-Id: I9eaa1d497d3abb84c1c32079dcb5ad84107a7bc8
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 28f2825150c2..e7a8a766610a 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -199,6 +199,8 @@ import android.graphics.Rect; import android.graphics.Region; import android.hardware.configstore.V1_0.OptionalBool; import android.hardware.configstore.V1_1.ISurfaceFlingerConfigs; +import android.hardware.devicestate.DeviceState; +import android.hardware.devicestate.DeviceStateManager; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.hardware.input.InputSettings; @@ -1034,6 +1036,21 @@ public class WindowManagerService extends IWindowManager.Stub PowerManager mPowerManager; PowerManagerInternal mPowerManagerInternal; + private DeviceStateManager mDeviceStateManager; + private DeviceStateCallback mDeviceStateCallback; + private class DeviceStateCallback implements DeviceStateManager.DeviceStateCallback { + private DeviceState mCurrentDeviceState; + @Override + public void onDeviceStateChanged(@NonNull DeviceState state) { + mCurrentDeviceState = state; + } + + boolean isInRearDisplayOuterDefaultState() { + return mCurrentDeviceState != null && mCurrentDeviceState + .hasProperties(DeviceState.PROPERTY_FEATURE_REAR_DISPLAY_OUTER_DEFAULT); + } + } + private float mWindowAnimationScaleSetting = 1.0f; private float mTransitionAnimationScaleSetting = 1.0f; private float mAnimatorDurationScaleSetting = 1.0f; @@ -1321,6 +1338,10 @@ public class WindowManagerService extends IWindowManager.Stub mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); + mDeviceStateManager = context.getSystemService(DeviceStateManager.class); + mDeviceStateCallback = new DeviceStateCallback(); + mDeviceStateManager.registerCallback(new HandlerExecutor(mH), mDeviceStateCallback); + if (mPowerManagerInternal != null) { mPowerManagerInternal.registerLowPowerModeObserver( new PowerManagerInternal.LowPowerModeListener() { @@ -8975,6 +8996,17 @@ public class WindowManagerService extends IWindowManager.Stub } } + if (mDeviceStateCallback.isInRearDisplayOuterDefaultState()) { + final Display[] rearDisplays = mDisplayManager + .getDisplays(DisplayManager.DISPLAY_CATEGORY_REAR); + if (rearDisplays.length > 0 && rearDisplays[0].getDisplayId() == t.getDisplayId()) { + // Do not change display focus to the inner display if we're in this mode. Note that + // in this mode, the inner display is configured as a rear display. + Slog.w(TAG, "Ignoring focus change because device is in RDM."); + return; + } + } + clearPointerDownOutsideFocusRunnable(); final InputTarget focusedInputTarget = mFocusedInputTarget; |