Loading core/java/android/view/IWindowManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -390,7 +390,7 @@ interface IWindowManager /** * Sets display rotation to {@link rotation} if auto-rotate is OFF. */ void setRotationAtAngleIfLocked(int rotation, String caller); void setRotationAtAngleIfAllowed(int rotation, String caller); /** * Lock the display orientation to the specified rotation, or to the current Loading core/java/com/android/internal/view/RotationPolicy.java +2 −2 Original line number Diff line number Diff line Loading @@ -144,13 +144,13 @@ public final class RotationPolicy { * Sets screen rotation to {@link rotation} if the value of {@link ACCELEROMETER_ROTATION} is * false. */ public static void setRotationAtAngleIfLocked(final int rotation, String caller) { public static void setRotationAtAngleIfAllowed(final int rotation, String caller) { AsyncTask.execute(new Runnable() { @Override public void run() { try { IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.setRotationAtAngleIfLocked(rotation, caller); wm.setRotationAtAngleIfAllowed(rotation, caller); } catch (RemoteException exc) { Log.w(TAG, "Unable to set rotation to:" + rotation); } Loading packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +28 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.shared.rotation; import static android.content.pm.PackageManager.FEATURE_PC; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.internal.view.RotationPolicy.NATURAL_ROTATION; Loading @@ -36,6 +38,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.hardware.devicestate.DeviceState; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -70,6 +74,7 @@ import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.window.flags.Flags; import java.io.PrintWriter; import java.util.List; import java.util.Optional; import java.util.concurrent.Executor; import java.util.concurrent.ThreadPoolExecutor; Loading Loading @@ -308,8 +313,8 @@ public class RotationButtonController { // Ignore if we can't read the setting for the current user return; } if (Flags.enableDeviceStateAutoRotateSettingRefactor()) { RotationPolicy.setRotationAtAngleIfLocked(rotationSuggestion, caller); if (isFoldable() && Flags.enableDeviceStateAutoRotateSettingRefactor()) { RotationPolicy.setRotationAtAngleIfAllowed(rotationSuggestion, caller); return; } Loading Loading @@ -701,6 +706,27 @@ public class RotationButtonController { } } private boolean isFoldable() { if (android.hardware.devicestate.feature.flags.Flags.deviceStatePropertyMigration()) { final DeviceStateManager deviceStateManager = mContext.getSystemService( DeviceStateManager.class); if (deviceStateManager == null) return false; List<DeviceState> deviceStates = deviceStateManager.getSupportedDeviceStates(); for (int i = 0; i < deviceStates.size(); i++) { DeviceState state = deviceStates.get(i); if (state.hasProperty(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY) || state.hasProperty( PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) { return true; } } return false; } else { return mContext.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates).length != 0; } } private class TaskStackListenerImpl implements TaskStackChangeListener { // Invalidate any rotation suggestion on task change or activity orientation change // Note: all callbacks happen on main thread Loading packages/SystemUI/src/com/android/systemui/util/wrapper/RotationPolicyWrapper.kt +4 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import javax.inject.Inject interface RotationPolicyWrapper { fun setRotationLock(enabled: Boolean, caller: String) fun setRotationLockAtAngle(enabled: Boolean, rotation: Int, caller: String) fun setRotationAtAngleIfLocked(rotation: Int, caller: String) fun setRotationAtAngleIfAllowed(rotation: Int, caller: String) fun getRotationLockOrientation(): Int fun isRotationLockToggleVisible(): Boolean fun isRotationLocked(): Boolean Loading Loading @@ -58,9 +58,9 @@ class RotationPolicyWrapperImpl @Inject constructor( /** * Sets screen rotation to [rotation] if the value of [ACCELEROMETER_ROTATION] is false. */ override fun setRotationAtAngleIfLocked(rotation: Int, caller: String) { traceSection("RotationPolicyWrapperImpl#setRotationAtAngleIfLocked") { RotationPolicy.setRotationAtAngleIfLocked(rotation, caller) override fun setRotationAtAngleIfAllowed(rotation: Int, caller: String) { traceSection("RotationPolicyWrapperImpl#setRotationAtAngleIfAllowed") { RotationPolicy.setRotationAtAngleIfAllowed(rotation, caller) } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public class DeviceStateRotationLockSettingControllerTest extends SysuiTestCase } @Override public void setRotationAtAngleIfLocked(int rotation, String caller) { public void setRotationAtAngleIfAllowed(int rotation, String caller) { throw new AssertionError("Not implemented"); } Loading Loading
core/java/android/view/IWindowManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -390,7 +390,7 @@ interface IWindowManager /** * Sets display rotation to {@link rotation} if auto-rotate is OFF. */ void setRotationAtAngleIfLocked(int rotation, String caller); void setRotationAtAngleIfAllowed(int rotation, String caller); /** * Lock the display orientation to the specified rotation, or to the current Loading
core/java/com/android/internal/view/RotationPolicy.java +2 −2 Original line number Diff line number Diff line Loading @@ -144,13 +144,13 @@ public final class RotationPolicy { * Sets screen rotation to {@link rotation} if the value of {@link ACCELEROMETER_ROTATION} is * false. */ public static void setRotationAtAngleIfLocked(final int rotation, String caller) { public static void setRotationAtAngleIfAllowed(final int rotation, String caller) { AsyncTask.execute(new Runnable() { @Override public void run() { try { IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); wm.setRotationAtAngleIfLocked(rotation, caller); wm.setRotationAtAngleIfAllowed(rotation, caller); } catch (RemoteException exc) { Log.w(TAG, "Unable to set rotation to:" + rotation); } Loading
packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +28 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.shared.rotation; import static android.content.pm.PackageManager.FEATURE_PC; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.internal.view.RotationPolicy.NATURAL_ROTATION; Loading @@ -36,6 +38,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.hardware.devicestate.DeviceState; import android.hardware.devicestate.DeviceStateManager; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -70,6 +74,7 @@ import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.window.flags.Flags; import java.io.PrintWriter; import java.util.List; import java.util.Optional; import java.util.concurrent.Executor; import java.util.concurrent.ThreadPoolExecutor; Loading Loading @@ -308,8 +313,8 @@ public class RotationButtonController { // Ignore if we can't read the setting for the current user return; } if (Flags.enableDeviceStateAutoRotateSettingRefactor()) { RotationPolicy.setRotationAtAngleIfLocked(rotationSuggestion, caller); if (isFoldable() && Flags.enableDeviceStateAutoRotateSettingRefactor()) { RotationPolicy.setRotationAtAngleIfAllowed(rotationSuggestion, caller); return; } Loading Loading @@ -701,6 +706,27 @@ public class RotationButtonController { } } private boolean isFoldable() { if (android.hardware.devicestate.feature.flags.Flags.deviceStatePropertyMigration()) { final DeviceStateManager deviceStateManager = mContext.getSystemService( DeviceStateManager.class); if (deviceStateManager == null) return false; List<DeviceState> deviceStates = deviceStateManager.getSupportedDeviceStates(); for (int i = 0; i < deviceStates.size(); i++) { DeviceState state = deviceStates.get(i); if (state.hasProperty(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY) || state.hasProperty( PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) { return true; } } return false; } else { return mContext.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates).length != 0; } } private class TaskStackListenerImpl implements TaskStackChangeListener { // Invalidate any rotation suggestion on task change or activity orientation change // Note: all callbacks happen on main thread Loading
packages/SystemUI/src/com/android/systemui/util/wrapper/RotationPolicyWrapper.kt +4 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import javax.inject.Inject interface RotationPolicyWrapper { fun setRotationLock(enabled: Boolean, caller: String) fun setRotationLockAtAngle(enabled: Boolean, rotation: Int, caller: String) fun setRotationAtAngleIfLocked(rotation: Int, caller: String) fun setRotationAtAngleIfAllowed(rotation: Int, caller: String) fun getRotationLockOrientation(): Int fun isRotationLockToggleVisible(): Boolean fun isRotationLocked(): Boolean Loading Loading @@ -58,9 +58,9 @@ class RotationPolicyWrapperImpl @Inject constructor( /** * Sets screen rotation to [rotation] if the value of [ACCELEROMETER_ROTATION] is false. */ override fun setRotationAtAngleIfLocked(rotation: Int, caller: String) { traceSection("RotationPolicyWrapperImpl#setRotationAtAngleIfLocked") { RotationPolicy.setRotationAtAngleIfLocked(rotation, caller) override fun setRotationAtAngleIfAllowed(rotation: Int, caller: String) { traceSection("RotationPolicyWrapperImpl#setRotationAtAngleIfAllowed") { RotationPolicy.setRotationAtAngleIfAllowed(rotation, caller) } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public class DeviceStateRotationLockSettingControllerTest extends SysuiTestCase } @Override public void setRotationAtAngleIfLocked(int rotation, String caller) { public void setRotationAtAngleIfAllowed(int rotation, String caller) { throw new AssertionError("Not implemented"); } Loading