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

Commit b2a142b5 authored by Hemant Gupta's avatar Hemant Gupta Committed by Android Git Automerger
Browse files

am d9566000: PBAP: Strip unwanted braces and spaces from telephone number.

* commit 'd9566000':
  PBAP: Strip unwanted braces and spaces from telephone number.
parents fa198f1a d9566000
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.
     */