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

Commit e1b6d7d8 authored by Cosmo Hsieh's avatar Cosmo Hsieh Committed by Android (Google) Code Review
Browse files

Merge "Show "Disconnect" on forget button for ephemeral network"

parents 3f2298c4 e4b3844d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -11032,4 +11032,7 @@
    <string name="automatic_system_heap_dump_title">Automatically capture system heap dumps</string>
    <!-- Summary of toggle for whether to enable automatic heap dumps for the system server or not. [CHAR LIMIT=NONE] -->
    <string name="automatic_system_heap_dump_summary">Automatically capture a heap dump for Android System when it uses too much memory</string>
    <!-- Button label to disconnect a Wi-Fi network. [CHAR LIMIT=40] -->
    <string name="wifi_disconnect_button_text">Disconnect</string>
</resources>
+15 −5
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
    private final WifiTracker mWifiTracker;
    private final MetricsFeatureProvider mMetricsFeatureProvider;
    private boolean mIsOutOfRange;
    private boolean mIsEphemeral;
    private boolean mConnected;
    private int mConnectingState;
    private WifiManager.ActionListener mConnectListener;
@@ -251,12 +252,14 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController

        @Override
        public void onLost(Network network) {
            // If support detail page for saved network, should update as disconnect but not exit.
            if (SavedAccessPointsWifiSettings.usingDetailsFragment(mContext)) {
            final boolean lostCurrentNetwork = network.equals(mNetwork);
            if (lostCurrentNetwork) {
                // If support detail page for saved network, should update as disconnect but not
                // exit. Except for ephemeral network which should not show on saved network list.
                if (SavedAccessPointsWifiSettings.usingDetailsFragment(mContext) && !mIsEphemeral) {
                    return;
                }

            if (network.equals(mNetwork)) {
                exitActivity();
            }
        }
@@ -350,6 +353,9 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
            mWifiTracker = null;
        }
        mConnected = mAccessPoint.isActive();
        // When lost the network connection, WifiInfo/NetworkInfo will be clear. So causes we
        // could not check if the AccessPoint is ephemeral. Need to cache it in first.
        mIsEphemeral = mAccessPoint.isEphemeral();
        mConnectingState = STATE_NONE;
        mConnectListener = new WifiManager.ActionListener() {
            @Override
@@ -703,6 +709,10 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
    }

    private void refreshButtons() {
        // Ephemeral network won't be removed permanently, but be putted in blacklist.
        mButtonsPref.setButton1Text(
                mIsEphemeral ? R.string.wifi_disconnect_button_text : R.string.forget);

        mButtonsPref.setButton1Visible(canForgetNetwork());
        mButtonsPref.setButton2Visible(canSignIntoNetwork());
        mButtonsPref.setButton3Visible(canConnectNetwork());