From 5e8db33bc59b7f1e57f616c1133ef1ad8b0401f2 Mon Sep 17 00:00:00 2001 From: Kenneth Ford Date: Tue, 14 Feb 2023 22:11:48 +0000 Subject: [PATCH] Return STATUS_UNSUPPORTED if WindowAreaComponent is not supported Devices may support WM Extensions and use the reference implementation, but may not support WindowAreaComponent features. This change returns UNSUPPORTED values instead of UNAVAILABLE for status updates on these devices. Bug: 269338840 Test: ExtensionRearDisplayTest#testRearDisplayStatusUnsupported_rearDisplayDeviceStateNotDefined Change-Id: I4b8d6c50474849442f67b18040ecee19c2b5e13b Merged-In: I4b8d6c50474849442f67b18040ecee19c2b5e13b --- .../extensions/area/WindowAreaComponentImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 274dcaee5a431..575b0cea78f75 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java @@ -263,8 +263,10 @@ public class WindowAreaComponentImpl implements WindowAreaComponent, return; } @WindowAreaStatus int currentStatus = getCurrentRearDisplayPresentationModeStatus(); + DisplayMetrics metrics = + currentStatus == STATUS_UNSUPPORTED ? null : getRearDisplayMetrics(); consumer.accept( - new RearDisplayPresentationStatus(currentStatus, getRearDisplayMetrics())); + new RearDisplayPresentationStatus(currentStatus, metrics)); } } @@ -408,6 +410,10 @@ public class WindowAreaComponentImpl implements WindowAreaComponent, @GuardedBy("mLock") private int getCurrentRearDisplayModeStatus() { + if (mRearDisplayState == INVALID_DEVICE_STATE) { + return WindowAreaComponent.STATUS_UNSUPPORTED; + } + if (mRearDisplaySessionStatus == WindowAreaComponent.SESSION_STATE_ACTIVE || !ArrayUtils.contains(mCurrentSupportedDeviceStates, mRearDisplayState) || isRearDisplayActive()) { @@ -441,6 +447,10 @@ public class WindowAreaComponentImpl implements WindowAreaComponent, @GuardedBy("mLock") private int getCurrentRearDisplayPresentationModeStatus() { + if (mConcurrentDisplayState == INVALID_DEVICE_STATE) { + return WindowAreaComponent.STATUS_UNSUPPORTED; + } + if (mCurrentDeviceState == mConcurrentDisplayState || !ArrayUtils.contains(mCurrentSupportedDeviceStates, mConcurrentDisplayState) || isDeviceFolded()) {