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

Commit dcba8f7e authored by Stanley Tng's avatar Stanley Tng
Browse files

Remove unwanted space characters from dialing number

Certain car kits might send an AT command with space characters in
the dialing number. This commit adds a workaround to trim these unwanted
space characters.

Bug: 6340999
Test: Manual test with a car kit but purposely added numbers with spaces.
Change-Id: I9c238bc625fff8503c45cbbfaeb8bdd15b8a7d9a
(cherry picked from commit 54a1461a29a8c71dd010d418ec1b23012bf32805)
parent 2c9c72bb
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -613,6 +613,19 @@ void bta_ag_at_hsp_cback(tBTA_AG_SCB* p_scb, uint16_t command_id,
  (*bta_ag_cb.p_cback)(command_id, (tBTA_AG*)&val);
}

static void remove_spaces(char* str) {
  char* dest_str = str;

  while (*str) {
    if (*str == ' ') {
      str++;
    } else {
      *dest_str++ = *str++;
    }
  }
  *dest_str = '\0';
}

/*******************************************************************************
 *
 * Function         bta_ag_find_empty_hf_ind)
@@ -874,12 +887,16 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      ** Let application decide whether to send OK or ERROR*/

      /* if mem dial cmd, make sure string contains only digits */
      if (p_arg[0] == '>') {
        if (!utl_isintstr(p_arg + 1)) {
      if (val.str[0] == '>') {
        /* Some car kits may add some unwanted space characters in the
        ** input string. This workaround will trim the unwanted chars. */
        remove_spaces(val.str + 1);

        if (!utl_isintstr(val.str + 1)) {
          event = 0;
          bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
        }
      } else if (p_arg[0] == 'V') /* ATDV : Dial VoIP Call */
      } else if (val.str[0] == 'V') /* ATDV : Dial VoIP Call */
      {
        /* We do not check string. Code will be added later if needed. */
        if (!((p_scb->peer_features & BTA_AG_PEER_FEAT_VOIP) &&
@@ -891,7 +908,11 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      /* If dial cmd, make sure string contains only dial digits
      ** Dial digits are 0-9, A-C, *, #, + */
      else {
        if (!utl_isdialstr(p_arg)) {
        /* Some car kits may add some unwanted space characters in the
        ** input string. This workaround will trim the unwanted chars. */
        remove_spaces(val.str);

        if (!utl_isdialstr(val.str)) {
          event = 0;
          bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_DSTR);
        }