Loading core/res/res/values/config.xml +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,17 @@ master volume stream and nothing else . --> <bool name="config_useMasterVolume">false</bool> <!-- Array of integer pairs controlling the rate at which the master volume changes in response to volume up and down key events. The first integer of each pair is compared against the current master volume (in range 0 to 100). The last pair with first integer <= the current volume is chosen, and the second integer of the pair indicates the amount to increase the master volume when volume up is pressed. --> <integer-array name="config_masterVolumeRamp"> <item>0</item> <item>5</item> <!-- default: always increase volume by 5% --> </integer-array> <!-- Flag indicating whether the AUDIO_BECOMING_NOISY notification should be sent during an change to the audio output device. --> <bool name="config_sendAudioBecomingNoisy">true</bool> Loading core/res/res/values/public.xml +1 −0 Original line number Diff line number Diff line Loading @@ -862,6 +862,7 @@ <java-symbol type="array" name="preloaded_drawables" /> <java-symbol type="array" name="special_locale_codes" /> <java-symbol type="array" name="special_locale_names" /> <java-symbol type="array" name="config_masterVolumeRamp" /> <java-symbol type="drawable" name="default_wallpaper" /> <java-symbol type="drawable" name="ic_suggestions_add" /> Loading media/java/android/media/AudioService.java +27 −13 Original line number Diff line number Diff line Loading @@ -137,10 +137,6 @@ public class AudioService extends IAudioService.Stub { // Timeout for connection to bluetooth headset service private static final int BT_HEADSET_CNCT_TIMEOUT_MS = 3000; // Amount to raise/lower master volume // FIXME - this should probably be in a resource private static final float MASTER_VOLUME_INCREMENT = 0.05f; /** @see AudioSystemThread */ private AudioSystemThread mAudioSystemThread; /** @see AudioHandler */ Loading Loading @@ -286,6 +282,8 @@ public class AudioService extends IAudioService.Stub { // True if we have master volume support private final boolean mUseMasterVolume; private final int[] mMasterVolumeRamp; // List of binder death handlers for setMode() client processes. // The last process to have called setMode() is at the top of the list. private final ArrayList <SetModeDeathHandler> mSetModeDeathHandlers = new ArrayList <SetModeDeathHandler>(); Loading Loading @@ -416,6 +414,9 @@ public class AudioService extends IAudioService.Stub { mUseMasterVolume = context.getResources().getBoolean( com.android.internal.R.bool.config_useMasterVolume); restoreMasterVolume(); mMasterVolumeRamp = context.getResources().getIntArray( com.android.internal.R.array.config_masterVolumeRamp); } private void createAudioSystemThread() { Loading Loading @@ -620,20 +621,28 @@ public class AudioService extends IAudioService.Stub { /** @see AudioManager#adjustMasterVolume(int) */ public void adjustMasterVolume(int direction, int flags) { ensureValidDirection(direction); float volume = AudioSystem.getMasterVolume(); if (volume >= 0.0) { // get current master volume adjusted to 0 to 100 int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME); int delta = 0; for (int i = 0; i < mMasterVolumeRamp.length; i += 2) { int testVolume = mMasterVolumeRamp[i]; int testDelta = mMasterVolumeRamp[i + 1]; if (direction == AudioManager.ADJUST_RAISE) { volume += MASTER_VOLUME_INCREMENT; if (volume > 1.0f) volume = 1.0f; if (volume >= testVolume) { delta = testDelta; } else { break; } } else if (direction == AudioManager.ADJUST_LOWER) { volume -= MASTER_VOLUME_INCREMENT; if (volume < 0.0f) volume = 0.0f; if (volume - testDelta >= testVolume) { delta = -testDelta; } else { break; } doSetMasterVolume(volume, flags); } } // Log.d(TAG, "adjustMasterVolume volume: " + volume + " delta: " + delta + " direction: " + direction); setMasterVolume(volume + delta, flags); } /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { Loading Loading @@ -805,6 +814,11 @@ public class AudioService extends IAudioService.Stub { } public void setMasterVolume(int volume, int flags) { if (volume < 0) { volume = 0; } else if (volume > MAX_MASTER_VOLUME) { volume = MAX_MASTER_VOLUME; } doSetMasterVolume((float)volume / MAX_MASTER_VOLUME, flags); } Loading Loading
core/res/res/values/config.xml +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,17 @@ master volume stream and nothing else . --> <bool name="config_useMasterVolume">false</bool> <!-- Array of integer pairs controlling the rate at which the master volume changes in response to volume up and down key events. The first integer of each pair is compared against the current master volume (in range 0 to 100). The last pair with first integer <= the current volume is chosen, and the second integer of the pair indicates the amount to increase the master volume when volume up is pressed. --> <integer-array name="config_masterVolumeRamp"> <item>0</item> <item>5</item> <!-- default: always increase volume by 5% --> </integer-array> <!-- Flag indicating whether the AUDIO_BECOMING_NOISY notification should be sent during an change to the audio output device. --> <bool name="config_sendAudioBecomingNoisy">true</bool> Loading
core/res/res/values/public.xml +1 −0 Original line number Diff line number Diff line Loading @@ -862,6 +862,7 @@ <java-symbol type="array" name="preloaded_drawables" /> <java-symbol type="array" name="special_locale_codes" /> <java-symbol type="array" name="special_locale_names" /> <java-symbol type="array" name="config_masterVolumeRamp" /> <java-symbol type="drawable" name="default_wallpaper" /> <java-symbol type="drawable" name="ic_suggestions_add" /> Loading
media/java/android/media/AudioService.java +27 −13 Original line number Diff line number Diff line Loading @@ -137,10 +137,6 @@ public class AudioService extends IAudioService.Stub { // Timeout for connection to bluetooth headset service private static final int BT_HEADSET_CNCT_TIMEOUT_MS = 3000; // Amount to raise/lower master volume // FIXME - this should probably be in a resource private static final float MASTER_VOLUME_INCREMENT = 0.05f; /** @see AudioSystemThread */ private AudioSystemThread mAudioSystemThread; /** @see AudioHandler */ Loading Loading @@ -286,6 +282,8 @@ public class AudioService extends IAudioService.Stub { // True if we have master volume support private final boolean mUseMasterVolume; private final int[] mMasterVolumeRamp; // List of binder death handlers for setMode() client processes. // The last process to have called setMode() is at the top of the list. private final ArrayList <SetModeDeathHandler> mSetModeDeathHandlers = new ArrayList <SetModeDeathHandler>(); Loading Loading @@ -416,6 +414,9 @@ public class AudioService extends IAudioService.Stub { mUseMasterVolume = context.getResources().getBoolean( com.android.internal.R.bool.config_useMasterVolume); restoreMasterVolume(); mMasterVolumeRamp = context.getResources().getIntArray( com.android.internal.R.array.config_masterVolumeRamp); } private void createAudioSystemThread() { Loading Loading @@ -620,20 +621,28 @@ public class AudioService extends IAudioService.Stub { /** @see AudioManager#adjustMasterVolume(int) */ public void adjustMasterVolume(int direction, int flags) { ensureValidDirection(direction); float volume = AudioSystem.getMasterVolume(); if (volume >= 0.0) { // get current master volume adjusted to 0 to 100 int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME); int delta = 0; for (int i = 0; i < mMasterVolumeRamp.length; i += 2) { int testVolume = mMasterVolumeRamp[i]; int testDelta = mMasterVolumeRamp[i + 1]; if (direction == AudioManager.ADJUST_RAISE) { volume += MASTER_VOLUME_INCREMENT; if (volume > 1.0f) volume = 1.0f; if (volume >= testVolume) { delta = testDelta; } else { break; } } else if (direction == AudioManager.ADJUST_LOWER) { volume -= MASTER_VOLUME_INCREMENT; if (volume < 0.0f) volume = 0.0f; if (volume - testDelta >= testVolume) { delta = -testDelta; } else { break; } doSetMasterVolume(volume, flags); } } // Log.d(TAG, "adjustMasterVolume volume: " + volume + " delta: " + delta + " direction: " + direction); setMasterVolume(volume + delta, flags); } /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { Loading Loading @@ -805,6 +814,11 @@ public class AudioService extends IAudioService.Stub { } public void setMasterVolume(int volume, int flags) { if (volume < 0) { volume = 0; } else if (volume > MAX_MASTER_VOLUME) { volume = MAX_MASTER_VOLUME; } doSetMasterVolume((float)volume / MAX_MASTER_VOLUME, flags); } Loading