summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-09-20 16:27:23 -0700
committerEric Laurent <elaurent@google.com>2012-09-21 09:22:26 -0700
commitf1a457d06c53a901ea08d2d3fb6e766bc06c4d4f (patch)
tree26a06b010de0b81a32d584b9765d91096af6a0b3 /media/java
parente6ff47840fc6d8ac5ba551101684011e328b4caa (diff)
downloadframeworks_base-f1a457d06c53a901ea08d2d3fb6e766bc06c4d4f.zip
frameworks_base-f1a457d06c53a901ea08d2d3fb6e766bc06c4d4f.tar.gz
frameworks_base-f1a457d06c53a901ea08d2d3fb6e766bc06c4d4f.tar.bz2
Do not turn safe volume on upon headset connection
It is not a requirement to force headphone volume limitation back on when a headset is plugged in. Only turn it back on when the device is power off or after 20 hours of cumulative music listening. Bug 7064975. Change-Id: Idabd417a9a9b8096552119c0ff528ba193cfdb5d
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/AudioService.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 5b3350a..cee8da8 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -457,6 +457,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
updateStreamVolumeAlias(false /*updateVolumes*/);
createStreamStates();
+ mSafeMediaVolumeEnabled = new Boolean(true);
synchronized (mSafeMediaVolumeEnabled) {
enforceSafeMediaVolume();
}
@@ -1715,7 +1716,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
checkAllAliasStreamVolumes();
synchronized (mSafeMediaVolumeEnabled) {
- enforceSafeMediaVolume();
+ if (mSafeMediaVolumeEnabled) {
+ enforceSafeMediaVolume();
+ }
}
// apply new ringer mode
@@ -2184,11 +2187,14 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
sendMsg(mAudioHandler,
MSG_CHECK_MUSIC_ACTIVE,
SENDMSG_REPLACE,
- device,
+ 0,
0,
null,
MUSIC_ACTIVE_POLL_PERIOD_MS);
- if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0)) {
+ int index = mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(device,
+ false /*lastAudible*/);
+ if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) &&
+ (index > mSafeMediaVolumeIndex)) {
// Approximate cumulative active music time
mMusicActiveMs += MUSIC_ACTIVE_POLL_PERIOD_MS;
if (mMusicActiveMs > UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX) {
@@ -2461,14 +2467,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
public void setWiredDeviceConnectionState(int device, int state, String name) {
synchronized (mConnectedDevices) {
int delay = checkSendBecomingNoisyIntent(device, state);
- if ((device & mSafeMediaVolumeDevices) != 0) {
- setSafeMediaVolumeEnabled(state != 0);
- // insert delay to allow new volume to apply before switching to headphones
- if ((delay < SAFE_VOLUME_DELAY_MS) && (state != 0)) {
- delay = SAFE_VOLUME_DELAY_MS;
- }
- }
-
queueMsgUnderWakeLock(mAudioHandler,
MSG_SET_WIRED_DEVICE_CONNECTION_STATE,
device,
@@ -3519,9 +3517,20 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
boolean isUsb = ((device & AudioSystem.DEVICE_OUT_ALL_USB) != 0);
handleDeviceConnection((state == 1), device, (isUsb ? name : ""));
- if ((state != 0) && ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
- (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE))) {
- setBluetoothA2dpOnInt(false);
+ if (state != 0) {
+ if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
+ (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE)) {
+ setBluetoothA2dpOnInt(false);
+ }
+ if ((device & mSafeMediaVolumeDevices) != 0) {
+ sendMsg(mAudioHandler,
+ MSG_CHECK_MUSIC_ACTIVE,
+ SENDMSG_REPLACE,
+ 0,
+ 0,
+ null,
+ MUSIC_ACTIVE_POLL_PERIOD_MS);
+ }
}
if (!isUsb) {
sendDeviceConnectionIntent(device, state, name);
@@ -5528,7 +5537,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// mSafeMediaVolumeEnabled indicates whether the media volume is limited over headphones.
// It is true by default when headphones or a headset are inserted and can be overriden by
// calling AudioService.disableSafeMediaVolume() (when user opts out).
- private Boolean mSafeMediaVolumeEnabled = new Boolean(false);
+ private Boolean mSafeMediaVolumeEnabled;
// mSafeMediaVolumeIndex is the cached value of config_safe_media_volume_index property
private final int mSafeMediaVolumeIndex;
// mSafeMediaVolumeDevices lists the devices for which safe media volume is enforced,
@@ -5540,7 +5549,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
private int mMusicActiveMs;
private static final int UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX = (20 * 3600 * 1000); // 20 hours
private static final int MUSIC_ACTIVE_POLL_PERIOD_MS = 60000; // 1 minute polling interval
- private static final int SAFE_VOLUME_DELAY_MS = 500; // 500ms before switching to headphones
private void setSafeMediaVolumeEnabled(boolean on) {
synchronized (mSafeMediaVolumeEnabled) {