Volume: Confirm unsafe media volume dialog on VOL_UP.
If the confirmation dialog is showing, consider a new
VOL_UP as a confirmation.
Bug:16540877
Change-Id: Ibdaa43ea423cc3b48d234bcaaa0c542178657b6c
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
index 149d09a..984a5f4 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
@@ -45,6 +45,7 @@
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -249,6 +250,8 @@
private final VolumePanel mVolumePanel;
private final AudioManager mAudioManager;
+ private boolean mNewVolumeUp;
+
SafetyWarning(Context context, VolumePanel volumePanel, AudioManager audioManager) {
super(context);
mContext = context;
@@ -267,6 +270,24 @@
}
@Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
+ mNewVolumeUp = true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && mNewVolumeUp) {
+ if (LOGD) Log.d(TAG, "Confirmed warning via VOLUME_UP");
+ mAudioManager.disableSafeMediaVolume();
+ dismiss();
+ }
+ return super.onKeyUp(keyCode, event);
+ }
+
+ @Override
public void onClick(DialogInterface dialog, int which) {
mAudioManager.disableSafeMediaVolume();
}