Merge "AudioService: prevent muting of alarm / accessibility" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
04dc4a02f0
@@ -320,13 +320,13 @@ public class AudioService extends IAudioService.Stub
|
||||
0, // STREAM_SYSTEM
|
||||
0, // STREAM_RING
|
||||
0, // STREAM_MUSIC
|
||||
0, // STREAM_ALARM
|
||||
1, // STREAM_ALARM
|
||||
0, // STREAM_NOTIFICATION
|
||||
0, // STREAM_BLUETOOTH_SCO
|
||||
0, // STREAM_SYSTEM_ENFORCED
|
||||
0, // STREAM_DTMF
|
||||
0, // STREAM_TTS
|
||||
0 // STREAM_ACCESSIBILITY
|
||||
1 // STREAM_ACCESSIBILITY
|
||||
};
|
||||
|
||||
/* mStreamVolumeAlias[] indicates for each stream if it uses the volume settings
|
||||
@@ -1208,6 +1208,8 @@ public class AudioService extends IAudioService.Stub
|
||||
System.VOLUME_SETTINGS_INT[a11yStreamAlias];
|
||||
mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].setAllIndexes(
|
||||
mStreamStates[a11yStreamAlias], caller);
|
||||
mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].refreshRange(
|
||||
mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY]);
|
||||
}
|
||||
}
|
||||
if (sIndependentA11yVolume) {
|
||||
@@ -1389,7 +1391,15 @@ public class AudioService extends IAudioService.Stub
|
||||
}
|
||||
|
||||
private int rescaleIndex(int index, int srcStream, int dstStream) {
|
||||
return (index * mStreamStates[dstStream].getMaxIndex() + mStreamStates[srcStream].getMaxIndex() / 2) / mStreamStates[srcStream].getMaxIndex();
|
||||
final int rescaled =
|
||||
(index * mStreamStates[dstStream].getMaxIndex()
|
||||
+ mStreamStates[srcStream].getMaxIndex() / 2)
|
||||
/ mStreamStates[srcStream].getMaxIndex();
|
||||
if (rescaled < mStreamStates[dstStream].getMinIndex()) {
|
||||
return mStreamStates[dstStream].getMinIndex();
|
||||
} else {
|
||||
return rescaled;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -4602,8 +4612,8 @@ public class AudioService extends IAudioService.Stub
|
||||
// 4 VolumeStreamState.class
|
||||
public class VolumeStreamState {
|
||||
private final int mStreamType;
|
||||
private final int mIndexMin;
|
||||
private final int mIndexMax;
|
||||
private int mIndexMin;
|
||||
private int mIndexMax;
|
||||
|
||||
private boolean mIsMuted;
|
||||
private String mVolumeIndexSettingName;
|
||||
@@ -4888,6 +4898,24 @@ public class AudioService extends IAudioService.Stub
|
||||
return mIndexMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the min/max index values from another stream. Use this when changing the alias
|
||||
* for the current stream type.
|
||||
* @param sourceStreamType
|
||||
*/
|
||||
// must be sync'd on mSettingsLock before VolumeStreamState.class
|
||||
@GuardedBy("VolumeStreamState.class")
|
||||
public void refreshRange(int sourceStreamType) {
|
||||
mIndexMin = MIN_STREAM_VOLUME[sourceStreamType] * 10;
|
||||
mIndexMax = MAX_STREAM_VOLUME[sourceStreamType] * 10;
|
||||
// verify all current volumes are within bounds
|
||||
for (int i = 0 ; i < mIndexMap.size(); i++) {
|
||||
final int device = mIndexMap.keyAt(i);
|
||||
final int index = mIndexMap.valueAt(i);
|
||||
mIndexMap.put(device, getValidIndex(index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all device/index pairs from the given VolumeStreamState after initializing
|
||||
* them with the volume for DEVICE_OUT_DEFAULT. No-op if the source VolumeStreamState
|
||||
|
||||
Reference in New Issue
Block a user