[Settings] Can not launch SIMs page correctly

The subId should be set from argument when launching MobileNetworkSettings by new SubSettings

Test: atest
Bug: 211843783
Change-Id: Ie2b675af278795930971c61d8b1c1c28b96bf0ee
This commit is contained in:
Zoey Chen
2021-12-23 16:45:07 +08:00
parent 8bf6efba9e
commit 0d89c09b3f
2 changed files with 12 additions and 7 deletions

View File

@@ -118,15 +118,19 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
@Override @Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
if (getArguments() == null) {
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID, mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
MobileNetworkUtils.getSearchableSubscriptionId(context)); MobileNetworkUtils.getSearchableSubscriptionId(context));
Log.i(LOG_TAG, "display subId from intent: " + mSubId); Log.d(LOG_TAG, "display subId from intent: " + mSubId);
} else {
Log.d(LOG_TAG, "intent is null, can not get the subId from intent.");
}
} else { } else {
mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID, mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID,
MobileNetworkUtils.getSearchableSubscriptionId(context)); MobileNetworkUtils.getSearchableSubscriptionId(context));
Log.i(LOG_TAG, "display subId from getArguments(): " + mSubId); Log.d(LOG_TAG, "display subId from getArguments(): " + mSubId);
} }
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) { if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {

View File

@@ -1014,10 +1014,11 @@ public class MobileNetworkUtils {
public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) { public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) {
final int subId = info.getSubscriptionId(); final int subId = info.getSubscriptionId();
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid"); Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid.");
return; return;
} }
Log.d(TAG, "launchMobileNetworkSettings for subId: " + subId);
final Bundle extra = new Bundle(); final Bundle extra = new Bundle();
extra.putInt(Settings.EXTRA_SUB_ID, subId); extra.putInt(Settings.EXTRA_SUB_ID, subId);
new SubSettingLauncher(context) new SubSettingLauncher(context)