diff options
author | Mike Lockwood <lockwood@android.com> | 2011-10-27 09:52:41 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@google.com> | 2012-02-10 09:05:49 -0800 |
commit | 8dc1dabd254249b7ddb8743e88fdb96580ffc585 (patch) | |
tree | 3bff43a9256894541d407f8d6ea18ae375b9ca31 /media/java | |
parent | 8517e46f3d3c2ce11de09aa849a8533ffc1a2026 (diff) | |
download | frameworks_base-8dc1dabd254249b7ddb8743e88fdb96580ffc585.zip frameworks_base-8dc1dabd254249b7ddb8743e88fdb96580ffc585.tar.gz frameworks_base-8dc1dabd254249b7ddb8743e88fdb96580ffc585.tar.bz2 |
VolumePanel: Add support for master volume
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/AudioManager.java | 12 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 11 | ||||
-rw-r--r-- | media/java/android/media/IAudioService.aidl | 6 |
3 files changed, 21 insertions, 8 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index d131176..3f5d192 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -386,7 +386,7 @@ public class AudioManager { * since the last volume key up, so cancel any sounds. */ if (mUseMasterVolume) { - adjustMasterVolume(ADJUST_SAME); + adjustMasterVolume(ADJUST_SAME, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE); } else { adjustSuggestedStreamVolume(ADJUST_SAME, stream, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE); @@ -410,7 +410,8 @@ public class AudioManager { adjustMasterVolume( keyCode == KeyEvent.KEYCODE_VOLUME_UP ? ADJUST_RAISE - : ADJUST_LOWER); + : ADJUST_LOWER, + flags); } else { if (mVolumeControlStream != -1) { stream = mVolumeControlStream; @@ -443,7 +444,7 @@ public class AudioManager { */ if (mUseMasterVolume) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { - adjustMasterVolume(ADJUST_SAME); + adjustMasterVolume(ADJUST_SAME, FLAG_PLAY_SOUND); } } else { int flags = FLAG_PLAY_SOUND; @@ -549,11 +550,12 @@ public class AudioManager { * @param direction The direction to adjust the volume. One of * {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or * {@link #ADJUST_SAME}. + * @param flags One or more flags. */ - private void adjustMasterVolume(int direction) { + private void adjustMasterVolume(int direction, int flags) { IAudioService service = getService(); try { - service.adjustMasterVolume(direction); + service.adjustMasterVolume(direction, flags); } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustMasterVolume", e); } diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 8b97594..8259202 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -615,7 +615,7 @@ public class AudioService extends IAudioService.Stub { } /** @see AudioManager#adjustMasterVolume(int) */ - public void adjustMasterVolume(int direction) { + public void adjustMasterVolume(int direction, int flags) { ensureValidDirection(direction); float volume = AudioSystem.getMasterVolume(); @@ -631,6 +631,7 @@ public class AudioService extends IAudioService.Stub { long origCallerIdentityToken = Binder.clearCallingIdentity(); Settings.System.putFloat(mContentResolver, Settings.System.VOLUME_MASTER, volume); Binder.restoreCallingIdentity(origCallerIdentityToken); + mVolumePanel.postMasterVolumeChanged(flags); } } @@ -764,6 +765,14 @@ public class AudioService extends IAudioService.Stub { return (mStreamStates[streamType].getIndex(device, false /* lastAudible */) + 5) / 10; } + public float getMasterVolume() { + return AudioSystem.getMasterVolume(); + } + + public void setMasterVolume(float volume) { + AudioSystem.setMasterVolume(volume); + } + /** @see AudioManager#getStreamMaxVolume(int) */ public int getStreamMaxVolume(int streamType) { ensureValidStreamType(streamType); diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index fd15c69..01a2314 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -33,7 +33,7 @@ interface IAudioService { void adjustStreamVolume(int streamType, int direction, int flags); - void adjustMasterVolume(int direction); + void adjustMasterVolume(int direction, int flags); void setStreamVolume(int streamType, int index, int flags); @@ -44,7 +44,9 @@ interface IAudioService { boolean isStreamMute(int streamType); int getStreamVolume(int streamType); - + + float getMasterVolume(); + int getStreamMaxVolume(int streamType); int getLastAudibleStreamVolume(int streamType); |