[Telephony settings] Settings crashes when rotate screen in Preferred network type
When activity is recreated, fragments are automatically reattached.
Need to check the savedInstanceState is null or not when we want to add framgment in MobileNetworkActivity.
(lost to check in ag/9667137)
Bug: 154087690
Test: Manual
make RunSettingsRoboTests -j ROBOTEST_FILTER=MobileNetworkActivityTest
Change-Id: Id169353f6dc10306dddd823a904f0803b26a6ddc
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index a792824..6513384 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -81,7 +81,7 @@
mCurSubscriptionId = updateSubscriptionIndex;
mFragmentForceReload = (mCurSubscriptionId == oldSubId);
final SubscriptionInfo info = getSubscription();
- updateSubscriptions(info);
+ updateSubscriptions(info, null);
// If the subscription has changed or the new intent doesnt contain the opt in action,
// remove the old discovery dialog. If the activity is being recreated, we will see
@@ -132,7 +132,7 @@
// perform registration after mCurSubscriptionId been configured.
registerActiveSubscriptionsListener();
- updateSubscriptions(subscription);
+ updateSubscriptions(subscription, savedInstanceState);
}
@VisibleForTesting
@@ -154,7 +154,7 @@
public void onChanged() {
SubscriptionInfo info = getSubscription();
int oldSubIndex = mCurSubscriptionId;
- updateSubscriptions(info);
+ updateSubscriptions(info, null);
// Remove the dialog if the subscription associated with this activity changes.
if (info == null) {
@@ -209,14 +209,16 @@
}
@VisibleForTesting
- void updateSubscriptions(SubscriptionInfo subscription) {
+ void updateSubscriptions(SubscriptionInfo subscription, Bundle savedInstanceState) {
if (subscription == null) {
return;
}
final int subscriptionIndex = subscription.getSubscriptionId();
updateTitleAndNavigation(subscription);
- switchFragment(subscription);
+ if (savedInstanceState == null) {
+ switchFragment(subscription);
+ }
mCurSubscriptionId = subscriptionIndex;
mFragmentForceReload = false;