summaryrefslogtreecommitdiffstats
path: root/jni
diff options
context:
space:
mode:
authorRakesh Iyer <rni@google.com>2015-04-08 12:27:53 -0700
committerRakesh Iyer <rni@google.com>2015-04-08 13:42:50 -0700
commitd96a7fa83d73bab7c87acda6f7dfc8c6bc71aff1 (patch)
tree7cb631af705312d07c9910652600f0cc57b66f04 /jni
parent10d5c2186fcc91042bc170956b344ed08c1b3a09 (diff)
downloadandroid_packages_apps_Bluetooth-d96a7fa83d73bab7c87acda6f7dfc8c6bc71aff1.tar.gz
android_packages_apps_Bluetooth-d96a7fa83d73bab7c87acda6f7dfc8c6bc71aff1.tar.bz2
android_packages_apps_Bluetooth-d96a7fa83d73bab7c87acda6f7dfc8c6bc71aff1.zip
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
Diffstat (limited to 'jni')
-rw-r--r--jni/com_android_bluetooth_hfpclient.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/jni/com_android_bluetooth_hfpclient.cpp b/jni/com_android_bluetooth_hfpclient.cpp
index 030681fff..e4d557ca2 100644
--- a/jni/com_android_bluetooth_hfpclient.cpp
+++ b/jni/com_android_bluetooth_hfpclient.cpp
@@ -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;
- 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;
}