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
This commit is contained in:
@@ -45,6 +45,7 @@ import android.provider.Settings.Global;
|
||||
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 @@ public class VolumePanel extends Handler {
|
||||
private final VolumePanel mVolumePanel;
|
||||
private final AudioManager mAudioManager;
|
||||
|
||||
private boolean mNewVolumeUp;
|
||||
|
||||
SafetyWarning(Context context, VolumePanel volumePanel, AudioManager audioManager) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
@@ -266,6 +269,24 @@ public class VolumePanel extends Handler {
|
||||
context.registerReceiver(mReceiver, filter);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
Reference in New Issue
Block a user