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
diff --git a/jni/com_android_bluetooth_hfpclient.cpp b/jni/com_android_bluetooth_hfpclient.cpp
index 030681f..e4d557c 100644
--- a/jni/com_android_bluetooth_hfpclient.cpp
+++ b/jni/com_android_bluetooth_hfpclient.cpp
@@ -567,18 +567,22 @@
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;
- arg = env->GetStringUTFChars(arg_str, NULL);
+ 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);
}
- env->ReleaseStringUTFChars(arg_str, arg);
+ if (arg != NULL) {
+ env->ReleaseStringUTFChars(arg_str, arg);
+ }
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}