summaryrefslogtreecommitdiff
path: root/java
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
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')
-rw-r--r--java/com/android/dialer/app/calllog/CallLogAdapter.java4
-rw-r--r--java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java4
-rw-r--r--java/com/android/dialer/calllog/database/Coalescer.java6
-rw-r--r--java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java3
-rw-r--r--java/com/android/dialer/calllog/ui/menu/Modules.java5
-rw-r--r--java/com/android/dialer/calllogutils/CallLogIntents.java4
-rw-r--r--java/com/android/dialer/calllogutils/PhoneAccountUtils.java32
-rw-r--r--java/com/android/dialer/dialpadview/DialpadFragment.java3
-rw-r--r--java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java5
-rw-r--r--java/com/android/dialer/telecom/TelecomUtil.java30
10 files changed, 48 insertions, 48 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 963967ffc..9e1d4a7b9 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -66,7 +66,6 @@ import com.android.dialer.calldetails.CallDetailsEntries;
import com.android.dialer.calldetails.CallDetailsEntries.CallDetailsEntry;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.calllogutils.PhoneCallDetails;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
@@ -91,6 +90,7 @@ import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumbercache.ContactInfoHelper;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.spam.SpamComponent;
+import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.PermissionsUtil;
import java.util.ArrayList;
import java.util.Map;
@@ -1020,7 +1020,7 @@ public class CallLogAdapter extends GroupingListAdapter
}
final PhoneAccountHandle accountHandle =
- PhoneAccountUtils.getAccount(details.accountComponentName, details.accountId);
+ TelecomUtil.composePhoneAccountHandle(details.accountComponentName, details.accountId);
final boolean isVoicemailNumber = callLogCache.isVoicemailNumber(accountHandle, details.number);
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
index a0bbfa0f1..0ddfb9f3b 100644
--- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
@@ -31,11 +31,11 @@ import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.dialer.app.R;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.notification.DialerNotificationManager;
import com.android.dialer.notification.NotificationChannelManager;
+import com.android.dialer.telecom.TelecomUtil;
/** Shows a notification in the status bar for legacy vociemail. */
@TargetApi(VERSION_CODES.O)
@@ -137,7 +137,7 @@ public final class LegacyVoicemailNotifier {
@NonNull
private static String getNotificationText(
@NonNull Context context, PhoneAccountHandle handle, String voicemailNumber) {
- if (PhoneAccountUtils.getSubscriptionPhoneAccounts(context).size() > 1) {
+ if (TelecomUtil.getCallCapablePhoneAccounts(context).size() > 1) {
TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
return phoneAccount.getShortDescription().toString();
diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java
index b10dea24a..e301c9f72 100644
--- a/java/com/android/dialer/calllog/database/Coalescer.java
+++ b/java/com/android/dialer/calllog/database/Coalescer.java
@@ -27,10 +27,10 @@ import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.Ann
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog;
import com.android.dialer.calllog.datasources.CallLogDataSource;
import com.android.dialer.calllog.datasources.DataSources;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.compat.telephony.TelephonyManagerCompat;
import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil;
+import com.android.dialer.telecom.TelecomUtil;
import com.google.common.base.Preconditions;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.protobuf.InvalidProtocolBufferException;
@@ -144,11 +144,11 @@ public class Coalescer {
DialerPhoneNumberUtil dialerPhoneNumberUtil, ContentValues row1, ContentValues row2) {
// Don't combine rows which don't use the same phone account.
PhoneAccountHandle phoneAccount1 =
- PhoneAccountUtils.getAccount(
+ TelecomUtil.composePhoneAccountHandle(
row1.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME),
row1.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_ID));
PhoneAccountHandle phoneAccount2 =
- PhoneAccountUtils.getAccount(
+ TelecomUtil.composePhoneAccountHandle(
row2.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME),
row2.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_ID));
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index 14cde46dd..93c35c5fa 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -51,6 +51,7 @@ import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
import com.android.dialer.common.concurrent.ThreadUtil;
import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil;
import com.android.dialer.storage.StorageComponent;
+import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.theme.R;
import com.android.dialer.util.PermissionsUtil;
import com.google.common.collect.Iterables;
@@ -363,7 +364,7 @@ public class SystemCallLogDataSource implements CallLogDataSource {
String phoneAccountComponentName,
String phoneAccountId) {
PhoneAccountHandle phoneAccountHandle =
- PhoneAccountUtils.getAccount(phoneAccountComponentName, phoneAccountId);
+ TelecomUtil.composePhoneAccountHandle(phoneAccountComponentName, phoneAccountId);
if (phoneAccountHandle == null) {
return;
}
diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java
index 67e51689d..beb2cf0db 100644
--- a/java/com/android/dialer/calllog/ui/menu/Modules.java
+++ b/java/com/android/dialer/calllog/ui/menu/Modules.java
@@ -24,12 +24,12 @@ import com.android.dialer.calldetails.CallDetailsActivity;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.calllogutils.CallLogContactTypes;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.contactactions.ContactActionModule;
import com.android.dialer.contactactions.DividerModule;
import com.android.dialer.contactactions.IntentModule;
import com.android.dialer.contactactions.SharedModules;
import com.android.dialer.dialercontact.DialerContact;
+import com.android.dialer.telecom.TelecomUtil;
import java.util.ArrayList;
import java.util.List;
@@ -82,7 +82,8 @@ final class Modules {
}
PhoneAccountHandle phoneAccountHandle =
- PhoneAccountUtils.getAccount(row.phoneAccountComponentName(), row.phoneAccountId());
+ TelecomUtil.composePhoneAccountHandle(
+ row.phoneAccountComponentName(), row.phoneAccountId());
if ((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) {
// Add an audio call item for video calls. Clicking the top entry on the bottom sheet will
diff --git a/java/com/android/dialer/calllogutils/CallLogIntents.java b/java/com/android/dialer/calllogutils/CallLogIntents.java
index b06fe6e93..05af8bfc7 100644
--- a/java/com/android/dialer/calllogutils/CallLogIntents.java
+++ b/java/com/android/dialer/calllogutils/CallLogIntents.java
@@ -24,6 +24,7 @@ import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.precall.PreCall;
+import com.android.dialer.telecom.TelecomUtil;
/** Provides intents related to call log entries. */
public final class CallLogIntents {
@@ -51,7 +52,8 @@ public final class CallLogIntents {
context,
new CallIntentBuilder(originalNumber, CallInitiationType.Type.CALL_LOG)
.setPhoneAccountHandle(
- PhoneAccountUtils.getAccount(row.phoneAccountComponentName(), row.phoneAccountId()))
+ TelecomUtil.composePhoneAccountHandle(
+ row.phoneAccountComponentName(), row.phoneAccountId()))
.setIsVideoCall((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO));
}
}
diff --git a/java/com/android/dialer/calllogutils/PhoneAccountUtils.java b/java/com/android/dialer/calllogutils/PhoneAccountUtils.java
index 153f29185..2ee50a134 100644
--- a/java/com/android/dialer/calllogutils/PhoneAccountUtils.java
+++ b/java/com/android/dialer/calllogutils/PhoneAccountUtils.java
@@ -16,47 +16,15 @@
package com.android.dialer.calllogutils;
-import android.content.ComponentName;
import android.content.Context;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
-import android.text.TextUtils;
import com.android.dialer.telecom.TelecomUtil;
-import java.util.ArrayList;
-import java.util.List;
/** Methods to help extract {@code PhoneAccount} information from database and Telecomm sources. */
public class PhoneAccountUtils {
- /** 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 PhoneAccount object from component name and account id. */
- @Nullable
- public static PhoneAccountHandle getAccount(
- @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);
- }
-
/** Extract account label from PhoneAccount object. */
@Nullable
public static String getAccountLabel(
diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java
index 9cee7bc2f..6b8401e6b 100644
--- a/java/com/android/dialer/dialpadview/DialpadFragment.java
+++ b/java/com/android/dialer/dialpadview/DialpadFragment.java
@@ -77,7 +77,6 @@ import com.android.contacts.common.util.StopWatch;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
@@ -967,7 +966,7 @@ public class DialpadFragment extends Fragment
removePreviousDigitIfPossible('1');
List<PhoneAccountHandle> subscriptionAccountHandles =
- PhoneAccountUtils.getSubscriptionPhoneAccounts(getActivity());
+ TelecomUtil.getSubscriptionPhoneAccounts(getActivity());
boolean hasUserSelectedDefault =
subscriptionAccountHandles.contains(
TelecomUtil.getDefaultOutgoingPhoneAccount(
diff --git a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
index 76892552b..2e4caa920 100644
--- a/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
+++ b/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java
@@ -44,7 +44,6 @@ import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;
import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
-import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.compat.telephony.TelephonyManagerCompat;
@@ -215,7 +214,7 @@ public class SpecialCharSequenceMgr {
sc.progressDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
List<PhoneAccountHandle> subscriptionAccountHandles =
- PhoneAccountUtils.getSubscriptionPhoneAccounts(context);
+ TelecomUtil.getSubscriptionPhoneAccounts(context);
Context applicationContext = context.getApplicationContext();
boolean hasUserSelectedDefault =
subscriptionAccountHandles.contains(
@@ -272,7 +271,7 @@ public class SpecialCharSequenceMgr {
static boolean handlePinEntry(final Context context, final String input) {
if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) {
List<PhoneAccountHandle> subscriptionAccountHandles =
- PhoneAccountUtils.getSubscriptionPhoneAccounts(context);
+ TelecomUtil.getSubscriptionPhoneAccounts(context);
boolean hasUserSelectedDefault =
subscriptionAccountHandles.contains(
TelecomUtil.getDefaultOutgoingPhoneAccount(context, PhoneAccount.SCHEME_TEL));
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.