summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/telecom
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-01-25 15:54:00 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-25 17:33:39 -0800
commitc1623fe219f3229bf9191afdcf0667efd0f549b8 (patch)
treee49206da45a253224ee9f7b33ca441c7bb36dc8e /java/com/android/dialer/telecom
parent8392f80d96bf8e5b070429e53c674522a30f796c (diff)
Remove non call log dependencies on PhoneAccountUtil
Methods moved to TelecomUtils Test: Unit tests PiperOrigin-RevId: 183305626 Change-Id: Idd6604e58c06a36066bd49870849dd71747969c6
Diffstat (limited to 'java/com/android/dialer/telecom')
-rw-r--r--java/com/android/dialer/telecom/TelecomUtil.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/java/com/android/dialer/telecom/TelecomUtil.java b/java/com/android/dialer/telecom/TelecomUtil.java
index f79ca8607..56349b651 100644
--- a/java/com/android/dialer/telecom/TelecomUtil.java
+++ b/java/com/android/dialer/telecom/TelecomUtil.java
@@ -18,6 +18,7 @@ package com.android.dialer.telecom;
import android.Manifest;
import android.Manifest.permission;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -49,6 +50,7 @@ import java.util.concurrent.ConcurrentHashMap;
* perform the required check and return the fallback default if the permission is missing,
* otherwise return the value from TelecomManager.
*/
+@SuppressWarnings("MissingPermission")
public abstract class TelecomUtil {
private static final String TAG = "TelecomUtil";
@@ -148,6 +150,34 @@ public abstract class TelecomUtil {
return new ArrayList<>();
}
+ /** Return a list of phone accounts that are subscription/SIM accounts. */
+ public static List<PhoneAccountHandle> getSubscriptionPhoneAccounts(Context context) {
+ List<PhoneAccountHandle> subscriptionAccountHandles = new ArrayList<>();
+ final List<PhoneAccountHandle> accountHandles =
+ TelecomUtil.getCallCapablePhoneAccounts(context);
+ for (PhoneAccountHandle accountHandle : accountHandles) {
+ PhoneAccount account = TelecomUtil.getPhoneAccount(context, accountHandle);
+ if (account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
+ subscriptionAccountHandles.add(accountHandle);
+ }
+ }
+ return subscriptionAccountHandles;
+ }
+
+ /** Compose {@link PhoneAccountHandle} object from component name and account id. */
+ @Nullable
+ public static PhoneAccountHandle composePhoneAccountHandle(
+ @Nullable String componentString, @Nullable String accountId) {
+ if (TextUtils.isEmpty(componentString) || TextUtils.isEmpty(accountId)) {
+ return null;
+ }
+ final ComponentName componentName = ComponentName.unflattenFromString(componentString);
+ if (componentName == null) {
+ return null;
+ }
+ return new PhoneAccountHandle(componentName, accountId);
+ }
+
/**
* @return the {@link SubscriptionInfo} of the SIM if {@code phoneAccountHandle} corresponds to a
* valid SIM. Absent otherwise.