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
This commit is contained in:
Chaohui Wang
2023-05-06 14:39:40 +08:00
parent 23d3eda967
commit ab8a130674
4 changed files with 0 additions and 142 deletions

View File

@@ -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;
}
}

View File

@@ -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<SubscriptionInfoEntity> 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<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;

View File

@@ -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,

View File

@@ -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;