Use Android 12L APIs directly
Some APIs from Android 12L were used either via reflection or constants values were hard-coded. We can now use these APIs directly since we upgraded the compile SDK version to 32. PiperOrigin-RevId: 446167543
This commit is contained in:
parent
648b085954
commit
90600e985e
@ -28,7 +28,6 @@ import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Attributes for audio playback, which configure the underlying platform {@link
|
||||
@ -97,9 +96,7 @@ public final class AudioAttributes implements Bundleable {
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO[b/190759307] Update javadoc to link to AudioAttributes.Builder#setSpatializationBehavior
|
||||
// once compile SDK target is set to 32.
|
||||
/** See {@code android.media.AudioAttributes.Builder.setSpatializationBehavior(int)}. */
|
||||
/** See {@link android.media.AudioAttributes.Builder#setSpatializationBehavior(int)}. */
|
||||
public Builder setSpatializationBehavior(@C.SpatializationBehavior int spatializationBehavior) {
|
||||
this.spatializationBehavior = spatializationBehavior;
|
||||
return this;
|
||||
@ -269,14 +266,7 @@ public final class AudioAttributes implements Bundleable {
|
||||
public static void setSpatializationBehavior(
|
||||
android.media.AudioAttributes.Builder builder,
|
||||
@C.SpatializationBehavior int spatializationBehavior) {
|
||||
try {
|
||||
// TODO[b/190759307]: Remove reflection once compile SDK target is set to 32.
|
||||
Method setSpatializationBehavior =
|
||||
builder.getClass().getMethod("setSpatializationBehavior", Integer.TYPE);
|
||||
setSpatializationBehavior.invoke(builder, spatializationBehavior);
|
||||
} catch (Exception e) {
|
||||
// Do nothing if reflection fails.
|
||||
}
|
||||
builder.setSpatializationBehavior(spatializationBehavior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,12 +333,16 @@ public final class C {
|
||||
@IntDef({SPATIALIZATION_BEHAVIOR_AUTO, SPATIALIZATION_BEHAVIOR_NEVER})
|
||||
public @interface SpatializationBehavior {}
|
||||
|
||||
// TODO[b/190759307]: Update constant values and javadoc to use SDK once compile SDK target is set
|
||||
// to 32.
|
||||
/** See AudioAttributes#SPATIALIZATION_BEHAVIOR_AUTO */
|
||||
public static final int SPATIALIZATION_BEHAVIOR_AUTO = 0;
|
||||
/** See AudioAttributes#SPATIALIZATION_BEHAVIOR_NEVER */
|
||||
public static final int SPATIALIZATION_BEHAVIOR_NEVER = 1;
|
||||
/**
|
||||
* @see AudioAttributes#SPATIALIZATION_BEHAVIOR_AUTO
|
||||
*/
|
||||
public static final int SPATIALIZATION_BEHAVIOR_AUTO =
|
||||
AudioAttributes.SPATIALIZATION_BEHAVIOR_AUTO;
|
||||
/**
|
||||
* @see AudioAttributes#SPATIALIZATION_BEHAVIOR_NEVER
|
||||
*/
|
||||
public static final int SPATIALIZATION_BEHAVIOR_NEVER =
|
||||
AudioAttributes.SPATIALIZATION_BEHAVIOR_NEVER;
|
||||
|
||||
/**
|
||||
* Stream types for an {@link android.media.AudioTrack}. One of {@link #STREAM_TYPE_ALARM}, {@link
|
||||
|
@ -856,9 +856,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||
mediaFormat.setInteger(MediaFormat.KEY_PCM_ENCODING, AudioFormat.ENCODING_PCM_FLOAT);
|
||||
}
|
||||
if (Util.SDK_INT >= 32) {
|
||||
// TODO[b/190759307] Use MediaFormat.KEY_MAX_OUTPUT_CHANNEL_COUNT once the
|
||||
// compile SDK target is set to 32.
|
||||
mediaFormat.setInteger("max-output-channel-count", 99);
|
||||
mediaFormat.setInteger(MediaFormat.KEY_MAX_OUTPUT_CHANNEL_COUNT, 99);
|
||||
}
|
||||
|
||||
return mediaFormat;
|
||||
|
Loading…
x
Reference in New Issue
Block a user