From 347616336c7f6b022ade89f7693a6a2221f0583a Mon Sep 17 00:00:00 2001 From: d34d Date: Tue, 12 Apr 2016 10:13:22 -0700 Subject: 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 --- .../com/android/server/policy/GlobalActions.java | 30 +++++++++++----------- 1 file 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) { -- cgit v1.1