Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cdc1e69 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix no option after mobile network was reseted." into main

parents c62e4b3a cadeeecd
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -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
     */
@@ -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;