OSDN Git Service

Ignore empty optional parameters in CLCC response
authorSatish Kodishala <skodisha@codeaurora.org>
Tue, 15 Sep 2015 14:16:41 +0000 (19:46 +0530)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 3 Mar 2016 18:11:42 +0000 (18:11 +0000)
Usecase:
Pair and connect with AG that sends the optional parameters
in CLCC response.

Failure:
When optional parameters in CLCC response from AG is empty,
HF client is not parsing the empty optional parameters.
User may not be see the phone number on UI properly on
hf client device.

Root cause:
AGs like iPhone sends optional parameters in the CLCC response.
HF client is returning NULL when it encounters empty optional parameters.

Fix:
Ignore empty optional parameters in CLCC Response from AG.

Change-Id: Ia90986ccc4c9c9f1a6fb3a914bc1df8b0a75ba0f

bta/hf_client/bta_hf_client_at.c

index a2a3354..3eafa23 100644 (file)
@@ -1013,39 +1013,33 @@ static char *bta_hf_client_parse_clcc(char *buffer)
     /* check optional part */
     if (*buffer == ',')
     {
-        int res2;
-
-        res2 = sscanf(buffer, ",\"%32[^\"]\",%hu%n", numstr, &type, &offset);
+        int res2 = sscanf(buffer, ",\"%32[^\"]\",%hu%n", numstr, &type, &offset);
         if (res2 < 0)
-        {
             return NULL;
-        }
 
         if (res2 == 0)
         {
             res2 = sscanf(buffer, ",\"\",%hu%n", &type, &offset);
             if (res < 0)
-            {
                 return NULL;
-            }
 
             /* numstr is not matched in second attempt, correct this */
             res2++;
             numstr[0] = '\0';
         }
 
-        if (res2 < 2)
+        if (res2 >= 2)
         {
-            return NULL;
+            res += res2;
+            buffer += offset;
         }
-
-        res += res2;
-        buffer += offset;
     }
 
+    /* Skip any remaing param,as they are not defined by BT HFP spec */
+    AT_SKIP_REST(buffer);
     AT_CHECK_RN(buffer);
 
-    if(res > 6)
+    if (res > 6)
     {
         /* we also have last two optional parameters */
         bta_hf_client_handle_clcc(idx, dir, status, mode, mpty, numstr, type);