Merge "Show settings suggestion" into pi-dev
am: 1b69d7b406
Change-Id: I844f26a32f1c72ed605946d690154fa1f3141a0a
This commit is contained in:
@@ -12747,6 +12747,25 @@ public final class Settings {
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -386,6 +386,9 @@ public class SettingsBackupTest {
|
||||
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,
|
||||
|
||||
@@ -2935,7 +2935,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
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 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
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 @@ public class SettingsProvider extends ContentProvider {
|
||||
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) {
|
||||
|
||||
@@ -508,6 +508,8 @@ public class ZenModeHelper {
|
||||
|
||||
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 @@ public class ZenModeHelper {
|
||||
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 @@ public class ZenModeHelper {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user