Merge "audioservice: modify default music volume" into oc-dr1-dev am: b6f946c081
am: aebf79edb4
Change-Id: I9e5ee08c8320799dd53e604005c4be57142832fb
This commit is contained in:
@@ -806,14 +806,14 @@ public class AudioSystem
|
||||
4, // STREAM_VOICE_CALL
|
||||
7, // STREAM_SYSTEM
|
||||
5, // STREAM_RING
|
||||
11, // STREAM_MUSIC
|
||||
5, // STREAM_MUSIC
|
||||
6, // STREAM_ALARM
|
||||
5, // STREAM_NOTIFICATION
|
||||
7, // STREAM_BLUETOOTH_SCO
|
||||
7, // STREAM_SYSTEM_ENFORCED
|
||||
11, // STREAM_DTMF
|
||||
11, // STREAM_TTS
|
||||
11, // STREAM_ACCESSIBILITY
|
||||
5, // STREAM_DTMF
|
||||
5, // STREAM_TTS
|
||||
5, // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
public static String streamToString(int stream) {
|
||||
|
||||
@@ -675,20 +675,29 @@ public class AudioService extends IAudioService.Stub
|
||||
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
|
||||
|
||||
// Initialize volume
|
||||
int maxVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps",
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
|
||||
if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]) {
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxVolume;
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = (maxVolume * 3) / 4;
|
||||
int maxCallVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps", -1);
|
||||
if (maxCallVolume != -1) {
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxCallVolume;
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] =
|
||||
(maxCallVolume * 3) / 4;
|
||||
}
|
||||
maxVolume = SystemProperties.getInt("ro.config.media_vol_steps",
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]);
|
||||
if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxVolume;
|
||||
|
||||
int maxMusicVolume = SystemProperties.getInt("ro.config.media_vol_steps", -1);
|
||||
if (maxMusicVolume != -1) {
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxMusicVolume;
|
||||
}
|
||||
|
||||
int defaultMusicVolume = SystemProperties.getInt("ro.config.media_vol_default", -1);
|
||||
if (defaultMusicVolume != -1 &&
|
||||
defaultMusicVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = defaultMusicVolume;
|
||||
} else {
|
||||
if (isPlatformTelevision()) {
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxVolume / 4;
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 4;
|
||||
} else {
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = (maxVolume * 3) / 4;
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] =
|
||||
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] / 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,6 +1027,19 @@ public class AudioService extends IAudioService.Stub
|
||||
checkAllFixedVolumeDevices();
|
||||
checkAllAliasStreamVolumes();
|
||||
checkMuteAffectedStreams();
|
||||
updateDefaultVolumes();
|
||||
}
|
||||
|
||||
// Update default indexes from aliased streams. Must be called after mStreamStates is created
|
||||
private void updateDefaultVolumes() {
|
||||
for (int stream = 0; stream < mStreamStates.length; stream++) {
|
||||
if (stream != mStreamVolumeAlias[stream]) {
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[stream] = rescaleIndex(
|
||||
AudioSystem.DEFAULT_STREAM_VOLUME[mStreamVolumeAlias[stream]],
|
||||
mStreamVolumeAlias[stream],
|
||||
stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpStreamStates(PrintWriter pw) {
|
||||
@@ -1066,7 +1088,9 @@ public class AudioService extends IAudioService.Stub
|
||||
mStreamVolumeAlias[AudioSystem.STREAM_DTMF] = dtmfStreamAlias;
|
||||
mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY] = a11yStreamAlias;
|
||||
|
||||
if (updateVolumes) {
|
||||
if (updateVolumes && mStreamStates != null) {
|
||||
updateDefaultVolumes();
|
||||
|
||||
mStreamStates[AudioSystem.STREAM_DTMF].setAllIndexes(mStreamStates[dtmfStreamAlias],
|
||||
caller);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user