mirror of https://github.com/M66B/NetGuard.git
Disable Wi-Fi home network feature on Android 8.1
https://issuetracker.google.com/issues/70633700
This commit is contained in:
parent
c67d03fdd2
commit
8f3d093da7
|
@ -126,6 +126,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
PreferenceGroup cat_options = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_options")).findPreference("category_options");
|
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_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_stats = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_stats")).findPreference("category_stats");
|
||||||
PreferenceGroup cat_backup = (PreferenceGroup) ((PreferenceGroup) screen.findPreference("screen_backup")).findPreference("category_backup");
|
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
|
// Wi-Fi home
|
||||||
MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) screen.findPreference("wifi_homes");
|
MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) screen.findPreference("wifi_homes");
|
||||||
Set<String> ssids = prefs.getStringSet("wifi_homes", new HashSet<String>());
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||||
if (ssids.size() > 0)
|
cat_network.removePreference(pref_wifi_homes);
|
||||||
pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssids)));
|
else {
|
||||||
else
|
Set<String> ssids = prefs.getStringSet("wifi_homes", new HashSet<String>());
|
||||||
pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-"));
|
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);
|
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
List<CharSequence> listSSID = new ArrayList<>();
|
List<CharSequence> listSSID = new ArrayList<>();
|
||||||
List<WifiConfiguration> configs = wm.getConfiguredNetworks();
|
List<WifiConfiguration> configs = wm.getConfiguredNetworks();
|
||||||
if (configs != null)
|
if (configs != null)
|
||||||
for (WifiConfiguration config : configs)
|
for (WifiConfiguration config : configs)
|
||||||
listSSID.add(config.SSID == null ? "NULL" : config.SSID);
|
listSSID.add(config.SSID == null ? "NULL" : config.SSID);
|
||||||
for (String ssid : ssids)
|
for (String ssid : ssids)
|
||||||
if (!listSSID.contains(ssid))
|
if (!listSSID.contains(ssid))
|
||||||
listSSID.add(ssid);
|
listSSID.add(ssid);
|
||||||
pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0]));
|
pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0]));
|
||||||
pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0]));
|
pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0]));
|
||||||
|
}
|
||||||
|
|
||||||
Preference pref_reset_usage = screen.findPreference("reset_usage");
|
Preference pref_reset_usage = screen.findPreference("reset_usage");
|
||||||
pref_reset_usage.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
pref_reset_usage.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
|
|
@ -1717,13 +1717,17 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
boolean org_metered = metered;
|
boolean org_metered = metered;
|
||||||
boolean org_roaming = roaming;
|
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
|
// Update metered state
|
||||||
if (wifi && !useMetered)
|
if (wifi && !useMetered)
|
||||||
metered = false;
|
metered = false;
|
||||||
if (wifi && ssidHomes.size() > 0 &&
|
if (wifi && ssidHomes.size() > 0 &&
|
||||||
!(ssidHomes.contains(ssidNetwork) || ssidHomes.contains('"' + ssidNetwork + '"'))) {
|
!(ssidHomes.contains(ssidNetwork) || ssidHomes.contains('"' + ssidNetwork + '"'))) {
|
||||||
metered = true;
|
metered = true;
|
||||||
Log.i(TAG, "!@home");
|
Log.i(TAG, "!@home=" + ssidNetwork + " homes=" + TextUtils.join(",", ssidHomes));
|
||||||
}
|
}
|
||||||
if (unmetered_2g && "2G".equals(generation))
|
if (unmetered_2g && "2G".equals(generation))
|
||||||
metered = false;
|
metered = false;
|
||||||
|
|
Loading…
Reference in New Issue