summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/ResetNetwork.java
diff options
context:
space:
mode:
authorBonian Chen <bonianchen@google.com>2020-12-15 03:57:43 +0800
committerBonian Chen <bonianchen@google.com>2020-12-16 02:35:26 +0000
commit0da056b2dd542f8cdca9ba05b89a67a5dad4b516 (patch)
treedea41a6eae06e1e6c221e787c9ffd8f1c23b9c3d /src/com/android/settings/ResetNetwork.java
parent030687150304b622afa1016713ead3fa8545448a (diff)
downloadpackages_apps_Settings-0da056b2dd542f8cdca9ba05b89a67a5dad4b516.tar.gz
packages_apps_Settings-0da056b2dd542f8cdca9ba05b89a67a5dad4b516.tar.bz2
packages_apps_Settings-0da056b2dd542f8cdca9ba05b89a67a5dad4b516.zip
[Settings] Close reset network confirm dialog when SIM removed
When SIM removed, the network reset confirm UI no longer represents the wordings which presented to the user. Proceed on resetting will only reset APN on removed SIM and lead to some side effect if user inserted a new SIM while keeping displaying the confirmation dialog. With this situation, close the confirmation dialog is current decision in design. And the UI which prior to the confirm UI also need to be updated to avoid from user accessing that removed SIM. Bug: 171070050 Test: manual Change-Id: I338835ca98593f95d98bafa70f12b177c43bf91a
Diffstat (limited to 'src/com/android/settings/ResetNetwork.java')
-rw-r--r--src/com/android/settings/ResetNetwork.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/com/android/settings/ResetNetwork.java b/src/com/android/settings/ResetNetwork.java
index 5ff59b5e61..c4fa90d3bc 100644
--- a/src/com/android/settings/ResetNetwork.java
+++ b/src/com/android/settings/ResetNetwork.java
@@ -32,6 +32,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -53,7 +54,9 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
/**
* Confirm and execute a reset of the device's network settings to a clean "just out of the box"
@@ -112,7 +115,7 @@ public class ResetNetwork extends InstrumentedFragment {
if (resultCode == Activity.RESULT_OK) {
showFinalConfirmation();
} else {
- establishInitialState();
+ establishInitialState(getActiveSubscriptionInfoList());
}
}
@@ -161,14 +164,15 @@ public class ResetNetwork extends InstrumentedFragment {
* inflate each view, caching all of the widget pointers we'll need at the
* time, then simply reuse the inflated views directly whenever we need
* to change contents.
+ *
+ * @param subscriptionsList is a list of SubscriptionInfo(s) which allow user to select from
*/
- private void establishInitialState() {
+ private void establishInitialState(List<SubscriptionInfo> subscriptionsList) {
mSubscriptionSpinner = (Spinner) mContentView.findViewById(R.id.reset_network_subscription);
mEsimContainer = mContentView.findViewById(R.id.erase_esim_container);
mEsimCheckbox = mContentView.findViewById(R.id.erase_esim);
- mSubscriptions = SubscriptionManager.from(getActivity())
- .getActiveSubscriptionInfoList();
+ mSubscriptions = subscriptionsList;
if (mSubscriptions != null && mSubscriptions.size() > 0) {
// Get the default subscription in the order of data, voice, sms, first up.
int defaultSubscription = SubscriptionManager.getDefaultDataSubscriptionId();
@@ -231,6 +235,31 @@ public class ResetNetwork extends InstrumentedFragment {
}
}
+ private List<SubscriptionInfo> getActiveSubscriptionInfoList() {
+ SubscriptionManager mgr = getActivity().getSystemService(SubscriptionManager.class);
+ if (mgr == null) {
+ Log.w(TAG, "No SubscriptionManager");
+ return Collections.emptyList();
+ }
+ return Optional.ofNullable(mgr.getActiveSubscriptionInfoList())
+ .orElse(Collections.emptyList());
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ // update options if subcription has been changed
+ List<SubscriptionInfo> updatedSubscriptions = getActiveSubscriptionInfoList();
+ if ((mSubscriptions != null)
+ && (mSubscriptions.size() == updatedSubscriptions.size())
+ && mSubscriptions.containsAll(updatedSubscriptions)) {
+ return;
+ }
+ Log.d(TAG, "subcription list changed");
+ establishInitialState(updatedSubscriptions);
+ }
+
private boolean showEuiccSettings(Context context) {
EuiccManager euiccManager =
(EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
@@ -261,7 +290,7 @@ public class ResetNetwork extends InstrumentedFragment {
mContentView = inflater.inflate(R.layout.reset_network, null);
- establishInitialState();
+ establishInitialState(getActiveSubscriptionInfoList());
return mContentView;
}