From 22a4d65f66a6155a60d77a22922c195fb22a1bd6 Mon Sep 17 00:00:00 2001 From: nadlabak Date: Mon, 13 May 2013 17:41:57 +0200 Subject: Re-implement orientation aware volume buttons at lower level Rework of http://review.cyanogenmod.org/31979 Fixes: 1. inconsistent volume button behaviour depending on app in use - the buttons were not swapped for some NDK/OPENSL ES apps like e.g. MX Player 2. the function of volume buttons on external input devices like BT/USB keyboards should not be affected by the main unit orientation This commit finishes http://review.cyanogenmod.org/18273 - use of system property has been replaced with config push via JNI as suggested during the original review. Patch Set 7: Circumvent the need for "keyboard.orientationAware = 1" idc Patch Set 8: Don't leak implementation details outside InputReader Change-Id: I19cc60cb0acb0005ab13fa069f52e3d468d694e7 --- media/java/android/media/AudioManager.java | 38 +++++++++--------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'media/java/android/media/AudioManager.java') diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index ac2588d..f55a0bb 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -36,9 +36,7 @@ import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; import android.view.KeyEvent; -import android.view.Surface; import android.view.VolumePanel; -import android.view.WindowManager; import java.util.HashMap; @@ -56,7 +54,6 @@ public class AudioManager { private final boolean mUseVolumeKeySounds; private static String TAG = "AudioManager"; private final ProfileManager mProfileManager; - private final WindowManager mWindowManager; /** * Broadcast intent, a hint for applications that audio is about to become @@ -429,7 +426,6 @@ public class AudioManager { mUseVolumeKeySounds = mContext.getResources().getBoolean( com.android.internal.R.bool.config_useVolumeKeySounds); mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE); - mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); } private static IAudioService getService() @@ -480,33 +476,21 @@ public class AudioManager { * Adjust the volume in on key down since it is more * responsive to the user. */ - int direction; - int swapKeys = Settings.System.getInt(mContext.getContentResolver(), - Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0); - int rotation = mWindowManager.getDefaultDisplay().getRotation(); - if (swapKeys == 1 // phone or hybrid - && (rotation == Surface.ROTATION_90 - || rotation == Surface.ROTATION_180)) { - direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP - ? ADJUST_LOWER - : ADJUST_RAISE; - } else if (swapKeys == 2 // tablet - && (rotation == Surface.ROTATION_180 - || rotation == Surface.ROTATION_270)) { - direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP - ? ADJUST_LOWER - : ADJUST_RAISE; - } else { - direction = keyCode == KeyEvent.KEYCODE_VOLUME_UP - ? ADJUST_RAISE - : ADJUST_LOWER; - } int flags = FLAG_SHOW_UI | FLAG_VIBRATE; if (mUseMasterVolume) { - adjustMasterVolume(direction, flags); + adjustMasterVolume( + keyCode == KeyEvent.KEYCODE_VOLUME_UP + ? ADJUST_RAISE + : ADJUST_LOWER, + flags); } else { - adjustSuggestedStreamVolume(direction, stream, flags); + adjustSuggestedStreamVolume( + keyCode == KeyEvent.KEYCODE_VOLUME_UP + ? ADJUST_RAISE + : ADJUST_LOWER, + stream, + flags); } break; case KeyEvent.KEYCODE_VOLUME_MUTE: -- cgit v1.1