各音频流默认值,定义文件路径:
frameworks/base/media/java/android/media/AudioSystem.java
默认音量定义数组:
/** @hide */
public static int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
5, // STREAM_RING
5, // STREAM_MUSIC
6, // STREAM_ALARM
5, // STREAM_NOTIFICATION
7, // STREAM_BLUETOOTH_SCO
7, // STREAM_SYSTEM_ENFORCED
5, // STREAM_DTMF
5, // STREAM_TTS
5, // STREAM_ACCESSIBILITY
5, // STREAM_ASSISTANT
};
不同音频流,默认音量get函数:
/** @hide */
public static int getDefaultStreamVolume(int streamType) {
return DEFAULT_STREAM_VOLUME[streamType];
}
各音频流默认值,加载文件路径:frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
音频流,默认值加载:
private void loadVolumeLevels(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
。。。
loadSetting(stmt, Settings.System.VOLUME_MUSIC,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_MUSIC));
loadSetting(stmt, Settings.System.VOLUME_RING,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_RING));
loadSetting(stmt, Settings.System.VOLUME_SYSTEM,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_SYSTEM));
loadSetting(
stmt,
Settings.System.VOLUME_VOICE,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL));
loadSetting(stmt, Settings.System.VOLUME_ALARM,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_ALARM));
loadSetting(
stmt,
Settings.System.VOLUME_NOTIFICATION,
AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_NOTIFICATION));
loadSetting(
stmt,
Settings.System.VOLUME_BLUETOOTH_SCO, AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO));
。。。
} finally {
if (stmt != null) stmt.close();
}
}
以上,系统启动过程,拉起loadVolumeLevels()函数,将默认音频流音量保存在数据库。
标签:STREAM,getDefaultStreamVolume,音频,AudioManager,stmt,VOLUME,android,audio,AudioSys From: https://blog.csdn.net/xuann/article/details/140520762