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

Commit 5f8c5866 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "PBAP: Strip unwanted braces from telephone number."

parents 5cd8529f a2e467a6
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -760,6 +760,8 @@ public class BluetoothPbapVcardManager {
                        vcard = vcardfilter.applyFilter(vcard, vcardType21);
                        Log.v (TAG , "vCard on applying filter: " + vcard);
                    }
                    vcard = StripTelephoneNumber(vcard);

                    if (vcard == null) {
                        Log.e(TAG, "Failed to read a contact. Error reason: "
                                + composer.getErrorReason());
@@ -831,6 +833,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.
     */