diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index bd533793..eb48999e 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -126,6 +126,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); PreferenceGroup cat_options = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_options")).findPreference("category_options"); + PreferenceGroup cat_network = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_network_options")).findPreference("category_network_options"); PreferenceGroup cat_advanced = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_advanced_options")).findPreference("category_advanced_options"); PreferenceGroup cat_stats = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_stats")).findPreference("category_stats"); PreferenceGroup cat_backup = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_backup")).findPreference("category_backup"); @@ -151,23 +152,27 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere // Wi-Fi home MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) screen.findPreference("wifi_homes"); - Set ssids = prefs.getStringSet("wifi_homes", new HashSet()); - if (ssids.size() > 0) - pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssids))); - else - pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-")); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) + cat_network.removePreference(pref_wifi_homes); + else { + Set ssids = prefs.getStringSet("wifi_homes", new HashSet()); + if (ssids.size() > 0) + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssids))); + else + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-")); - WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); - List listSSID = new ArrayList<>(); - List configs = wm.getConfiguredNetworks(); - if (configs != null) - for (WifiConfiguration config : configs) - listSSID.add(config.SSID == null ? "NULL" : config.SSID); - for (String ssid : ssids) - if (!listSSID.contains(ssid)) - listSSID.add(ssid); - pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0])); - pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0])); + WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); + List listSSID = new ArrayList<>(); + List configs = wm.getConfiguredNetworks(); + if (configs != null) + for (WifiConfiguration config : configs) + listSSID.add(config.SSID == null ? "NULL" : config.SSID); + for (String ssid : ssids) + if (!listSSID.contains(ssid)) + listSSID.add(ssid); + pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0])); + pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0])); + } Preference pref_reset_usage = screen.findPreference("reset_usage"); pref_reset_usage.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index 3a28aba0..e95d8aac 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -1717,13 +1717,17 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS boolean org_metered = metered; boolean org_roaming = roaming; + // https://issuetracker.google.com/issues/70633700 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) + ssidHomes.clear(); + // Update metered state if (wifi && !useMetered) metered = false; if (wifi && ssidHomes.size() > 0 && !(ssidHomes.contains(ssidNetwork) || ssidHomes.contains('"' + ssidNetwork + '"'))) { metered = true; - Log.i(TAG, "!@home"); + Log.i(TAG, "!@home=" + ssidNetwork + " homes=" + TextUtils.join(",", ssidHomes)); } if (unmetered_2g && "2G".equals(generation)) metered = false;