Disabling Location permission on Android 6 seems to affect WiFi parameter queries - android

I have an Android application that accesses the device's location and then queries the WiFi parameters. Everything typically runs smoothly.
If I turn off the Location permission for the app (as I can do in Android 6) I no longer get the device's location (as is expected). However, I also get a modified WiFiInfo object when I try to query the WiFi parameters. In particular:
getScanResults() normally lists all of the networks available, but with Location turned off it only contains the network the device is connected to.
If I look at the capabilities of the network that is found, the string is empty. Normally it contains information such as the wireless encryption information.
Has anyone else seen this? I've verified it using the same code with the Location permission turned on/off on 2 different devices. Any idea on what's happening?
Update: On further review, I was wrong when I said that getScanResults() returns information about the AP that the device us connected to. It in fact returns an empty list. This would support the idea that Google doesn't want us to have any information about the local APs if Location permission is denied.

WiFi-based location is basically a lookup of WiFi access point information in a giant database of known APs and locations to discover where a device is. This is what services such as Google, SkyHook, and Apple use when you enable WiFi or network location.
I suspect Google is trying to prevent an application from accessing information from which location can be derived when location is disabled. They have previously blocked access to Google Play location services when location is disabled, but this does not prevent a device from doing a scan, collecting the same data that would be sent to Google, and sending this data to a different service to discover location.

Related

Getting WIFI SSID in Android 8.1 without GPS

I need to find the SSID of the current connected method. I've read this already, but it uses GPS, which I don't want to. Is there a way I can achieve that?
as far as I know, there is no workaround or trick to achieve this, except rooting the user's device or using a far outdated targetSDKversion.
The main point is to understand why Android requires this permission and for this you have to see it from the end users point of view: an App who can scan for all SSIDs available on the current location of the device can use this scanresults (SSID + BSSID) in combination with online services like https://wigle.net/ to determine the users location with +-100m precision. That's why the user has to give the location-permission when your app simply wants to scan for SSIDs.
Another question is whether Google uses the position determined by GPS together with the scan results to fill and maintain its own Wifi location database.

Google maps Android API getting wifi location

So I am working on this app that will get the location of a wifi hotspot by just detecting it using the sensor wifi of the phone (The phone is not actually connecting to the hotspot wifi, it just detect).
I was doing some preliminary research before start developing the app, and it seems that the Google Geolocation API will do the work for me. However, it is not free (at least what I understood after reading through the API). I had checked other apps that detects wifi hotspot, and I am just wondering if those apps have their own database with all the wifi hotspot information (SSID, location coordinates, etc) so when the wifi sensor detects a wifi hotspot, it will lookup the database and get the information such as location.
Also, I was mentioned by a colleague that Google Maps also stores wifi info. Is is true? Cause I couldn't find any info about that.
Android has multiple LocationProviders, including:
LocationManager.GPS_PROVIDER : get position using GPS
LocationManager.NETWORK_PROVIDER : get position using Wifi, cell network, etc.
LocationManager.PASSIVE_PROVIDER: get position using data provided by already running providers. This allows several apps to share geolocation information)
You don't have to pay anything to use NETWORK_PROVIDER
Some providers might not be present on all devices, depending on phone model and android version.
Providers have different characteristics: NETWORK is fast but not always precise enough, GPS is precise but slow and battery intensive, etc. The best strategy is to request location from several providers, and cancel pending request as soon as you get a location that is good enough depending on your criteria (precision, response time, etc.)
I found this article by Reto Meier quite useful to wrap my head around geolocation on Android

Is android application able to retrieve location info from connected WiFi hotspot AP?

Wanted to know how Lat/Long info will be retrieved for specific location where my mobile device is connected to one of the public WiFi hotspot AP. So, my program gets the data and pass on to find location info to originate E911 calls or sending location info for any calls made?
if this possible, let us know how this can be done? are there any specific Android APIs to do so? Please provide the details if possible.
You can't get location direction from WiFi hotspot (actually WiFi spot itself doesn't know where it's located).
However, there are databases which contains mapping between WiFi hotspot MAC address and locations. So, your application should get info about WiFi hotspot and after go to one of this databases.
As example, check this out:
http://en.wikipedia.org/wiki/Skyhook_Wireless
Location can be retrieved using various ways in android from GPS or from your internet access ( whether its wifi or 3G) the great thing is that in android the last location that was retrieved from any application on the device will be saved and you can actually compare your currently retrieved location with the previous to see if its better or more accurate.
Here is a link that can let you understand better how location works with android.

Does the phone need to be connected to the internet so that the network provider can determine a location?

Does the phone need to be connected to the internet all the time, so that the network provider can determine a location?
When I test my app on my phone, and in Settings->Location only Use wireless network is checked, and I am not connected to the internet via Wi-Fi, I can not get a location fix.
I know there was something that the network provider uses availability of cell tower, but I don't know how that works exactly and should I have full internet access.
Please someone make this clear for me.
Yes, you need to be connected to the Internet in order to get correct network location fixes. At least most of the time.
The phone collects the following data (it does not need a connection to the Internet to do this):
nearby wifi information by scanning for wifi access points
nearby mobile cell information is available from the phone's cellular radio
The phone then sends this data to a server. The server uses this data to look in its database to determine the phone's most likely position. The server sends the location information back to the phone. This is all done using data connection via Internet (either mobile Internet or wifi).
Some implementations additionally download a small amount of the server's database to the phone (describing a small area around the phone's current position) so that the phone doesn't have to query the Internet all the time. However, once the phone has moved outside of this small area it will need to access the Internet to get correct locations again.
So, basically, without Internet connectivity you can't (reliably) use network location.
I would expect network location to work differently depending on the carrier. It will need connection to the network, and really I wouldn't be surprised if that's classified as a data connection.
You can figure it out yourself through experimenting, but that's probably what prompted the question.
To get a definitive answer you'd probably have to talk to someone from the carrier. If they have a developer program that'd be your best bet.
I hope that helps.

Get location of wifi ip in android

Would it be possible to take the ip address of a wireless router that an android phone would connect to and determine in the app the relative location of the ip?
There's lots of online APIs available to determine a location based on an IP address, e.g. here, here, or here.
You could make a request to one of those services, passing in the appropriate "Internet-facing" IP address (which is different than the internal IP address that usually starts with 192.168., see here for an explanation).
If your goal is to get the user's location, use Android location services. if your app has requested it and the user hasn't disabled wireless location services, it will use WiFi as well cellular networks. It's already packaged right into the SDK and convenient to use.
It might not be a nice thing to go behind the user's back with other methods and get their location without requesting a permission to do so. If you need their location, you might as well go through the approved mechanism.

Categories

Resources