summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-N/com/android/dialer/compat/CallsSdkCompat.java24
-rw-r--r--src-pre-N/com/android/dialer/compat/CallsSdkCompat.java24
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java10
-rw-r--r--src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java22
-rw-r--r--src/com/android/dialer/calllog/CallLogGroupBuilder.java11
-rw-r--r--src/com/android/dialer/calllog/CallLogQuery.java13
-rw-r--r--src/com/android/dialer/calllog/ContactInfoHelper.java4
-rw-r--r--src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java10
-rw-r--r--src/com/android/dialer/util/AppCompatConstants.java2
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogAdapterTest.java12
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java5
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java4
12 files changed, 91 insertions, 50 deletions
diff --git a/src-N/com/android/dialer/compat/CallsSdkCompat.java b/src-N/com/android/dialer/compat/CallsSdkCompat.java
new file mode 100644
index 000000000..3d72e356e
--- /dev/null
+++ b/src-N/com/android/dialer/compat/CallsSdkCompat.java
@@ -0,0 +1,24 @@
+/*
+ * 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.compat;
+
+import android.provider.CallLog;
+
+public class CallsSdkCompat {
+
+ public static final String POST_DIAL_DIGITS = CallLog.Calls.POST_DIAL_DIGITS;
+}
diff --git a/src-pre-N/com/android/dialer/compat/CallsSdkCompat.java b/src-pre-N/com/android/dialer/compat/CallsSdkCompat.java
new file mode 100644
index 000000000..836f091a1
--- /dev/null
+++ b/src-pre-N/com/android/dialer/compat/CallsSdkCompat.java
@@ -0,0 +1,24 @@
+/*
+ * 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.compat;
+
+import android.support.annotation.Nullable;
+
+public class CallsSdkCompat {
+
+ @Nullable public static final String POST_DIAL_DIGITS = null;
+}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index e97f8e235..dfb5190e1 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -16,10 +16,6 @@
package com.android.dialer.calllog;
-import com.android.contacts.common.util.PermissionsUtil;
-
-import com.android.dialer.DialtactsActivity;
-import com.android.dialer.database.VoicemailArchiveContract;
import com.google.common.annotations.VisibleForTesting;
import android.content.Context;
@@ -40,7 +36,6 @@ import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.AccessibilityDelegate;
@@ -48,15 +43,18 @@ import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import com.android.contacts.common.ContactsUtils;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
import com.android.contacts.common.preference.ContactsPreferences;
import com.android.contacts.common.util.PermissionsUtil;
+import com.android.dialer.DialtactsActivity;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.R;
import com.android.dialer.calllog.calllogcache.CallLogCache;
import com.android.dialer.contactinfo.ContactInfoCache;
import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener;
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
+import com.android.dialer.database.VoicemailArchiveContract;
import com.android.dialer.filterednumber.BlockNumberDialogFragment.Callback;
import com.android.dialer.logging.InteractionEvent;
import com.android.dialer.logging.Logger;
@@ -492,7 +490,7 @@ public class CallLogAdapter extends GroupingListAdapter
int count = getGroupSize(position);
final String number = c.getString(CallLogQuery.NUMBER);
- final String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial()
+ final String postDialDigits = CompatUtils.isNCompatible()
&& mActivityType != ACTIVITY_TYPE_ARCHIVE ?
c.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
index 13de0775d..7cb35f514 100644
--- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
+++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
@@ -16,6 +16,8 @@
package com.android.dialer.calllog;
+import com.google.common.annotations.VisibleForTesting;
+
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -30,18 +32,16 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.contacts.common.GeoUtil;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.util.PermissionsUtil;
-import com.android.dialer.DialtactsActivity;
import com.android.dialer.PhoneCallDetails;
+import com.android.dialer.compat.CallsSdkCompat;
import com.android.dialer.database.VoicemailArchiveContract;
-import com.android.dialer.util.AppCompatConstants;
import com.android.dialer.util.AsyncTaskExecutor;
import com.android.dialer.util.AsyncTaskExecutors;
import com.android.dialer.util.PhoneNumberUtil;
import com.android.dialer.util.TelecomUtil;
-import com.google.common.annotations.VisibleForTesting;
-
import java.util.ArrayList;
import java.util.Arrays;
@@ -94,8 +94,8 @@ public class CallLogAsyncTaskUtil {
static {
ArrayList<String> projectionList = new ArrayList<>();
projectionList.addAll(Arrays.asList(CALL_LOG_PROJECTION_INTERNAL));
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
- projectionList.add(AppCompatConstants.POST_DIAL_DIGITS);
+ if (CompatUtils.isNCompatible()) {
+ projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS);
}
projectionList.trimToSize();
CALL_LOG_PROJECTION = projectionList.toArray(new String[projectionList.size()]);
@@ -113,13 +113,13 @@ public class CallLogAsyncTaskUtil {
}
public interface CallLogAsyncTaskListener {
- public void onDeleteCall();
- public void onDeleteVoicemail();
- public void onGetCallDetails(PhoneCallDetails[] details);
+ void onDeleteCall();
+ void onDeleteVoicemail();
+ void onGetCallDetails(PhoneCallDetails[] details);
}
public interface OnCallLogQueryFinishedListener {
- public void onQueryFinished(boolean hasEntry);
+ void onQueryFinished(boolean hasEntry);
}
// Try to identify if a call log entry corresponds to a number which was blocked. We match by
@@ -185,7 +185,7 @@ public class CallLogAsyncTaskUtil {
// Read call log.
final String countryIso = cursor.getString(CallDetailQuery.COUNTRY_ISO_COLUMN_INDEX);
final String number = cursor.getString(CallDetailQuery.NUMBER_COLUMN_INDEX);
- final String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial()
+ final String postDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallDetailQuery.POST_DIAL_DIGITS) : "";
final int numberPresentation =
cursor.getInt(CallDetailQuery.NUMBER_PRESENTATION_COLUMN_INDEX);
diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
index 950f63471..0931e0644 100644
--- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java
+++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
@@ -16,17 +16,18 @@
package com.android.dialer.calllog;
+import com.google.common.annotations.VisibleForTesting;
+
import android.database.Cursor;
import android.telephony.PhoneNumberUtils;
-import android.text.format.Time;
import android.text.TextUtils;
+import android.text.format.Time;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.util.DateUtils;
import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.dialer.util.AppCompatConstants;
-import com.google.common.annotations.VisibleForTesting;
-
/**
* Groups together calls in the call log. The primary grouping attempts to group together calls
* to and from the same number into a single row on the call log.
@@ -122,7 +123,7 @@ public class CallLogGroupBuilder {
// Instantiate the group values to those of the first call in the cursor.
String groupNumber = cursor.getString(CallLogQuery.NUMBER);
- String groupPostDialDigits = PhoneNumberDisplayUtil.canShowPostDial()
+ String groupPostDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
int groupCallType = cursor.getInt(CallLogQuery.CALL_TYPE);
String groupAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
@@ -138,7 +139,7 @@ public class CallLogGroupBuilder {
while (cursor.moveToNext()) {
// Obtain the values for the current call to group.
number = cursor.getString(CallLogQuery.NUMBER);
- numberPostDialDigits = PhoneNumberDisplayUtil.canShowPostDial()
+ numberPostDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
callType = cursor.getInt(CallLogQuery.CALL_TYPE);
accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java
index 905a4b789..4900354bf 100644
--- a/src/com/android/dialer/calllog/CallLogQuery.java
+++ b/src/com/android/dialer/calllog/CallLogQuery.java
@@ -16,12 +16,13 @@
package com.android.dialer.calllog;
+import com.google.common.collect.Lists;
+
import android.provider.CallLog.Calls;
+import com.android.contacts.common.compat.CompatUtils;
+import com.android.dialer.compat.CallsSdkCompat;
import com.android.dialer.compat.DialerCompatUtils;
-import com.android.dialer.util.AppCompatConstants;
-
-import com.google.common.collect.Lists;
import java.util.List;
@@ -89,7 +90,7 @@ public final class CallLogQuery {
/**
* Only available in versions > M
- * Call {@link PhoneNumberDisplayUtil#canShowPostDial()} prior to use
+ * Call {@link CompatUtils#isNCompatible()} prior to use
*/
public static int POST_DIAL_DIGITS = -1;
@@ -101,8 +102,8 @@ public final class CallLogQuery {
projectionList.add(Calls.CACHED_PHOTO_URI);
CACHED_PHOTO_URI = projectionList.size() - 1;
}
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
- projectionList.add(AppCompatConstants.POST_DIAL_DIGITS);
+ if (CompatUtils.isNCompatible()) {
+ projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS);
POST_DIAL_DIGITS = projectionList.size() - 1;
}
_PROJECTION = projectionList.toArray(new String[projectionList.size()]);
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index ff7a3f6a5..6e84a92f9 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -32,6 +32,7 @@ import android.util.Log;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.ContactsUtils.UserType;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.common.util.PhoneNumberHelper;
@@ -41,7 +42,6 @@ import com.android.dialer.service.CachedNumberLookupService;
import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
import com.android.dialer.util.TelecomUtil;
import com.android.dialerbind.ObjectFactory;
-import com.google.common.annotations.VisibleForTesting;
import org.json.JSONException;
import org.json.JSONObject;
@@ -435,7 +435,7 @@ public class ContactInfoHelper {
info.type = c.getInt(CallLogQuery.CACHED_NUMBER_TYPE);
info.label = c.getString(CallLogQuery.CACHED_NUMBER_LABEL);
String matchedNumber = c.getString(CallLogQuery.CACHED_MATCHED_NUMBER);
- String postDialDigits = PhoneNumberDisplayUtil.canShowPostDial()
+ String postDialDigits = CompatUtils.isNCompatible()
? c.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
info.number = (matchedNumber == null) ?
c.getString(CallLogQuery.NUMBER) + postDialDigits : matchedNumber;
diff --git a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
index 09b42e9f6..5b1fc9e3a 100644
--- a/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
+++ b/src/com/android/dialer/calllog/PhoneNumberDisplayUtil.java
@@ -17,7 +17,6 @@
package com.android.dialer.calllog;
import android.content.Context;
-import android.os.Build;
import android.provider.CallLog.Calls;
import android.text.TextUtils;
@@ -81,13 +80,4 @@ public class PhoneNumberDisplayUtil {
return context.getResources().getString(R.string.unknown);
}
}
-
- /**
- * Returns whether we can expect the post-dial digits to be in the call log.
- *
- * These digits will be present in versions N+.
- */
- public static boolean canShowPostDial() {
- return Build.VERSION.SDK_INT > Build.VERSION_CODES.M;
- }
}
diff --git a/src/com/android/dialer/util/AppCompatConstants.java b/src/com/android/dialer/util/AppCompatConstants.java
index 0bb78df26..1d52eee1d 100644
--- a/src/com/android/dialer/util/AppCompatConstants.java
+++ b/src/com/android/dialer/util/AppCompatConstants.java
@@ -27,6 +27,4 @@ public final class AppCompatConstants {
public static final int CALLS_REJECTED_TYPE = 5;
// Added to android.provider.CallLog.Calls in N+.
public static final int CALLS_BLOCKED_TYPE = 6;
- // Added to android.provider.CallLog.Calls in N+.
- public static final String POST_DIAL_DIGITS = "post_dial_digits";
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
index e80131140..f6ef7ef22 100644
--- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java
@@ -16,6 +16,8 @@
package com.android.dialer.calllog;
+import com.google.common.collect.Lists;
+
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
@@ -29,12 +31,12 @@ import android.test.suitebuilder.annotation.MediumTest;
import android.text.TextUtils;
import android.view.View;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.preference.ContactsPreferences;
import com.android.dialer.contactinfo.ContactInfoCache;
import com.android.dialer.database.VoicemailArchiveContract;
import com.android.dialer.util.AppCompatConstants;
import com.android.dialer.util.TestConstants;
-import com.google.common.collect.Lists;
import java.util.Date;
import java.util.List;
@@ -235,7 +237,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.changeCursor(mCursor);
mAdapter.onBindViewHolder(mViewHolder, 0);
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
assertHasCallActionToGivenNumber(mViewHolder, TEST_NUMBER + TEST_POST_DIAL_DIGITS);
}
}
@@ -259,7 +261,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.changeCursor(mCursor);
mAdapter.onBindViewHolder(mViewHolder, 0);
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
assertNameIs(mViewHolder, TEST_NUMBER + TEST_POST_DIAL_DIGITS);
}
}
@@ -273,7 +275,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
mAdapter.changeCursor(mCursor);
mAdapter.onBindViewHolder(mViewHolder, 0);
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
assertNameIs(mViewHolder, TEST_CACHED_NAME_PRIMARY);
}
}
@@ -673,7 +675,7 @@ public class CallLogAdapterTest extends AndroidTestCase {
if (!TextUtils.isEmpty(number)) {
values[CallLogQuery.NUMBER] = number;
}
- if (!TextUtils.isEmpty(postDialDigits) && PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (!TextUtils.isEmpty(postDialDigits) && CompatUtils.isNCompatible()) {
values[CallLogQuery.POST_DIAL_DIGITS] = postDialDigits;
}
if (presentation != NO_VALUE_SET) {
diff --git a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
index c31c38e1d..107cf7562 100644
--- a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
@@ -22,6 +22,7 @@ import android.database.MatrixCursor;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.dialer.util.AppCompatConstants;
import java.util.List;
@@ -98,7 +99,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
mBuilder.addGroups(mCursor);
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
assertEquals(2, mFakeGroupCreator.groups.size());
assertGroupIs(0, 2, mFakeGroupCreator.groups.get(0));
assertGroupIs(2, 1, mFakeGroupCreator.groups.get(1));
@@ -380,7 +381,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
values[CallLogQuery.ID] = mCursor.getPosition();
values[CallLogQuery.NUMBER] = number;
values[CallLogQuery.CALL_TYPE] = type;
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
values[CallLogQuery.POST_DIAL_DIGITS] = postDialDigits;
}
mCursor.addRow(values);
diff --git a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
index 1e4a00000..f1b1a9ab9 100644
--- a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
+++ b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
@@ -20,13 +20,15 @@ import static junit.framework.Assert.assertEquals;
import android.provider.CallLog.Calls;
+import com.android.contacts.common.compat.CompatUtils;
+
/**
* Helper class to create test values for {@link CallLogQuery}.
*/
public class CallLogQueryTestUtils {
public static Object[] createTestValues() {
Object[] values;
- if (PhoneNumberDisplayUtil.canShowPostDial()) {
+ if (CompatUtils.isNCompatible()) {
values = new Object[]{
0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null,
null, 0L, null, 0, Calls.PRESENTATION_ALLOWED, null, null, 0, null, null,