Skip to content

Commit

Permalink
Hide option for enabling Wi-Fi on Android 10+
Browse files Browse the repository at this point in the history
  • Loading branch information
farmerbb committed Dec 11, 2020
1 parent 375a95d commit b22cd54
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void onCreate(Bundle savedInstanceState) {
if(!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH))
disablePreference("bluetooth_on", "additional_settings", true);

if(!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI))
if(!U.canEnableWifi(getActivity()))
disablePreference("wifi_on", "additional_settings", true);

if(!getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void loadProfile(SharedPreferences prefCurrent) {
}

// Wi-Fi
if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
if(U.canEnableWifi(this)) {
WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if(prefCurrent.getBoolean("not_active", true))
editor.putBoolean("wifi_on_system", wifi.isWifiEnabled());
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/farmerbb/secondscreen/util/U.java
Original file line number Diff line number Diff line change
Expand Up @@ -1558,4 +1558,9 @@ public static boolean canEnableOverscan() {
public static boolean canEnableImmersiveMode() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && U.getCurrentApiVersion() <= 29.0f;
}

public static boolean canEnableWifi(Context context) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
&& context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
}
}

0 comments on commit b22cd54

Please sign in to comment.