diff options
author | linyuh <linyuh@google.com> | 2018-03-26 12:46:18 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-26 22:23:52 -0700 |
commit | 437ae9552cce7768068fa92663740711ee541417 (patch) | |
tree | 1ae9af42ed23c09404b87ca613247e18c3fa10d2 /java/com/android/dialer/phonenumbercache | |
parent | cf14ecbc3cb604804ae1f9d01e47444fcf0eedc6 (diff) |
Remove obsolete version checks and compat utilities after min SDK was bumped up to N.
Test: Existing tests
PiperOrigin-RevId: 190508397
Change-Id: Ia5f33e45af1d1cc666fec5f43efa564b2b68c193
Diffstat (limited to 'java/com/android/dialer/phonenumbercache')
4 files changed, 23 insertions, 104 deletions
diff --git a/java/com/android/dialer/phonenumbercache/CallLogQuery.java b/java/com/android/dialer/phonenumbercache/CallLogQuery.java index 2ebc302cf..488aa26e5 100644 --- a/java/com/android/dialer/phonenumbercache/CallLogQuery.java +++ b/java/com/android/dialer/phonenumbercache/CallLogQuery.java @@ -63,7 +63,7 @@ public final class CallLogQuery { @RequiresApi(VERSION_CODES.O) public static final int TRANSCRIPTION_STATE = 26; - private static final String[] PROJECTION_M = + private static final String[] PROJECTION_N = new String[] { Calls._ID, // 0 Calls.NUMBER, // 1 @@ -89,17 +89,10 @@ public final class CallLogQuery { Calls.DATA_USAGE, // 21 Calls.TRANSCRIPTION, // 22 Calls.CACHED_PHOTO_URI, // 23 + CallLog.Calls.POST_DIAL_DIGITS, // 24 + CallLog.Calls.VIA_NUMBER // 25 }; - private static final String[] PROJECTION_N; - - static { - List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_M)); - projectionList.add(CallLog.Calls.POST_DIAL_DIGITS); - projectionList.add(CallLog.Calls.VIA_NUMBER); - PROJECTION_N = projectionList.toArray(new String[projectionList.size()]); - } - private static final String[] PROJECTION_O; // TODO(mdooley): remove when this becomes a public api @@ -114,12 +107,6 @@ public final class CallLogQuery { @NonNull public static String[] getProjection() { - if (VERSION.SDK_INT >= VERSION_CODES.O) { - return PROJECTION_O; - } - if (VERSION.SDK_INT >= VERSION_CODES.N) { - return PROJECTION_N; - } - return PROJECTION_M; + return VERSION.SDK_INT >= VERSION_CODES.O ? PROJECTION_O : PROJECTION_N; } } diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java index d6e378cf2..777175e00 100644 --- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java @@ -35,7 +35,6 @@ import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.util.Constants; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.cp2.DirectoryCompat; import com.android.dialer.logging.ContactSource; import com.android.dialer.oem.CequintCallerIdManager; import com.android.dialer.oem.CequintCallerIdManager.CequintCallerIdContact; @@ -107,12 +106,12 @@ public class ContactInfoHelper { if (directoryId != null) { // Query {@link Contacts#CONTENT_LOOKUP_URI} with work lookup key is not allowed. - if (DirectoryCompat.isEnterpriseDirectoryId(directoryId)) { + if (Directory.isEnterpriseDirectoryId(directoryId)) { return null; } // Skip this to avoid an extra remote network call for alternative name - if (DirectoryCompat.isRemoteDirectoryId(directoryId)) { + if (Directory.isRemoteDirectoryId(directoryId)) { return null; } } @@ -289,7 +288,7 @@ public class ContactInfoHelper { try { while (cursor.moveToNext()) { long directoryId = cursor.getLong(idIndex); - if (DirectoryCompat.isRemoteDirectoryId(directoryId)) { + if (Directory.isRemoteDirectoryId(directoryId)) { remoteDirectories.add(directoryId); } } @@ -323,7 +322,7 @@ public class ContactInfoHelper { .getContentResolver() .query( uri, - PhoneQuery.getPhoneLookupProjection(uri), + PhoneQuery.getPhoneLookupProjection(), null /* selection */, null /* selectionArgs */, null /* sortOrder */)) { diff --git a/java/com/android/dialer/phonenumbercache/PhoneLookupUtil.java b/java/com/android/dialer/phonenumbercache/PhoneLookupUtil.java deleted file mode 100644 index 74175e8ba..000000000 --- a/java/com/android/dialer/phonenumbercache/PhoneLookupUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.dialer.phonenumbercache; - -import android.net.Uri; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; -import android.provider.ContactsContract; -import android.provider.ContactsContract.PhoneLookup; - -public final class PhoneLookupUtil { - - private PhoneLookupUtil() {} - - /** @return the column name that stores contact id for phone lookup query. */ - public static String getContactIdColumnNameForUri(Uri phoneLookupUri) { - if (VERSION.SDK_INT >= VERSION_CODES.N) { - return PhoneLookup.CONTACT_ID; - } - // In pre-N, contact id is stored in {@link PhoneLookup#_ID} in non-sip query. - boolean isSip = - phoneLookupUri.getBooleanQueryParameter( - ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false); - return (isSip) ? PhoneLookup.CONTACT_ID : ContactsContract.PhoneLookup._ID; - } -} diff --git a/java/com/android/dialer/phonenumbercache/PhoneQuery.java b/java/com/android/dialer/phonenumbercache/PhoneQuery.java index 5ddd5f846..a43e489e5 100644 --- a/java/com/android/dialer/phonenumbercache/PhoneQuery.java +++ b/java/com/android/dialer/phonenumbercache/PhoneQuery.java @@ -16,10 +16,6 @@ package com.android.dialer.phonenumbercache; -import android.net.Uri; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; -import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.PhoneLookup; @@ -27,27 +23,27 @@ import android.provider.ContactsContract.PhoneLookup; /** The queries to look up the {@link ContactInfo} for a given number in the Call Log. */ final class PhoneQuery { - public static final int PERSON_ID = 0; - public static final int NAME = 1; - public static final int PHONE_TYPE = 2; - public static final int LABEL = 3; - public static final int MATCHED_NUMBER = 4; - public static final int NORMALIZED_NUMBER = 5; - public static final int PHOTO_ID = 6; - public static final int LOOKUP_KEY = 7; - public static final int PHOTO_URI = 8; + static final int PERSON_ID = 0; + static final int NAME = 1; + static final int PHONE_TYPE = 2; + static final int LABEL = 3; + static final int MATCHED_NUMBER = 4; + static final int NORMALIZED_NUMBER = 5; + static final int PHOTO_ID = 6; + static final int LOOKUP_KEY = 7; + static final int PHOTO_URI = 8; /** Projection to look up a contact's DISPLAY_NAME_ALTERNATIVE */ - public static final String[] DISPLAY_NAME_ALTERNATIVE_PROJECTION = + static final String[] DISPLAY_NAME_ALTERNATIVE_PROJECTION = new String[] { Contacts.DISPLAY_NAME_ALTERNATIVE, }; - public static final int NAME_ALTERNATIVE = 0; + static final int NAME_ALTERNATIVE = 0; - public static final String[] ADDITIONAL_CONTACT_INFO_PROJECTION = + static final String[] ADDITIONAL_CONTACT_INFO_PROJECTION = new String[] {Phone.DISPLAY_NAME_ALTERNATIVE, Phone.CARRIER_PRESENCE}; - public static final int ADDITIONAL_CONTACT_INFO_DISPLAY_NAME_ALTERNATIVE = 0; - public static final int ADDITIONAL_CONTACT_INFO_CARRIER_PRESENCE = 1; + static final int ADDITIONAL_CONTACT_INFO_DISPLAY_NAME_ALTERNATIVE = 0; + static final int ADDITIONAL_CONTACT_INFO_CARRIER_PRESENCE = 1; /** * Projection to look up the ContactInfo. Does not include DISPLAY_NAME_ALTERNATIVE as that column @@ -66,31 +62,8 @@ final class PhoneQuery { PhoneLookup.LOOKUP_KEY, PhoneLookup.PHOTO_URI }; - /** - * Similar to {@link PHONE_LOOKUP_PROJECTION}. In pre-N, contact id is stored in {@link - * PhoneLookup#_ID} in non-sip query. - */ - private static final String[] BACKWARD_COMPATIBLE_NON_SIP_PHONE_LOOKUP_PROJECTION = - new String[] { - PhoneLookup._ID, - PhoneLookup.DISPLAY_NAME, - PhoneLookup.TYPE, - PhoneLookup.LABEL, - PhoneLookup.NUMBER, - PhoneLookup.NORMALIZED_NUMBER, - PhoneLookup.PHOTO_ID, - PhoneLookup.LOOKUP_KEY, - PhoneLookup.PHOTO_URI - }; - public static String[] getPhoneLookupProjection(Uri phoneLookupUri) { - if (VERSION.SDK_INT >= VERSION_CODES.N) { + static String[] getPhoneLookupProjection() { return PHONE_LOOKUP_PROJECTION; - } - // Pre-N - boolean isSip = - phoneLookupUri.getBooleanQueryParameter( - ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false); - return (isSip) ? PHONE_LOOKUP_PROJECTION : BACKWARD_COMPATIBLE_NON_SIP_PHONE_LOOKUP_PROJECTION; } } |