Merge "Show settings suggestion" into pi-dev
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 10ee728..29bbddc 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -12740,6 +12740,25 @@
public static final String SHOW_ZEN_UPGRADE_NOTIFICATION = "show_zen_upgrade_notification";
/**
+ * If nonzero, will show the zen update settings suggestion.
+ * @hide
+ */
+ public static final String SHOW_ZEN_SETTINGS_SUGGESTION = "show_zen_settings_suggestion";
+
+ /**
+ * If nonzero, zen has not been updated to reflect new changes.
+ * @hide
+ */
+ public static final String ZEN_SETTINGS_UPDATED = "zen_settings_updated";
+
+ /**
+ * If nonzero, zen setting suggestion has beem viewed by user
+ * @hide
+ */
+ public static final String ZEN_SETTINGS_SUGGESTION_VIEWED =
+ "zen_settings_suggestion_viewed";
+
+ /**
* Backup and restore agent timeout parameters.
* These parameters are represented by a comma-delimited key-value list.
*
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index 18bc20c..ab9fc13 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -385,6 +385,9 @@
Settings.Global.SHOW_RESTART_IN_CRASH_DIALOG,
Settings.Global.SHOW_TEMPERATURE_WARNING,
Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION,
+ Settings.Global.SHOW_ZEN_SETTINGS_SUGGESTION,
+ Settings.Global.ZEN_SETTINGS_UPDATED,
+ Settings.Global.ZEN_SETTINGS_SUGGESTION_VIEWED,
Settings.Global.SMART_SELECTION_UPDATE_CONTENT_URL,
Settings.Global.SMART_SELECTION_UPDATE_METADATA_URL,
Settings.Global.SMS_OUTGOING_CHECK_INTERVAL_MS,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 32aafea..7b76fce 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -2935,7 +2935,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 165;
+ private static final int SETTINGS_VERSION = 166;
private final int mUserId;
@@ -3733,7 +3733,7 @@
}
if (currentVersion == 164) {
- // Version 164: Add a gesture for silencing phones
+ // Version 164: show zen upgrade notification
final SettingsState settings = getGlobalSettingsLocked();
final Setting currentSetting = settings.getSettingLocked(
Global.SHOW_ZEN_UPGRADE_NOTIFICATION);
@@ -3747,6 +3747,36 @@
currentVersion = 165;
}
+ if (currentVersion == 165) {
+ // Version 165: Show zen settings suggestion and zen updated
+ final SettingsState settings = getGlobalSettingsLocked();
+ final Setting currentSetting = settings.getSettingLocked(
+ Global.SHOW_ZEN_SETTINGS_SUGGESTION);
+ if (currentSetting.isNull()) {
+ settings.insertSettingLocked(
+ Global.SHOW_ZEN_SETTINGS_SUGGESTION, "1",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ final Setting currentUpdatedSetting = settings.getSettingLocked(
+ Global.ZEN_SETTINGS_UPDATED);
+ if (currentUpdatedSetting.isNull()) {
+ settings.insertSettingLocked(
+ Global.ZEN_SETTINGS_UPDATED, "0",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ final Setting currentSettingSuggestionViewed = settings.getSettingLocked(
+ Global.ZEN_SETTINGS_SUGGESTION_VIEWED);
+ if (currentSettingSuggestionViewed.isNull()) {
+ settings.insertSettingLocked(
+ Global.ZEN_SETTINGS_SUGGESTION_VIEWED, "0",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ currentVersion = 166;
+ }
+
// vXXX: Add new settings above this point.
if (currentVersion != newVersion) {
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 658c7f1..669d556 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -508,6 +508,8 @@
public void setManualZenMode(int zenMode, Uri conditionId, String caller, String reason) {
setManualZenMode(zenMode, conditionId, reason, caller, true /*setRingerMode*/);
+ Settings.Global.putInt(mContext.getContentResolver(), Global.SHOW_ZEN_SETTINGS_SUGGESTION,
+ 0);
}
private void setManualZenMode(int zenMode, Uri conditionId, String reason, String caller,
@@ -635,6 +637,10 @@
appendDefaultRules(config);
reason += ", reset to default rules";
}
+ } else {
+ // devices not restoring/upgrading already have updated zen settings
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Global.ZEN_SETTINGS_UPDATED, 1);
}
if (DEBUG) Log.d(TAG, reason);
synchronized (mConfig) {
@@ -813,6 +819,12 @@
for (ZenRule automaticRule : mConfig.automaticRules.values()) {
if (automaticRule.isAutomaticActive()) {
if (zenSeverity(automaticRule.zenMode) > zenSeverity(zen)) {
+ // automatic rule triggered dnd and user hasn't seen update dnd dialog
+ if (Settings.Global.getInt(mContext.getContentResolver(),
+ Global.ZEN_SETTINGS_SUGGESTION_VIEWED, 1) == 0) {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Global.SHOW_ZEN_SETTINGS_SUGGESTION, 1);
+ }
zen = automaticRule.zenMode;
}
}