|
楼主 |
发表于 2012-3-21 11:00:55
|
显示全部楼层
第二部分则是低电提示音,在网上看帖子,这个功能令很多人恼火啊,特别是学生深受其害,那么是否让用户有选择的打开此功能呢?
实现这部分功能需要两步
POWER_SOUNDS_ENABLED
841 if (Settings.System.getInt(cr,
842 Settings.System.POWER_SOUNDS_ENABLED, 1) == 1)
我们知道Settings.System.POWER_SOUNDS_ENABLED是一个系统属性,通过在源码中并没有查找到有用此属性的地方
Settings.System.LOW_BATTERY_SOUND
844 final String soundPath = Settings.System.getString(cr,
845 Settings.System.LOW_BATTERY_SOUND);
846 if (soundPath != null) {
定义在文件Settings.java
frameworks/base / core / java / android / provider / Settings.java
1656 /**
1657 * Whether to play a sound for low-battery alerts.
1658 * @hide
1659 */
1660 public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled";
1674 /**
1675 * URI for the low battery sound file.
1676 * @hide
1677 */
1678 public static final String LOW_BATTERY_SOUND = "low_battery_sound";
通过如下方式读取默认值
frameworks/base/ packages / SettingsProvider / src / com / android / providers / settings / DatabaseHelper.java
1081 private void loadUISoundEffectsSettings(SQLiteStatement stmt) {
1082 loadIntegerSetting(stmt, Settings.System.POWER_SOUNDS_ENABLED,
1083 R.integer.def_power_sounds_enabled);
1084 loadStringSetting(stmt, Settings.System.LOW_BATTERY_SOUND,
1085 R.string.def_low_battery_sound);
1098 loadIntegerSetting(stmt, Settings.System.LOCKSCREEN_SOUNDS_ENABLED,
1099 R.integer.def_lockscreen_sounds_enabled);
1100 loadStringSetting(stmt, Settings.System.LOCK_SOUND,
1101 R.string.def_lock_sound);
1102 loadStringSetting(stmt, Settings.System.UNLOCK_SOUND,
1103 R.string.def_unlock_sound);
上面包括是否开启解锁屏声音,默认值定义在如下文件中
61 <!-- user interface sound effects -->
62 <integer name="def_power_sounds_enabled">1</integer>
63 <string name="def_low_battery_sound" translatable="false">/system/media/audio/ui/LowBattery.ogg</string>
64 <integer name="def_dock_sounds_enabled">0</integer>
69 <integer name="def_lockscreen_sounds_enabled">0</integer>
70 <string name="def_lock_sound" translatable="false">/system/media/audio/ui/Lock.ogg</string>
71 <string name="def_unlock_sound" translatable="false">/system/media/audio/ui/Unlock.ogg</string> |
|