Clean up DefaultSubscriptionController.getSummary
Which is always overridden by subclass after Change
I7d29b58ca5476ae0bb6fe2e04fecb96164cb1ada
This is a no op.
Bug: 277301125
Test: Manually with Mobile Settings
Test: Unit test
Change-Id: Ifa5928e1026b18c33f2bdd51fdcba267249dcee5
diff --git a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
index 249c855..eb833b1 100644
--- a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
@@ -26,25 +26,17 @@
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 cb18b33..78947aa 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -19,11 +19,7 @@
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 @@
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<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
@@ -84,10 +75,6 @@
}
}
- /** @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 @@
}
}
- @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 @@
}
}
- /**
- * 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<PhoneAccountHandle> 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<SubscriptionInfoEntity> getSubscriptionInfoList() {
return mSubInfoEntityList;
diff --git a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
index be37513..c49647d 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 @@
public class SmsDefaultSubscriptionController extends DefaultSubscriptionController {
private final boolean mIsAskEverytimeSupported;
- private SubscriptionInfoEntity mSubscriptionInfoEntity;
public SmsDefaultSubscriptionController(Context context, String preferenceKey,
Lifecycle lifecycle, LifecycleOwner lifecycleOwner) {
@@ -38,17 +36,11 @@
}
@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;
}
}
@@ -66,12 +58,6 @@
}
@Override
- public PhoneAccountHandle getDefaultCallingAccountHandle() {
- // Not supporting calling account override by VoIP
- return null;
- }
-
- @Override
public CharSequence getSummary() {
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, false,
mSubInfoEntityList);
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 bbec5bb..b2ad3d7 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;
@@ -152,13 +147,6 @@
}
@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,
SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
@@ -344,11 +332,6 @@
}
@Override
- protected SubscriptionInfoEntity getDefaultSubscriptionInfo() {
- return null;
- }
-
- @Override
protected int getDefaultSubscriptionId() {
return mSubId;
}