diff --git a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java index 249c85542b0..eb833b1ae1b 100644 --- a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java +++ b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java @@ -26,25 +26,17 @@ import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity; public class CallsDefaultSubscriptionController extends DefaultSubscriptionController { - private SubscriptionInfoEntity mSubscriptionInfoEntity; - public CallsDefaultSubscriptionController(Context context, String preferenceKey, Lifecycle lifecycle, LifecycleOwner lifecycleOwner) { super(context, preferenceKey, lifecycle, lifecycleOwner); } - @Override - protected SubscriptionInfoEntity getDefaultSubscriptionInfo() { - return mSubscriptionInfoEntity; - } - @Override protected int getDefaultSubscriptionId() { int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId(); for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) { int subId = subInfo.getSubId(); if (subInfo.isActiveSubscriptionId && subId == defaultCallSubId) { - mSubscriptionInfoEntity = subInfo; return subId; } } diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java index cb18b331c2a..78947aa425b 100644 --- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java +++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java @@ -19,11 +19,7 @@ package com.android.settings.network.telephony; import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE; import static androidx.lifecycle.Lifecycle.Event.ON_RESUME; -import android.content.ComponentName; import android.content.Context; -import android.telecom.PhoneAccount; -import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; import android.view.View; @@ -57,15 +53,10 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere protected ListPreference mPreference; protected SubscriptionManager mManager; - protected TelecomManager mTelecomManager; protected MobileNetworkRepository mMobileNetworkRepository; protected LifecycleOwner mLifecycleOwner; private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver; - private static final String EMERGENCY_ACCOUNT_HANDLE_ID = "E"; - private static final ComponentName PSTN_CONNECTION_SERVICE_COMPONENT = - new ComponentName("com.android.phone", - "com.android.services.telephony.TelephonyConnectionService"); private boolean mIsRtlMode; List mSubInfoEntityList = new ArrayList<>(); @@ -84,10 +75,6 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere } } - /** @return SubscriptionInfo for the default subscription for the service, or null if there - * isn't one. */ - protected abstract SubscriptionInfoEntity getDefaultSubscriptionInfo(); - /** @return the id of the default subscription for the service, or * SubscriptionManager.INVALID_SUBSCRIPTION_ID if there isn't one. */ protected abstract int getDefaultSubscriptionId(); @@ -138,26 +125,6 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere } } - @Override - public CharSequence getSummary() { - final PhoneAccountHandle handle = getDefaultCallingAccountHandle(); - if ((handle != null) && (!isCallingAccountBindToSubscription(handle))) { - // display VoIP account in summary when configured through settings within dialer - return getLabelFromCallingAccount(handle); - } - final SubscriptionInfoEntity info = getDefaultSubscriptionInfo(); - if (info != null) { - // display subscription based account - return info.uniqueName; - } else { - if (isAskEverytimeSupported()) { - return mContext.getString(R.string.calls_and_sms_ask_every_time); - } else { - return ""; - } - } - } - @VisibleForTesting void updateEntries() { if (mPreference == null) { @@ -218,76 +185,6 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere } } - /** - * Get default calling account - * - * @return current calling account {@link PhoneAccountHandle} - */ - public PhoneAccountHandle getDefaultCallingAccountHandle() { - final PhoneAccountHandle currentSelectPhoneAccount = - getTelecomManager().getUserSelectedOutgoingPhoneAccount(); - if (currentSelectPhoneAccount == null) { - return null; - } - final List accountHandles = - getTelecomManager().getCallCapablePhoneAccounts(false); - final PhoneAccountHandle emergencyAccountHandle = new PhoneAccountHandle( - PSTN_CONNECTION_SERVICE_COMPONENT, EMERGENCY_ACCOUNT_HANDLE_ID); - if (currentSelectPhoneAccount.equals(emergencyAccountHandle)) { - return null; - } - for (PhoneAccountHandle handle : accountHandles) { - if (currentSelectPhoneAccount.equals(handle)) { - return currentSelectPhoneAccount; - } - } - return null; - } - - @VisibleForTesting - TelecomManager getTelecomManager() { - if (mTelecomManager == null) { - mTelecomManager = mContext.getSystemService(TelecomManager.class); - } - return mTelecomManager; - } - - @VisibleForTesting - PhoneAccount getPhoneAccount(PhoneAccountHandle handle) { - return getTelecomManager().getPhoneAccount(handle); - } - - /** - * Check if calling account bind to subscription - * - * @param handle {@link PhoneAccountHandle} for specific calling account - */ - public boolean isCallingAccountBindToSubscription(PhoneAccountHandle handle) { - final PhoneAccount account = getPhoneAccount(handle); - if (account == null) { - return false; - } - return account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION); - } - - /** - * Get label from calling account - * - * @param handle to get label from {@link PhoneAccountHandle} - * @return label of calling account - */ - public CharSequence getLabelFromCallingAccount(PhoneAccountHandle handle) { - CharSequence label = null; - final PhoneAccount account = getPhoneAccount(handle); - if (account != null) { - label = account.getLabel(); - } - if (label != null) { - label = mContext.getPackageManager().getUserBadgedLabel(label, handle.getUserHandle()); - } - return (label != null) ? label : ""; - } - @VisibleForTesting protected List getSubscriptionInfoList() { return mSubInfoEntityList; diff --git a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java index be3751308dc..c49647dd105 100644 --- a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java +++ b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java @@ -17,7 +17,6 @@ package com.android.settings.network.telephony; import android.content.Context; -import android.telecom.PhoneAccountHandle; import android.telephony.SubscriptionManager; import androidx.lifecycle.LifecycleOwner; @@ -28,7 +27,6 @@ import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity; public class SmsDefaultSubscriptionController extends DefaultSubscriptionController { private final boolean mIsAskEverytimeSupported; - private SubscriptionInfoEntity mSubscriptionInfoEntity; public SmsDefaultSubscriptionController(Context context, String preferenceKey, Lifecycle lifecycle, LifecycleOwner lifecycleOwner) { @@ -37,18 +35,12 @@ public class SmsDefaultSubscriptionController extends DefaultSubscriptionControl .getBoolean(com.android.internal.R.bool.config_sms_ask_every_time_support); } - @Override - protected SubscriptionInfoEntity getDefaultSubscriptionInfo() { - return mSubscriptionInfoEntity; - } - @Override protected int getDefaultSubscriptionId() { int defaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId(); for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) { int subId = subInfo.getSubId(); if (subInfo.isActiveSubscriptionId && subId == defaultSmsSubId) { - mSubscriptionInfoEntity = subInfo; return subId; } } @@ -65,12 +57,6 @@ public class SmsDefaultSubscriptionController extends DefaultSubscriptionControl return mIsAskEverytimeSupported; } - @Override - public PhoneAccountHandle getDefaultCallingAccountHandle() { - // Not supporting calling account override by VoIP - return null; - } - @Override public CharSequence getSummary() { return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, false, diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java index bbec5bb5a9f..b2ad3d793bc 100644 --- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java +++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java @@ -16,15 +16,10 @@ package com.android.settings.network.telephony; -import static androidx.lifecycle.Lifecycle.Event; - import static com.android.settings.core.BasePreferenceController.AVAILABLE; -import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -151,13 +146,6 @@ public class DefaultSubscriptionControllerTest { assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } - @Test - public void isCallingAccountBindToSubscription_invalidAccount_withoutCrash() { - doReturn(null).when(mTelecomManager).getPhoneAccount(any()); - - mController.isCallingAccountBindToSubscription(null); - } - @Test public void onPreferenceChange_prefChangedToSub2_callbackCalledCorrectly() { mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1, @@ -343,11 +331,6 @@ public class DefaultSubscriptionControllerTest { super(context, preferenceKey, lifecycle, lifecycleOwner); } - @Override - protected SubscriptionInfoEntity getDefaultSubscriptionInfo() { - return null; - } - @Override protected int getDefaultSubscriptionId() { return mSubId;