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

Commit 71fc6ec6 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Use geocoded location from call log content provider.

When showing the geocoded location in the call log, use the value from
the provider instead of querying the geocoder each time: that would be
too slow and cause a strict mode violation.

Bug: 5129581
Change-Id: Ia0eb5bdd33c5bcebcf6267ce01f7d36c53396c30
parent b7a508f9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ public class CallDetailActivity extends ListActivity implements
        CallLog.Calls.NUMBER,
        CallLog.Calls.TYPE,
        CallLog.Calls.COUNTRY_ISO,
        CallLog.Calls.GEOCODED_LOCATION,
    };

    static final int DATE_COLUMN_INDEX = 0;
@@ -123,6 +124,7 @@ public class CallDetailActivity extends ListActivity implements
    static final int NUMBER_COLUMN_INDEX = 2;
    static final int CALL_TYPE_COLUMN_INDEX = 3;
    static final int COUNTRY_ISO_COLUMN_INDEX = 4;
    static final int GEOCODED_LOCATION_COLUMN_INDEX = 5;

    static final String[] PHONES_PROJECTION = new String[] {
        PhoneLookup._ID,
@@ -403,6 +405,8 @@ public class CallDetailActivity extends ListActivity implements
            long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
            int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
            String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
            final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);

            if (TextUtils.isEmpty(countryIso)) {
                countryIso = mDefaultCountryIso;
            }
@@ -448,7 +452,7 @@ public class CallDetailActivity extends ListActivity implements
                    numberText = candidateNumberText;
                }
            }
            return new PhoneCallDetails(number, numberText, countryIso,
            return new PhoneCallDetails(number, numberText, countryIso, geocode,
                    new int[]{ callType }, date, duration,
                    nameText, numberType, numberLabel, personId, photoUri);
        } finally {
+7 −3
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ public class PhoneCallDetails {
    public final CharSequence formattedNumber;
    /** The country corresponding with the phone number. */
    public final String countryIso;
    /** The geocoded location for the phone number. */
    public final String geocode;
    /**
     * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
     * <p>
@@ -56,18 +58,20 @@ public class PhoneCallDetails {

    /** Create the details for a call with a number not associated with a contact. */
    public PhoneCallDetails(CharSequence number, CharSequence formattedNumber,
            String countryIso, int[] callTypes, long date, long duration) {
        this(number, formattedNumber, countryIso, callTypes, date, duration, "", 0, "", -1L, null);
            String countryIso, String geocode, int[] callTypes, long date, long duration) {
        this(number, formattedNumber, countryIso, geocode, callTypes, date, duration, "", 0, "",
                -1L, null);
    }

    /** Create the details for a call with a number associated with a contact. */
    public PhoneCallDetails(CharSequence number, CharSequence formattedNumber,
            String countryIso, int[] callTypes, long date, long duration,
            String countryIso, String geocode, int[] callTypes, long date, long duration,
            CharSequence name, int numberType, CharSequence numberLabel, long personId,
            Uri photoUri) {
        this.number = number;
        this.formattedNumber = formattedNumber;
        this.countryIso = countryIso;
        this.geocode = geocode;
        this.callTypes = callTypes;
        this.date = date;
        this.duration = duration;
+2 −4
Original line number Diff line number Diff line
@@ -107,12 +107,10 @@ public class PhoneCallDetailsHelper {
            mPhoneNumberHelper.getDisplayNumber(details.number, details.formattedNumber);
        if (TextUtils.isEmpty(details.name)) {
            nameText = displayNumber;
            String geocode = mPhoneNumberHelper.getGeocodeForNumber(
                    details.number.toString(), details.countryIso);
            if (TextUtils.isEmpty(geocode)) {
            if (TextUtils.isEmpty(details.geocode)) {
                numberText = mResources.getString(R.string.call_log_empty_gecode);
            } else {
                numberText = geocode;
                numberText = details.geocode;
            }
        } else {
            nameText = details.name;
+6 −3
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
                Calls.TYPE,
                Calls.COUNTRY_ISO,
                Calls.VOICEMAIL_URI,
                Calls.GEOCODED_LOCATION,
        };

        public static final int ID = 0;
@@ -98,6 +99,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
        public static final int CALL_TYPE = 4;
        public static final int COUNTRY_ISO = 5;
        public static final int VOICEMAIL_URI = 6;
        public static final int GEOCODED_LOCATION = 7;

        /**
         * The name of the synthetic "section" column.
@@ -107,7 +109,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
         */
        public static final String SECTION_NAME = "section";
        /** The index of the "section" column in the projection. */
        public static final int SECTION = 7;
        public static final int SECTION = 8;
        /** The value of the "section" column for the header of the new section. */
        public static final int SECTION_NEW_HEADER = 0;
        /** The value of the "section" column for the items of the new section. */
@@ -756,12 +758,13 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
            final Uri thumbnailUri = info.thumbnailUri;
            final String lookupKey = info.lookupKey;
            final int[] callTypes = getCallTypes(c, count);
            final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION);
            final PhoneCallDetails details;
            if (TextUtils.isEmpty(name)) {
                details = new PhoneCallDetails(number, formattedNumber, countryIso,
                details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
                        callTypes, date, duration);
            } else {
                details = new PhoneCallDetails(number, formattedNumber, countryIso,
                details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
                        callTypes, date, duration, name, ntype, label, personId, thumbnailUri);
            }

+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ import javax.annotation.concurrent.GuardedBy;
                new MatrixCursor(CallLogFragment.CallLogQuery.EXTENDED_PROJECTION);
        // The values in this row correspond to default values for _PROJECTION from CallLogQuery
        // plus the section value.
        matrixCursor.addRow(new Object[]{ -1L, "", 0L, 0L, 0, "", "", section });
        matrixCursor.addRow(new Object[]{ -1L, "", 0L, 0L, 0, "", "", "", section });
        return matrixCursor;
    }

Loading