Loading core/res/res/values/config.xml +14 −0 Original line number Original line Diff line number Diff line Loading @@ -658,6 +658,20 @@ --> --> </integer-array> </integer-array> <!-- The device states (supplied by DeviceStateManager) that should be treated as half-folded by the display fold controller. Default is empty. --> <integer-array name="config_halfFoldedDeviceStates"> <!-- Example: <item>0</item> <item>1</item> <item>2</item> --> </integer-array> <!-- Indicates whether the window manager reacts to half-fold device states by overriding rotation. --> <bool name="config_windowManagerHalfFoldAutoRotateOverride">false</bool> <!-- When a device enters any of these states, it should be woken up. States are defined in <!-- When a device enters any of these states, it should be woken up. States are defined in device_state_configuration.xml. --> device_state_configuration.xml. --> <integer-array name="config_deviceStatesOnWhichToWakeUp"> <integer-array name="config_deviceStatesOnWhichToWakeUp"> Loading core/res/res/values/symbols.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -4005,6 +4005,8 @@ <!-- For Foldables --> <!-- For Foldables --> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_halfFoldedDeviceStates" /> <java-symbol type="bool" name="config_windowManagerHalfFoldAutoRotateOverride" /> <java-symbol type="array" name="config_deviceStatesOnWhichToWakeUp" /> <java-symbol type="array" name="config_deviceStatesOnWhichToWakeUp" /> <java-symbol type="array" name="config_deviceStatesOnWhichToSleep" /> <java-symbol type="array" name="config_deviceStatesOnWhichToSleep" /> <java-symbol type="string" name="config_foldedArea" /> <java-symbol type="string" name="config_foldedArea" /> Loading data/etc/services.core.protolog.json +12 −0 Original line number Original line Diff line number Diff line Loading @@ -1087,6 +1087,12 @@ "group": "WM_DEBUG_FOCUS", "group": "WM_DEBUG_FOCUS", "at": "com\/android\/server\/wm\/WindowState.java" "at": "com\/android\/server\/wm\/WindowState.java" }, }, "-1043981272": { "message": "Reverting orientation. Rotating to %s from %s rather than %s.", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/DisplayRotation.java" }, "-1042574499": { "-1042574499": { "message": "Attempted to add Accessibility overlay window with unknown token %s. Aborting.", "message": "Attempted to add Accessibility overlay window with unknown token %s. Aborting.", "level": "WARN", "level": "WARN", Loading Loading @@ -4285,6 +4291,12 @@ "group": "WM_ERROR", "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" "at": "com\/android\/server\/wm\/WindowManagerService.java" }, }, "2066210760": { "message": "foldStateChanged: displayId %d, halfFoldStateChanged %s, saved rotation: %d, mUserRotation: %d, mLastSensorRotation: %d, mLastOrientation: %d, mRotation: %d", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/DisplayRotation.java" }, "2070726247": { "2070726247": { "message": "InsetsSource updateVisibility for %s, serverVisible: %s clientVisible: %s", "message": "InsetsSource updateVisibility for %s, serverVisible: %s clientVisible: %s", "level": "DEBUG", "level": "DEBUG", Loading packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -132,8 +132,11 @@ public class RotationButtonController { mMainThreadHandler.postAtFrontOfQueue(() -> { mMainThreadHandler.postAtFrontOfQueue(() -> { // If the screen rotation changes while locked, potentially update lock to flow with // If the screen rotation changes while locked, potentially update lock to flow with // new screen rotation and hide any showing suggestions. // new screen rotation and hide any showing suggestions. if (isRotationLocked()) { boolean rotationLocked = isRotationLocked(); if (shouldOverrideUserLockPrefs(rotation)) { // The isVisible check makes the rotation button disappear when we are not locked // (e.g. for tabletop auto-rotate). if (rotationLocked || mRotationButton.isVisible()) { if (shouldOverrideUserLockPrefs(rotation) && rotationLocked) { setRotationLockedAtAngle(rotation); setRotationLockedAtAngle(rotation); } } setRotateSuggestionButtonState(false /* visible */, true /* forced */); setRotateSuggestionButtonState(false /* visible */, true /* forced */); Loading services/core/java/com/android/server/wm/DeviceStateController.java 0 → 100644 +96 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm; import android.annotation.Nullable; import android.content.Context; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.HandlerExecutor; import com.android.internal.util.ArrayUtils; import java.util.function.Consumer; /** * Class that registers callbacks with the {@link DeviceStateManager} and * responds to fold state changes by forwarding such events to a delegate. */ final class DeviceStateController { private final DeviceStateManager mDeviceStateManager; private final Context mContext; private FoldStateListener mDeviceStateListener; public enum FoldState { UNKNOWN, OPEN, FOLDED, HALF_FOLDED } DeviceStateController(Context context, Handler handler, Consumer<FoldState> delegate) { mContext = context; mDeviceStateManager = mContext.getSystemService(DeviceStateManager.class); if (mDeviceStateManager != null) { mDeviceStateListener = new FoldStateListener(mContext, delegate); mDeviceStateManager .registerCallback(new HandlerExecutor(handler), mDeviceStateListener); } } void unregisterFromDeviceStateManager() { if (mDeviceStateListener != null) { mDeviceStateManager.unregisterCallback(mDeviceStateListener); } } /** * A listener for half-fold device state events that dispatches state changes to a delegate. */ static final class FoldStateListener implements DeviceStateManager.DeviceStateCallback { private final int[] mHalfFoldedDeviceStates; private final int[] mFoldedDeviceStates; @Nullable private FoldState mLastResult; private final Consumer<FoldState> mDelegate; FoldStateListener(Context context, Consumer<FoldState> delegate) { mFoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates); mHalfFoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_halfFoldedDeviceStates); mDelegate = delegate; } @Override public void onStateChanged(int state) { final boolean halfFolded = ArrayUtils.contains(mHalfFoldedDeviceStates, state); FoldState result; if (halfFolded) { result = FoldState.HALF_FOLDED; } else { final boolean folded = ArrayUtils.contains(mFoldedDeviceStates, state); result = folded ? FoldState.FOLDED : FoldState.OPEN; } if (mLastResult == null || !mLastResult.equals(result)) { mLastResult = result; mDelegate.accept(result); } } } } Loading
core/res/res/values/config.xml +14 −0 Original line number Original line Diff line number Diff line Loading @@ -658,6 +658,20 @@ --> --> </integer-array> </integer-array> <!-- The device states (supplied by DeviceStateManager) that should be treated as half-folded by the display fold controller. Default is empty. --> <integer-array name="config_halfFoldedDeviceStates"> <!-- Example: <item>0</item> <item>1</item> <item>2</item> --> </integer-array> <!-- Indicates whether the window manager reacts to half-fold device states by overriding rotation. --> <bool name="config_windowManagerHalfFoldAutoRotateOverride">false</bool> <!-- When a device enters any of these states, it should be woken up. States are defined in <!-- When a device enters any of these states, it should be woken up. States are defined in device_state_configuration.xml. --> device_state_configuration.xml. --> <integer-array name="config_deviceStatesOnWhichToWakeUp"> <integer-array name="config_deviceStatesOnWhichToWakeUp"> Loading
core/res/res/values/symbols.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -4005,6 +4005,8 @@ <!-- For Foldables --> <!-- For Foldables --> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_halfFoldedDeviceStates" /> <java-symbol type="bool" name="config_windowManagerHalfFoldAutoRotateOverride" /> <java-symbol type="array" name="config_deviceStatesOnWhichToWakeUp" /> <java-symbol type="array" name="config_deviceStatesOnWhichToWakeUp" /> <java-symbol type="array" name="config_deviceStatesOnWhichToSleep" /> <java-symbol type="array" name="config_deviceStatesOnWhichToSleep" /> <java-symbol type="string" name="config_foldedArea" /> <java-symbol type="string" name="config_foldedArea" /> Loading
data/etc/services.core.protolog.json +12 −0 Original line number Original line Diff line number Diff line Loading @@ -1087,6 +1087,12 @@ "group": "WM_DEBUG_FOCUS", "group": "WM_DEBUG_FOCUS", "at": "com\/android\/server\/wm\/WindowState.java" "at": "com\/android\/server\/wm\/WindowState.java" }, }, "-1043981272": { "message": "Reverting orientation. Rotating to %s from %s rather than %s.", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/DisplayRotation.java" }, "-1042574499": { "-1042574499": { "message": "Attempted to add Accessibility overlay window with unknown token %s. Aborting.", "message": "Attempted to add Accessibility overlay window with unknown token %s. Aborting.", "level": "WARN", "level": "WARN", Loading Loading @@ -4285,6 +4291,12 @@ "group": "WM_ERROR", "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" "at": "com\/android\/server\/wm\/WindowManagerService.java" }, }, "2066210760": { "message": "foldStateChanged: displayId %d, halfFoldStateChanged %s, saved rotation: %d, mUserRotation: %d, mLastSensorRotation: %d, mLastOrientation: %d, mRotation: %d", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/DisplayRotation.java" }, "2070726247": { "2070726247": { "message": "InsetsSource updateVisibility for %s, serverVisible: %s clientVisible: %s", "message": "InsetsSource updateVisibility for %s, serverVisible: %s clientVisible: %s", "level": "DEBUG", "level": "DEBUG", Loading
packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -132,8 +132,11 @@ public class RotationButtonController { mMainThreadHandler.postAtFrontOfQueue(() -> { mMainThreadHandler.postAtFrontOfQueue(() -> { // If the screen rotation changes while locked, potentially update lock to flow with // If the screen rotation changes while locked, potentially update lock to flow with // new screen rotation and hide any showing suggestions. // new screen rotation and hide any showing suggestions. if (isRotationLocked()) { boolean rotationLocked = isRotationLocked(); if (shouldOverrideUserLockPrefs(rotation)) { // The isVisible check makes the rotation button disappear when we are not locked // (e.g. for tabletop auto-rotate). if (rotationLocked || mRotationButton.isVisible()) { if (shouldOverrideUserLockPrefs(rotation) && rotationLocked) { setRotationLockedAtAngle(rotation); setRotationLockedAtAngle(rotation); } } setRotateSuggestionButtonState(false /* visible */, true /* forced */); setRotateSuggestionButtonState(false /* visible */, true /* forced */); Loading
services/core/java/com/android/server/wm/DeviceStateController.java 0 → 100644 +96 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm; import android.annotation.Nullable; import android.content.Context; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.HandlerExecutor; import com.android.internal.util.ArrayUtils; import java.util.function.Consumer; /** * Class that registers callbacks with the {@link DeviceStateManager} and * responds to fold state changes by forwarding such events to a delegate. */ final class DeviceStateController { private final DeviceStateManager mDeviceStateManager; private final Context mContext; private FoldStateListener mDeviceStateListener; public enum FoldState { UNKNOWN, OPEN, FOLDED, HALF_FOLDED } DeviceStateController(Context context, Handler handler, Consumer<FoldState> delegate) { mContext = context; mDeviceStateManager = mContext.getSystemService(DeviceStateManager.class); if (mDeviceStateManager != null) { mDeviceStateListener = new FoldStateListener(mContext, delegate); mDeviceStateManager .registerCallback(new HandlerExecutor(handler), mDeviceStateListener); } } void unregisterFromDeviceStateManager() { if (mDeviceStateListener != null) { mDeviceStateManager.unregisterCallback(mDeviceStateListener); } } /** * A listener for half-fold device state events that dispatches state changes to a delegate. */ static final class FoldStateListener implements DeviceStateManager.DeviceStateCallback { private final int[] mHalfFoldedDeviceStates; private final int[] mFoldedDeviceStates; @Nullable private FoldState mLastResult; private final Consumer<FoldState> mDelegate; FoldStateListener(Context context, Consumer<FoldState> delegate) { mFoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates); mHalfFoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_halfFoldedDeviceStates); mDelegate = delegate; } @Override public void onStateChanged(int state) { final boolean halfFolded = ArrayUtils.contains(mHalfFoldedDeviceStates, state); FoldState result; if (halfFolded) { result = FoldState.HALF_FOLDED; } else { final boolean folded = ArrayUtils.contains(mFoldedDeviceStates, state); result = folded ? FoldState.FOLDED : FoldState.OPEN; } if (mLastResult == null || !mLastResult.equals(result)) { mLastResult = result; mDelegate.accept(result); } } } }