summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/jni/android_media_AudioSystem.cpp10
-rw-r--r--media/java/android/media/AudioSystem.java14
2 files changed, 17 insertions, 7 deletions
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index feb8930a0dbf..1cb8e9e65340 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -2273,7 +2273,7 @@ android_media_AudioSystem_setSurroundFormatEnabled(JNIEnv *env, jobject thiz,
return (jint)nativeToJavaStatus(status);
}
-static jint android_media_AudioSystem_get_FCC_8(JNIEnv *env, jobject thiz) {
+static jint android_media_AudioSystem_getMaxChannelCount(JNIEnv *env, jobject thiz) {
return FCC_8;
}
@@ -2672,14 +2672,16 @@ static const JNINativeMethod gEventHandlerMethods[] = {
(void *)android_media_AudioSystem_eventHandlerFinalize},
};
-static const JNINativeMethod gGetFCC8Methods[] = {
- {"native_get_FCC_8", "()I", (void *)android_media_AudioSystem_get_FCC_8},
+static const JNINativeMethod gFrameworkCapabilities[] = {
+ {"native_getMaxChannelCount", "()I", (void *)android_media_AudioSystem_getMaxChannelCount},
};
int register_android_media_AudioSystem(JNIEnv *env)
{
// This needs to be done before hooking up methods AudioTrackRoutingProxy (below)
- RegisterMethodsOrDie(env, kClassPathName, gGetFCC8Methods, NELEM(gGetFCC8Methods));
+ // as the calls are performed in the static initializer of AudioSystem.
+ RegisterMethodsOrDie(env, kClassPathName, gFrameworkCapabilities,
+ NELEM(gFrameworkCapabilities));
jclass arrayListClass = FindClassOrDie(env, "java/util/ArrayList");
gArrayListClass = MakeGlobalRefOrDie(env, arrayListClass);
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 8425185b90d0..81f99859b387 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -101,11 +101,19 @@ public class AudioSystem
*/
public static final int NUM_STREAMS = 5;
+ /*
+ * Framework static final constants that are primitives or Strings
+ * accessed by CTS tests or internal applications must be set from methods
+ * (or in a static block) to prevent Java compile-time replacement.
+ * We set them from methods so they are read from the device framework.
+ * Do not un-hide or change to a numeric literal.
+ */
+
/** Maximum value for AudioTrack channel count
- * @hide public for MediaCode only, do not un-hide or change to a numeric literal
+ * @hide
*/
- public static final int OUT_CHANNEL_COUNT_MAX = native_get_FCC_8();
- private static native int native_get_FCC_8();
+ public static final int OUT_CHANNEL_COUNT_MAX = native_getMaxChannelCount();
+ private static native int native_getMaxChannelCount();
// Expose only the getter method publicly so we can change it in the future
private static final int NUM_STREAM_TYPES = 12;