Move some global settings to secure settings
The following Settings are being moved to Settings.Secure
from Settings.Global since they are settings that exist
per user
- CHARGING_SOUNDS_ENABLED
- CHARGING_VIBRATION_ENABLED
- ZEN_DURATION
- SHOW_ZEN_UPGRADE_NOTIFICATION
- SHOW_ZEN_SETTINGS_SUGGESTION
- ZEN_SETTINGS_UPDATE
- ZEN_SETTINGS_SUGGESTION_VIEWED
zen_duration used to be a global setting -> move it to
Settings.Secure since users can set different values
Fixes: 110926544
Test: make RunSettingsLibRoboTests -j40 ROBOTEST_FILTER=ZenDurationDialogTest
Test: manual upgrade
Change-Id: Ifa36affe3e52e67a54698a8cf2c3424343877179
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index ebd90bd..f4f43e3 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6031,6 +6031,57 @@
NON_NEGATIVE_INTEGER_VALIDATOR;
/**
+ * Whether to play a sound for charging events.
+ * @hide
+ */
+ public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled";
+
+ /**
+ * Whether to vibrate for wireless charging events.
+ * @hide
+ */
+ public static final String CHARGING_VIBRATION_ENABLED = "charging_vibration_enabled";
+
+ /**
+ * If 0, turning on dnd manually will last indefinitely.
+ * Else if non-negative, turning on dnd manually will last for this many minutes.
+ * Else (if negative), turning on dnd manually will surface a dialog that prompts
+ * user to specify a duration.
+ * @hide
+ */
+ public static final String ZEN_DURATION = "zen_duration";
+
+ private static final Validator ZEN_DURATION_VALIDATOR = ANY_INTEGER_VALIDATOR;
+
+ /** @hide */ public static final int ZEN_DURATION_PROMPT = -1;
+ /** @hide */ public static final int ZEN_DURATION_FOREVER = 0;
+
+ /**
+ * If nonzero, will show the zen upgrade notification when the user toggles DND on/off.
+ * @hide
+ */
+ 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 been viewed by user
+ * @hide
+ */
+ public static final String ZEN_SETTINGS_SUGGESTION_VIEWED =
+ "zen_settings_suggestion_viewed";
+
+ /**
* Whether the in call notification is enabled to play sound during calls. The value is
* boolean (1 or 0).
* @hide
@@ -8033,6 +8084,13 @@
IN_CALL_NOTIFICATION_ENABLED,
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ ZEN_DURATION,
+ SHOW_ZEN_UPGRADE_NOTIFICATION,
+ SHOW_ZEN_SETTINGS_SUGGESTION,
+ ZEN_SETTINGS_UPDATED,
+ ZEN_SETTINGS_SUGGESTION_VIEWED,
+ CHARGING_SOUNDS_ENABLED,
+ CHARGING_VIBRATION_ENABLED,
};
/**
@@ -8178,6 +8236,13 @@
VALIDATORS.put(IN_CALL_NOTIFICATION_ENABLED, IN_CALL_NOTIFICATION_ENABLED_VALIDATOR);
VALIDATORS.put(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR);
VALIDATORS.put(LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR);
+ VALIDATORS.put(SHOW_ZEN_UPGRADE_NOTIFICATION, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(SHOW_ZEN_SETTINGS_SUGGESTION, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(ZEN_SETTINGS_UPDATED, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(ZEN_SETTINGS_SUGGESTION_VIEWED, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(CHARGING_SOUNDS_ENABLED, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(CHARGING_VIBRATION_ENABLED, BOOLEAN_VALIDATOR);
}
/**
@@ -8651,16 +8716,20 @@
/**
* Whether to play a sound for charging events.
+ * @deprecated Use {@link android.provider.Settings.Secure#CHARGING_SOUNDS_ENABLED} instead
* @hide
*/
+ @Deprecated
public static final String CHARGING_SOUNDS_ENABLED = "charging_sounds_enabled";
private static final Validator CHARGING_SOUNDS_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
/**
* Whether to vibrate for wireless charging events.
+ * @deprecated Use {@link android.provider.Settings.Secure#CHARGING_VIBRATION_ENABLED}
* @hide
*/
+ @Deprecated
public static final String CHARGING_VIBRATION_ENABLED = "charging_vibration_enabled";
private static final Validator CHARGING_VIBRATION_ENABLED_VALIDATOR = BOOLEAN_VALIDATOR;
@@ -11721,18 +11790,27 @@
public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
/**
- * If 0, turning on dnd manually will last indefinitely.
- * Else if non-negative, turning on dnd manually will last for this many minutes.
- * Else (if negative), turning on dnd manually will surface a dialog that prompts
- * user to specify a duration.
+ * @deprecated Use {@link android.provider.Settings.Secure#ZEN_DURATION} instead
* @hide
*/
+ @Deprecated
public static final String ZEN_DURATION = "zen_duration";
private static final Validator ZEN_DURATION_VALIDATOR = ANY_INTEGER_VALIDATOR;
- /** @hide */ public static final int ZEN_DURATION_PROMPT = -1;
- /** @hide */ public static final int ZEN_DURATION_FOREVER = 0;
+ /**
+ * @deprecated Use {@link android.provider.Settings.Secure#ZEN_DURATION_PROMPT} instead
+ * @hide
+ */
+ @Deprecated
+ public static final int ZEN_DURATION_PROMPT = -1;
+
+ /**
+ * @deprecated Use {@link android.provider.Settings.Secure#ZEN_DURATION_FOREVER} instead
+ * @hide
+ */
+ @Deprecated
+ public static final int ZEN_DURATION_FOREVER = 0;
/**
* Defines global heads up toggle. One of HEADS_UP_OFF, HEADS_UP_ON.
@@ -12276,8 +12354,16 @@
// Certain settings have been moved from global to the per-user secure namespace
private static final HashSet<String> MOVED_TO_SECURE;
static {
- MOVED_TO_SECURE = new HashSet<>(1);
- MOVED_TO_SECURE.add(Settings.Global.INSTALL_NON_MARKET_APPS);
+ MOVED_TO_SECURE = new HashSet<>(8);
+ MOVED_TO_SECURE.add(Global.INSTALL_NON_MARKET_APPS);
+ MOVED_TO_SECURE.add(Global.ZEN_DURATION);
+ MOVED_TO_SECURE.add(Global.SHOW_ZEN_UPGRADE_NOTIFICATION);
+ MOVED_TO_SECURE.add(Global.SHOW_ZEN_SETTINGS_SUGGESTION);
+ MOVED_TO_SECURE.add(Global.ZEN_SETTINGS_UPDATED);
+ MOVED_TO_SECURE.add(Global.ZEN_SETTINGS_SUGGESTION_VIEWED);
+ MOVED_TO_SECURE.add(Global.CHARGING_SOUNDS_ENABLED);
+ MOVED_TO_SECURE.add(Global.CHARGING_VIBRATION_ENABLED);
+
}
/** @hide */
@@ -12953,28 +13039,37 @@
*/
public static final String SHOW_MUTE_IN_CRASH_DIALOG = "show_mute_in_crash_dialog";
+
/**
* If nonzero, will show the zen upgrade notification when the user toggles DND on/off.
* @hide
+ * @deprecated - Use {@link android.provider.Settings.Secure#SHOW_ZEN_UPGRADE_NOTIFICATION}
*/
+ @Deprecated
public static final String SHOW_ZEN_UPGRADE_NOTIFICATION = "show_zen_upgrade_notification";
/**
* If nonzero, will show the zen update settings suggestion.
* @hide
+ * @deprecated - Use {@link android.provider.Settings.Secure#SHOW_ZEN_SETTINGS_SUGGESTION}
*/
+ @Deprecated
public static final String SHOW_ZEN_SETTINGS_SUGGESTION = "show_zen_settings_suggestion";
/**
* If nonzero, zen has not been updated to reflect new changes.
+ * @deprecated - Use {@link android.provider.Settings.Secure#ZEN_SETTINGS_UPDATED}
* @hide
*/
+ @Deprecated
public static final String ZEN_SETTINGS_UPDATED = "zen_settings_updated";
/**
- * If nonzero, zen setting suggestion has beem viewed by user
+ * If nonzero, zen setting suggestion has been viewed by user
* @hide
+ * @deprecated - Use {@link android.provider.Settings.Secure#ZEN_SETTINGS_SUGGESTION_VIEWED}
*/
+ @Deprecated
public static final String ZEN_SETTINGS_SUGGESTION_VIEWED =
"zen_settings_suggestion_viewed";
diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto
index ed7316a..040e36a 100644
--- a/core/proto/android/providers/settings/global.proto
+++ b/core/proto/android/providers/settings/global.proto
@@ -745,7 +745,7 @@
optional SettingProto car_dock = 1;
optional SettingProto car_undock = 2;
- optional SettingProto charging_sounds_enabled = 3 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ reserved 3; // Moved to secure settings Sound.charging_sounds_enabled
optional SettingProto charging_started = 4;
optional SettingProto desk_dock = 5;
optional SettingProto desk_undock = 6;
@@ -941,12 +941,8 @@
optional SettingProto mode = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto mode_ringer_level = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto mode_config_etag = 3;
- // If 0, turning on dnd manually will last indefinitely. Else if
- // non-negative, turning on dnd manually will last for this many minutes.
- // Else (if negative), turning on dnd manually will surface a dialog that
- // prompts user to specify a duration.
- optional SettingProto duration = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
- optional SettingProto show_zen_upgrade_notification = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ reserved 4; // Moved to secure settings Zen.duration
+ reserved 5; // Moved to secure settings Zen.show_zen_upgrade_notification
}
optional Zen zen = 138;
diff --git a/core/proto/android/providers/settings/secure.proto b/core/proto/android/providers/settings/secure.proto
index 237efd8..f2e8c70 100644
--- a/core/proto/android/providers/settings/secure.proto
+++ b/core/proto/android/providers/settings/secure.proto
@@ -300,6 +300,7 @@
optional SettingProto enabled_policy_access_packages = 3 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto badging = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto show_note_about_notification_hiding = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto in_call_notification_enabled = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
}
optional Notification notification = 41;
@@ -404,6 +405,15 @@
optional SettingProto skip_first_use_hints = 52 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto sleep_timeout = 53 [ (android.privacy).dest = DEST_AUTOMATIC ];
optional SettingProto sms_default_application = 54 [ (android.privacy).dest = DEST_AUTOMATIC ];
+
+ message Sounds {
+ option (android.msg_privacy).dest = DEST_EXPLICIT;
+
+ optional SettingProto charging_sounds_enabled = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto charging_vibration_enabled = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ }
+ optional Sounds sounds = 72;
+
// Defines whether managed profile ringtones should be synced from its
// parent profile.
optional SettingProto sync_parent_sounds = 55 [ (android.privacy).dest = DEST_AUTOMATIC ];
@@ -484,7 +494,22 @@
optional SettingProto wake_gesture_enabled = 68 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ message Zen {
+ option (android.msg_privacy).dest = DEST_EXPLICIT;
+
+ // If 0, turning on dnd manually will last indefinitely. Else if
+ // non-negative, turning on dnd manually will last for this many minutes.
+ // Else (if negative), turning on dnd manually will surface a dialog that
+ // prompts user to specify a duration.
+ optional SettingProto duration = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto show_zen_upgrade_notification = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto show_zen_settings_suggestion = 3 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto settings_updated = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ optional SettingProto settings_suggestion_viewed = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ }
+ optional Zen zen = 71;
+
// Please insert fields in alphabetical order and group them into messages
// if possible (to avoid reaching the method limit).
- // Next tag = 71;
+ // Next tag = 73;
}
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index 37dec13..1a87fa2 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -389,10 +389,6 @@
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS,
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,
@@ -495,8 +491,8 @@
Settings.Global.WIFI_VERBOSE_LOGGING_ENABLED,
Settings.Global.WIFI_WATCHDOG_ON,
Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON,
- Settings.Global.WINDOW_ANIMATION_SCALE,
Settings.Global.CHARGING_STARTED_SOUND,
+ Settings.Global.WINDOW_ANIMATION_SCALE,
Settings.Global.WTF_IS_FATAL,
Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_CONFIG_ETAG,