mDisableNotificationEffects = true;
}
mZenModeHelper.initZenMode();
+ mZenModeHelper.readAllowLightsFromSettings();
mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
mUserProfiles.updateCache(getContext());
// light
// release the light
boolean wasShowLights = mLights.remove(key);
- final boolean aboveThresholdWithLight = aboveThreshold || isLedNotificationForcedOn(record);
- if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && aboveThresholdWithLight
+ final boolean canInterruptWithLight = canInterrupt ||
+ isLedNotificationForcedOn(record) ||
+ (!canInterrupt && mZenModeHelper.getAllowLights());
+ if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0 && canInterruptWithLight
&& ((record.getSuppressedVisualEffects()
& NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_OFF) == 0)) {
mLights.add(key);
import com.android.internal.R;
import com.android.internal.logging.MetricsLogger;
import com.android.server.LocalServices;
+import cyanogenmod.providers.CMSettings;
import libcore.io.IoUtils;
private AudioManagerInternal mAudioManager;
private PackageManager mPm;
private long mSuppressedEffects;
+ private boolean mAllowLights;
public static final long SUPPRESSED_EFFECT_NOTIFICATIONS = 1;
public static final long SUPPRESSED_EFFECT_CALLS = 1 << 1;
ZenLog.traceSetZenMode(zen, reason);
mZenMode = zen;
updateRingerModeAffectedStreams();
+ readAllowLightsFromSettings();
setZenModeSetting(mZenMode);
if (setRingerMode) {
applyZenToRingerMode();
}
}
+ public boolean getAllowLights() {
+ return mAllowLights;
+ }
+
+ public void readAllowLightsFromSettings() {
+ switch (mZenMode) {
+ case Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Global.ZEN_MODE_ALARMS:
+ mAllowLights = CMSettings.System.getInt(mContext.getContentResolver(),
+ CMSettings.System.ZEN_ALLOW_LIGHTS, 1) == 1;
+ break;
+ case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
+ mAllowLights = CMSettings.System.getInt(mContext.getContentResolver(),
+ CMSettings.System.ZEN_PRIORITY_ALLOW_LIGHTS, 1) == 1;
+ break;
+ }
+ }
+
private void applyRestrictions() {
final boolean zen = mZenMode != Global.ZEN_MODE_OFF;
applyRestrictions(muteEverything, i);
}
}
+
+ readAllowLightsFromSettings();
}
private void applyRestrictions(boolean mute, int usage) {
private final class SettingsObserver extends ContentObserver {
private final Uri ZEN_MODE = Global.getUriFor(Global.ZEN_MODE);
+ private final Uri ZEN_ALLOW_LIGHTS = CMSettings.System.getUriFor(
+ CMSettings.System.ZEN_ALLOW_LIGHTS);
+ private final Uri ZEN_PRIORITY_ALLOW_LIGHTS = CMSettings.System.getUriFor(
+ CMSettings.System.ZEN_PRIORITY_ALLOW_LIGHTS);
public SettingsObserver(Handler handler) {
super(handler);
public void observe() {
final ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(ZEN_MODE, false /*notifyForDescendents*/, this);
+ resolver.registerContentObserver(
+ ZEN_ALLOW_LIGHTS, false /*notifyForDescendents*/, this);
+ resolver.registerContentObserver(
+ ZEN_PRIORITY_ALLOW_LIGHTS, false /*notifyForDescendents*/, this);
update(null);
}
if (DEBUG) Log.d(TAG, "Fixing zen mode setting");
setZenModeSetting(mZenMode);
}
+ } else if (ZEN_ALLOW_LIGHTS.equals(uri) || ZEN_PRIORITY_ALLOW_LIGHTS.equals(uri)) {
+ readAllowLightsFromSettings();
}
}
}