is there a way I can find information about my device's connectivity to WiFi network? I need information like: what network I'm connected too, what is the mac address of the router, how long have I been connected, when was the initial connection.
I tried looking in proc/net
, but I didn't find any useful information there? Is there any other place I can look in?
1 Answer
You can use various Wifi/network analysis apps from Play Store to get some of the information you're looking for. I suggest IP Tools. In its default screen/view, you would get to see following information et al:
- SSID
- Internal IP
- Your Android device's MAC address
- Gateway
- DNS
- Frequency
- BSSID (your router's MAC address)
- Lease duration
If you need more information, you'd need to setup adb and issue this command:
adb shell dumpsys wifi
It would throw incredible amount of information, most of it incomprehensible for an end-user. However, it would show even such information not available to apps, such as, when was the device last connected or disconnected from a Wi-Fi.
In my Android 8.1.0 (OnePlus 6), I get to see this information et al:
WifiMetrics: mConnectionEvents: startTime=12-23 21:36:05.762, SSID="Connected, no internet", BSSID=ROUTER'S_MAC_ADDRESS, durationMillis=1530, roamType=ROAM_UNRELATED, connectionResult= 1, level2FailureCode=NONE, connectivityLevelFailureCode=NONE, signalStrength=-34, wifiState=WIFI_DISCONNECTED, screenOn=true. mRouterFingerprint: mCo nnectionEvent.roamType=0, mChannelInfo=2412, mDtim=0, mAuthentication=2, mHidden=false, mRouterTechnology=4, mSupportsIpv6=false startTime=12-23 22:32:56.874, SSID="Connected, no internet", BSSID=ROUTER'S_MAC_ADDRESS, durationMillis=1541, roamType=ROAM_UNRELATED, connectionResult= 1, level2FailureCode=NONE, connectivityLevelFailureCode=NONE, signalStrength=-28, wifiState=WIFI_DISCONNECTED, screenOn=true. mRouterFingerprint: mCo nnectionEvent.roamType=0, mChannelInfo=2412, mDtim=0, mAuthentication=2, mHidden=false, mRouterTechnology=4, mSupportsIpv6=false startTime=12-23 22:36:49.886, SSID="Connected, no internet", BSSID=ROUTER'S_MAC_ADDRESS, durationMillis=1542, roamType=ROAM_UNRELATED, connectionResult= 1, level2FailureCode=NONE, connectivityLevelFailureCode=NONE, signalStrength=-28, wifiState=WIFI_DISCONNECTED, screenOn=true. mRouterFingerprint: mCo nnectionEvent.roamType=0, mChannelInfo=2412, mDtim=0, mAuthentication=2, mHidden=false, mRouterTechnology=4, mSupportsIpv6=false
The aforesaid information tells me the last three times (because I restarted my device earlier, so not much of earlier information available) my device connected to a Wi-Fi.
If you look into the log entries under Dump of WifiConnectivityManager you would get to know more info on when the device was disconnected and then connected.
Moreover, the dump output also has all the information I listed above for IP Tools app. It is only a matter of filtering the important information out of that dump.
-
1Thanks for the reply? Is it possible running dumpsys wifi, using Java RunTime, I want to process that information and show connection time to the user.– KeselmeCommented Dec 23, 2018 at 17:31
-