summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hongwei Wang <hwwang@google.com> 2019-03-28 08:21:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-03-28 08:21:59 +0000
commit50b1abc246069f4b4681bcea188eede08156dfae (patch)
treecf517688d0b715dd9f3af0b3632b8320a8bfc965
parentd711ed3021a68e106b1eb1654671434043f0e5d5 (diff)
parente220d3b5c4c8c6a4e2c794f5a9c28fec16e89955 (diff)
Merge changes from topic "renault-non-api-change"
* changes: Get volume indexes from Audio Policy Service Use AudioProductStrategies within AudioAttributes
-rw-r--r--media/java/android/media/AudioAttributes.java12
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java25
2 files changed, 37 insertions, 0 deletions
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java
index efb7f4698797..e925731db7ff 100644
--- a/media/java/android/media/AudioAttributes.java
+++ b/media/java/android/media/AudioAttributes.java
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
+import android.media.audiopolicy.AudioProductStrategies;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
@@ -794,6 +795,13 @@ public final class AudioAttributes implements Parcelable {
*/
@UnsupportedAppUsage
public Builder setInternalLegacyStreamType(int streamType) {
+ final AudioProductStrategies ps = new AudioProductStrategies();
+ if (ps.size() > 0) {
+ AudioAttributes attributes = ps.getAudioAttributesForLegacyStreamType(streamType);
+ if (attributes != null) {
+ return new Builder(attributes);
+ }
+ }
switch(streamType) {
case AudioSystem.STREAM_VOICE_CALL:
mContentType = CONTENT_TYPE_SPEECH;
@@ -1169,6 +1177,10 @@ public final class AudioAttributes implements Parcelable {
AudioSystem.STREAM_MUSIC : AudioSystem.STREAM_TTS;
}
+ final AudioProductStrategies ps = new AudioProductStrategies();
+ if (ps.size() > 0) {
+ return ps.getLegacyStreamTypeForAudioAttributes(aa);
+ }
// usage to stream type mapping
switch (aa.getUsage()) {
case USAGE_MEDIA:
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 82a4f1df2e10..32781a90348b 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -640,6 +640,26 @@ public class AudioService extends IAudioService.Stub
sAudioVolumeGroups = new AudioVolumeGroups();
// Initialize volume
+ // Priority 1 - Android Property
+ // Priority 2 - Audio Policy Service
+ // Priority 3 - Default Value
+ if (sAudioProductStrategies.size() > 0) {
+ int numStreamTypes = AudioSystem.getNumStreamTypes();
+
+ for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
+ AudioAttributes attr =
+ sAudioProductStrategies.getAudioAttributesForLegacyStreamType(streamType);
+ int maxVolume = AudioSystem.getMaxVolumeIndexForAttributes(attr);
+ if (maxVolume != -1) {
+ MAX_STREAM_VOLUME[streamType] = maxVolume;
+ }
+ int minVolume = AudioSystem.getMinVolumeIndexForAttributes(attr);
+ if (minVolume != -1) {
+ MIN_STREAM_VOLUME[streamType] = minVolume;
+ }
+ }
+ }
+
int maxCallVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps", -1);
if (maxCallVolume != -1) {
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxCallVolume;
@@ -1468,6 +1488,11 @@ public class AudioService extends IAudioService.Stub
}
private int rescaleIndex(int index, int srcStream, int dstStream) {
+ int max = mStreamStates[srcStream].getMaxIndex();
+ if (max == 0) {
+ Log.e(TAG, "rescaleIndex : Max index should not be zero");
+ return mStreamStates[srcStream].getMinIndex();
+ }
final int rescaled =
(index * mStreamStates[dstStream].getMaxIndex()
+ mStreamStates[srcStream].getMaxIndex() / 2)