diff options
author | Amith Yamasani <yamasani@google.com> | 2011-12-02 11:22:32 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-12-02 11:22:32 -0800 |
commit | afd01086795c7c1f6950a709180b2361625b8b6a (patch) | |
tree | e60d1c42d3e8d76e70776585167dbc8605ff9a74 /policy | |
parent | f96aa3b197b96f9cb276485420c09a7b36606599 (diff) | |
parent | 2ef6f1bb5603c2e221191117695725237f49a5d5 (diff) | |
download | frameworks_base-afd01086795c7c1f6950a709180b2361625b8b6a.zip frameworks_base-afd01086795c7c1f6950a709180b2361625b8b6a.tar.gz frameworks_base-afd01086795c7c1f6950a709180b2361625b8b6a.tar.bz2 |
Merge "Further volume improvements." into ics-mr1
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/GlobalActions.java | 54 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/KeyguardViewBase.java | 40 |
2 files changed, 55 insertions, 39 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index 8052c80..3fc53aa 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) { |