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.Activity;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
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
|
* 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
|
* 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.
|
* to sleep, is locked, et cetera, then the confirmation sequence is abandoned.
|
||||||
*
|
* <p>
|
||||||
* This is the initial screen.
|
* This is the initial screen.
|
||||||
*/
|
*/
|
||||||
public class ResetNetwork extends InstrumentedFragment {
|
public class ResetNetwork extends InstrumentedFragment {
|
||||||
@@ -81,8 +84,20 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
private View mContentView;
|
private View mContentView;
|
||||||
private Spinner mSubscriptionSpinner;
|
private Spinner mSubscriptionSpinner;
|
||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
@VisibleForTesting View mEsimContainer;
|
@VisibleForTesting
|
||||||
@VisibleForTesting CheckBox mEsimCheckbox;
|
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
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -97,6 +112,7 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
/**
|
/**
|
||||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||||
* component as a subactivity
|
* component as a subactivity
|
||||||
|
*
|
||||||
* @param request the request code to be returned once confirmation finishes
|
* @param request the request code to be returned once confirmation finishes
|
||||||
* @return true if confirmation launched
|
* @return true if confirmation launched
|
||||||
*/
|
*/
|
||||||
@@ -215,7 +231,6 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
int size = mSubscriptions.size();
|
|
||||||
List<String> subscriptionNames = new ArrayList<>();
|
List<String> subscriptionNames = new ArrayList<>();
|
||||||
for (SubscriptionInfo record : mSubscriptions) {
|
for (SubscriptionInfo record : mSubscriptions) {
|
||||||
if (record.getSubscriptionId() == defaultSubscription) {
|
if (record.getSubscriptionId() == defaultSubscription) {
|
||||||
@@ -281,6 +296,8 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
getContext().registerReceiver(mDefaultSubChangeReceiver,
|
||||||
|
new IntentFilter(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED));
|
||||||
|
|
||||||
if (mContentView == null) {
|
if (mContentView == null) {
|
||||||
return;
|
return;
|
||||||
@@ -297,6 +314,12 @@ public class ResetNetwork extends InstrumentedFragment {
|
|||||||
establishInitialState(updatedSubscriptions);
|
establishInitialState(updatedSubscriptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
getContext().unregisterReceiver(mDefaultSubChangeReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean showEuiccSettings(Context context) {
|
private boolean showEuiccSettings(Context context) {
|
||||||
if (!SubscriptionUtil.isSimHardwareVisible(context)) {
|
if (!SubscriptionUtil.isSimHardwareVisible(context)) {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user