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,
diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
index 6da486a..fd9d02b 100644
--- a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
+++ b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
@@ -24,7 +24,6 @@
import android.provider.Settings;
import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
-import androidx.annotation.VisibleForTesting;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CompoundButton;
@@ -42,6 +41,8 @@
import java.util.Arrays;
+import androidx.annotation.VisibleForTesting;
+
public class ZenDurationDialog {
private static final int[] MINUTE_BUCKETS = ZenModeConfig.MINUTE_BUCKETS;
@VisibleForTesting protected static final int MIN_BUCKET_MINUTES = MINUTE_BUCKETS[0];
@@ -66,9 +67,9 @@
}
public Dialog createDialog() {
- int zenDuration = Settings.Global.getInt(
- mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_FOREVER);
+ int zenDuration = Settings.Secure.getInt(
+ mContext.getContentResolver(), Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_FOREVER);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
.setTitle(R.string.zen_mode_duration_settings_title)
@@ -91,12 +92,12 @@
protected void updateZenDuration(int currZenDuration) {
final int checkedRadioButtonId = mZenRadioGroup.getCheckedRadioButtonId();
- int newZenDuration = Settings.Global.getInt(
- mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_FOREVER);
+ int newZenDuration = Settings.Secure.getInt(
+ mContext.getContentResolver(), Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_FOREVER);
switch (checkedRadioButtonId) {
case FOREVER_CONDITION_INDEX:
- newZenDuration = Settings.Global.ZEN_DURATION_FOREVER;
+ newZenDuration = Settings.Secure.ZEN_DURATION_FOREVER;
MetricsLogger.action(mContext,
MetricsProto.MetricsEvent.
NOTIFICATION_ZEN_MODE_DURATION_FOREVER);
@@ -110,7 +111,7 @@
newZenDuration);
break;
case ALWAYS_ASK_CONDITION_INDEX:
- newZenDuration = Settings.Global.ZEN_DURATION_PROMPT;
+ newZenDuration = Settings.Secure.ZEN_DURATION_PROMPT;
MetricsLogger.action(mContext,
MetricsProto.MetricsEvent.
NOTIFICATION_ZEN_MODE_DURATION_PROMPT);
@@ -118,8 +119,8 @@
}
if (currZenDuration != newZenDuration) {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.ZEN_DURATION, newZenDuration);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ZEN_DURATION, newZenDuration);
}
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
index 9b491c2..c8619d8 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
@@ -72,7 +72,7 @@
@Test
public void testAlwaysPrompt() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Global.ZEN_DURATION_PROMPT);
mController.createDialog();
@@ -86,8 +86,8 @@
@Test
public void testForever() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_FOREVER);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_FOREVER);
mController.createDialog();
assertTrue(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb
@@ -100,7 +100,7 @@
@Test
public void testSpecificDuration() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION, 45);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, 45);
mController.createDialog();
assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb
@@ -114,51 +114,51 @@
@Test
public void testChooseAlwaysPromptSetting() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_FOREVER);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_FOREVER);
AlertDialog dialog = (AlertDialog) mController.createDialog();
mController.getConditionTagAt(ZenDurationDialog.ALWAYS_ASK_CONDITION_INDEX).rb.setChecked(
true);
- mController.updateZenDuration(Settings.Global.ZEN_DURATION_FOREVER);
+ mController.updateZenDuration(Settings.Secure.ZEN_DURATION_FOREVER);
- assertEquals(Settings.Global.ZEN_DURATION_PROMPT, Settings.Global.getInt(mContentResolver,
- Settings.Global.ZEN_DURATION, Settings.Global.ZEN_DURATION_FOREVER));
+ assertEquals(Settings.Secure.ZEN_DURATION_PROMPT, Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER));
}
@Test
public void testChooseForeverSetting() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_PROMPT);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_PROMPT);
AlertDialog dialog = (AlertDialog) mController.createDialog();
mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb.setChecked(
true);
- mController.updateZenDuration(Settings.Global.ZEN_DURATION_PROMPT);
+ mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT);
- assertEquals(Settings.Global.ZEN_DURATION_FOREVER, Settings.Global.getInt(mContentResolver,
- Settings.Global.ZEN_DURATION, Settings.Global.ZEN_DURATION_PROMPT));
+ assertEquals(Settings.Secure.ZEN_DURATION_FOREVER, Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT));
}
@Test
public void testChooseTimeSetting() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_PROMPT);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_PROMPT);
AlertDialog dialog = (AlertDialog) mController.createDialog();
mController.getConditionTagAt(ZenDurationDialog.COUNTDOWN_CONDITION_INDEX).rb.setChecked(
true);
- mController.updateZenDuration(Settings.Global.ZEN_DURATION_PROMPT);
+ mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT);
// countdown defaults to 60 minutes:
- assertEquals(60, Settings.Global.getInt(mContentResolver,
- Settings.Global.ZEN_DURATION, Settings.Global.ZEN_DURATION_PROMPT));
+ assertEquals(60, Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT));
}
@Test
public void testGetTimeFromBucket() {
- Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
- Settings.Global.ZEN_DURATION_PROMPT);
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+ Settings.Secure.ZEN_DURATION_PROMPT);
AlertDialog dialog = (AlertDialog) mController.createDialog();
// click time button starts at 60 minutes
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index e1a602b..c53417b 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -217,4 +217,10 @@
<!-- Default for Settings.System.VIBRATE_WHEN_RINGING -->
<bool name="def_vibrate_when_ringing">false</bool>
+
+ <!-- Default for Settings.Secure.CHARGING_VIBRATION_ENABLED -->
+ <bool name="def_charging_vibration_enabled">true</bool>
+
+ <!-- Default for Settings.Secure.CHARGING_SOUNDS_ENABLED -->
+ <bool name="def_charging_sounds_enabled">true</bool>
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index 10c1211..007e140 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -1182,9 +1182,6 @@
dumpSetting(s, p,
Settings.Global.CHARGING_STARTED_SOUND,
GlobalSettingsProto.Sounds.CHARGING_STARTED);
- dumpSetting(s, p,
- Settings.Global.CHARGING_SOUNDS_ENABLED,
- GlobalSettingsProto.Sounds.CHARGING_SOUNDS_ENABLED);
p.end(soundsToken);
final long soundTriggerToken = p.start(GlobalSettingsProto.SOUND_TRIGGER);
@@ -1478,12 +1475,6 @@
dumpSetting(s, p,
Settings.Global.ZEN_MODE_CONFIG_ETAG,
GlobalSettingsProto.Zen.MODE_CONFIG_ETAG);
- dumpSetting(s, p,
- Settings.Global.ZEN_DURATION,
- GlobalSettingsProto.Zen.DURATION);
- dumpSetting(s, p,
- Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION,
- GlobalSettingsProto.Zen.SHOW_ZEN_UPGRADE_NOTIFICATION);
p.end(zenToken);
dumpSetting(s, p,
@@ -1984,6 +1975,9 @@
dumpSetting(s, p,
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING,
SecureSettingsProto.Notification.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING);
+ dumpSetting(s, p,
+ Settings.Secure.IN_CALL_NOTIFICATION_ENABLED,
+ SecureSettingsProto.Notification.IN_CALL_NOTIFICATION_ENABLED);
p.end(notificationToken);
final long packageVerifierToken = p.start(SecureSettingsProto.PACKAGE_VERIFIER);
@@ -2146,6 +2140,16 @@
dumpSetting(s, p,
Settings.Secure.SMS_DEFAULT_APPLICATION,
SecureSettingsProto.SMS_DEFAULT_APPLICATION);
+
+ final long soundsToken = p.start(SecureSettingsProto.SOUNDS);
+ dumpSetting(s, p,
+ Settings.Secure.CHARGING_SOUNDS_ENABLED,
+ SecureSettingsProto.Sounds.CHARGING_SOUNDS_ENABLED);
+ dumpSetting(s, p,
+ Settings.Secure.CHARGING_VIBRATION_ENABLED,
+ SecureSettingsProto.Sounds.CHARGING_VIBRATION_ENABLED);
+ p.end(soundsToken);
+
dumpSetting(s, p,
Settings.Secure.SYNC_PARENT_SOUNDS,
SecureSettingsProto.SYNC_PARENT_SOUNDS);
@@ -2252,6 +2256,24 @@
SecureSettingsProto.Launcher.SWIPE_UP_TO_SWITCH_APPS_ENABLED);
p.end(launcherToken);
+ final long zenToken = p.start(SecureSettingsProto.ZEN);
+ dumpSetting(s, p,
+ Settings.Secure.ZEN_DURATION,
+ SecureSettingsProto.Zen.DURATION);
+ dumpSetting(s, p,
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION,
+ SecureSettingsProto.Zen.SHOW_ZEN_UPGRADE_NOTIFICATION);
+ dumpSetting(s, p,
+ Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION,
+ SecureSettingsProto.Zen.SHOW_ZEN_SETTINGS_SUGGESTION);
+ dumpSetting(s, p,
+ Settings.Secure.ZEN_SETTINGS_UPDATED,
+ SecureSettingsProto.Zen.SETTINGS_UPDATED);
+ dumpSetting(s, p,
+ Settings.Secure.ZEN_SETTINGS_SUGGESTION_VIEWED,
+ SecureSettingsProto.Zen.SETTINGS_SUGGESTION_VIEWED);
+ p.end(zenToken);
+
// Please insert new settings using the same order as in SecureSettingsProto.
p.end(token);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 9592b63..773ff27 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 = 170;
+ private static final int SETTINGS_VERSION = 171;
private final int mUserId;
@@ -3595,7 +3595,8 @@
}
if (currentVersion == 156) {
- // Version 157: Set a default value for zen duration
+ // Version 157: Set a default value for zen duration,
+ // in version 169, zen duration is moved to secure settings
final SettingsState globalSettings = getGlobalSettingsLocked();
final Setting currentSetting = globalSettings.getSettingLocked(
Global.ZEN_DURATION);
@@ -3731,32 +3732,8 @@
}
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);
- }
-
+ // Version 165: MOVED: Show zen settings suggestion and zen updated settings
+ // moved to secure settings and are set in version 169
currentVersion = 166;
}
@@ -3783,15 +3760,8 @@
}
if (currentVersion == 167) {
- // Version 167: by default, vibrate for wireless charging
- final SettingsState globalSettings = getGlobalSettingsLocked();
- final Setting currentSetting = globalSettings.getSettingLocked(
- Global.CHARGING_VIBRATION_ENABLED);
- if (currentSetting.isNull()) {
- globalSettings.insertSettingLocked(
- Global.CHARGING_VIBRATION_ENABLED, "1",
- null, true, SettingsState.SYSTEM_PACKAGE_NAME);
- }
+ // Version 167: MOVED - Settings.Global.CHARGING_VIBRATION_ENABLED moved to
+ // Settings.Secure.CHARGING_VIBRATION_ENABLED, set in version 170
currentVersion = 168;
}
@@ -3811,36 +3781,112 @@
}
if (currentVersion == 169) {
- // Version 169: by default, add STREAM_VOICE_CALL to list of streams that can
- // be muted.
- final SettingsState systemSettings = getSystemSettingsLocked(userId);
- final Setting currentSetting = systemSettings.getSettingLocked(
- Settings.System.MUTE_STREAMS_AFFECTED);
- if (!currentSetting.isNull()) {
- try {
- int currentSettingIntegerValue = Integer.parseInt(
- currentSetting.getValue());
- if ((currentSettingIntegerValue
- & (1 << AudioManager.STREAM_VOICE_CALL)) == 0) {
- systemSettings.insertSettingLocked(
- Settings.System.MUTE_STREAMS_AFFECTED,
- Integer.toString(
- currentSettingIntegerValue
- | (1 << AudioManager.STREAM_VOICE_CALL)),
- null, true, SettingsState.SYSTEM_PACKAGE_NAME);
- }
- } catch (NumberFormatException e) {
- // remove the setting in case it is not a valid integer
- Slog.w("Failed to parse integer value of MUTE_STREAMS_AFFECTED"
- + "setting, removing setting", e);
- systemSettings.deleteSettingLocked(
- Settings.System.MUTE_STREAMS_AFFECTED);
- }
+ // Version 169: Set the default value for Secure Settings ZEN_DURATION,
+ // SHOW_ZEN_SETTINGS_SUGGESTION, ZEN_SETTINGS_UPDATE and
+ // ZEN_SETTINGS_SUGGESTION_VIEWED
+ final SettingsState globalSettings = getGlobalSettingsLocked();
+ final Setting globalZenDuration = globalSettings.getSettingLocked(
+ Global.ZEN_DURATION);
+
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+ final Setting secureZenDuration = secureSettings.getSettingLocked(
+ Secure.ZEN_DURATION);
+
+ // ZEN_DURATION
+ if (!globalZenDuration.isNull()) {
+ secureSettings.insertSettingLocked(
+ Secure.ZEN_DURATION, globalZenDuration.getValue(), null, false,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+
+ // set global zen duration setting to null since it's deprecated
+ globalSettings.insertSettingLocked(
+ Global.ZEN_DURATION, null, null, true,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ } else if (secureZenDuration.isNull()) {
+ String defaultZenDuration = Integer.toString(getContext()
+ .getResources().getInteger(R.integer.def_zen_duration));
+ secureSettings.insertSettingLocked(
+ Secure.ZEN_DURATION, defaultZenDuration, null, true,
+ SettingsState.SYSTEM_PACKAGE_NAME);
}
+
+ // SHOW_ZEN_SETTINGS_SUGGESTION
+ final Setting currentShowZenSettingSuggestion = secureSettings.getSettingLocked(
+ Secure.SHOW_ZEN_SETTINGS_SUGGESTION);
+ if (currentShowZenSettingSuggestion.isNull()) {
+ secureSettings.insertSettingLocked(
+ Secure.SHOW_ZEN_SETTINGS_SUGGESTION, "1",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ // ZEN_SETTINGS_UPDATED
+ final Setting currentUpdatedSetting = secureSettings.getSettingLocked(
+ Secure.ZEN_SETTINGS_UPDATED);
+ if (currentUpdatedSetting.isNull()) {
+ secureSettings.insertSettingLocked(
+ Secure.ZEN_SETTINGS_UPDATED, "0",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ // ZEN_SETTINGS_SUGGESTION_VIEWED
+ final Setting currentSettingSuggestionViewed = secureSettings.getSettingLocked(
+ Secure.ZEN_SETTINGS_SUGGESTION_VIEWED);
+ if (currentSettingSuggestionViewed.isNull()) {
+ secureSettings.insertSettingLocked(
+ Secure.ZEN_SETTINGS_SUGGESTION_VIEWED, "0",
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
currentVersion = 170;
}
+ if (currentVersion == 170) {
+ // Version 170: Set the default value for Secure Settings:
+ // CHARGING_SOUNDS_ENABLED and CHARGING_VIBRATION_ENABLED
+
+ final SettingsState globalSettings = getGlobalSettingsLocked();
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+
+ // CHARGING_SOUNDS_ENABLED
+ final Setting globalChargingSoundEnabled = globalSettings.getSettingLocked(
+ Global.CHARGING_SOUNDS_ENABLED);
+ final Setting secureChargingSoundsEnabled = secureSettings.getSettingLocked(
+ Secure.CHARGING_SOUNDS_ENABLED);
+
+ if (!globalChargingSoundEnabled.isNull()) {
+ secureSettings.insertSettingLocked(
+ Secure.CHARGING_SOUNDS_ENABLED,
+ globalChargingSoundEnabled.getValue(), null, false,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+
+ // set global charging_sounds_enabled setting to null since it's deprecated
+ globalSettings.insertSettingLocked(
+ Global.CHARGING_SOUNDS_ENABLED, null, null, true,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ } else if (secureChargingSoundsEnabled.isNull()) {
+ String defChargingSoundsEnabled = getContext().getResources()
+ .getBoolean(R.bool.def_charging_sounds_enabled) ? "1" : "0";
+ secureSettings.insertSettingLocked(
+ Secure.CHARGING_SOUNDS_ENABLED, defChargingSoundsEnabled, null,
+ true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ // CHARGING_VIBRATION_ENABLED
+ final Setting secureChargingVibrationEnabled = secureSettings.getSettingLocked(
+ Secure.CHARGING_VIBRATION_ENABLED);
+
+ if (secureChargingVibrationEnabled.isNull()) {
+ String defChargingVibrationEnabled = getContext().getResources()
+ .getBoolean(R.bool.def_charging_vibration_enabled) ? "1" : "0";
+ secureSettings.insertSettingLocked(
+ Secure.CHARGING_VIBRATION_ENABLED, defChargingVibrationEnabled,
+ null, true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ currentVersion = 171;
+ }
+
// vXXX: Add new settings above this point.
if (currentVersion != newVersion) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index d1e33d3..f523196 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -142,14 +142,14 @@
@Override
public void showDetail(boolean show) {
- int zenDuration = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.ZEN_DURATION, 0);
- boolean showOnboarding = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0) != 0;
+ int zenDuration = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.ZEN_DURATION, 0);
+ boolean showOnboarding = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 0) != 0;
if (showOnboarding) {
// don't show on-boarding again or notification ever
- Settings.Global.putInt(mContext.getContentResolver(),
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
// turn on DND
mController.setZen(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, TAG);
// show on-boarding screen
@@ -158,7 +158,7 @@
Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(intent, 0);
} else {
switch (zenDuration) {
- case Settings.Global.ZEN_DURATION_PROMPT:
+ case Settings.Secure.ZEN_DURATION_PROMPT:
mUiHandler.post(() -> {
Dialog mDialog = new EnableZenModeDialog(mContext).createDialog();
mDialog.getWindow().setType(
@@ -170,7 +170,7 @@
mHost.collapsePanels();
});
break;
- case Settings.Global.ZEN_DURATION_FOREVER:
+ case Settings.Secure.ZEN_DURATION_FOREVER:
mController.setZen(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, TAG);
break;
default:
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 9c5e064..c87f927 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -508,8 +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);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, 0);
}
private void setManualZenMode(int zenMode, Uri conditionId, String reason, String caller,
@@ -627,8 +627,8 @@
}
if (config.version < ZenModeConfig.XML_VERSION || forRestore) {
- Settings.Global.putInt(mContext.getContentResolver(),
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 1);
// resets zen automatic rules to default
// if all prev auto rules were disabled on update
@@ -639,8 +639,8 @@
}
} else {
// devices not restoring/upgrading already have updated zen settings
- Settings.Global.putInt(mContext.getContentResolver(),
- Global.ZEN_SETTINGS_UPDATED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
}
if (DEBUG) Log.d(TAG, reason);
synchronized (mConfig) {
@@ -824,10 +824,10 @@
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);
+ if (Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.ZEN_SETTINGS_SUGGESTION_VIEWED, 1) == 0) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, 1);
}
zen = automaticRule.zenMode;
}
@@ -1192,18 +1192,18 @@
&& zen != Global.ZEN_MODE_OFF
&& !isWatch
&& Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0) != 0;
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 0) != 0;
if (isWatch) {
Settings.Global.putInt(mContext.getContentResolver(),
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
}
if (showNotification) {
mNotificationManager.notify(TAG, SystemMessage.NOTE_ZEN_UPGRADE,
createZenUpgradeNotification());
- Settings.Global.putInt(mContext.getContentResolver(),
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.SHOW_ZEN_UPGRADE_NOTIFICATION, 0);
}
}
diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java
index d445611..b4dafc9 100644
--- a/services/core/java/com/android/server/power/Notifier.java
+++ b/services/core/java/com/android/server/power/Notifier.java
@@ -585,9 +585,9 @@
}
/**
- * Called when wireless charging has started so as to provide user feedback (sound and visual).
+ * Called when wireless charging has started - to provide user feedback (sound and visual).
*/
- public void onWirelessChargingStarted(int batteryLevel) {
+ public void onWirelessChargingStarted(int batteryLevel, @UserIdInt int userId) {
if (DEBUG) {
Slog.d(TAG, "onWirelessChargingStarted");
}
@@ -596,13 +596,14 @@
Message msg = mHandler.obtainMessage(MSG_WIRELESS_CHARGING_STARTED);
msg.setAsynchronous(true);
msg.arg1 = batteryLevel;
+ msg.arg2 = userId;
mHandler.sendMessage(msg);
}
/**
- * Called when wired charging has started so as to provide user feedback
+ * Called when wired charging has started - to provide user feedback
*/
- public void onWiredChargingStarted() {
+ public void onWiredChargingStarted(@UserIdInt int userId) {
if (DEBUG) {
Slog.d(TAG, "onWiredChargingStarted");
}
@@ -610,6 +611,7 @@
mSuspendBlocker.acquire();
Message msg = mHandler.obtainMessage(MSG_WIRED_CHARGING_STARTED);
msg.setAsynchronous(true);
+ msg.arg1 = userId;
mHandler.sendMessage(msg);
}
@@ -748,10 +750,10 @@
/**
* Plays the wireless charging sound for both wireless and non-wireless charging
*/
- private void playChargingStartedSound() {
+ private void playChargingStartedSound(@UserIdInt int userId) {
final String soundPath = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.CHARGING_STARTED_SOUND);
- if (isChargingFeedbackEnabled() && soundPath != null) {
+ if (isChargingFeedbackEnabled(userId) && soundPath != null) {
final Uri soundUri = Uri.parse("file://" + soundPath);
if (soundUri != null) {
final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
@@ -763,17 +765,17 @@
}
}
- private void showWirelessChargingStarted(int batteryLevel) {
- playWirelessChargingVibration();
- playChargingStartedSound();
+ private void showWirelessChargingStarted(int batteryLevel, @UserIdInt int userId) {
+ playWirelessChargingVibration(userId);
+ playChargingStartedSound(userId);
if (mStatusBarManagerInternal != null) {
mStatusBarManagerInternal.showChargingAnimation(batteryLevel);
}
mSuspendBlocker.release();
}
- private void showWiredChargingStarted() {
- playChargingStartedSound();
+ private void showWiredChargingStarted(@UserIdInt int userId) {
+ playChargingStartedSound(userId);
mSuspendBlocker.release();
}
@@ -781,17 +783,17 @@
mTrustManager.setDeviceLockedForUser(userId, true /*locked*/);
}
- private void playWirelessChargingVibration() {
- final boolean vibrateEnabled = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.CHARGING_VIBRATION_ENABLED, 0) != 0;
- if (vibrateEnabled && isChargingFeedbackEnabled()) {
+ private void playWirelessChargingVibration(@UserIdInt int userId) {
+ final boolean vibrateEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.CHARGING_VIBRATION_ENABLED, 1, userId) != 0;
+ if (vibrateEnabled && isChargingFeedbackEnabled(userId)) {
mVibrator.vibrate(WIRELESS_CHARGING_VIBRATION_EFFECT, VIBRATION_ATTRIBUTES);
}
}
- private boolean isChargingFeedbackEnabled() {
- final boolean enabled = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.CHARGING_SOUNDS_ENABLED, 1) != 0;
+ private boolean isChargingFeedbackEnabled(@UserIdInt int userId) {
+ final boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.CHARGING_SOUNDS_ENABLED, 1, userId) != 0;
final boolean dndOff = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS)
== Settings.Global.ZEN_MODE_OFF;
@@ -813,7 +815,7 @@
sendNextBroadcast();
break;
case MSG_WIRELESS_CHARGING_STARTED:
- showWirelessChargingStarted(msg.arg1);
+ showWirelessChargingStarted(msg.arg1, msg.arg2);
break;
case MSG_SCREEN_BRIGHTNESS_BOOST_CHANGED:
sendBrightnessBoostChangedBroadcast();
@@ -822,7 +824,7 @@
lockProfile(msg.arg1);
break;
case MSG_WIRED_CHARGING_STARTED:
- showWiredChargingStarted();
+ showWiredChargingStarted(msg.arg1);
break;
}
}
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 9468dd7..13800b6 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -1705,9 +1705,9 @@
if (mBootCompleted) {
if (mIsPowered && !BatteryManager.isPlugWired(oldPlugType)
&& BatteryManager.isPlugWired(mPlugType)) {
- mNotifier.onWiredChargingStarted();
+ mNotifier.onWiredChargingStarted(mForegroundProfile);
} else if (dockedOnWirelessCharger) {
- mNotifier.onWirelessChargingStarted(mBatteryLevel);
+ mNotifier.onWirelessChargingStarted(mBatteryLevel, mForegroundProfile);
}
}
}