Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
- index 1723dcd..99d5fb1 100644
- --- a/core/java/android/provider/Settings.java
- +++ b/core/java/android/provider/Settings.java
- @@ -1836,6 +1836,17 @@ public final class Settings {
- public static final String ACCELEROMETER_ROTATION_MODE = "accelerometer_rotation_mode";
- /**
- + * Swap the volume key assignment in selected orientations
- + * Value is a bitwise combination of
- + * 1 = 0 degrees
- + * 2 = 90 degrees (left)
- + * 4 = 180 degrees (upside down)
- + * 8 = 270 degrees (right)
- + * @hide
- + */
- + public static final String SWAP_VOLUME_KEYS_ORIENTATION = "swap_volume_keys_orientation";
- +
- + /**
- * Specifies the number of recent apps to show (8, 12, 16)
- * @hide
- */
- diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
- index 1e73ade..3ab85fb 100644
- --- a/core/res/res/values/config.xml
- +++ b/core/res/res/values/config.xml
- @@ -176,6 +176,11 @@
- A value of -1 means no change in orientation by default. -->
- <integer name="config_carDockRotation">-1</integer>
- + <!-- The orientation(s) in which case volume keys should be swapped.
- + See ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270 in android.view.Surface.
- + This value is a bitmask of (1 << ROTATION_0), (1 << ROTATION_90) etc. -->
- + <integer name="swap_volume_keys_orientation">0</integer>
- +
- <!-- Control whether being in the desk dock (and powered) always
- keeps the screen on. By default it stays on when plugged in to
- AC. 0 will not keep it on; or together 1 to stay on when plugged
- diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
- index a7c72b4..8c3f9da 100644
- --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
- +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
- @@ -239,6 +239,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
- int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
- static final int DEFAULT_ACCELEROMETER_ROTATION = 0;
- int mAccelerometerDefault = DEFAULT_ACCELEROMETER_ROTATION;
- + int mCurrentOrientation = Surface.ROTATION_0;
- boolean mHasSoftInput = false;
- boolean mCameraKeyPressable = false;
- static final long NEXT_DURATION = 400;
- @@ -1991,8 +1992,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
- // that the music stops right before we call this
- mBroadcastWakeLock.acquire();
- + int volumeUpKey = KeyEvent.KEYCODE_VOLUME_UP;
- + int swapOrientations = Settings.System.getInt(
- + mContext.getContentResolver(),
- + Settings.System.SWAP_VOLUME_KEYS_ORIENTATION,
- + mContext.getResources().getInteger(
- + com.android.internal.R.integer.swap_volume_keys_orientation));
- +
- + if (swapOrientations & (1 << mCurrentOrientation)) {
- + volumeUpKey = KeyEvent.KEYCODE_VOLUME_DOWN;
- + }
- +
- audioService.adjustStreamVolume(stream,
- - keycode == KeyEvent.KEYCODE_VOLUME_UP
- + keycode == volumeUpKey
- ? AudioManager.ADJUST_RAISE
- : AudioManager.ADJUST_LOWER,
- 0);
- @@ -2475,17 +2487,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
- // or orientation sensor disabled
- //or case.unspecified
- if (mLidOpen) {
- - return mLidOpenRotation;
- + mCurrentOrientation = mLidOpenRotation;
- } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
- - return mCarDockRotation;
- + mCurrentOrientation = mCarDockRotation;
- } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
- - return mDeskDockRotation;
- + mCurrentOrientation = mDeskDockRotation;
- } else {
- if (useSensorForOrientationLp(orientation)) {
- - return mOrientationListener.getCurrentRotation(lastRotation);
- + mCurrentOrientation = mOrientationListener.getCurrentRotation(lastRotation);
- + } else {
- + mCurrentOrientation = Surface.ROTATION_0;
- }
- - return Surface.ROTATION_0;
- }
- +
- + return mCurrentOrientation;
- }
- }
Add Comment
Please, Sign In to add comment