daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest May 26th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
  2. index 1723dcd..99d5fb1 100644
  3. --- a/core/java/android/provider/Settings.java
  4. +++ b/core/java/android/provider/Settings.java
  5. @@ -1836,6 +1836,17 @@ public final class Settings {
  6.          public static final String ACCELEROMETER_ROTATION_MODE = "accelerometer_rotation_mode";
  7.  
  8.          /**
  9. +         * Swap the volume key assignment in selected orientations
  10. +         * Value is a bitwise combination of
  11. +         * 1 = 0 degrees
  12. +         * 2 = 90 degrees (left)
  13. +         * 4 = 180 degrees (upside down)
  14. +         * 8 = 270 degrees (right)
  15. +         * @hide
  16. +         */
  17. +        public static final String SWAP_VOLUME_KEYS_ORIENTATION = "swap_volume_keys_orientation";
  18. +
  19. +        /**
  20.           * Specifies the number of recent apps to show (8, 12, 16)
  21.           * @hide
  22.           */
  23. diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
  24. index 1e73ade..3ab85fb 100644
  25. --- a/core/res/res/values/config.xml
  26. +++ b/core/res/res/values/config.xml
  27. @@ -176,6 +176,11 @@
  28.           A value of -1 means no change in orientation by default. -->
  29.      <integer name="config_carDockRotation">-1</integer>
  30.  
  31. +    <!-- The orientation(s) in which case volume keys should be swapped.
  32. +         See ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270 in android.view.Surface.
  33. +         This value is a bitmask of (1 << ROTATION_0), (1 << ROTATION_90) etc. -->
  34. +    <integer name="swap_volume_keys_orientation">0</integer>
  35. +
  36.      <!-- Control whether being in the desk dock (and powered) always
  37.           keeps the screen on.  By default it stays on when plugged in to
  38.           AC.  0 will not keep it on; or together 1 to stay on when plugged
  39. diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
  40. index a7c72b4..8c3f9da 100644
  41. --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
  42. +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
  43. @@ -239,6 +239,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
  44.      int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  45.      static final int DEFAULT_ACCELEROMETER_ROTATION = 0;
  46.      int mAccelerometerDefault = DEFAULT_ACCELEROMETER_ROTATION;
  47. +    int mCurrentOrientation = Surface.ROTATION_0;
  48.      boolean mHasSoftInput = false;
  49.      boolean mCameraKeyPressable = false;
  50.      static final long NEXT_DURATION = 400;
  51. @@ -1991,8 +1992,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
  52.              // that the music stops right before we call this
  53.              mBroadcastWakeLock.acquire();
  54.  
  55. +            int volumeUpKey = KeyEvent.KEYCODE_VOLUME_UP;
  56. +            int swapOrientations = Settings.System.getInt(
  57. +                    mContext.getContentResolver(),
  58. +                    Settings.System.SWAP_VOLUME_KEYS_ORIENTATION,
  59. +                    mContext.getResources().getInteger(
  60. +                            com.android.internal.R.integer.swap_volume_keys_orientation));
  61. +
  62. +            if (swapOrientations & (1 << mCurrentOrientation)) {
  63. +                volumeUpKey = KeyEvent.KEYCODE_VOLUME_DOWN;
  64. +            }
  65. +
  66.              audioService.adjustStreamVolume(stream,
  67. -                keycode == KeyEvent.KEYCODE_VOLUME_UP
  68. +                    keycode == volumeUpKey
  69.                              ? AudioManager.ADJUST_RAISE
  70.                              : AudioManager.ADJUST_LOWER,
  71.                      0);
  72. @@ -2475,17 +2487,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
  73.              // or orientation sensor disabled
  74.              //or case.unspecified
  75.              if (mLidOpen) {
  76. -                return mLidOpenRotation;
  77. +                mCurrentOrientation = mLidOpenRotation;
  78.              } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
  79. -                return mCarDockRotation;
  80. +                mCurrentOrientation = mCarDockRotation;
  81.              } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
  82. -                return mDeskDockRotation;
  83. +                mCurrentOrientation = mDeskDockRotation;
  84.              } else {
  85.                  if (useSensorForOrientationLp(orientation)) {
  86. -                    return mOrientationListener.getCurrentRotation(lastRotation);
  87. +                    mCurrentOrientation = mOrientationListener.getCurrentRotation(lastRotation);
  88. +                } else {
  89. +                    mCurrentOrientation = Surface.ROTATION_0;
  90.                  }
  91. -                return Surface.ROTATION_0;
  92.              }
  93. +
  94. +            return mCurrentOrientation;
  95.          }
  96.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top