Merge "[Settings] Change the restart policy for MobileNetworkActivity" into rvc-dev am: fbe5a997d3
Change-Id: Ibb1ccf9625f7aa7d644bd5f4071068af007507ec
This commit is contained in:
@@ -56,10 +56,15 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ProxySubscriptionManager mProxySubscriptionMgr;
|
ProxySubscriptionManager mProxySubscriptionMgr;
|
||||||
|
|
||||||
private int mCurSubscriptionId;
|
private int mCurSubscriptionId;
|
||||||
// To avoid from Preference Controller to have a complex design for the case of Activity
|
|
||||||
// restart. mIsEffectiveSubId is designed to force recreate of Preference Controller(s).
|
// This flag forces subscription information fragment to be re-created.
|
||||||
private boolean mIsEffectiveSubId;
|
// Otherwise, fragment will be kept when subscription id has not been changed.
|
||||||
|
//
|
||||||
|
// Set initial value to true allows subscription information fragment to be re-created when
|
||||||
|
// Activity re-create occur.
|
||||||
|
private boolean mFragmentForceReload = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
@@ -73,7 +78,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
}
|
}
|
||||||
int oldSubId = mCurSubscriptionId;
|
int oldSubId = mCurSubscriptionId;
|
||||||
mCurSubscriptionId = updateSubscriptionIndex;
|
mCurSubscriptionId = updateSubscriptionIndex;
|
||||||
mIsEffectiveSubId = (mCurSubscriptionId != SUB_ID_NULL);
|
mFragmentForceReload = (mCurSubscriptionId == oldSubId);
|
||||||
updateSubscriptions(getSubscription());
|
updateSubscriptions(getSubscription());
|
||||||
|
|
||||||
// If the subscription has changed or the new intent doesnt contain the opt in action,
|
// If the subscription has changed or the new intent doesnt contain the opt in action,
|
||||||
@@ -117,7 +122,6 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
: ((startIntent != null)
|
: ((startIntent != null)
|
||||||
? startIntent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
|
? startIntent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
|
||||||
: SUB_ID_NULL);
|
: SUB_ID_NULL);
|
||||||
mIsEffectiveSubId = (mCurSubscriptionId != SUB_ID_NULL);
|
|
||||||
|
|
||||||
final SubscriptionInfo subscription = getSubscription();
|
final SubscriptionInfo subscription = getSubscription();
|
||||||
updateTitleAndNavigation(subscription);
|
updateTitleAndNavigation(subscription);
|
||||||
@@ -207,7 +211,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
switchFragment(subscription);
|
switchFragment(subscription);
|
||||||
|
|
||||||
mCurSubscriptionId = subscriptionIndex;
|
mCurSubscriptionId = subscriptionIndex;
|
||||||
mIsEffectiveSubId = true;
|
mFragmentForceReload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,7 +221,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SubscriptionInfo getSubscription() {
|
SubscriptionInfo getSubscription() {
|
||||||
if (mIsEffectiveSubId && (mCurSubscriptionId != SUB_ID_NULL)) {
|
if (mCurSubscriptionId != SUB_ID_NULL) {
|
||||||
return getSubscriptionForSubId(mCurSubscriptionId);
|
return getSubscriptionForSubId(mCurSubscriptionId);
|
||||||
}
|
}
|
||||||
final List<SubscriptionInfo> subInfos = getProxySubscriptionManager()
|
final List<SubscriptionInfo> subInfos = getProxySubscriptionManager()
|
||||||
@@ -245,7 +249,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
final String fragmentTag = buildFragmentTag(subId);
|
final String fragmentTag = buildFragmentTag(subId);
|
||||||
if (fragmentManager.findFragmentByTag(fragmentTag) != null) {
|
if (fragmentManager.findFragmentByTag(fragmentTag) != null) {
|
||||||
if (mIsEffectiveSubId) {
|
if (!mFragmentForceReload) {
|
||||||
Log.d(TAG, "Keep current fragment: " + fragmentTag);
|
Log.d(TAG, "Keep current fragment: " + fragmentTag);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user