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

Commit 7af19fcb authored by Quang Luong's avatar Quang Luong Committed by Android (Google) Code Review
Browse files

Merge "Fixed Passpoint network "Not in range" issue and forget button" into qt-dev

parents 47bea2d4 0af9b836
Loading
Loading
Loading
Loading
+29 −19
Original line number Diff line number Diff line
@@ -554,14 +554,10 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController

        mIsOutOfRange = true;

        if (mAccessPoint.getConfig() == null) {
            return;
        }

        for (AccessPoint ap : mWifiTracker.getAccessPoints()) {
            if (ap.getConfig() != null
                    && mAccessPoint.matches(ap.getConfig())) {
            if (mAccessPoint.matches(ap)) {
                mAccessPoint = ap;
                mWifiConfig = ap.getConfig();
                mIsOutOfRange = !mAccessPoint.isReachable();
                return;
            }
@@ -825,7 +821,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
     * Returns whether the network represented by this preference can be forgotten.
     */
    private boolean canForgetNetwork() {
        return (mWifiInfo != null && mWifiInfo.isEphemeral()) || canModifyNetwork();
        return (mWifiInfo != null && mWifiInfo.isEphemeral()) || canModifyNetwork()
                || mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig();
    }

    /**
@@ -856,19 +853,23 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
    private void forgetNetwork() {
        if (mWifiInfo != null && mWifiInfo.isEphemeral()) {
            mWifiManager.disableEphemeralNetwork(mWifiInfo.getSSID());
        } else if (mWifiConfig != null) {
            if (mWifiConfig.isPasspoint()) {
        } else if (mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig()) {
            // Post a dialog to confirm if user really want to forget the passpoint network.
            if (FeatureFlagPersistent.isEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2)) {
                showConfirmForgetDialog();
                return;
            }

                mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
            } else {
                mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
            try {
                mWifiManager.removePasspointConfiguration(mAccessPoint.getPasspointFqdn());
            } catch (RuntimeException e) {
                Log.e(TAG, "Failed to remove Passpoint configuration for "
                        + mAccessPoint.getPasspointFqdn());
            }
        } else if (mWifiConfig != null) {
            mWifiManager.forget(mWifiConfig.networkId, null /* action listener */);
        }

        mMetricsFeatureProvider.action(
                mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
        mFragment.getActivity().finish();
@@ -878,7 +879,12 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
    protected void showConfirmForgetDialog() {
        final AlertDialog dialog = new AlertDialog.Builder(mContext)
                .setPositiveButton(R.string.forget, ((dialog1, which) -> {
                    mWifiManager.removePasspointConfiguration(mWifiConfig.FQDN);
                    try {
                        mWifiManager.removePasspointConfiguration(mAccessPoint.getPasspointFqdn());
                    } catch (RuntimeException e) {
                        Log.e(TAG, "Failed to remove Passpoint configuration for "
                                + mAccessPoint.getPasspointFqdn());
                    }
                    mMetricsFeatureProvider.action(
                            mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
                    mFragment.getActivity().finish();
@@ -1000,7 +1006,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
                } else if (state == STATE_CONNECTING) {
                    Log.d(TAG, "connecting...");
                    updateConnectedButton(STATE_CONNECTING);
                    if (mAccessPoint.isPasspoint()) {
                        mWifiManager.connect(mWifiConfig, mConnectListener);
                    } else {
                        mWifiManager.connect(mWifiConfig.networkId, mConnectListener);
                    }
                    // start timer for error handling since framework didn't call back if failed
                    startTimer();
                } else if (state == STATE_ENABLE_WIFI_FAILED) {