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

Commit 57705a57 authored by Smriti Gupta's avatar Smriti Gupta Committed by Linux Build Service Account
Browse files

PBAP: Add provision for filtering date and time

This change adds provision for filtering call log date and
time when it is not been asked as per the filter since it
is not a mandatory attribute as per the specification.

Change-Id: I4f166aec4030cbc887833980e9a900f35c4f8fb0
CRs-Fixed: 712696
parent b55cd6e5
Loading
Loading
Loading
Loading
+34 −6
Original line number Diff line number Diff line
@@ -748,13 +748,14 @@ public class BluetoothPbapVcardManager {
        long timestamp = 0;
        if (V) timestamp = System.currentTimeMillis();

        if (isContacts) {
            VCardComposer composer = null;
        FilterVcard vcardfilter= new FilterVcard();
        if (!ignorefilter) {
            vcardfilter.setFilter(filter);
        }
        HandlerForStringBuffer buffer = null;

        if (isContacts) {
            VCardComposer composer = null;
            try {
                // Currently only support Generic Vcard 2.1 and 3.0
                int vcardType;
@@ -830,7 +831,6 @@ public class BluetoothPbapVcardManager {
            }
        } else { // CallLog
            BluetoothPbapCallLogComposer composer = null;
            HandlerForStringBuffer buffer = null;
            try {

                composer = new BluetoothPbapCallLogComposer(mContext);
@@ -848,6 +848,11 @@ public class BluetoothPbapVcardManager {
                        break;
                    }
                    String vcard = composer.createOneEntry(vcardType21);
                    Log.v (TAG , "vCard from composer: " + vcard);
                    if (!ignorefilter) {
                        vcard = vcardfilter.applyFilter(vcard, vcardType21);
                        Log.v (TAG , "vCard on applying filter: " + vcard);
                    }
                    if (vcard == null) {
                        Log.e(TAG, "Failed to read a contact. Error reason: "
                                + composer.getErrorReason());
@@ -1000,6 +1005,10 @@ public class BluetoothPbapVcardManager {

        private boolean nickname = true;

        private final int DATETIME_BIT = 28;

        private boolean datetime = true;

        public void setFilter(byte[] filter){

           fn = checkbit(FN_BIT, filter);
@@ -1012,6 +1021,7 @@ public class BluetoothPbapVcardManager {
           notes = checkbit(NOTES_BIT, filter);
           url = checkbit(URL_BIT, filter);
           nickname = checkbit(NICKNAME_BIT, filter);
           datetime = checkbit(DATETIME_BIT, filter);
        }

        private boolean checkbit (int attr_bit, byte[] filter){
@@ -1208,6 +1218,24 @@ public class BluetoothPbapVcardManager {
                    }
                }
            }

            if((!datetime) && (vCard.contains("X-IRMC-CALL-DATETIME"))) {
                for (int i=0; i < attr.length; i++) {
                    if(attr[i].startsWith("X-IRMC-CALL-DATETIME")){
                        attr[i] = "";
                        /** Remove multiline Content, if any */
                        /** End traversal before END:VCARD */
                        for (int j = i+1; j < attr.length - 1; j++) {
                            if (checkValidFilter(attr[j])) {
                                break;
                            } else {
                                /** Continuation of above attribute, remove */
                                attr[j] = "";
                            }
                        }
                    }
                }
            }
            /*Since PBAP does not have filter bit for IM and SIP,
             *removing them by default.
            */