* commit '022ed34cd6af9a23b31cc8854f004a5c1c74b23c': Zen: Tweak default automatic rules.
This commit is contained in:
@@ -735,17 +735,20 @@ public class ZenModeConfig implements Parcelable {
|
||||
&& conditionId.getPathSegments().get(0).equals(EVENT_PATH);
|
||||
if (!isEvent) return null;
|
||||
final EventInfo rt = new EventInfo();
|
||||
rt.calendar = tryParseLong(conditionId.getQueryParameter("calendar"), 0L);
|
||||
rt.calendar = tryParseLong(conditionId.getQueryParameter("calendar"),
|
||||
EventInfo.ANY_CALENDAR);
|
||||
rt.reply = tryParseInt(conditionId.getQueryParameter("reply"), 0);
|
||||
return rt;
|
||||
}
|
||||
|
||||
public static class EventInfo {
|
||||
public static final long ANY_CALENDAR = 0;
|
||||
|
||||
public static final int REPLY_ANY_EXCEPT_NO = 0;
|
||||
public static final int REPLY_YES_OR_MAYBE = 1;
|
||||
public static final int REPLY_YES = 2;
|
||||
|
||||
public long calendar; // CalendarContract.Calendars._ID, or 0 for any
|
||||
public long calendar = ANY_CALENDAR; // CalendarContract.Calendars._ID, or ANY_CALENDAR
|
||||
public int reply;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4068,10 +4068,13 @@
|
||||
<string name="zen_mode_downtime_feature_name">Downtime</string>
|
||||
|
||||
<!-- Zen mode - name of default automatic schedule for weeknights. [CHAR LIMIT=40] -->
|
||||
<string name="zen_mode_default_weeknights_name">Weeknights</string>
|
||||
<string name="zen_mode_default_weeknights_name">Weeknight</string>
|
||||
|
||||
<!-- Zen mode - name of default automatic schedule for weekends. [CHAR LIMIT=40] -->
|
||||
<string name="zen_mode_default_weekends_name">Weekends</string>
|
||||
<string name="zen_mode_default_weekends_name">Weekend</string>
|
||||
|
||||
<!-- Zen mode - name of default automatic calendar event-based rule. [CHAR LIMIT=40] -->
|
||||
<string name="zen_mode_default_events_name">Event</string>
|
||||
|
||||
<!-- Indication that the current volume and other effects (vibration) are being suppressed by a third party, such as a notification listener. [CHAR LIMIT=30] -->
|
||||
<string name="muted_by">Muted by <xliff:g id="third_party">%1$s</xliff:g></string>
|
||||
|
||||
@@ -2065,6 +2065,7 @@
|
||||
<java-symbol type="string" name="zen_mode_downtime_feature_name" />
|
||||
<java-symbol type="string" name="zen_mode_default_weeknights_name" />
|
||||
<java-symbol type="string" name="zen_mode_default_weekends_name" />
|
||||
<java-symbol type="string" name="zen_mode_default_events_name" />
|
||||
<java-symbol type="array" name="config_system_condition_providers" />
|
||||
<java-symbol type="string" name="muted_by" />
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.notification;
|
||||
|
||||
import static android.service.notification.ZenModeConfig.EventInfo.ANY_CALENDAR;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
@@ -150,7 +152,7 @@ public class CalendarTracker {
|
||||
eventId, owner, calendarId));
|
||||
final boolean meetsTime = time >= begin && time < end;
|
||||
final boolean meetsCalendar = visible
|
||||
&& (filter.calendar == 0 || filter.calendar == calendarId)
|
||||
&& (filter.calendar == ANY_CALENDAR || filter.calendar == calendarId)
|
||||
&& availability != Instances.AVAILABILITY_FREE;
|
||||
if (meetsCalendar) {
|
||||
if (DEBUG) Log.d(TAG, " MEETS CALENDAR");
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.provider.Settings.Global;
|
||||
import android.service.notification.IConditionListener;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
import android.service.notification.ZenModeConfig.EventInfo;
|
||||
import android.service.notification.ZenModeConfig.ScheduleInfo;
|
||||
import android.service.notification.ZenModeConfig.ZenRule;
|
||||
import android.util.ArraySet;
|
||||
@@ -91,6 +92,7 @@ public class ZenModeHelper {
|
||||
mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
mDefaultConfig = readDefaultConfig(context.getResources());
|
||||
appendDefaultScheduleRules(mDefaultConfig);
|
||||
appendDefaultEventRules(mDefaultConfig);
|
||||
mConfig = mDefaultConfig;
|
||||
mSettingsObserver = new SettingsObserver(mHandler);
|
||||
mSettingsObserver.observe();
|
||||
@@ -439,6 +441,20 @@ public class ZenModeHelper {
|
||||
config.automaticRules.put(config.newRuleId(), rule2);
|
||||
}
|
||||
|
||||
private void appendDefaultEventRules(ZenModeConfig config) {
|
||||
if (config == null) return;
|
||||
|
||||
final EventInfo events = new EventInfo();
|
||||
events.calendar = EventInfo.ANY_CALENDAR;
|
||||
events.reply = EventInfo.REPLY_YES_OR_MAYBE;
|
||||
final ZenRule rule = new ZenRule();
|
||||
rule.enabled = false;
|
||||
rule.name = mContext.getResources().getString(R.string.zen_mode_default_events_name);
|
||||
rule.conditionId = ZenModeConfig.toEventConditionId(events);
|
||||
rule.zenMode = Global.ZEN_MODE_ALARMS;
|
||||
config.automaticRules.put(config.newRuleId(), rule);
|
||||
}
|
||||
|
||||
private static int zenSeverity(int zen) {
|
||||
switch (zen) {
|
||||
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return 1;
|
||||
@@ -481,6 +497,7 @@ public class ZenModeHelper {
|
||||
Log.i(TAG, "No existing V1 downtime found, generating default schedules");
|
||||
appendDefaultScheduleRules(rt);
|
||||
}
|
||||
appendDefaultEventRules(rt);
|
||||
return rt;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user