diff options
| author | 2017-12-07 21:53:13 +0000 | |
|---|---|---|
| committer | 2017-12-07 21:53:13 +0000 | |
| commit | 6e15c2a89ae9733d2552d9d0a20504a4bdf69c29 (patch) | |
| tree | 2c0cc9ee438843abfc91dd1d8e65a8ee2254dad8 | |
| parent | 0d79306b0de30b44fa57ec325999c0232a6abd64 (diff) | |
| parent | 6ca8711b7b1a87aec2ad81bf07663bb54058eaca (diff) | |
Merge "Extend RotationPolicy to lock the screen at a specific rotation"
4 files changed, 19 insertions, 1 deletions
diff --git a/core/java/com/android/internal/view/RotationPolicy.java b/core/java/com/android/internal/view/RotationPolicy.java index b479cb1fb6d3..d7b91325c961 100644 --- a/core/java/com/android/internal/view/RotationPolicy.java +++ b/core/java/com/android/internal/view/RotationPolicy.java @@ -108,11 +108,19 @@ public final class RotationPolicy { * Enables or disables rotation lock from the system UI toggle. */ public static void setRotationLock(Context context, final boolean enabled) { + final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; + setRotationLockAtAngle(context, enabled, rotation); + } + + /** + * Enables or disables rotation lock at a specific rotation from system UI. + */ + public static void setRotationLockAtAngle(Context context, final boolean enabled, + final int rotation) { Settings.System.putIntForUser(context.getContentResolver(), Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0, UserHandle.USER_CURRENT); - final int rotation = areAllRotationsAllowed(context) ? CURRENT_ROTATION : NATURAL_ROTATION; setRotationLock(enabled, rotation); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java index 722874b07c97..f258fb19ff7d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockController.java @@ -24,6 +24,7 @@ public interface RotationLockController extends Listenable, boolean isRotationLockAffordanceVisible(); boolean isRotationLocked(); void setRotationLocked(boolean locked); + void setRotationLockedAtAngle(boolean locked, int rotation); public interface RotationLockControllerCallback { void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockControllerImpl.java index 4f964964cd68..5418dc14e0bb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RotationLockControllerImpl.java @@ -63,6 +63,10 @@ public final class RotationLockControllerImpl implements RotationLockController RotationPolicy.setRotationLock(mContext, locked); } + public void setRotationLockedAtAngle(boolean locked, int rotation){ + RotationPolicy.setRotationLockAtAngle(mContext, locked, rotation); + } + public boolean isRotationLockAffordanceVisible() { return RotationPolicy.isRotationLockToggleVisible(mContext); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeRotationLockController.java b/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeRotationLockController.java index d60fe78e9d6e..be110242a3eb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeRotationLockController.java +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/leaks/FakeRotationLockController.java @@ -49,4 +49,9 @@ public class FakeRotationLockController extends BaseLeakChecker<RotationLockCont public void setRotationLocked(boolean locked) { } + + @Override + public void setRotationLockedAtAngle(boolean locked, int rotation) { + + } } |