• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修訂3f8962fc4f47eeea11cf6d39a60c182baba9a98c (tree)
時間2016-10-05 20:38:59
作者DvTonder <david.vantonder@gmai...>
CommiterSteve Kondik

Log Message

Frameworks: Allow/Prevent notification light in Zen mode (1 of 3)

This allows the user to prevent the notification lights from showing during Zen mode

Change-Id: I831c475204c8647d8ee281094aca837ee9594eb4

Change Summary

差異

--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1162,6 +1162,7 @@ public class NotificationManagerService extends SystemService {
11621162 mDisableNotificationEffects = true;
11631163 }
11641164 mZenModeHelper.initZenMode();
1165+ mZenModeHelper.readAllowLightsFromSettings();
11651166 mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
11661167
11671168 mUserProfiles.updateCache(getContext());
@@ -3091,8 +3092,10 @@ public class NotificationManagerService extends SystemService {
30913092 // light
30923093 // release the light
30933094 boolean wasShowLights = mLights.remove(key);
3094- final boolean aboveThresholdWithLight = aboveThreshold || isLedNotificationForcedOn(record);
3095- if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && aboveThresholdWithLight
3095+ final boolean canInterruptWithLight = canInterrupt ||
3096+ isLedNotificationForcedOn(record) ||
3097+ (!canInterrupt && mZenModeHelper.getAllowLights());
3098+ if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && canInterruptWithLight
30963099 && ((record.getSuppressedVisualEffects()
30973100 & NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_OFF) == 0)) {
30983101 mLights.add(key);
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -62,6 +62,7 @@ import android.util.SparseArray;
6262 import com.android.internal.R;
6363 import com.android.internal.logging.MetricsLogger;
6464 import com.android.server.LocalServices;
65+import cyanogenmod.providers.CMSettings;
6566
6667 import libcore.io.IoUtils;
6768
@@ -104,6 +105,7 @@ public class ZenModeHelper {
104105 private AudioManagerInternal mAudioManager;
105106 private PackageManager mPm;
106107 private long mSuppressedEffects;
108+ private boolean mAllowLights;
107109
108110 public static final long SUPPRESSED_EFFECT_NOTIFICATIONS = 1;
109111 public static final long SUPPRESSED_EFFECT_CALLS = 1 << 1;
@@ -688,6 +690,7 @@ public class ZenModeHelper {
688690 ZenLog.traceSetZenMode(zen, reason);
689691 mZenMode = zen;
690692 updateRingerModeAffectedStreams();
693+ readAllowLightsFromSettings();
691694 setZenModeSetting(mZenMode);
692695 if (setRingerMode) {
693696 applyZenToRingerMode();
@@ -721,6 +724,24 @@ public class ZenModeHelper {
721724 }
722725 }
723726
727+ public boolean getAllowLights() {
728+ return mAllowLights;
729+ }
730+
731+ public void readAllowLightsFromSettings() {
732+ switch (mZenMode) {
733+ case Global.ZEN_MODE_NO_INTERRUPTIONS:
734+ case Global.ZEN_MODE_ALARMS:
735+ mAllowLights = CMSettings.System.getInt(mContext.getContentResolver(),
736+ CMSettings.System.ZEN_ALLOW_LIGHTS, 1) == 1;
737+ break;
738+ case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
739+ mAllowLights = CMSettings.System.getInt(mContext.getContentResolver(),
740+ CMSettings.System.ZEN_PRIORITY_ALLOW_LIGHTS, 1) == 1;
741+ break;
742+ }
743+ }
744+
724745 private void applyRestrictions() {
725746 final boolean zen = mZenMode != Global.ZEN_MODE_OFF;
726747
@@ -742,6 +763,8 @@ public class ZenModeHelper {
742763 applyRestrictions(muteEverything, i);
743764 }
744765 }
766+
767+ readAllowLightsFromSettings();
745768 }
746769
747770 private void applyRestrictions(boolean mute, int usage) {
@@ -1022,6 +1045,10 @@ public class ZenModeHelper {
10221045
10231046 private final class SettingsObserver extends ContentObserver {
10241047 private final Uri ZEN_MODE = Global.getUriFor(Global.ZEN_MODE);
1048+ private final Uri ZEN_ALLOW_LIGHTS = CMSettings.System.getUriFor(
1049+ CMSettings.System.ZEN_ALLOW_LIGHTS);
1050+ private final Uri ZEN_PRIORITY_ALLOW_LIGHTS = CMSettings.System.getUriFor(
1051+ CMSettings.System.ZEN_PRIORITY_ALLOW_LIGHTS);
10251052
10261053 public SettingsObserver(Handler handler) {
10271054 super(handler);
@@ -1030,6 +1057,10 @@ public class ZenModeHelper {
10301057 public void observe() {
10311058 final ContentResolver resolver = mContext.getContentResolver();
10321059 resolver.registerContentObserver(ZEN_MODE, false /*notifyForDescendents*/, this);
1060+ resolver.registerContentObserver(
1061+ ZEN_ALLOW_LIGHTS, false /*notifyForDescendents*/, this);
1062+ resolver.registerContentObserver(
1063+ ZEN_PRIORITY_ALLOW_LIGHTS, false /*notifyForDescendents*/, this);
10331064 update(null);
10341065 }
10351066
@@ -1044,6 +1075,8 @@ public class ZenModeHelper {
10441075 if (DEBUG) Log.d(TAG, "Fixing zen mode setting");
10451076 setZenModeSetting(mZenMode);
10461077 }
1078+ } else if (ZEN_ALLOW_LIGHTS.equals(uri) || ZEN_PRIORITY_ALLOW_LIGHTS.equals(uri)) {
1079+ readAllowLightsFromSettings();
10471080 }
10481081 }
10491082 }