From 0d89c09b3f970cba400c25228b6001c4c395b23e Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Thu, 23 Dec 2021 16:45:07 +0800 Subject: [PATCH] [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 --- .../network/telephony/MobileNetworkSettings.java | 16 ++++++++++------ .../network/telephony/MobileNetworkUtils.java | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java index f1a40183a20..3110d6abb75 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java +++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java @@ -118,15 +118,19 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings { @Override protected List createPreferenceControllers(Context context) { - Intent intent = getIntent(); - if (intent != null) { - mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID, - MobileNetworkUtils.getSearchableSubscriptionId(context)); - Log.i(LOG_TAG, "display subId from intent: " + mSubId); + if (getArguments() == null) { + Intent intent = getIntent(); + if (intent != null) { + mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID, + MobileNetworkUtils.getSearchableSubscriptionId(context)); + 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 { mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID, 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)) { diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java index e2d158dfe5d..df6033ebb99 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java +++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java @@ -1014,10 +1014,11 @@ public class MobileNetworkUtils { public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) { final int subId = info.getSubscriptionId(); if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { - Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid"); + Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid."); return; } + Log.d(TAG, "launchMobileNetworkSettings for subId: " + subId); final Bundle extra = new Bundle(); extra.putInt(Settings.EXTRA_SUB_ID, subId); new SubSettingLauncher(context)