0

I want to programmatically switch on/off Connect to open networks and Open network notification from the android settings: https://source.android.com/devices/tech/connect/wifi-infrastructure

How can I do this? Do I have to use ConnectivityManager / WifiManager?

The reason for this is that I am annoyed by my phone telling me about "open" telekom wifi/hotspot when I am outside. Also I cannot find the settings page to turn these settings off on my Samsung Galaxy S7.

Update

As I have not found a viable solution programatically I have solved the problem the following way: Remove public hotpots that I do not want to connect to from my "Saved WiFi Network" list. Use MacroDroid/Tasker to disable WiFi when I am leaving my home.

Dennis
  • 1,027
  • 1
  • 14
  • 30
  • Try action "android.settings.WIFI_IP_SETTINGS" to start this wifi settings activity? – cowboi-peng Jun 10 '19 at 08:31
  • @ihsan.gaozp This opens the wifi settings page which I can also access in the samsung settings. There is no option `Connect to open networks` on my Galaxy S7. On the S9 there seems to be this option in this menu. But this does not help me with my S7. – Dennis Jun 10 '19 at 11:00
  • I found that, your device must support network score , So that you could tell wether this network should be connected . http://androidxref.com/9.0.0_r3/xref/packages/apps/Settings/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java#66 check this link. – cowboi-peng Jun 11 '19 at 09:35
  • You can try "adb shell dumpsys network_score" , My output is "scoring is disabled" , So I can't find the connect to open networks. – cowboi-peng Jun 11 '19 at 10:06
  • @ihsan.gaozp For my device it actually returns scoring information. The value for all networks is -128 though. – Dennis Jun 12 '19 at 10:44

1 Answers1

0

It seems you can disable Open network notification:

Settings.Secure.putInt(cr, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0);

But therefore you need the permission android.permission.WRITE_SECURE_SETTINGS which is only available to system apps.

Dennis
  • 1,027
  • 1
  • 14
  • 30