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

Commit f91444c5 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Disallow tethering disable by Wifi

Disallow Tethering being disabled by Wifi
and vice versa. We now need to explicitly
disable tethering to enable Wifi.

Bug: 2539071
Change-Id: Id34a5335e70cb7234367b4709882937a4b8cc526
parent b54727e0
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -421,12 +421,18 @@ public class WifiService extends IWifiManager.Stub {
            return false;
        }

        setWifiEnabledState(enable ? WIFI_STATE_ENABLING : WIFI_STATE_DISABLING, uid);

        /**
         * Fail Wifi if AP is enabled
         * TODO: Deprecate WIFI_STATE_UNKNOWN and rename it
         * WIFI_STATE_FAILED
         */
        if ((mWifiApState == WIFI_AP_STATE_ENABLED) && enable) {
            setWifiApEnabledBlocking(false, Process.myUid(), null);
            setWifiEnabledState(WIFI_STATE_UNKNOWN, uid);
            return false;
        }

        setWifiEnabledState(enable ? WIFI_STATE_ENABLING : WIFI_STATE_DISABLING, uid);

        if (enable) {
            if (!mWifiStateTracker.loadDriver()) {
                Slog.e(TAG, "Failed to load Wi-Fi driver.");
@@ -665,18 +671,19 @@ public class WifiService extends IWifiManager.Stub {
            }
        }

        /**
         * Fail AP if Wifi is enabled
         */
        if ((mWifiStateTracker.getWifiState() == WIFI_STATE_ENABLED) && enable) {
            setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.NO_DRIVER_UNLOAD);
            return false;
        }

        setWifiApEnabledState(enable ? WIFI_AP_STATE_ENABLING :
                                       WIFI_AP_STATE_DISABLING, uid, DriverAction.NO_DRIVER_UNLOAD);

        if (enable) {

            /**
             * Disable client mode for starting AP
             */
            if (mWifiStateTracker.getWifiState() == WIFI_STATE_ENABLED) {
                setWifiEnabledBlocking(false, true, Process.myUid());
            }

            /* Use default config if there is no existing config */
            if (wifiConfig == null && ((wifiConfig = getWifiApConfiguration()) == null)) {
                wifiConfig = new WifiConfiguration();