summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-07-24 18:10:48 -0400
committerJohn Spurlock <jspurlock@google.com>2014-07-25 11:27:51 -0400
commit351346092acdfbfcc1d9ebf98d539d2a1196c5e8 (patch)
treecac60a4a224053998b911033a3a8aac3f38ccec9 /packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
parented1391a9297db5e2a8671bbf2d83654ee5d28702 (diff)
downloadframeworks_base-351346092acdfbfcc1d9ebf98d539d2a1196c5e8.zip
frameworks_base-351346092acdfbfcc1d9ebf98d539d2a1196c5e8.tar.gz
frameworks_base-351346092acdfbfcc1d9ebf98d539d2a1196c5e8.tar.bz2
Volume: Show safe media warning in settings.
If the safe media warning is enabled, make sure we display it from the new inline slider preference in Settings (without showing the volume dialog itself). Also: - Update the warning dialog to the new sysui theme. - Separate the warning sentences with an additional line. - Fix the auto-dismiss timeout. - Add a system property to additionally enable the safe media warning for testing - Add more information to audio service dumpsys. Bug:15434662 Change-Id: I95fec12c9049bbfdb7ebdf246160e4b12c0c5be3
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java93
1 files changed, 50 insertions, 43 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
index b85fbf3..149d09a 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
@@ -58,6 +58,7 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import com.android.internal.R;
+import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.ZenModeController;
import java.io.FileDescriptor;
@@ -89,6 +90,7 @@ public class VolumePanel extends Handler {
private static final int TIMEOUT_DELAY = 3000;
private static final int TIMEOUT_DELAY_SHORT = 1500;
private static final int TIMEOUT_DELAY_COLLAPSED = 4500;
+ private static final int TIMEOUT_DELAY_SAFETY_WARNING = 5000;
private static final int TIMEOUT_DELAY_EXPANDED = 10000;
private static final int MSG_VOLUME_CHANGED = 0;
@@ -238,42 +240,61 @@ public class VolumePanel extends Handler {
private ToneGenerator mToneGenerators[];
private Vibrator mVibrator;
- private static AlertDialog sConfirmSafeVolumeDialog;
- private static Object sConfirmSafeVolumeLock = new Object();
+ private static AlertDialog sSafetyWarning;
+ private static Object sSafetyWarningLock = new Object();
- private static class WarningDialogReceiver extends BroadcastReceiver
- implements DialogInterface.OnDismissListener {
+ private static class SafetyWarning extends SystemUIDialog
+ implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener {
private final Context mContext;
- private final Dialog mDialog;
private final VolumePanel mVolumePanel;
+ private final AudioManager mAudioManager;
- WarningDialogReceiver(Context context, Dialog dialog, VolumePanel volumePanel) {
+ SafetyWarning(Context context, VolumePanel volumePanel, AudioManager audioManager) {
+ super(context);
mContext = context;
- mDialog = dialog;
mVolumePanel = volumePanel;
+ mAudioManager = audioManager;
+
+ setMessage(mContext.getString(com.android.internal.R.string.safe_media_volume_warning));
+ setButton(DialogInterface.BUTTON_POSITIVE,
+ mContext.getString(com.android.internal.R.string.yes), this);
+ setButton(DialogInterface.BUTTON_NEGATIVE,
+ mContext.getString(com.android.internal.R.string.no), (OnClickListener) null);
+ setOnDismissListener(this);
+
IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
- context.registerReceiver(this, filter);
+ context.registerReceiver(mReceiver, filter);
}
@Override
- public void onReceive(Context context, Intent intent) {
- mDialog.cancel();
- cleanUp();
+ public void onClick(DialogInterface dialog, int which) {
+ mAudioManager.disableSafeMediaVolume();
}
@Override
public void onDismiss(DialogInterface unused) {
- mContext.unregisterReceiver(this);
+ mContext.unregisterReceiver(mReceiver);
cleanUp();
}
private void cleanUp() {
- synchronized (sConfirmSafeVolumeLock) {
- sConfirmSafeVolumeDialog = null;
+ synchronized (sSafetyWarningLock) {
+ sSafetyWarning = null;
}
mVolumePanel.forceTimeout(0);
mVolumePanel.updateStates();
}
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
+ if (LOGD) Log.d(TAG, "Received ACTION_CLOSE_SYSTEM_DIALOGS");
+ cancel();
+ cleanUp();
+ }
+ }
+ };
}
public VolumePanel(Context context, ZenModeController zenController) {
@@ -305,7 +326,7 @@ public class VolumePanel extends Handler {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE &&
- sConfirmSafeVolumeDialog == null) {
+ sSafetyWarning == null) {
forceTimeout(0);
return true;
}
@@ -389,7 +410,7 @@ public class VolumePanel extends Handler {
pw.print(" isShowing()="); pw.println(isShowing());
pw.print(" mCallback="); pw.println(mCallback);
pw.print(" sConfirmSafeVolumeDialog=");
- pw.println(sConfirmSafeVolumeDialog != null ? "<not null>" : null);
+ pw.println(sSafetyWarning != null ? "<not null>" : null);
pw.print(" mActiveStreamType="); pw.println(mActiveStreamType);
pw.print(" mStreamControls=");
if (mStreamControls == null) {
@@ -640,7 +661,7 @@ public class VolumePanel extends Handler {
sc.seekbarView.setEnabled(!fixedVolume);
} else if (fixedVolume ||
(sc.streamType != mAudioManager.getMasterStreamType() && muted) ||
- (sConfirmSafeVolumeDialog != null)) {
+ (sSafetyWarning != null)) {
sc.seekbarView.setEnabled(false);
} else if (isRinger && mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
sc.seekbarView.setEnabled(false);
@@ -687,7 +708,8 @@ public class VolumePanel extends Handler {
}
private void updateTimeoutDelay() {
- mTimeoutDelay = mActiveStreamType == AudioManager.STREAM_MUSIC ? TIMEOUT_DELAY_SHORT
+ mTimeoutDelay = sSafetyWarning != null ? TIMEOUT_DELAY_SAFETY_WARNING
+ : mActiveStreamType == AudioManager.STREAM_MUSIC ? TIMEOUT_DELAY_SHORT
: mZenPanelExpanded ? TIMEOUT_DELAY_EXPANDED
: isZenPanelVisible() ? TIMEOUT_DELAY_COLLAPSED
: TIMEOUT_DELAY;
@@ -1105,30 +1127,14 @@ public class VolumePanel extends Handler {
}
protected void onDisplaySafeVolumeWarning(int flags) {
- if ((flags & AudioManager.FLAG_SHOW_UI) != 0 || isShowing()) {
- synchronized (sConfirmSafeVolumeLock) {
- if (sConfirmSafeVolumeDialog != null) {
+ if ((flags & (AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_SHOW_UI_WARNINGS)) != 0
+ || isShowing()) {
+ synchronized (sSafetyWarningLock) {
+ if (sSafetyWarning != null) {
return;
}
- sConfirmSafeVolumeDialog = new AlertDialog.Builder(mContext)
- .setMessage(com.android.internal.R.string.safe_media_volume_warning)
- .setPositiveButton(com.android.internal.R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- mAudioManager.disableSafeMediaVolume();
- }
- })
- .setNegativeButton(com.android.internal.R.string.no, null)
- .setIconAttribute(android.R.attr.alertDialogIcon)
- .create();
- final WarningDialogReceiver warning = new WarningDialogReceiver(mContext,
- sConfirmSafeVolumeDialog, this);
-
- sConfirmSafeVolumeDialog.setOnDismissListener(warning);
- sConfirmSafeVolumeDialog.getWindow().setType(
- WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
- sConfirmSafeVolumeDialog.show();
+ sSafetyWarning = new SafetyWarning(mContext, this, mAudioManager);
+ sSafetyWarning.show();
}
updateStates();
}
@@ -1232,9 +1238,10 @@ public class VolumePanel extends Handler {
mCallback.onVisible(false);
}
}
- synchronized (sConfirmSafeVolumeLock) {
- if (sConfirmSafeVolumeDialog != null) {
- sConfirmSafeVolumeDialog.dismiss();
+ synchronized (sSafetyWarningLock) {
+ if (sSafetyWarning != null) {
+ if (LOGD) Log.d(mTag, "SafetyWarning timeout");
+ sSafetyWarning.dismiss();
}
}
break;