Hide multiple-account information if there is only a single account
Hide account icon from call log and call details if only a single
account is registered and enabled.
Bug: 16483795
Change-Id: I401924e7be657d0c8da47406b4bf56d88d2c6e3f
diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java
index adb12f9..326ffa6 100644
--- a/src/com/android/dialer/calllog/PhoneAccountUtils.java
+++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java
@@ -44,11 +44,35 @@
* Generate account icon from data in Telecomm database
*/
public static Drawable getAccountIcon(Context context, PhoneAccountHandle phoneAccount) {
- final PhoneAccount accountMetadata = TelecommManager.from(context)
- .getPhoneAccount(phoneAccount);
- if (accountMetadata == null) {
+ final PhoneAccount account = getAccountOrNull(context, phoneAccount);
+ if (account == null) {
return null;
}
- return accountMetadata.getIcon(context);
+ return account.getIcon(context);
+ }
+
+ /**
+ * Generate account label from data in Telecomm database
+ */
+ public static CharSequence getAccountLabel(Context context, PhoneAccountHandle phoneAccount) {
+ final PhoneAccount account = getAccountOrNull(context, phoneAccount);
+ if (account == null) {
+ return null;
+ }
+ return account.getLabel();
+ }
+
+ /**
+ * Retrieve the account metadata, but if the account does not exist or the device has only a
+ * single registered and enabled account, return null.
+ */
+ private static PhoneAccount getAccountOrNull(Context context,
+ PhoneAccountHandle phoneAccount) {
+ final TelecommManager telecommManager = TelecommManager.from(context);
+ final PhoneAccount account = telecommManager.getPhoneAccount(phoneAccount);
+ if (account == null || !telecommManager.hasMultipleEnabledAccounts()) {
+ return null;
+ }
+ return account;
}
}