summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-04-12 10:13:22 -0700
committerd34d <clark@cyngn.com>2016-04-12 10:35:45 -0700
commit347616336c7f6b022ade89f7693a6a2221f0583a (patch)
tree5dadcbafdcbfef1416b26f38c82356dc293a73e7
parent65bda831af304b6d53a1f84ad895e158b48a78c5 (diff)
downloadframeworks_base-347616336c7f6b022ade89f7693a6a2221f0583a.zip
frameworks_base-347616336c7f6b022ade89f7693a6a2221f0583a.tar.gz
frameworks_base-347616336c7f6b022ade89f7693a6a2221f0583a.tar.bz2
GlobalActions: Always use setZenMode
When set to silent mode, the user cannot change the ringer mode to vibrate or ring. Notification manager listens for changes to the zen mode setting and will switch it back if there is a mismatch. Using INotificationManager.setZenMode takes care of changing the mode and keeping track of the updated change. Change-Id: I5139a9a8cde4ca59f64bd21cf7c184d4745a7d59 TICKET: CYNGNOS-2417 BACON-4658
-rw-r--r--services/core/java/com/android/server/policy/GlobalActions.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/policy/GlobalActions.java b/services/core/java/com/android/server/policy/GlobalActions.java
index 9b5f5d0..7ba49c5 100644
--- a/services/core/java/com/android/server/policy/GlobalActions.java
+++ b/services/core/java/com/android/server/policy/GlobalActions.java
@@ -1153,6 +1153,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
private final class SilentModeTriStateAction implements Action, View.OnClickListener {
private final int[] ITEM_IDS = { R.id.option1, R.id.option2, R.id.option3, R.id.option4 };
+ private final int[] ITEM_INDEX_TO_ZEN_MODE = {
+ Global.ZEN_MODE_NO_INTERRUPTIONS,
+ Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
+ Global.ZEN_MODE_OFF,
+ Global.ZEN_MODE_OFF
+ };
private final AudioManager mAudioManager;
private final Handler mHandler;
@@ -1236,21 +1242,15 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
if (!(v.getTag() instanceof Integer)) return;
int index = (Integer) v.getTag();
- if (index == 0 || index == 1) {
- int zenMode = index == 0
- ? Global.ZEN_MODE_NO_INTERRUPTIONS
- : Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
- // ZenModeHelper will revert zen mode back to the previous value if we just
- // put the value into the Settings db, so use INotificationManager instead
- INotificationManager noMan = INotificationManager.Stub.asInterface(
- ServiceManager.getService(Context.NOTIFICATION_SERVICE));
- try {
- noMan.setZenMode(zenMode, null, TAG);
- } catch (RemoteException e) {
- Log.e(TAG, "Unable to set zen mode", e);
- }
- } else {
- Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE, Global.ZEN_MODE_OFF);
+ int zenMode = ITEM_INDEX_TO_ZEN_MODE[index];
+ // ZenModeHelper will revert zen mode back to the previous value if we just
+ // put the value into the Settings db, so use INotificationManager instead
+ INotificationManager noMan = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ try {
+ noMan.setZenMode(zenMode, null, TAG);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to set zen mode", e);
}
if (index == 2 || index == 3) {