Always show disabled pSIMs in single-sim mode

In single-sim mode, you can have both an eSIM subscription and a pSIM
inserted into the device, and only one of them can be enabled. It turns
out that if the pSIM is the disabled one, we would not show it in the
settings UI; this CL fixes that.

It also fixes a somewhat related problem that I noticed while testing
this, that if you have only one subscription that happens to be
disabled, we were not showing the on/off switch at the top of the page,
which would leave you with no way to enable it.

Bug: 129864878
Test: make RunSettingsRoboTests
Change-Id: I4214ad34c59ac2df429772c066c51a9318f5baa7
This commit is contained in:
Antony Sargent
2019-04-23 10:55:51 -07:00
parent f263f489e2
commit bdd9eb3ba7
9 changed files with 197 additions and 31 deletions

View File

@@ -22,6 +22,7 @@ import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
import android.content.Context;
import android.content.Intent;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.euicc.EuiccManager;
@@ -99,7 +100,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
@Override
public CharSequence getSummary() {
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
mSubscriptionManager);
mContext);
if (subs.isEmpty()) {
if (MobileNetworkUtils.showEuiccSettings(mContext)) {
return mContext.getResources().getString(
@@ -132,7 +133,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
mPreference.setEnabled(!mChangeListener.isAirplaneModeOn());
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
mSubscriptionManager);
mContext);
if (subs.isEmpty()) {
if (MobileNetworkUtils.showEuiccSettings(mContext)) {
@@ -154,6 +155,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
if (subs.size() == 1) {
mPreference.setOnPreferenceClickListener((Preference pref) -> {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
intent.putExtra(Settings.EXTRA_SUB_ID, subs.get(0).getSubscriptionId());
mContext.startActivity(intent);
return true;
});