int maxMusicVolume = SystemProperties.getInt("ro.config.media_vol_steps", -1);
//获取media的最大值
if (maxMusicVolume != -1) {
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxMusicVolume;
}
int defaultMusicVolume = SystemProperties.getInt("ro.config.media_vol_default", -1);
//获取medio的默认值
if (defaultMusicVolume != -1 &&
defaultMusicVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] &&
defaultMusicVolume >= MIN_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = defaultMusicVolume;
} else {
if (isPlatformTelevision()) {
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 4;
} else {
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 3;
}
}
代码主要获取两个安卓的配置:
1.ro.config.media_vol_steps //音量最大值
2.ro.config.media_vol_default //开机时,音量默认值
如果在安卓的配置文件没有正确的获取参数,则会预设默认值。
// int maxMusicVolume = SystemProperties.getInt("ro.config.media_vol_steps", -1);
// Log.e(TAG,"oncethings media_vol_steps :"+maxMusicVolume);
// if (maxMusicVolume != -1) {
// MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxMusicVolume;
// }
// int defaultMusicVolume = SystemProperties.getInt("ro.config.media_vol_default", -1);
// Log.e(TAG,"oncethings media_vol_default :"+defaultMusicVolume);
// if (defaultMusicVolume != -1 &&
// defaultMusicVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] &&
// defaultMusicVolume >= MIN_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
// AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = defaultMusicVolume;
// } else {
// if (isPlatformTelevision()) {
// AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
// MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 4;
// } else {
// AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
// MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 3;
// }
// }
//直接赋值
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = 15;
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = 0;
修改方法:增加一行 echo "ro.config.media_vol_default=5" ,参照其他怎么写,学会照猫画虎。
修改方法:ro.config.media_vol_default=5 ,同理参照这个文件的其他。
修改方法:
ro.config.alarm_alert u:object_r:exported2_config_prop:s0 exact string
ro.config.media_vol_steps u:object_r:exported2_config_prop:s0 exact int
ro.config.alarm_vol_steps u:object_r:exported2_config_prop:s0 exact int
ro.config.system_vol_steps u:object_r:exported2_config_prop:s0 exact int
ro.config.notification_sound u:object_r:exported2_config_prop:s0 exact string
ro.config.ringtone u:object_r:exported2_config_prop:s0 exact string
ro.config.media_vol_default u:object_r:exported2_config_prop:s0 exact int
ro.config.alarm_vol_default u:object_r:exported2_config_prop:s0 exact int
ro.config.system_vol_default u:object_r:exported2_config_prop:s0 exact int
public static final int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
4, // STREAM_RING
8, // STREAM_MUSIC
4, // STREAM_ALARM
4, // STREAM_NOTIFICATION
7, // STREAM_BLUETOOTH_SCO
7, // STREAM_SYSTEM_ENFORCED
11, // STREAM_DTMF
11, // STREAM_TTS
4, // STREAM_FM
4 // STREAM_MATV
};
private int[] MAX_STREAM_VOLUME = new int[] {
6, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
7, // STREAM_RING
13, // STREAM_MUSIC
7, // STREAM_ALARM
7, // STREAM_NOTIFICATION
15, // STREAM_BLUETOOTH_SCO
7, // STREAM_SYSTEM_ENFORCED
15, // STREAM_DTMF
15, // STREAM_TTS
13, //STREAM_FM
13 //stream_MATV