diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-04-21 22:59:43 +0700 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2015-12-18 13:29:38 -0800 |
commit | d171b9a3e4ee73cbe19cdb1b99e8e02b53a9c9e0 (patch) | |
tree | 4dad1768c59eff9329158f446fbb04bdf308f1cd /services | |
parent | 46a77b33666c9407845440516685eb4cbef41ff2 (diff) | |
download | frameworks_base-d171b9a3e4ee73cbe19cdb1b99e8e02b53a9c9e0.zip frameworks_base-d171b9a3e4ee73cbe19cdb1b99e8e02b53a9c9e0.tar.gz frameworks_base-d171b9a3e4ee73cbe19cdb1b99e8e02b53a9c9e0.tar.bz2 |
Option to use volume keys to control media volume anytime (2/2)
See Settings part for description
Fix forcing media stream control on tablet
There's option volume_keys_control_ring_stream (Volume keys control ringtone
volume / If on, volume keys control ringtone volume. If off, volume keys
control media volume.) in Settings which is also available on tablets but it
doesn't work on these devices (I didn't find reported issue).
As I like this option and think it may be even more wanted on media devices
such as tablets, here's a fix.
Change-Id: I2f6ebfcbb4ea6e092e4cd29c5acf5f0dbe769718
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index b922218..82c658e 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -126,6 +126,8 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Objects; +import cyanogenmod.providers.CMSettings; + /** * The implementation of the volume manager service. * <p> @@ -590,6 +592,7 @@ public class AudioService extends IAudioService.Stub { private AudioManagerInternal.RingerModeDelegate mRingerModeDelegate; private VolumePolicy mVolumePolicy = VolumePolicy.DEFAULT; private long mLoweredFromNormalToVibrateTime; + private boolean mVolumeKeysControlRingStream; // Intent "extra" data keys. public static final String CONNECT_INTENT_KEY_PORT_NAME = "portName"; @@ -1166,6 +1169,10 @@ public class AudioService extends IAudioService.Stub { updateRingerModeAffectedStreams(); readDockAudioSettings(cr); + + mVolumeKeysControlRingStream = CMSettings.System.getIntForUser(cr, + CMSettings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1, + UserHandle.USER_CURRENT) == 1; } mLinkNotificationWithVolume = Settings.Secure.getInt(cr, @@ -3607,10 +3614,16 @@ public class AudioService extends IAudioService.Stub { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC stream active"); return AudioSystem.STREAM_MUSIC; - } else { + } else { + if (mVolumeKeysControlRingStream) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING b/c default"); return AudioSystem.STREAM_RING; + } else { + if (DEBUG_VOL) + Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC b/c default"); + return AudioSystem.STREAM_MUSIC; + } } } else if (isAfMusicActiveRecently(0)) { if (DEBUG_VOL) @@ -3645,9 +3658,16 @@ public class AudioService extends IAudioService.Stub { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: forcing STREAM_MUSIC"); return AudioSystem.STREAM_MUSIC; } else { - if (DEBUG_VOL) Log.v(TAG, - "getActiveStreamType: using STREAM_NOTIFICATION as default"); - return AudioSystem.STREAM_NOTIFICATION; + if (mVolumeKeysControlRingStream) { + if (DEBUG_VOL) + Log.v(TAG, + "getActiveStreamType: using STREAM_NOTIFICATION as default"); + return AudioSystem.STREAM_NOTIFICATION; + } else { + if (DEBUG_VOL) + Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC b/c default"); + return AudioSystem.STREAM_MUSIC; + } } } break; @@ -4726,6 +4746,8 @@ public class AudioService extends IAudioService.Stub { Settings.Global.DOCK_AUDIO_MEDIA_ENABLED), false, this); mContentResolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.VOLUME_LINK_NOTIFICATION), false, this); + mContentResolver.registerContentObserver(CMSettings.System.getUriFor( + CMSettings.System.VOLUME_KEYS_CONTROL_RING_STREAM), false, this); } @Override @@ -4752,6 +4774,9 @@ public class AudioService extends IAudioService.Stub { createStreamStates(); updateStreamVolumeAlias(true, TAG); } + mVolumeKeysControlRingStream = CMSettings.System.getIntForUser(mContentResolver, + CMSettings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1, + UserHandle.USER_CURRENT) == 1; } } } |