Fix no option after mobile network was reseted.
- When reseting mobile network, subscription info will also be reset. It has a racing bewteen showing the UI and udpating the subscription info. - Register a receiver to receive subscription change to dynamically update the UI Flag: EXEMPT bugfix Bug: 362382003 Test: Manual test. Change-Id: I16811503685a6b82eee5ecf3fa725255d356a765
This commit is contained in:
@@ -18,8 +18,11 @@ package com.android.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -66,7 +69,7 @@ import java.util.Optional;
|
||||
* prompt, followed by a keyguard pattern trace if the user has defined one, followed by a final
|
||||
* strongly-worded "THIS WILL RESET EVERYTHING" prompt. If at any time the phone is allowed to go
|
||||
* to sleep, is locked, et cetera, then the confirmation sequence is abandoned.
|
||||
*
|
||||
* <p>
|
||||
* This is the initial screen.
|
||||
*/
|
||||
public class ResetNetwork extends InstrumentedFragment {
|
||||
@@ -81,8 +84,20 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
private View mContentView;
|
||||
private Spinner mSubscriptionSpinner;
|
||||
private Button mInitiateButton;
|
||||
@VisibleForTesting View mEsimContainer;
|
||||
@VisibleForTesting CheckBox mEsimCheckbox;
|
||||
@VisibleForTesting
|
||||
View mEsimContainer;
|
||||
@VisibleForTesting
|
||||
CheckBox mEsimCheckbox;
|
||||
|
||||
private BroadcastReceiver mDefaultSubChangeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction() != SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED) {
|
||||
return;
|
||||
}
|
||||
establishInitialState(getActiveSubscriptionInfoList());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -97,6 +112,7 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
/**
|
||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||
* component as a subactivity
|
||||
*
|
||||
* @param request the request code to be returned once confirmation finishes
|
||||
* @return true if confirmation launched
|
||||
*/
|
||||
@@ -139,7 +155,7 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
|
||||
int subId = subscription.getSubscriptionId();
|
||||
request.setResetTelephonyAndNetworkPolicyManager(subId)
|
||||
.setResetApn(subId);
|
||||
.setResetApn(subId);
|
||||
if (Flags.resetMobileNetworkSettings()) {
|
||||
request.setResetImsSubId(subId);
|
||||
}
|
||||
@@ -215,7 +231,6 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
}
|
||||
|
||||
int selectedIndex = 0;
|
||||
int size = mSubscriptions.size();
|
||||
List<String> subscriptionNames = new ArrayList<>();
|
||||
for (SubscriptionInfo record : mSubscriptions) {
|
||||
if (record.getSubscriptionId() == defaultSubscription) {
|
||||
@@ -281,6 +296,8 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getContext().registerReceiver(mDefaultSubChangeReceiver,
|
||||
new IntentFilter(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED));
|
||||
|
||||
if (mContentView == null) {
|
||||
return;
|
||||
@@ -297,6 +314,12 @@ public class ResetNetwork extends InstrumentedFragment {
|
||||
establishInitialState(updatedSubscriptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getContext().unregisterReceiver(mDefaultSubChangeReceiver);
|
||||
}
|
||||
|
||||
private boolean showEuiccSettings(Context context) {
|
||||
if (!SubscriptionUtil.isSimHardwareVisible(context)) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user