Fix for affordances to add a mobile subscription
This changes the behavior for when we show an affordance to add a mobile subscription via the eSIM manager (if eSIM is supported). On the Network & internet page, the behavior we now want for the "Mobile network" pref has several possibilities as detailed below. No existing subscriptions: - Summary is "Add a network" - Tapping on pref leads to the add subscription flow One existing subscription: - Summary is the name of the subscription (usually the carrier name) - Tapping left-hand side of the pref leads to mobile network details - A "+" button is shown on right of pref, and tapping "+" leads to the add subscription flow 2 or more existing subscriptions: - Summary is "<count> SIMs" - Tapping left-hand side of the pref leads to a new page with the list of subscriptions - A "+" button is shown on right of pref, and tapping "+" leads to the add subscription flow The existing code controlling the "Mobile network" pref (in MobileNetworkSummaryController.java) already had behavior similar to this, but needed to be updated to no longer rely on whether we're in DSDS mode. Also, the page with the list of subscriptions that you can go to in the "2 or more existing subscriptions" case mentioned above has an "Add more" link at the bottom which leads to the same eSIM manager flow, but it was always showing this link even if the device doesn't support eSIM. This CL also fixes that problem. Bug: 127870567 Test: make RunSettingsRoboTests Change-Id: Ie8cca47ac81f8992fa6ecf1940bdfed411fd333b
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static android.telephony.TelephonyManager.MultiSimVariants.UNKNOWN;
|
||||
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
@@ -25,7 +23,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -52,7 +49,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private TelephonyManager mTelephonyMgr;
|
||||
private EuiccManager mEuiccManager;
|
||||
private AddPreference mPreference;
|
||||
|
||||
@@ -74,7 +70,6 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
public MobileNetworkSummaryController(Context context, Lifecycle lifecycle) {
|
||||
super(context);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mTelephonyMgr = mContext.getSystemService(TelephonyManager.class);
|
||||
mEuiccManager = mContext.getSystemService(EuiccManager.class);
|
||||
if (lifecycle != null) {
|
||||
mChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
@@ -124,48 +119,43 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean shouldShowAddButton() {
|
||||
// The add button should only show up if the device is in multi-sim mode and the eSIM
|
||||
// manager is enabled.
|
||||
return mTelephonyMgr.getMultiSimConfiguration() != UNKNOWN && mEuiccManager.isEnabled();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if (mPreference == null) {
|
||||
return;
|
||||
}
|
||||
final boolean showAddButton = shouldShowAddButton();
|
||||
refreshSummary(mPreference);
|
||||
if (!showAddButton) {
|
||||
mPreference.setOnAddClickListener(null);
|
||||
} else {
|
||||
mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
|
||||
mPreference.setOnAddClickListener(p -> {
|
||||
startAddSimFlow();
|
||||
});
|
||||
}
|
||||
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
|
||||
mSubscriptionManager);
|
||||
mPreference.setOnPreferenceClickListener(null);
|
||||
mPreference.setOnAddClickListener(null);
|
||||
mPreference.setFragment(null);
|
||||
mPreference.setEnabled(!mChangeListener.isAirplaneModeOn());
|
||||
|
||||
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
|
||||
mSubscriptionManager);
|
||||
|
||||
if (subs.isEmpty()) {
|
||||
if (showAddButton) {
|
||||
mPreference.setEnabled(false);
|
||||
} else if (mEuiccManager.isEnabled()) {
|
||||
if (mEuiccManager.isEnabled()) {
|
||||
mPreference.setOnPreferenceClickListener((Preference pref) -> {
|
||||
startAddSimFlow();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
} else if (subs.size() == 1) {
|
||||
mPreference.setOnPreferenceClickListener((Preference pref) -> {
|
||||
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
mPreference.setFragment(MobileNetworkListFragment.class.getCanonicalName());
|
||||
// We have one or more existing subscriptions, so we want the plus button if eSIM is
|
||||
// supported.
|
||||
if (mEuiccManager.isEnabled()) {
|
||||
mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
|
||||
mPreference.setOnAddClickListener(p -> startAddSimFlow());
|
||||
}
|
||||
|
||||
if (subs.size() == 1) {
|
||||
mPreference.setOnPreferenceClickListener((Preference pref) -> {
|
||||
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
mPreference.setFragment(MobileNetworkListFragment.class.getCanonicalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user