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

Commit fc68b229 authored by Jay Shrauner's avatar Jay Shrauner
Browse files

Use new CallLog number presentation column

Switch to using new number presentation column in the CallLog table.

Bug:6948882
Change-Id: I5df2969465c19f2357dbbc3266315e020e30476e
parent e8e14a74
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class AtPhonebook {
     *   dialed calls respectively)
     */
    private static final String[] CALLS_PROJECTION = new String[] {
        Calls._ID, Calls.NUMBER
        Calls._ID, Calls.NUMBER, Calls.NUMBER_PRESENTATION
    };

    /** The projection to use when querying the contacts database in response
@@ -69,6 +69,7 @@ public class AtPhonebook {
    private class PhonebookResult {
        public Cursor  cursor; // result set of last query
        public int     numberColumn;
        public int     numberPresentationColumn;
        public int     typeColumn;
        public int     nameColumn;
    };
@@ -403,6 +404,8 @@ public class AtPhonebook {
            if (pbr.cursor == null) return false;

            pbr.numberColumn = pbr.cursor.getColumnIndexOrThrow(Calls.NUMBER);
            pbr.numberPresentationColumn =
                    pbr.cursor.getColumnIndexOrThrow(Calls.NUMBER_PRESENTATION);
            pbr.typeColumn = -1;
            pbr.nameColumn = -1;
        } else {
@@ -411,6 +414,7 @@ public class AtPhonebook {
            if (pbr.cursor == null) return false;

            pbr.numberColumn = pbr.cursor.getColumnIndex(Phone.NUMBER);
            pbr.numberPresentationColumn = -1;
            pbr.typeColumn = pbr.cursor.getColumnIndex(Phone.TYPE);
            pbr.nameColumn = pbr.cursor.getColumnIndex(Phone.DISPLAY_NAME);
        }
@@ -523,9 +527,14 @@ public class AtPhonebook {
            number = number.trim();
            number = PhoneNumberUtils.stripSeparators(number);
            if (number.length() > 30) number = number.substring(0, 30);
            if (number.equals("-1")) {
                // unknown numbers are stored as -1 in our database
            int numberPresentation = Calls.PRESENTATION_ALLOWED;
            if (pbr.numberPresentationColumn != -1) {
                numberPresentation = pbr.cursor.getInt(pbr.numberPresentationColumn);
            }
            if (numberPresentation != Calls.PRESENTATION_ALLOWED) {
                number = "";
                // TODO: there are 3 types of numbers should have resource
                // strings for: unknown, private, and payphone
                name = mContext.getString(R.string.unknownNumber);
            }

+8 −10
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.bluetooth.pbap;

import com.android.bluetooth.R;
import com.android.internal.telephony.CallerInfo;

import android.content.ContentResolver;
import android.content.Context;
@@ -60,7 +59,7 @@ public class BluetoothPbapCallLogComposer {
    /** The projection to use when querying the call log table */
    private static final String[] sCallLogProjection = new String[] {
            Calls.NUMBER, Calls.DATE, Calls.TYPE, Calls.CACHED_NAME, Calls.CACHED_NUMBER_TYPE,
            Calls.CACHED_NUMBER_LABEL
            Calls.CACHED_NUMBER_LABEL, Calls.NUMBER_PRESENTATION
    };
    private static final int NUMBER_COLUMN_INDEX = 0;
    private static final int DATE_COLUMN_INDEX = 1;
@@ -68,6 +67,7 @@ public class BluetoothPbapCallLogComposer {
    private static final int CALLER_NAME_COLUMN_INDEX = 3;
    private static final int CALLER_NUMBERTYPE_COLUMN_INDEX = 4;
    private static final int CALLER_NUMBERLABEL_COLUMN_INDEX = 5;
    private static final int NUMBER_PRESENTATION_COLUMN_INDEX = 6;

    // Property for call log entry
    private static final String VCARD_PROPERTY_X_TIMESTAMP = "X-IRMC-CALL-DATETIME";
@@ -139,24 +139,22 @@ public class BluetoothPbapCallLogComposer {
                VCardConfig.FLAG_REFRAIN_PHONE_NUMBER_FORMATTING;
        final VCardBuilder builder = new VCardBuilder(vcardType);
        String name = mCursor.getString(CALLER_NAME_COLUMN_INDEX);
        String number = mCursor.getString(NUMBER_COLUMN_INDEX);
        final int numberPresentation = mCursor.getInt(NUMBER_PRESENTATION_COLUMN_INDEX);
        if (TextUtils.isEmpty(name)) {
            name = "";
        }
        if (CallerInfo.UNKNOWN_NUMBER.equals(name) || CallerInfo.PRIVATE_NUMBER.equals(name) ||
                CallerInfo.PAYPHONE_NUMBER.equals(name)) {
        if (numberPresentation != Calls.PRESENTATION_ALLOWED) {
            // setting name to "" as FN/N must be empty fields in this case.
            name = "";
            // TODO: there are really 3 possible strings that could be set here:
            // "unknown", "private", and "payphone".
            number = mContext.getString(R.string.unknownNumber);
        }
        final boolean needCharset = !(VCardUtils.containsOnlyPrintableAscii(name));
        builder.appendLine(VCardConstants.PROPERTY_FN, name, needCharset, false);
        builder.appendLine(VCardConstants.PROPERTY_N, name, needCharset, false);

        String number = mCursor.getString(NUMBER_COLUMN_INDEX);
        if (CallerInfo.UNKNOWN_NUMBER.equals(number) ||
                CallerInfo.PRIVATE_NUMBER.equals(number) ||
                CallerInfo.PAYPHONE_NUMBER.equals(number)) {
            number = mContext.getString(R.string.unknownNumber);
        }
        final int type = mCursor.getInt(CALLER_NUMBERTYPE_COLUMN_INDEX);
        String label = mCursor.getString(CALLER_NUMBERLABEL_COLUMN_INDEX);
        if (TextUtils.isEmpty(label)) {
+7 −6
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.util.Log;
import com.android.bluetooth.R;
import com.android.vcard.VCardComposer;
import com.android.vcard.VCardConfig;
import com.android.internal.telephony.CallerInfo;
import com.android.vcard.VCardPhoneNumberTranslationCallback;

import java.io.IOException;
@@ -200,10 +199,11 @@ public class BluetoothPbapVcardManager {
        final Uri myUri = CallLog.Calls.CONTENT_URI;
        String selection = BluetoothPbapObexServer.createSelectionPara(type);
        String[] projection = new String[] {
                Calls.NUMBER, Calls.CACHED_NAME
                Calls.NUMBER, Calls.CACHED_NAME, Calls.NUMBER_PRESENTATION
        };
        final int CALLS_NUMBER_COLUMN_INDEX = 0;
        final int CALLS_NAME_COLUMN_INDEX = 1;
        final int CALLS_NUMBER_PRESENTATION_COLUMN_INDEX = 2;

        Cursor callCursor = null;
        ArrayList<String> list = new ArrayList<String>();
@@ -216,11 +216,12 @@ public class BluetoothPbapVcardManager {
                    String name = callCursor.getString(CALLS_NAME_COLUMN_INDEX);
                    if (TextUtils.isEmpty(name)) {
                        // name not found, use number instead
                        name = callCursor.getString(CALLS_NUMBER_COLUMN_INDEX);
                        if (CallerInfo.UNKNOWN_NUMBER.equals(name) ||
                                CallerInfo.PRIVATE_NUMBER.equals(name) ||
                                CallerInfo.PAYPHONE_NUMBER.equals(name)) {
                        final int numberPresentation = callCursor.getInt(
                                CALLS_NUMBER_PRESENTATION_COLUMN_INDEX);
                        if (numberPresentation != Calls.PRESENTATION_ALLOWED) {
                            name = mContext.getString(R.string.unknownNumber);
                        } else {
                            name = callCursor.getString(CALLS_NUMBER_COLUMN_INDEX);
                        }
                    }
                    list.add(name);