AudioService: Fire volume-changed intents for all streams.
Allow observing all stream changed events, including streams that are bound to another stream via aliasing. Change-Id: I2c1717ce632c4cb045c06785cb1ecc531a221ff8
This commit is contained in:
@@ -1459,16 +1459,6 @@ public class AudioService extends IAudioService.Stub {
|
||||
flags = updateFlagsForSystemAudio(flags);
|
||||
}
|
||||
mVolumeController.postVolumeChanged(streamType, flags);
|
||||
|
||||
if ((flags & AudioManager.FLAG_FIXED_VOLUME) == 0) {
|
||||
oldIndex = (oldIndex + 5) / 10;
|
||||
index = (index + 5) / 10;
|
||||
Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION);
|
||||
intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType);
|
||||
intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
|
||||
intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
|
||||
sendBroadcastToAll(intent);
|
||||
}
|
||||
}
|
||||
|
||||
// If Hdmi-CEC system audio mode is on, we show volume bar only when TV
|
||||
@@ -3506,6 +3496,7 @@ public class AudioService extends IAudioService.Stub {
|
||||
private int mIndexMax;
|
||||
private final ConcurrentHashMap<Integer, Integer> mIndex =
|
||||
new ConcurrentHashMap<Integer, Integer>(8, 0.75f, 4);
|
||||
private final Intent mVolumeChanged;
|
||||
|
||||
private VolumeStreamState(String settingName, int streamType) {
|
||||
|
||||
@@ -3517,6 +3508,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
mIndexMax *= 10;
|
||||
|
||||
readSettings();
|
||||
mVolumeChanged = new Intent(AudioManager.VOLUME_CHANGED_ACTION);
|
||||
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, mStreamType);
|
||||
}
|
||||
|
||||
public String getSettingNameForDevice(int device) {
|
||||
@@ -3631,8 +3624,10 @@ public class AudioService extends IAudioService.Stub {
|
||||
}
|
||||
|
||||
public boolean setIndex(int index, int device) {
|
||||
boolean changed = false;
|
||||
int oldIndex;
|
||||
synchronized (VolumeStreamState.class) {
|
||||
int oldIndex = getIndex(device);
|
||||
oldIndex = getIndex(device);
|
||||
index = getValidIndex(index);
|
||||
synchronized (mCameraSoundForced) {
|
||||
if ((mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED) && mCameraSoundForced) {
|
||||
@@ -3641,7 +3636,8 @@ public class AudioService extends IAudioService.Stub {
|
||||
}
|
||||
mIndex.put(device, index);
|
||||
|
||||
if (oldIndex != index) {
|
||||
changed = oldIndex != index;
|
||||
if (changed) {
|
||||
// Apply change to all streams using this one as alias
|
||||
// if changing volume of current device, also change volume of current
|
||||
// device on aliased stream
|
||||
@@ -3659,11 +3655,16 @@ public class AudioService extends IAudioService.Stub {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
oldIndex = (oldIndex + 5) / 10;
|
||||
index = (index + 5) / 10;
|
||||
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
|
||||
mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
|
||||
sendBroadcastToAll(mVolumeChanged);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public int getIndex(int device) {
|
||||
|
||||
Reference in New Issue
Block a user