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

Commit 6ba53bde authored by David Stevens's avatar David Stevens
Browse files

Fix redial JNI crash

Redial is implemented as dial(null). On eng builds, passing null into
dial triggers a fatal assert. Add null checks to prevent the crash.

Change-Id: Ieb168a79647ef7d56a7c81e058f7269ed20c22b1
parent 298f3b7c
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -475,15 +475,19 @@ static jboolean setVolumeNative(JNIEnv *env, jobject object, jint volume_type, j

static jboolean dialNative(JNIEnv *env, jobject object, jstring number_str) {
    bt_status_t status;
    const char *number;
    const char *number = NULL;
    if (!sBluetoothHfpClientInterface) return JNI_FALSE;

    if (number_str != NULL) {
        number = env->GetStringUTFChars(number_str, NULL);
    }

    if ( (status = sBluetoothHfpClientInterface->dial(number)) != BT_STATUS_SUCCESS) {
        ALOGE("Failed to dial, status: %d", status);
    }
    if (number != NULL) {
        env->ReleaseStringUTFChars(number_str, number);
    }
    return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}