Merge "Fwk: Only chime when docked and accessbility is on" into cw-f-dev

This commit is contained in:
TreeHugger Robot
2016-10-21 20:41:07 +00:00
committed by Android (Google) Code Review
4 changed files with 18 additions and 2 deletions

View File

@@ -6862,6 +6862,12 @@ public final class Settings {
*/
public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled";
/**
* Whether to play a sound for dock events, only when an accessibility service is on.
* @hide
*/
public static final String DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY = "dock_sounds_enabled_when_accessbility";
/**
* URI for the "device locked" (keyguard shown) sound.
* @hide

View File

@@ -69,6 +69,7 @@
<integer name="def_power_sounds_enabled">1</integer>
<string name="def_low_battery_sound" translatable="false">/system/media/audio/ui/LowBattery.ogg</string>
<integer name="def_dock_sounds_enabled">0</integer>
<integer name="def_dock_sounds_enabled_when_accessibility">0</integer>
<string name="def_desk_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string>
<string name="def_desk_undock_sound" translatable="false">/system/media/audio/ui/Undock.ogg</string>
<string name="def_car_dock_sound" translatable="false">/system/media/audio/ui/Dock.ogg</string>

View File

@@ -2662,6 +2662,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
R.string.def_low_battery_sound);
loadIntegerSetting(stmt, Settings.Global.DOCK_SOUNDS_ENABLED,
R.integer.def_dock_sounds_enabled);
loadIntegerSetting(stmt, Settings.Global.DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY,
R.integer.def_dock_sounds_enabled_when_accessibility);
loadStringSetting(stmt, Settings.Global.DESK_DOCK_SOUND,
R.string.def_desk_dock_sound);
loadStringSetting(stmt, Settings.Global.DESK_UNDOCK_SOUND,

View File

@@ -167,10 +167,17 @@ final class DockObserver extends SystemService {
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intent.EXTRA_DOCK_STATE, mReportedDockState);
boolean dockSoundsEnabled = Settings.Global.getInt(cr,
Settings.Global.DOCK_SOUNDS_ENABLED, 1) == 1;
boolean dockSoundsEnabledWhenAccessibility = Settings.Global.getInt(cr,
Settings.Global.DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY, 1) == 1;
boolean accessibilityEnabled = Settings.Secure.getInt(cr,
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
// Play a sound to provide feedback to confirm dock connection.
// Particularly useful for flaky contact pins...
if (Settings.Global.getInt(cr,
Settings.Global.DOCK_SOUNDS_ENABLED, 1) == 1) {
if ((dockSoundsEnabled) ||
(accessibilityEnabled && dockSoundsEnabledWhenAccessibility)) {
String whichSound = null;
if (mReportedDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
if ((previousDockState == Intent.EXTRA_DOCK_STATE_DESK) ||