Merge "Make MobileNetworkActivity support onNewIntent" into qt-r1-dev am: 20ec6a4b6f

am: f61428cf1d

Change-Id: I21991a0d06bf861d6a0fd6906b455a36d8b10c55
This commit is contained in:
Antony Sargent
2019-07-18 20:06:19 -07:00
committed by android-build-merger
2 changed files with 24 additions and 0 deletions

View File

@@ -76,6 +76,13 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
}
};
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
updateSubscriptions(null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -40,6 +40,8 @@ import android.view.View;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.network.SubscriptionUtil;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@@ -207,4 +209,19 @@ public class MobileNetworkActivityTest {
assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(PREV_SUB_ID);
}
@Test
public void onNewIntent_newSubscriptionId_fragmentReplaced() {
FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
mSubscriptionInfos.add(mSubscriptionInfo);
mSubscriptionInfos.add(mSubscriptionInfo2);
SubscriptionUtil.setAvailableSubscriptionsForTesting(mSubscriptionInfos);
mMobileNetworkActivity.mCurSubscriptionId = PREV_SUB_ID;
final Intent newIntent = new Intent();
newIntent.putExtra(Settings.EXTRA_SUB_ID, CURRENT_SUB_ID);
mMobileNetworkActivity.onNewIntent(newIntent);
assertThat(mMobileNetworkActivity.mCurSubscriptionId).isEqualTo(CURRENT_SUB_ID);
}
}