From 195aad55fac3e845a5552e08d08c6712a5e129ef Mon Sep 17 00:00:00 2001 From: Jiaming Liu Date: Fri, 3 Feb 2023 06:37:24 +0000 Subject: [PATCH] Fix CTS test on devices not supporting concurrent display In onSupportedStatesChanged and updateRearDisplayPresentationStatusListeners, it tries to get the rear display metrics, which will crash on devices without the mode. Bug: 251747141 Test: atest ExtensionWindowLayoutComponentTest Change-Id: I8698e62fdb414f798b9268d568119e9be2712f72 --- .../window/extensions/area/WindowAreaComponentImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java index 3c0c2a10ba683..274dcaee5a431 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java @@ -429,6 +429,9 @@ public class WindowAreaComponentImpl implements WindowAreaComponent, @GuardedBy("mLock") private void updateRearDisplayStatusListeners(@WindowAreaStatus int windowAreaStatus) { + if (mRearDisplayState == INVALID_DEVICE_STATE) { + return; + } synchronized (mLock) { for (int i = 0; i < mRearDisplayStatusListeners.size(); i++) { mRearDisplayStatusListeners.valueAt(i).accept(windowAreaStatus); @@ -454,6 +457,9 @@ public class WindowAreaComponentImpl implements WindowAreaComponent, @GuardedBy("mLock") private void updateRearDisplayPresentationStatusListeners( @WindowAreaStatus int windowAreaStatus) { + if (mConcurrentDisplayState == INVALID_DEVICE_STATE) { + return; + } RearDisplayPresentationStatus consumerValue = new RearDisplayPresentationStatus( windowAreaStatus, getRearDisplayMetrics()); synchronized (mLock) {