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

Commit 25054ba3 authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Stop disabling wifi toggle when tethering is restricted

When an admin disallows the user from configuring tethering, the
user should still be able to configure wifi.
When an admin disallows wifi configuration, the behavior is
unchanged: the toggle stays enabled and allows the user to turn
wifi on and off, but clicking on the text results in admin
transparency dialog, so the user won't be able to change wifi
config.

Bug: 149481093
Test: manual with TestDPC as the device owner
Change-Id: I6b33e43901454125c7f3f4dd3c70f050997e4e71
parent 0c99ecae
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import android.net.NetworkInfo;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.widget.Toast;

@@ -35,8 +33,6 @@ import androidx.annotation.VisibleForTesting;

import com.android.settings.R;
import com.android.settings.widget.SwitchWidgetController;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.WirelessUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;

@@ -76,9 +72,6 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
        }
    };

    private static final String EVENT_DATA_IS_WIFI_ON = "is_wifi_on";
    private static final int EVENT_UPDATE_INDEX = 0;

    public WifiEnabler(Context context, SwitchWidgetController switchWidget,
        MetricsFeatureProvider metricsFeatureProvider) {
        this(context, switchWidget, metricsFeatureProvider,
@@ -161,15 +154,6 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
                setSwitchBarChecked(false);
                mSwitchWidget.setEnabled(true);
        }

        if (RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
                UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) {
            mSwitchWidget.setEnabled(false);
        } else {
            final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(
                    mContext, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId());
            mSwitchWidget.setDisabledByAdmin(admin);
        }
    }

    private void setSwitchBarChecked(boolean checked) {