- colucci-web.it
- Re: Connectivity change detected: WiFi —
- Re: Connectivity change detected: WiFi —
- Re: Connectivity change detected: WiFi —
- WiFi getSSID() always returns «»
- On Oreo (8.1.0) not getting the correct Wifi SSID. It’s showing though it is connected to a wifi with SSID
- 7 Answers 7
- 2BrightSparks Help and Support
- Wifi connected to unknown ssid
- Mike — mSecure
colucci-web.it
First of all, thank you for the great app. The only issue I have is, that the wireguard VPN does not disconnect automatically when connected to the home wifi, even if the SSID is selected in the auto connect exception list (see screenshot). The app doesn’t seem to recognize the SSID the phone (Samsung Note10+, Android 10 original) connects to. Is there a known fix to this I have to change on the router or the phone? (Btw. even selecting «Disconnect when the mobile connectivity is down» doesn’t fix the issue).
Thank you for ur support
Thomas
Log:
2020-03-22 16:45:03 Connectivity change detected: WiFi —
2020-03-22 16:45:03 The connectivity is changed.
2020-03-22 16:45:03 Restarting.
2020-03-22 16:45:05 Add peer x.x.com[x.x.x.x]
2020-03-22 16:45:05 set keep alive to 60
2020-03-22 16:45:05 -> 0.0.0.0/0
2020-03-22 16:45:05 -> ::/0
2020-03-22 16:45:05 Send handshake (1) to x
2020-03-22 16:45:05 Handshake with x completed
2020-03-22 16:45:05 Connected
admin Site Admin Posts: 936 Joined: Fri Feb 15, 2019 4:04 pm Contact:
Re: Connectivity change detected: WiFi —
Post by admin » Tue Mar 24, 2020 10:43 am
Thank you too for using the app
On latest Android versions the WiFi SSID can be get only if the App has the Location permission and the Android’s Location (GPS) feature is enabled.
Please try to open Android’s settings, check the app permission and enable the Location feaure
Re: Connectivity change detected: WiFi —
Post by usadream » Wed Apr 29, 2020 8:15 am
Thank you for your feedback, I now switched the permission to have the location always available instead of only when using the app, will report back in case that didn’t help.
Re: Connectivity change detected: WiFi —
Post by ThePhantom79 » Wed Nov 04, 2020 1:06 pm
Hello,
after migrate my config to my new phone OnePlus 8T (Android 11 !!) , I have some issues.
I want to use autoconnect as before and VPN should be disconnected, if I am connected to specific WLANs.
So.
— autoconnect is enabled
— «disconnect, when mobil connectivity is down» is enabled
— «connect when wifi is up, except » is enabled
Disconnet does not work, and I can see in the log, that only «unknow SSID» is logged.
As I know, the APP must have access to location services, so I give access to them, BUT:
I have only three options for allow access to location in android 11 for this (!) app:
— access while app is running
— ask everytime
— deny
I miss the option «allways give access». This option is available for many other apps (like facebook, maps), but also not for all other apps. What is the difference for that? I think, that is the reason, why I get the «unknown SSID»-LOG (and therefor disconnection does not work)
WiFi getSSID() always returns «»
This question has already been asked by many people, but the solution that worked for them is not working for me. I have tested on Android 8.1 and Android 9.0 and cannot get the name of the SSID. Broadcast receiver for getting WiFi state changes:
private final BroadcastReceiver mReceiver = new BroadcastReceiver() < public void onReceive(Context context, Intent intent) < String action = intent.getAction(); if(intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION) || intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION) || intent.getAction().equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION) || intent.getAction().equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION) || intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) < setWifiIndicator(); >> >;
The receiver is registered onCreate and unregistered in onDestroy , which I think is proper, and I’m seeing the log lines when the receiver is called. in onCreate :
IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ScannerService.ACTION_READ_SCANNER); intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); registerReceiver(mReceiver, intentFilter); setWifiIndicator();
private void setWifiIndicator() < ConnectivityManager connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); //getApplicationContext solves memory leak issues prior to Android N (must use Application Context to get wifi system service. WifiManager wifiMgr = (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE); ImageView wifiIndicator = (ImageView)findViewById(R.id.wifi_indicator); TextView wifiSSID = (TextView)findViewById(R.id.wifi_ssid); try < if (wifiMgr != null) < if (wifiMgr.isWifiEnabled()) < //wifi is enabled. toggle on wifi indicator. wifiIndicator.setImageResource(R.drawable.wifi_indicator); String ssid = wifiMgr.getConnectionInfo().getSSID(); if (ssid != null) < Log.v(this.getClass().getSimpleName(), "SSID: " + ssid + " Supplicant State: " + info.getSupplicantState()); wifiSSID.setText(ssid); >> else < //wifi is disabled. toggle off wifi indicator. wifiSSID.setText(""); //check for 3G NetworkInfo mobileInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mobileInfo != null && mobileInfo.getState().equals(NetworkInfo.State.CONNECTED)) < wifiIndicator.setImageResource(R.drawable.cellular_indicator); >else < wifiIndicator.setImageResource(R.drawable.down_indicator); >> > else < //check for 3G NetworkInfo mobileInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mobileInfo != null && mobileInfo.getState().equals(NetworkInfo.State.CONNECTED)) < wifiIndicator.setImageResource(R.drawable.cellular_indicator); >else < wifiIndicator.setImageResource(R.drawable.down_indicator); >> > catch(Exception e) < //catching anything thrown in this block just so it doesn't crash the program unnecessarily e.printStackTrace(); >>
My app already had permission for ACCESS_COARSE_LOCATION but I aslo added ACCESS_FINE_LOCATION just in case. getSSID() is till returning
Perhaps it has to do with compile target SDK? I’m really clueless here. gradle file: apply plugin: ‘com.android.application’
android < compileSdkVersion 28 defaultConfig < applicationId "com.noneofyour.business" minSdkVersion 15 targetSdkVersion 28 versionCode 59 versionName "1.44" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" >buildTypes < release < minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' >> > dependencies < implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:28.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation files('libs/android.jar') >
On Oreo (8.1.0) not getting the correct Wifi SSID. It’s showing though it is connected to a wifi with SSID
I need to check the current connected wifi SSID on android. I checked with Nokia 6 and OnePlus 5 with respectively Oreo 8.1.0 and Oreo 8.0. Other phones with different OS version is working fine with this code. Is there anything wrong with my code?
private WifiInfo wifiInfo; private String ssid = ""; private WifiManager wifiManager; private boolean getWifiStatus() < wifiManager= (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiInfo = wifiManager.getConnectionInfo(); ssid = ""; ssid = wifiInfo.getSSID(); ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isWiFi = false; if(activeNetwork != null)< isWiFi = activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; >Log.d(TAG, "getWifiStatus: " + ssid); if(ssid.contains("TripleMZim") && wifiManager.isWifiEnabled() && isWiFi ) < return true; >else < return false; >>
7 Answers 7
There are different approaches how you can get the WIFI information (such as SSID) in android.
Some of them already listed here, for example WifiManager service.
Is there anything wrong with my code?
No, the problem is not in your code. The main reason for the unexpected behavior, is because of the security patch of the last android releases.
Before the patch (or any device that didn’t get an update), the hackers could steal sensitive information that was leaked through the wifi info.
For example the hackers could obtain the device geolocation, that should be accessible only with the Dangerous Permission LOCATION, that should be requested at runtime and can be revoked at any moment. But in the other hand — the WifiInfo is accessible only with the Normal Permission android.permission.ACCESS_WIFI_STATE which is granted at install time and cannot be revoked. That way, hackers could bypass the permission mechanism and access the data from dangerous permission using only normal permission.
The issue was reported and tracked by CVE-2018-9489 , you can read more about it here: Sensitive information expose via WIFI
So the reason why you having those problems is because now android blocks the sensitive wifi info, unless the app holds the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION .
So, if you request those permissions explicitly (and allowed by the user), your code should work fine.
private static final int LOCATION = 1; protected void onStart() < super.onStart(); //Assume you want to read the SSID when the activity is started tryToReadSSID(); >@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) < if(grantResults[0] == PackageManager.PERMISSION_GRANTED && requestCode == LOCATION)< //User allowed the location and you can read it now tryToReadSSID(); >> private void tryToReadSSID() < //If requested permission isn't Granted yet if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) < //Request permission from user ActivityCompat.requestPermissions(this, new String[], LOCATION); >else/Permission already granted WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if(wifiInfo.getSupplicantState() == SupplicantState.COMPLETED)< String ssid = wifiInfo.getSSID();//Here you can access your SSID System.out.println(ssid); > > >
2BrightSparks Help and Support
When you run SyncBack Touch application on Android for the first time, it will request your permission to use the device’s location. If you do not grant this permission when asked, you will see the message “Connected to WiFi ” on the main screen of SyncBack Touch application when you connect to a WiFi network.
Note the device’s location is only needed to provide information about the WiFi network name at which SyncBack Touch is connected to at that moment. The network name is also needed if the user has enabled network fencing which enables SyncBack Touch to accept connection only in certain networks.
Since Android 8.0, location permission is required to query the active network name as per Google’s Android documentation (https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-permissions)
If you want to grant permission to access your device’s location:
1. Open SyncBack Touch application on the device.
2. Stop the service by sliding the switch to the left.
3. Go to Menu > Settings and then click the Misc. tab.
4. Click the Permissions button and make sure both Location and Storage permissions are enabled.
5. Exit the SyncBack Touch application and start it again.
NOTE: If you are still seeing the message “Connected to WiFi ” after you have checked all of the above then make sure the device’s Location service feature is enabled as it’s required to be enabled for this feature to work.
Did you find it helpful? Yes No
Wifi connected to unknown ssid
Sorry if I sounded grumpy — but I am just frustrated that a no-brainer like moving a small but important software to a new computer takes so much time, complications and is unsuccessful in the end.
When I could not activate mSecure3 I still was trusting it so I purchased the new version — just to meet another dead end.
Of course there is something you could do to help — make it work 😉 — for example add the v3 sync routines as «WIFI Legacy Sync» option.
Mike — mSecure
@Trekky For sure, the mSecure 5 app will not be updated with any Wi-Fi enhancements, as we’re getting ready to release mSecure 6 after the beta testing has finished. I’m not sure if there will be enhancements to the feature in later releases of v6, and I do understand you’re looking for something that wouldn’t be considered an enhancement. For v5 and v5, however, it is an enhancement. The thing is, because I’m not exactly sure if adding the ability to set a port would actually fix the problem, it’s not certain that adding that capability would help.
One of the big problems with Wi-Fi syncing is that it’s an incredibly complicated system, and we rely heavily on the systems built in to the OS. So many of our customers have reported so many different configurations, that it would be next to impossible to make all of them work correctly, not without a dedicated Wi-Fi systems engineer. I’m sure that sounds crazy, but it’s really what we have experienced. We try to keep the Wi-Fi syncing working solidly for the majority use cases, and we believe we achieve that goal. When it deviates much from those use cases, things can get more unstable.
I say all of this to be transparent about how we handle the Wi-Fi syncing. It’s possible the feature will be enhanced in the future, but at this time, I we don’t have active plans for doing so.