diff options
author | Amith Yamasani <yamasani@google.com> | 2011-12-01 14:01:30 -0800 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2011-12-01 15:05:54 -0800 |
commit | 2ef6f1bb5603c2e221191117695725237f49a5d5 (patch) | |
tree | 3bcbff95c91f81308cd8520563b28179df796e59 | |
parent | 0433c157141b9122f6c61498e909770f1db27c7c (diff) | |
download | frameworks_base-2ef6f1bb5603c2e221191117695725237f49a5d5.zip frameworks_base-2ef6f1bb5603c2e221191117695725237f49a5d5.tar.gz frameworks_base-2ef6f1bb5603c2e221191117695725237f49a5d5.tar.bz2 |
Further volume improvements.
- Remove silent mode from Power menu
- Show volume dialog on lockscreen
- Allow beeps when adjusting volume in lockscreen
Bug: 5586083
Change-Id: I93052a8ec5004c784f20e04488af9382d495e711
3 files changed, 57 insertions, 47 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 5e7a7eb..afb28a8 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -21,7 +21,6 @@ import static android.media.AudioManager.RINGER_MODE_SILENT; import static android.media.AudioManager.RINGER_MODE_VIBRATE; import android.app.ActivityManagerNative; -import android.app.KeyguardManager; import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.bluetooth.BluetoothA2dp; @@ -320,8 +319,6 @@ public class AudioService extends IAudioService.Stub { private static final int NOTIFICATION_VOLUME_DELAY_MS = 5000; // previous volume adjustment direction received by checkForRingerModeChange() private int mPrevVolDirection = AudioManager.ADJUST_SAME; - // Keyguard manager proxy - private KeyguardManager mKeyguardManager; /////////////////////////////////////////////////////////////////////////// // Construction @@ -506,10 +503,9 @@ public class AudioService extends IAudioService.Stub { streamType = getActiveStreamType(suggestedStreamType); } - // Play sounds on STREAM_RING only and if lock screen is not on. + // Play sounds on STREAM_RING only. if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0 && - ((STREAM_VOLUME_ALIAS[streamType] != AudioSystem.STREAM_RING) || - (mKeyguardManager != null && mKeyguardManager.isKeyguardLocked()))) { + ((STREAM_VOLUME_ALIAS[streamType] != AudioSystem.STREAM_RING))) { flags &= ~AudioManager.FLAG_PLAY_SOUND; } @@ -2595,8 +2591,6 @@ public class AudioService extends IAudioService.Stub { sendMsg(mAudioHandler, MSG_LOAD_SOUND_EFFECTS, SHARED_MSG, SENDMSG_NOOP, 0, 0, null, 0); - mKeyguardManager = - (KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE); mScoConnectionState = AudioManager.SCO_AUDIO_STATE_ERROR; resetBluetoothSco(); getBluetoothHeadset(); diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index f040e87..abbb54b 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -56,6 +56,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private static final String TAG = "GlobalActions"; + private static final boolean SHOW_SILENT_TOGGLE = false; + private final Context mContext; private final AudioManager mAudioManager; @@ -187,29 +189,35 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } }; - mItems = Lists.newArrayList( - // silent mode - mSilentModeToggle, - // next: airplane mode - mAirplaneModeOn, - // last: power off - new SinglePressAction( - com.android.internal.R.drawable.ic_lock_power_off, - R.string.global_action_power_off) { - - public void onPress() { - // shutdown by making sure radio and power are handled accordingly. - ShutdownThread.shutdown(mContext, true); - } - - public boolean showDuringKeyguard() { - return true; - } - - public boolean showBeforeProvisioning() { - return true; - } - }); + mItems = new ArrayList<Action>(); + + // silent mode + if (SHOW_SILENT_TOGGLE) { + mItems.add(mSilentModeToggle); + } + + // next: airplane mode + mItems.add(mAirplaneModeOn); + + // last: power off + mItems.add( + new SinglePressAction( + com.android.internal.R.drawable.ic_lock_power_off, + R.string.global_action_power_off) { + + public void onPress() { + // shutdown by making sure radio and power are handled accordingly. + ShutdownThread.shutdown(mContext, true); + } + + public boolean showDuringKeyguard() { + return true; + } + + public boolean showBeforeProvisioning() { + return true; + } + }); mAdapter = new MyAdapter(); diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java index 26bd697..de7547b 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java @@ -46,6 +46,10 @@ public abstract class KeyguardViewBase extends FrameLayout { private KeyguardViewCallback mCallback; private AudioManager mAudioManager; private TelephonyManager mTelephonyManager = null; + // Whether the volume keys should be handled by keyguard. If true, then + // they will be handled here for specific media types such as music, otherwise + // the audio service will bring up the volume dialog. + private static final boolean KEYGUARD_MANAGES_VOLUME = false; // This is a faster way to draw the background on devices without hardware acceleration Drawable mBackgroundDrawable = new Drawable() { @@ -203,24 +207,28 @@ public abstract class KeyguardViewBase extends FrameLayout { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: { - synchronized (this) { - if (mAudioManager == null) { - mAudioManager = (AudioManager) getContext().getSystemService( - Context.AUDIO_SERVICE); + if (KEYGUARD_MANAGES_VOLUME) { + synchronized (this) { + if (mAudioManager == null) { + mAudioManager = (AudioManager) getContext().getSystemService( + Context.AUDIO_SERVICE); + } } + // Volume buttons should only function for music. + if (mAudioManager.isMusicActive()) { + // TODO: Actually handle MUTE. + mAudioManager.adjustStreamVolume( + AudioManager.STREAM_MUSIC, + keyCode == KeyEvent.KEYCODE_VOLUME_UP + ? AudioManager.ADJUST_RAISE + : AudioManager.ADJUST_LOWER, + 0); + } + // Don't execute default volume behavior + return true; + } else { + return false; } - // Volume buttons should only function for music. - if (mAudioManager.isMusicActive()) { - // TODO: Actually handle MUTE. - mAudioManager.adjustStreamVolume( - AudioManager.STREAM_MUSIC, - keyCode == KeyEvent.KEYCODE_VOLUME_UP - ? AudioManager.ADJUST_RAISE - : AudioManager.ADJUST_LOWER, - 0); - } - // Don't execute default volume behavior - return true; } } } else if (event.getAction() == KeyEvent.ACTION_UP) { |