I am working on a GPS device (not a phone, no screen ...) with a custom rom. My app is a system app.
NETWORK_PROVIDER is not available, only FUSED_PROVIDER and GPS_PROVIDER are enable. I check with this code :
locationManager.getProvider(LocationManager.FUSED_PROVIDER) != null,
locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null
locationManager.getProvider(LocationManager.GPS_PROVIDER) != null
getAllProviders() return [passive, gps]
If I use LocationManager.GPS_PROVIDER I get the locationbut only outside.
If I use LocationManager.FUSED_PROVIDER I get nothing ...
Off course if I use LocationManager.NETWORK_PROVIDER I get nothing
I have tried with Wifi enable and disable, same result.
I am listening the location like this :
Settings.Secure.putInt(caniGPSApplication.getApplicationContext().getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
locationManager.requestLocationUpdates(LocationManager.FUSED_PROVIDER, GPSTimerMS, 0, this);
I think FUSED_PROVIDER is not working because NETWORK_PROVIDER is not available but I do not really know.
I wish to have NETWORK_PROVIDER because it will help to have a location when GPS is not available. Do you know why NETWORK_PROVIDER is not available ? What should I do to enable it ?
Thank you :)
I have solved the problem.
I have added 3 packages in priv-app :
NetworkLocation.apk (middleware) from https://github.com/microg/UnifiedNlp#usage
org.openbmap_27.apk (provider) from https://github.com/openbmap/radiocells-nlp-android
IchnaeaNlpBackend.apk (provider) from https://github.com/microg/IchnaeaNlpBackend
NetworkLocation.apk is a apps which replace the Google Network provider, this one is only a middleware and need providers to get data (cells database ...).
Off course i am working on a custom rom, I can install apk in priv-app, consequently I have all specifics right necessary to do it.
Related
I've been trying to get mock locations on my OnePlus One working for quite some time now, but I have unfortunately been unable to determine the cause of this. Essentially my issue is that when setting a mock location, they do work, but for some reason my location appears to "teleport" between where I set my mock location and my current location. I've been using Google Maps to test my current location. Following the guidance of this answer, I set my location mode to "Device only", but it appears to still be happening. Furthermore, I turned off WiFi completely, to no avail.
The app I am using to spoof my location is here. I've tried other apps to the same effect. My phone is running the latest CyanogenMod 13 snapshot (20160419).
If anyone would happen to know how to solve this, it would be much appreciated :)
The steps given below worked for my Nexus 6:
(I have assumed that your device is rooted. If not you need to root it first)
Install Xposed framework. You can use the tutorial here.
After Xposed is installed go to its Download section and install the module Mock Mock Locations. Then go to the Modules section in the Xposed app and activate the downloaded plugin(needs restart).
In developer options select the mock location app you are using in Debugging->Select mock location app
Download the app Disable Service. In the app select the System tab search for the service named Fused Location and disable it. Also search for the service group Google Play Services. Inside it there will be another
Fused Location service. You need to disable it too.
If it is still not working try disabling Google Location History as given here. Also set your GPS accuracy to Device Only.
Install Fake GPS Location app in your Android device and set your desired location inside the app. Your device will behave as if it is at the location you have set. Don't forget to select Select mock location app in Developer options in your device Settings.
In case someone has issues with mock location software to get working:
override fun onLocationResult(locationResult: LocationResult) {
var LastLocation: Location = currentLocation
if (LastLocation.longitude > X.XXX && LastLocation.longitude < X.XXX && LastLocation.latitude > X.XXX && LastLocation.latitude < X.XXX) {
LastLocation.latitude += Y.YYY; LastLocation.longitude += Y.YYY
}
X.XXX is a placeholder. Set a bounding box for your ow current location to shift your location to the new destination by changing Y.YYY
With something like this, you could shift your location and simulate hardcoded from your home/office location your desired location.
I've developed an app that receives the location from both GPS_PROVIDER and NETWORK_PROVIDER, however the NETWORK_PROVIDER returns the best values retrieved from WIFI and GPRS, without having any control over it. I need to get the value returned by the GPRS location listener even when you have WIFI active, so I can use it to dismiss the fake locations from other apps.
Is it possible to do this?
At the moment I'm testing this solution Disable / Check for Mock Location (prevent gps spoofing) , I'll let you know if it solves my issue
Unfortunately it is not possible, no.
You can do something like this:
final LocationManager locationManager = getLocationManager();
final List<String> providers = locationManager.getProviders(true);
if (providers.size() > 1) {
providers.remove(LocationManager.NETWORK_PROVIDER);
}
But you don't have the option to distinguish between a cell or a wifi network-provider!
This provider determines location based on availability of cell tower
and WiFi access points. Results are retrieved by means of a network
lookup.
Constant Value: "network"
Source: http://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER
What you can try is to use this solution. However, since this doesn't seem to be documented I'd be careful relying on it because it might break in future OS versions or might not work on every device.
I'm looking for a way to know the country-level location.
How to do it on a phone, or devices that have cellular network connectivity or GPS is clear. But what about devices that don't have that?
I know from Google Analytics that Google has that kind of location information,
How?
How can I get that information as well? Maybe from the play-store locale or something?
By "Tablets" I mean devices that have no GPS and no GSM / cellular network connection.
10x
Use the WiFi aproximated location. It checks your IP adress and tries to locate it geographically.
please see this or this.
a quick summary of the WiFi location method form one of the posted links:
How it works: Unless you opt out, your phone is periodically sending anonymous data to Google with, among other things, your last known location and any Wi-Fi network you were connected to at the time. The accumulated data builds on a database begun by traveling Google Streetview cars that recorded Wi-Fi networks available along their routes (the cars no longer do this).
When using this method, your application will ask for the COARSE LOCATION permission on installation.
Since there's no clear indication (at least none that I've found) whether or not Google estimates location based on IP as a last resort, my 'getCountry' logic would be as follows:
Location location = LocationClient.getLastLocation()
If (location == null) location = getLocationByIp()
where getLocationByIP() will use a publicly available, RESTful free web service such as http://freegeoip.net/
Open to suggestions here. If line 2 is redundant I will be happy to drop it.
Cheers
(Y)
I have written a small app that receives the location from mobile 3g/wifi by using locationManager & NETWORK_PROVIDER parameter.
according to google's api it will get the location i wish (the other option is using the GPS_PROVIDER)
what i really desired was the WIFI location. I wanted to see its behavior and how the phone gets its location (i.e with wireshark)
in order to do that, i changed into flight mode & activated wifi.
then, i launched the app and clicked the button which starts the NETWORK_PROVIDER location service by calling the requestLocationUpdates function with time parameter = 10.
what that actually happened is that i managed to get the location but saw no traffic at all in wireshark.
could it be that Google gives me the approx. location in advance, when connecting to the wifi? (its the only explenation)
If so, is it possible to clear that cache, or whatever data it have stored, and force the phone to get a new (but the same) location?
Thanks in advance,
Eran.
Have you tried re-booting the phone, just so to remove any cache files which might be storing the location?
Since NETWORK_PROVIDER use cell location, wifi ssid and their signal strength to get your GPS coordinates.
Since you are in flight mode and cannot get cell location, just try to switch the connected wifi , maybe google service will be invoked to get new location.
I have an application that uses a Network provider for its location. Every time the apps starts it checks to see whether the Network provider is enabled using isProviderEnabled() method in LocationManager.
If it returns false I present an alert to the user to enable Network Provider and then use the application. This logic had been working really well, with a few exceptions with non-Google certified devices(not a concern since they usually do not have Maps API either). Lately, with some devices on ICS and now on JellyBean emulator, I get a consistent "false" for isProviderEnabled() even though it is enabled.
I have since moved to use the string returned from
Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED)) to see whether it contains "network". It is a hack but it is working for now. I would love to be able to use isProviderEnabled() method.
Has anyone seen this issue before?
#naqi #gkris
I also noticed this issue where isProviderEnabled(LocationManager.GPS_PROVIDER) was returning false.
Solution to this is to also ask user to set the Location Method to High Accuracy instead of Battery Saving or Device Only
This setting is available under location settings and has different name on different devices. On some devices that I have tested on, this setting is with name Mode, Location Mode, Location Method etc Also the value can be High Accuracy or GPS or GPS, Wifi and Mobile Networks
Developers will have to train users on this.
From the API doc for : LocationManager.GPS_PROVIDER
This provider determines location using satellites. Depending on
conditions, this provider may take a while to return a location fix.
Requires the permission ACCESS_FINE_LOCATION.
So if you're not requiring ACCESS_FINE_LOCATION it will return false.