Android4.4修改最大音量MAX_STREAM_VOLUME 时不起作用,可以修改mIndexMax = MAX_STREAM_VOLUME[streamType];中的mIndexMax的值。来达到自己想要的效果。
****
默认音量
frameworks\base\media\java\android\media\AudioManager.java
/** @hide Default volume index values for audio streams */
public static final int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
2, // STREAM_SYSTEM
1, // STREAM_RING
4, // STREAM_MUSIC
1, // STREAM_ALARM
1, // STREAM_NOTIFICATION
7, // STREAM_BLUETOOTH_SCO
7, // STREAM_SYSTEM_ENFORCED
6, // STREAM_DTMF
6, // STREAM_TTS
6 // STREAM_FM
};
最大音量
frameworks\base\media\java\android\media\AudioService.java
/** @hide Maximum volume index values for audio streams */
private static final int[] MAX_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
6, // STREAM_SYSTEM
6, // STREAM_RING
13, // STREAM_MUSIC
6, // STREAM_ALARM
6, // STREAM_NOTIFICATION
13, // STREAM_BLUETOOTH_SCO
6, // STREAM_SYSTEM_ENFORCED
13, // STREAM_DTMF
13, // STREAM_TTS
13 // STREAM_FM
};
如果改上述数字不起作用,更改 mIndexMax *=;的值。
mStreamType = streamType;
mIndexMax = MAX_STREAM_VOLUME[streamType];
AudioSystem.initStreamVolume(streamType, 0, mIndexMax);
mIndexMax *= 7;