summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2015-04-07 12:47:12 -0400
committerJohn Spurlock <jspurlock@google.com>2015-04-09 21:45:08 -0400
commitb2278d65714c0dd0a6f94d1913db1ebc8bfc8b06 (patch)
tree5be1145c8db05cf9f5bee3ce09afa6d10dac9d07 /packages/SystemUI/src/com/android/systemui/statusbar
parent6498506330952b0239aa076e643cd6a0f320c5e9 (diff)
downloadframeworks_base-b2278d65714c0dd0a6f94d1913db1ebc8bfc8b06.zip
frameworks_base-b2278d65714c0dd0a6f94d1913db1ebc8bfc8b06.tar.gz
frameworks_base-b2278d65714c0dd0a6f94d1913db1ebc8bfc8b06.tar.bz2
An update on Downtime.
The update is that Downtime is obsolete. Replaced by the ability to define multiple named schedule calendars. - Make changes to ZenModeConfig to properly model manual and automatic rules. - Refactor the zen mode helper (and supporting classes) to properly handle / report multiple claims on zen mode. The "manual" rule (specified by the user in the UI) vs one or more automatic rules. - Automatic rules are still backed by condition providers, but the layering is now cleaner. ConditionProviders is now completely generic, has no ties to zen mode. - Specifically, the new layering for zen mode (below noman) is: ZenModeHelper: Source of truth for zen state ZenModeFiltering: Subhelper dedicated to filtering rules. ZenModeConditions: Subhelper dedicated to managing automatic rules. ConditionProviders: Underlying engine for reporting named boolean state. - Migration story for users with existing downtime config, migrated to a single new calendar named downtime. - For users with no existing downtime, two default calendars are created for weeknights + weekends (icu4j for all locales will be done in a followup). - Remove obsolete DowntimeConditionProvider/NextAlarmConditionProvider and tracking. - Clean up obsolete resources. - Add common zen summary description string computation. - Add proper noman wrappers for the new model. - Change the semantics of the global zen setting. It is now read-only. Setters must call noman, added a "reason" to all calls for better attribution. - Update zenmodepanel + volumedialog to the new model. - Display the one or more automatic rules in the new zen footer summary. - "Snooze" the automatic rules when the user explicitly turns zen off. Bug: 20064962 Change-Id: Idd9deb865a6035ad0cfae660198dccb517e6d7cc
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java43
2 files changed, 39 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
index 0e21457..67cc788 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
@@ -17,16 +17,19 @@
package com.android.systemui.statusbar.policy;
import android.content.ComponentName;
+import android.net.Uri;
import android.service.notification.Condition;
+import android.service.notification.ZenModeConfig;
+import android.service.notification.ZenModeConfig.ZenRule;
public interface ZenModeController {
void addCallback(Callback callback);
void removeCallback(Callback callback);
- void setZen(int zen);
+ void setZen(int zen, Uri conditionId, String reason);
int getZen();
void requestConditions(boolean request);
- void setExitCondition(Condition exitCondition);
- Condition getExitCondition();
+ ZenRule getManualRule();
+ ZenModeConfig getConfig();
long getNextAlarm();
void setUserId(int userId);
boolean isZenAvailable();
@@ -35,10 +38,11 @@ public interface ZenModeController {
public static class Callback {
public void onZenChanged(int zen) {}
- public void onExitConditionChanged(Condition exitCondition) {}
public void onConditionsChanged(Condition[] conditions) {}
public void onNextAlarmChanged() {}
public void onZenAvailableChanged(boolean available) {}
public void onEffectsSupressorChanged() {}
+ public void onManualRuleChanged(ZenRule rule) {}
+ public void onConfigChanged(ZenModeConfig config) {}
}
} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
index bea0c86..830a197 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
@@ -33,6 +33,7 @@ import android.provider.Settings.Secure;
import android.service.notification.Condition;
import android.service.notification.IConditionListener;
import android.service.notification.ZenModeConfig;
+import android.service.notification.ZenModeConfig.ZenRule;
import android.util.Log;
import android.util.Slog;
@@ -40,6 +41,7 @@ import com.android.systemui.qs.GlobalSetting;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.Objects;
/** Platform implementation of the zen mode controller. **/
public class ZenModeControllerImpl implements ZenModeController {
@@ -58,6 +60,7 @@ public class ZenModeControllerImpl implements ZenModeController {
private int mUserId;
private boolean mRequesting;
private boolean mRegistered;
+ private ZenModeConfig mConfig;
public ZenModeControllerImpl(Context context, Handler handler) {
mContext = context;
@@ -70,12 +73,13 @@ public class ZenModeControllerImpl implements ZenModeController {
mConfigSetting = new GlobalSetting(mContext, handler, Global.ZEN_MODE_CONFIG_ETAG) {
@Override
protected void handleValueChanged(int value) {
- fireExitConditionChanged();
+ updateZenModeConfig();
}
};
+ mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ mConfig = mNoMan.getZenModeConfig();
mModeSetting.setListening(true);
mConfigSetting.setListening(true);
- mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mSetupObserver = new SetupObserver(handler);
mSetupObserver.register();
@@ -97,8 +101,8 @@ public class ZenModeControllerImpl implements ZenModeController {
}
@Override
- public void setZen(int zen) {
- mModeSetting.setValue(zen);
+ public void setZen(int zen, Uri conditionId, String reason) {
+ mNoMan.setZenMode(zen, conditionId, reason);
}
@Override
@@ -116,13 +120,13 @@ public class ZenModeControllerImpl implements ZenModeController {
}
@Override
- public void setExitCondition(Condition exitCondition) {
- mNoMan.setZenModeCondition(exitCondition);
+ public ZenRule getManualRule() {
+ return mConfig == null ? null : mConfig.manualRule;
}
@Override
- public Condition getExitCondition() {
- return mNoMan.getZenModeCondition();
+ public ZenModeConfig getConfig() {
+ return mConfig;
}
@Override
@@ -185,11 +189,15 @@ public class ZenModeControllerImpl implements ZenModeController {
}
}
- private void fireExitConditionChanged() {
- final Condition exitCondition = getExitCondition();
- if (DEBUG) Slog.d(TAG, "exitCondition changed: " + exitCondition);
+ private void fireManualRuleChanged(ZenRule rule) {
+ for (Callback cb : mCallbacks) {
+ cb.onManualRuleChanged(rule);
+ }
+ }
+
+ private void fireConfigChanged(ZenModeConfig config) {
for (Callback cb : mCallbacks) {
- cb.onExitConditionChanged(exitCondition);
+ cb.onConfigChanged(config);
}
}
@@ -203,6 +211,17 @@ public class ZenModeControllerImpl implements ZenModeController {
mConditions.values().toArray(new Condition[mConditions.values().size()]));
}
+ private void updateZenModeConfig() {
+ final ZenModeConfig config = mNoMan.getZenModeConfig();
+ if (Objects.equals(config, mConfig)) return;
+ final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null;
+ mConfig = config;
+ fireConfigChanged(config);
+ final ZenRule newRule = config != null ? config.manualRule : null;
+ if (Objects.equals(oldRule, newRule)) return;
+ fireManualRuleChanged(newRule);
+ }
+
private final IConditionListener mListener = new IConditionListener.Stub() {
@Override
public void onConditionsReceived(Condition[] conditions) {