Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fbc205f authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Eric Laurent
Browse files

audio: Send A2DP codec to AudioSystem on connection state change

Add A2DP codec parameter to AudioSystem and AudioService APIs
for connection state change and device config change. Update
native interface to pass codec parameter.

Bug: 111812273
Test: make
Change-Id: I9bcc9c97241a2ac2d941ae6902469ef9957a993c
parent 37f2ba0a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -487,7 +487,8 @@ android_media_AudioSystem_recording_callback(int event,
}

static jint
android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address, jstring device_name)
android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address, jstring device_name,
                                                   jint codec __unused)
{
    const char *c_address = env->GetStringUTFChars(device_address, NULL);
    const char *c_name = env->GetStringUTFChars(device_name, NULL);
@@ -510,7 +511,8 @@ android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, ji
}

static jint
android_media_AudioSystem_handleDeviceConfigChange(JNIEnv *env, jobject thiz, jint device, jstring device_address, jstring device_name)
android_media_AudioSystem_handleDeviceConfigChange(JNIEnv *env, jobject thiz, jint device, jstring device_address, jstring device_name,
                                                   jint codec __unused)
{
    const char *c_address = env->GetStringUTFChars(device_address, NULL);
    const char *c_name = env->GetStringUTFChars(device_name, NULL);
@@ -2142,9 +2144,9 @@ static const JNINativeMethod gMethods[] = {
    {"isSourceActive",      "(I)Z",     (void *)android_media_AudioSystem_isSourceActive},
    {"newAudioSessionId",   "()I",      (void *)android_media_AudioSystem_newAudioSessionId},
    {"newAudioPlayerId",    "()I",      (void *)android_media_AudioSystem_newAudioPlayerId},
    {"setDeviceConnectionState", "(IILjava/lang/String;Ljava/lang/String;)I", (void *)android_media_AudioSystem_setDeviceConnectionState},
    {"setDeviceConnectionState", "(IILjava/lang/String;Ljava/lang/String;I)I", (void *)android_media_AudioSystem_setDeviceConnectionState},
    {"getDeviceConnectionState", "(ILjava/lang/String;)I",  (void *)android_media_AudioSystem_getDeviceConnectionState},
    {"handleDeviceConfigChange", "(ILjava/lang/String;Ljava/lang/String;)I", (void *)android_media_AudioSystem_handleDeviceConfigChange},
    {"handleDeviceConfigChange", "(ILjava/lang/String;Ljava/lang/String;I)I", (void *)android_media_AudioSystem_handleDeviceConfigChange},
    {"setPhoneState",       "(I)I",     (void *)android_media_AudioSystem_setPhoneState},
    {"setForceUse",         "(II)I",    (void *)android_media_AudioSystem_setForceUse},
    {"getForceUse",         "(I)I",     (void *)android_media_AudioSystem_getForceUse},
+28 −2
Original line number Diff line number Diff line
@@ -140,6 +140,30 @@ public class AudioSystem
        }
    }

    /* Formats for A2DP codecs, must match system/audio-base.h audio_format_t */
    public static final int AUDIO_FORMAT_INVALID        = 0xFFFFFFFF;
    public static final int AUDIO_FORMAT_DEFAULT        = 0;
    public static final int AUDIO_FORMAT_AAC            = 0x04000000;
    public static final int AUDIO_FORMAT_SBC            = 0x1F000000;
    public static final int AUDIO_FORMAT_APTX           = 0x20000000;
    public static final int AUDIO_FORMAT_APTX_HD        = 0x21000000;
    public static final int AUDIO_FORMAT_LDAC           = 0x23000000;

    /** converts audio format enum to string */
    public static String audioFormatToString(int audioFormat) {
        switch (audioFormat) {
            case AUDIO_FORMAT_INVALID: return "AUDIO_FORMAT_INVALID";
            case AUDIO_FORMAT_DEFAULT: return "AUDIO_FORMAT_DEFAULT";
            case AUDIO_FORMAT_AAC: return "AUDIO_FORMAT_AAC";
            case AUDIO_FORMAT_SBC: return "AUDIO_FORMAT_SBC";
            case AUDIO_FORMAT_APTX: return "AUDIO_FORMAT_APTX";
            case AUDIO_FORMAT_APTX_HD: return "AUDIO_FORMAT_APTX_HD";
            case AUDIO_FORMAT_LDAC: return "AUDIO_FORMAT_LDAC";
            default: return "unknown audio format (" + audioFormat + ")";
        }
    }


    /* Routing bits for the former setRouting/getRouting API */
    /** @deprecated */
    @Deprecated public static final int ROUTE_EARPIECE          = (1 << 0);
@@ -860,12 +884,14 @@ public class AudioSystem
     */
    @UnsupportedAppUsage
    public static native int setDeviceConnectionState(int device, int state,
                                                      String device_address, String device_name);
                                                      String device_address, String device_name,
                                                      int codecFormat);
    @UnsupportedAppUsage
    public static native int getDeviceConnectionState(int device, String device_address);
    public static native int handleDeviceConfigChange(int device,
                                                      String device_address,
                                                      String device_name);
                                                      String device_name,
                                                      int codecFormat);
    @UnsupportedAppUsage
    public static native int setPhoneState(int state);
    @UnsupportedAppUsage
+173 −61

File changed.

Preview size limit exceeded, changes collapsed.