summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-10-07 17:52:10 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-07 17:52:10 +0000
commit00e57d521e6ac17ec277c09c69f79d26a303f013 (patch)
tree9c780dea7d2a6771bc553d21c90f67f16c58b656
parent22c8f439ec76d11a36413eb34851ea483c3f89b4 (diff)
parenta0a08083e2f21ec45ef40064687b550b9af6a388 (diff)
am a0a08083: Merge "Group blocked calls separately in call log." into ub-contactsdialer-a-dev
* commit 'a0a08083e2f21ec45ef40064687b550b9af6a388': Group blocked calls separately in call log.
-rw-r--r--src/com/android/dialer/calllog/CallLogGroupBuilder.java25
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java44
2 files changed, 57 insertions, 12 deletions
diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
index 4cf2d07cd..5eea096b8 100644
--- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java
+++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
@@ -24,6 +24,7 @@ import android.text.TextUtils;
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;
@@ -145,10 +146,11 @@ public class CallLogGroupBuilder {
final boolean isSameAccount = isSameAccount(
groupAccountComponentName, accountComponentName, groupAccountId, accountId);
- // Group with the same number and account which are not voicemail.
- if (isSameNumber && isSameAccount
- && (callType != Calls.VOICEMAIL_TYPE)
- && (groupCallType != Calls.VOICEMAIL_TYPE)) {
+ // Group with the same number and account. Never group voicemails. Only group blocked
+ // calls with other blocked calls.
+ if (isSameNumber && isSameAccount && areBothNotVoicemail(callType, groupCallType)
+ && (areBothNotBlocked(callType, groupCallType)
+ || areBothBlocked(callType, groupCallType))) {
// Increment the size of the group to include the current call, but do not create
// the group until finding a call that does not match.
groupSize++;
@@ -240,4 +242,19 @@ public class CallLogGroupBuilder {
return DAY_GROUP_OTHER;
}
}
+
+ private boolean areBothNotVoicemail(int callType, int groupCallType) {
+ return callType != AppCompatConstants.CALLS_VOICEMAIL_TYPE
+ && groupCallType != AppCompatConstants.CALLS_VOICEMAIL_TYPE;
+ }
+
+ private boolean areBothNotBlocked(int callType, int groupCallType) {
+ return callType != AppCompatConstants.CALLS_BLOCKED_TYPE
+ && groupCallType != AppCompatConstants.CALLS_BLOCKED_TYPE;
+ }
+
+ private boolean areBothBlocked(int callType, int groupCallType) {
+ return callType == AppCompatConstants.CALLS_BLOCKED_TYPE
+ && groupCallType == AppCompatConstants.CALLS_BLOCKED_TYPE;
+ }
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
index f5a9fe612..5d0b6bebb 100644
--- a/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogGroupBuilderTest.java
@@ -95,7 +95,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
assertGroupIs(0, 3, mFakeGroupCreator.groups.get(0));
}
- public void testAddGroups_Voicemail() {
+ public void testGrouping_Voicemail() {
// Does not group with other types of calls, include voicemail themselves.
assertCallsAreNotGrouped(
AppCompatConstants.CALLS_VOICEMAIL_TYPE, AppCompatConstants.CALLS_MISSED_TYPE);
@@ -107,7 +107,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
AppCompatConstants.CALLS_VOICEMAIL_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE);
}
- public void testAddGroups_Missed() {
+ public void testGrouping_Missed() {
// Groups with one or more missed calls.
assertCallsAreGrouped(
AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_MISSED_TYPE);
@@ -124,7 +124,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
AppCompatConstants.CALLS_MISSED_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE);
}
- public void testAddGroups_Incoming() {
+ public void testGrouping_Incoming() {
// Groups with one or more incoming or outgoing.
assertCallsAreGrouped(
AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE);
@@ -145,7 +145,7 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_VOICEMAIL_TYPE);
}
- public void testAddGroups_Outgoing() {
+ public void testGrouping_Outgoing() {
// Groups with one or more incoming or outgoing.
assertCallsAreGrouped(
AppCompatConstants.CALLS_OUTGOING_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE);
@@ -166,20 +166,31 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
AppCompatConstants.CALLS_INCOMING_TYPE, AppCompatConstants.CALLS_VOICEMAIL_TYPE);
}
+ public void testGrouping_Blocked() {
+ assertCallsAreNotGrouped(
+ AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_INCOMING_TYPE);
+ assertCallsAreNotGrouped(
+ AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_OUTGOING_TYPE);
+ assertCallsAreNotGrouped(
+ AppCompatConstants.CALLS_BLOCKED_TYPE, AppCompatConstants.CALLS_MISSED_TYPE);
+
+ }
+
public void testAddGroups_Mixed() {
addMultipleCallLogEntries(TEST_NUMBER1,
- AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 1:Stand-alone
+ AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 1: 0
AppCompatConstants.CALLS_INCOMING_TYPE, // Group 2: 1-4
AppCompatConstants.CALLS_OUTGOING_TYPE,
AppCompatConstants.CALLS_MISSED_TYPE,
AppCompatConstants.CALLS_MISSED_TYPE,
- AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 3: Stand-alone
- AppCompatConstants.CALLS_INCOMING_TYPE, // Group 4: Stand-alone
- AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 5: Stand-alone
+ AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 3: 5
+ AppCompatConstants.CALLS_INCOMING_TYPE, // Group 4: 6
+ AppCompatConstants.CALLS_VOICEMAIL_TYPE, // Group 5: 7
AppCompatConstants.CALLS_MISSED_TYPE, // Group 6: 8-10
AppCompatConstants.CALLS_MISSED_TYPE,
AppCompatConstants.CALLS_OUTGOING_TYPE);
mBuilder.addGroups(mCursor);
+
assertEquals(6, mFakeGroupCreator.groups.size());
assertGroupIs(0, 1, mFakeGroupCreator.groups.get(0));
assertGroupIs(1, 4, mFakeGroupCreator.groups.get(1));
@@ -189,6 +200,23 @@ public class CallLogGroupBuilderTest extends AndroidTestCase {
assertGroupIs(8, 3, mFakeGroupCreator.groups.get(5));
}
+ public void testAddGroups_Blocked() {
+ addMultipleCallLogEntries(TEST_NUMBER1,
+ AppCompatConstants.CALLS_INCOMING_TYPE, // Group 1: 0-1
+ AppCompatConstants.CALLS_OUTGOING_TYPE,
+ AppCompatConstants.CALLS_BLOCKED_TYPE, // Group 2: 2
+ AppCompatConstants.CALLS_MISSED_TYPE, // Group 3: 3
+ AppCompatConstants.CALLS_BLOCKED_TYPE, // Group 4: 4-5
+ AppCompatConstants.CALLS_BLOCKED_TYPE);
+ mBuilder.addGroups(mCursor);
+
+ assertEquals(4, mFakeGroupCreator.groups.size());
+ assertGroupIs(0, 2, mFakeGroupCreator.groups.get(0));
+ assertGroupIs(2, 1, mFakeGroupCreator.groups.get(1));
+ assertGroupIs(3, 1, mFakeGroupCreator.groups.get(2));
+ assertGroupIs(4, 2, mFakeGroupCreator.groups.get(3));
+ }
+
public void testEqualPhoneNumbers() {
// Identical.
assertTrue(mBuilder.equalNumbers("6505555555", "6505555555"));