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

Commit 49285283 authored by Rakesh Iyer's avatar Rakesh Iyer
Browse files

Fix spurious CHECKJNI failure in hfpclient.

sendATCmdNative is allowed to have a null args parameter
but the jni code calls getUTF8Chars without checking
resulting in a checkjni failure on eng builds. Add a null
check around so that it doesn't fail this way.

Change-Id: I1432c6b528da1c53627694cc1c7a91c038b7cc24
parent 9f9adf1d
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -567,18 +567,22 @@ static jboolean requestLastVoiceTagNumberNative(JNIEnv *env, jobject object) {
static jboolean sendATCmdNative(JNIEnv *env, jobject object, jint cmd,
                                jint val1, jint val2, jstring arg_str) {
    bt_status_t status;
    const char *arg;
    const char *arg = NULL;

    if (!sBluetoothHfpClientInterface) return JNI_FALSE;

    if (arg_str != NULL) {
        arg = env->GetStringUTFChars(arg_str, NULL);
    }

    if ((status = sBluetoothHfpClientInterface->send_at_cmd(cmd,val1,val2,arg)) !=
            BT_STATUS_SUCCESS) {
        ALOGE("Failed to send cmd, status: %d", status);
    }

    if (arg != NULL) {
        env->ReleaseStringUTFChars(arg_str, arg);
    }
    return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}