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

Commit d9566000 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

PBAP: Strip unwanted braces and spaces from telephone number.

This patch removes unwanted spaces and braces from the telephone
number on vcard entry formation. Handsfree call was failing because
of these characters due to handling of only digits in utl_isdialstr
API in BD stack (external/bluetooth/bluedroid/bta/ag/bta_ag_cmd.c)

Change-Id: I2d63967059a9cb97f214b370fac17234f6e58f55
parent 9e90e3d5
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -565,6 +565,7 @@ public class BluetoothPbapVcardManager {
                                + composer.getErrorReason());
                        return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
                    }
                    vcard = StripTelephoneNumber(vcard);
                    if (V) {
                        Log.v(TAG, "Vcard Entry:");
                        Log.v(TAG,vcard);
@@ -631,6 +632,27 @@ public class BluetoothPbapVcardManager {
        return ResponseCodes.OBEX_HTTP_OK;
    }

    public String StripTelephoneNumber (String vCard){
        String attr [] = vCard.split(System.getProperty("line.separator"));
        String Vcard = "";
            for (int i=0; i < attr.length; i++) {
                if(attr[i].startsWith("TEL")) {
                    attr[i] = attr[i].replace("(", "");
                    attr[i] = attr[i].replace(")", "");
                    attr[i] = attr[i].replace("-", "");
                    attr[i] = attr[i].replace(" ", "");
                }
            }

            for (int i=0; i < attr.length; i++) {
                if(!attr[i].equals("")){
                    Vcard = Vcard.concat(attr[i] + "\n");
                }
            }
        Log.v(TAG, "Vcard with stripped telephone no.: " + Vcard);
        return Vcard;
    }

    /**
     * Handler to emit vCards to PCE.
     */