From 42e25341043525b7f9bc991dfe1afba7846b4f5f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 2 Oct 2015 16:47:57 -0700 Subject: Group blocked calls separately in call log. + Group blocked calls separately from other call types, but group adjacent blocked calls together. + Add unit tests. Bug: 23943480 Change-Id: Iffe6fac800007f6b88e0feb15d91c63515e496f8 --- .../dialer/calllog/CallLogGroupBuilder.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/com/android') 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; + } } -- cgit v1.2.3