OSDN Git Service

if the element attribute string is more than the maximum length, try to send partial...
authorZhihai Xu <zhihaixu@google.com>
Tue, 26 Mar 2013 00:45:56 +0000 (17:45 -0700)
committerZhihai Xu <zhihaixu@google.com>
Tue, 26 Mar 2013 00:45:56 +0000 (17:45 -0700)
issue 8470888

Change-Id: Ibfc3a25839bd07bd99dbb3328f56aad1d21720ea

jni/com_android_bluetooth_avrcp.cpp

index ee7083e..125ac4b 100644 (file)
@@ -226,14 +226,15 @@ static jboolean getPlayStatusRspNative(JNIEnv *env, jobject object, jint playSta
             env->DeleteLocalRef(text);
             break;
         }
+
+        pAttrs[i].attr_id = attr[i];
         if (strlen(textStr) >= BTRC_MAX_ATTR_STR_LEN) {
             ALOGE("get_element_attr_rsp: string length exceed maximum");
-            env->ReleaseStringUTFChars(text, textStr);
-            env->DeleteLocalRef(text);
-            break;
+            strncpy((char *)pAttrs[i].text, textStr, BTRC_MAX_ATTR_STR_LEN-1);
+            pAttrs[i].text[BTRC_MAX_ATTR_STR_LEN-1] = 0;
+        } else {
+            strcpy((char *)pAttrs[i].text, textStr);
         }
-        pAttrs[i].attr_id = attr[i];
-        strcpy((char *)pAttrs[i].text, textStr);
         env->ReleaseStringUTFChars(text, textStr);
         env->DeleteLocalRef(text);
     }