Add via number to CallLog Account entry
Call Log now provides the phone number that an incoming call was
received on if that number is different than the SIM subscription
number. This "via number" is appended to the Phone Account of the Call
Log entry in Dialer if it exists.
Screenshots:
- One PhoneAccount: http://screen/HuCSL0U6jU6.png
- Multiple PhoneAccounts: http://screen/pDg8F9zpMei.png
Bug: 25594198
Change-Id: I8c05ea98409e54d20493fbdb20096bf851480719
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 42bee1e..94c2f00 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -142,10 +142,23 @@
}
}
- String accountLabel =
- PhoneAccountUtils.getAccountLabel(mContext, mDetails.accountHandle);
+ CharSequence accountLabel = PhoneAccountUtils.getAccountLabel(mContext,
+ mDetails.accountHandle);
+ CharSequence accountContentDescription =
+ PhoneCallDetails.createAccountLabelDescription(mResources, mDetails.viaNumber,
+ accountLabel);
+ if (!TextUtils.isEmpty(mDetails.viaNumber)) {
+ if (!TextUtils.isEmpty(accountLabel)) {
+ accountLabel = mResources.getString(R.string.call_log_via_number_phone_account,
+ accountLabel, mDetails.viaNumber);
+ } else {
+ accountLabel = mResources.getString(R.string.call_log_via_number,
+ mDetails.viaNumber);
+ }
+ }
if (!TextUtils.isEmpty(accountLabel)) {
mAccountLabel.setText(accountLabel);
+ mAccountLabel.setContentDescription(accountContentDescription);
mAccountLabel.setVisibility(View.VISIBLE);
} else {
mAccountLabel.setVisibility(View.GONE);
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index b332b43..17f1c2b 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -18,11 +18,14 @@
import com.android.contacts.common.ContactsUtils.UserType;
import com.android.contacts.common.preference.ContactsPreferences;
+import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.dialer.calllog.PhoneNumberDisplayUtil;
import android.content.Context;
+import android.content.res.Resources;
import android.net.Uri;
import android.provider.CallLog.Calls;
+import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
import android.text.TextUtils;
@@ -34,6 +37,8 @@
public CharSequence number;
// Post-dial digits associated with the outgoing call.
public String postDialDigits;
+ // The secondary line number the call was received via.
+ public String viaNumber;
// The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED}
public int numberPresentation;
// The formatted version of {@link #number}.
@@ -149,4 +154,31 @@
}
return nameAlternative;
}
+
+ /**
+ * Construct the "on {accountLabel} via {viaNumber}" accessibility description for the account
+ * list item, depending on the existence of the accountLabel and viaNumber.
+ * @param viaNumber The number that this call is being placed via.
+ * @param accountLabel The {@link PhoneAccount} label that this call is being placed with.
+ * @return The description of the account that this call has been placed on.
+ */
+ public static CharSequence createAccountLabelDescription(Resources resources,
+ @Nullable String viaNumber, @Nullable CharSequence accountLabel) {
+
+ if((!TextUtils.isEmpty(viaNumber)) && !TextUtils.isEmpty(accountLabel)) {
+ String msg = resources.getString(R.string.description_via_number_phone_account,
+ accountLabel, viaNumber);
+ CharSequence accountNumberLabel = ContactDisplayUtils.getTelephoneTtsSpannable(msg,
+ viaNumber);
+ return (accountNumberLabel == null) ? msg : accountNumberLabel;
+ } else if (!TextUtils.isEmpty(viaNumber)) {
+ CharSequence viaNumberLabel = ContactDisplayUtils.getTtsSpannedPhoneNumber(resources,
+ R.string.description_via_number, viaNumber);
+ return (viaNumberLabel == null) ? viaNumber : viaNumberLabel;
+ } else if (!TextUtils.isEmpty(accountLabel)) {
+ return TextUtils.expandTemplate(
+ resources.getString(R.string.description_phone_account), accountLabel);
+ }
+ return "";
+ }
}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 165594e..3958611 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -490,15 +490,17 @@
int count = getGroupSize(position);
final String number = c.getString(CallLogQuery.NUMBER);
+ final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
final String postDialDigits = CompatUtils.isNCompatible()
&& mActivityType != ACTIVITY_TYPE_ARCHIVE ?
c.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
-
+ final String viaNumber = CompatUtils.isNCompatible()
+ && mActivityType != ACTIVITY_TYPE_ARCHIVE ?
+ c.getString(CallLogQuery.VIA_NUMBER) : "";
final int numberPresentation = c.getInt(CallLogQuery.NUMBER_PRESENTATION);
final PhoneAccountHandle accountHandle = PhoneAccountUtils.getAccount(
c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME),
c.getString(CallLogQuery.ACCOUNT_ID));
- final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(c);
final boolean isVoicemailNumber =
mCallLogCache.isVoicemailNumber(accountHandle, number);
@@ -518,6 +520,7 @@
final PhoneCallDetails details = new PhoneCallDetails(
mContext, number, numberPresentation, formattedNumber,
postDialDigits, isVoicemailNumber);
+ details.viaNumber = viaNumber;
details.accountHandle = accountHandle;
details.countryIso = countryIso;
details.date = c.getLong(CallLogQuery.DATE);
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
index 7cb35f5..34b2f0e 100644
--- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
+++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
@@ -28,6 +28,7 @@
import android.provider.CallLog;
import android.provider.VoicemailContract.Voicemails;
import android.telecom.PhoneAccountHandle;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Log;
@@ -44,6 +45,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Locale;
public class CallLogAsyncTaskUtil {
private static String TAG = CallLogAsyncTaskUtil.class.getSimpleName();
@@ -90,12 +92,14 @@
static final int DATA_USAGE = 10;
static final int TRANSCRIPTION_COLUMN_INDEX = 11;
static final int POST_DIAL_DIGITS = 12;
+ static final int VIA_NUMBER = 13;
static {
ArrayList<String> projectionList = new ArrayList<>();
projectionList.addAll(Arrays.asList(CALL_LOG_PROJECTION_INTERNAL));
if (CompatUtils.isNCompatible()) {
projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS);
+ projectionList.add(CallsSdkCompat.VIA_NUMBER);
}
projectionList.trimToSize();
CALL_LOG_PROJECTION = projectionList.toArray(new String[projectionList.size()]);
@@ -187,6 +191,8 @@
final String number = cursor.getString(CallDetailQuery.NUMBER_COLUMN_INDEX);
final String postDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallDetailQuery.POST_DIAL_DIGITS) : "";
+ final String viaNumber = CompatUtils.isNCompatible() ?
+ cursor.getString(CallDetailQuery.VIA_NUMBER) : "";
final int numberPresentation =
cursor.getInt(CallDetailQuery.NUMBER_PRESENTATION_COLUMN_INDEX);
@@ -211,6 +217,7 @@
context, number, numberPresentation, info.formattedNumber,
postDialDigits, isVoicemail);
+ details.viaNumber = viaNumber;
details.accountHandle = accountHandle;
details.contactUri = info.lookupUri;
details.namePrimary = info.name;
diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
index 0931e06..aa45029 100644
--- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java
+++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java
@@ -125,6 +125,8 @@
String groupNumber = cursor.getString(CallLogQuery.NUMBER);
String groupPostDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
+ String groupViaNumbers = CompatUtils.isNCompatible()
+ ? cursor.getString(CallLogQuery.VIA_NUMBER) : "";
int groupCallType = cursor.getInt(CallLogQuery.CALL_TYPE);
String groupAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
String groupAccountId = cursor.getString(CallLogQuery.ACCOUNT_ID);
@@ -132,6 +134,7 @@
String number;
String numberPostDialDigits;
+ String numberViaNumbers;
int callType;
String accountComponentName;
String accountId;
@@ -141,18 +144,21 @@
number = cursor.getString(CallLogQuery.NUMBER);
numberPostDialDigits = CompatUtils.isNCompatible()
? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : "";
+ numberViaNumbers = CompatUtils.isNCompatible()
+ ? cursor.getString(CallLogQuery.VIA_NUMBER) : "";
callType = cursor.getInt(CallLogQuery.CALL_TYPE);
accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
accountId = cursor.getString(CallLogQuery.ACCOUNT_ID);
final boolean isSameNumber = equalNumbers(groupNumber, number);
final boolean isSamePostDialDigits = groupPostDialDigits.equals(numberPostDialDigits);
+ final boolean isSameViaNumbers = groupViaNumbers.equals(numberViaNumbers);
final boolean isSameAccount = isSameAccount(
groupAccountComponentName, accountComponentName, groupAccountId, accountId);
// Group with the same number and account. Never group voicemails. Only group blocked
// calls with other blocked calls.
- if (isSameNumber && isSameAccount && isSamePostDialDigits
+ if (isSameNumber && isSameAccount && isSamePostDialDigits && isSameViaNumbers
&& areBothNotVoicemail(callType, groupCallType)
&& (areBothNotBlocked(callType, groupCallType)
|| areBothBlocked(callType, groupCallType))) {
@@ -174,6 +180,7 @@
// Update the group values to those of the current call.
groupNumber = number;
groupPostDialDigits = numberPostDialDigits;
+ groupViaNumbers = numberViaNumbers;
groupCallType = callType;
groupAccountComponentName = accountComponentName;
groupAccountId = accountId;
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 5d2bc85..07e2bb4 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -188,20 +188,15 @@
callDescription.append(mResources.getString(R.string.description_video_call));
}
- int stringID = getCallDescriptionStringID(details.callTypes, details.isRead);
String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);
+ CharSequence onAccountLabel = PhoneCallDetails.createAccountLabelDescription(mResources,
+ details.viaNumber, accountLabel);
- // Use chosen string resource to build up the message.
- CharSequence onAccountLabel = accountLabel == null
- ? ""
- : TextUtils.expandTemplate(
- mResources.getString(R.string.description_phone_account),
- accountLabel);
+ int stringID = getCallDescriptionStringID(details.callTypes, details.isRead);
callDescription.append(
TextUtils.expandTemplate(
mResources.getString(stringID),
nameOrNumber,
- // If no type or location can be determined, sub in empty string.
typeOrLocation == null ? "" : typeOrLocation,
timeOfCall,
onAccountLabel));
diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java
index 4900354..e1a4119 100644
--- a/src/com/android/dialer/calllog/CallLogQuery.java
+++ b/src/com/android/dialer/calllog/CallLogQuery.java
@@ -93,6 +93,7 @@
* Call {@link CompatUtils#isNCompatible()} prior to use
*/
public static int POST_DIAL_DIGITS = -1;
+ public static int VIA_NUMBER = -1;
public static final String[] _PROJECTION;
@@ -105,6 +106,8 @@
if (CompatUtils.isNCompatible()) {
projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS);
POST_DIAL_DIGITS = projectionList.size() - 1;
+ projectionList.add(CallsSdkCompat.VIA_NUMBER);
+ VIA_NUMBER = projectionList.size() - 1;
}
_PROJECTION = projectionList.toArray(new String[projectionList.size()]);
}
diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
index 7b149e2..4f1c455 100644
--- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
@@ -116,8 +116,16 @@
// Set the account label if it exists.
String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);
-
- if (accountLabel != null) {
+ if (!TextUtils.isEmpty(details.viaNumber)) {
+ if (!TextUtils.isEmpty(accountLabel)) {
+ accountLabel = mResources.getString(R.string.call_log_via_number_phone_account,
+ accountLabel, details.viaNumber);
+ } else {
+ accountLabel = mResources.getString(R.string.call_log_via_number,
+ details.viaNumber);
+ }
+ }
+ if (!TextUtils.isEmpty(accountLabel)) {
views.callAccountLabel.setVisibility(View.VISIBLE);
views.callAccountLabel.setText(accountLabel);
int color = mCallLogCache.getAccountColor(details.accountHandle);