Geolocation API With "mock location" GPS provider selected in Developer Options
Reported by
jeastman...@gmail.com,
May 5 2017
|
||||||||||||
Issue descriptionSteps to reproduce the problem: 1. Acquire an external GPS unit with Bluetooth capabilities. In my example I am using a Trimble R1 unit. 2. Download the accompanying app for the GPS unit. In my example I am using the GNSS Status app that is provided by Trimble for this unit. 3. Enable mock locations and set the GNSS Status app as the mock location app. 4. Find a site that will provide you with the accuracy of the gps coordinates being provided by the unit. In my case I'm displaying the accuracy from the Geolocation API on my site. 5. Geolocation API is returning an accuracy of around 19meters while I'm receiving an accuracy of less than 1 meter from the Trimble R1 unit. 6. Once an external device is connected via bluetooth, and the app set as the mock location app, Chrome stops grabbing high precision data from the GPS. What is the expected behavior? In other browsers the correct accuracy is being shown on my website and the data is received from the external GPS. I would expect Chrome to also be able to access the data provided from the external GPS unit using mock locations. What went wrong? Chrome appears to stop receiving high accuracy GPS coordinates and resorts to triangulation/wifi to provide the location information instead. Did this work before? No Does this work in other browsers? Yes Chrome version: 58.0.3029.83 Channel: stable OS Version: 6.0.1 Flash Version: I've attached 3 screenshots from my phone. One showing the accuracy being received by the GPS in the GNSS Status App, One showing the accuracy returned from the Geolocation API in Chrome and another showing the accuracy returned from the Geolocation API in Mozilla
,
May 12 2017
+benwells@ for his opinion.
,
May 12 2017
That's correct. I'm setting the mock location app in the developer options menu as you stated. In regards to the second more. I don't have access to the code for the GNSS Status app because it's provided by a third party. However, they must have access mock locations in their manifest, as you've stated, because I'm able to access the mock location data in other browsers. I greatly appreciate the response and help!
,
May 16 2017
+dougt who's team is taking over geolocation API. I'm unfamiliar with mock location providers and am still confused by step 3. Do you mean you updated the chrome manifest and rebuilt chrome?
,
May 16 2017
Sorry for the confusion. I have not touched the chrome manifest. I attached an image showing the mock location setting in developer options. I just set the GNSS Status App as the mock location provider so it should override the onboard GPS on my phone.
,
May 16 2017
Is this as simple as Chrome not having the allow_mock_location permission in the manifest?
,
May 17 2017
#6: I believe allowing the mock locations and rebuilding might do the trick. Would you like to try locally? (instructions here : https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md benwells@ the question is if we are not allowing <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> for any particular reason, be that security or otherwise. This permission will allow power users to fake their GPS location.
,
May 17 2017
I will give this a try hopefully in the next few days. I'm trying to think of a security issue or some other reason this wouldn't be allowed. But I'm not sure I can think of any real concerns that would come from allowing this. Interested to hear the thoughts on this. Thanks again!
,
May 18 2017
I can't think of any reason not to allow it.
,
May 20 2017
jeastmancee@gmail.com have you had a chance to try out #7 ?
,
May 20 2017
,
May 23 2017
Sorry, I have not had a chance to try this yet. I still am hoping to get to this asap.
,
May 23 2017
I'm hoping this won't be above my head. But at which point in these steps to rebuild chrome am I able to modify the manifest to include the mock location permission?
,
May 23 2017
#13: I think it'd be as simple as adding the mock permission <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> to the vicinity of [1], then recompiling the chrome_public_apk target, installing it on your device (it'll show as a "Chromium" app) and giving it a go with a Fake position provider. https://cs.chromium.org/chromium/src/chrome/android/java/AndroidManifest.xml?type=cs&l=23
,
May 23 2017
You rock, thanks! That's the info I needed. I'll report back soon with the findings.
,
May 31 2017
Any luck jeastmancee@ ?
,
Jun 1 2017
Sorry, I was out on vacation so haven't gotten to it just yet. But I'm back, I will 100% attempt this before the weekend is over.
,
Jun 5 2017
Is there any possible way that someone can compile this and share the files after? I've been so short on time I haven't been able to find the time to put it together myself. It would be a huge help!
,
Jun 23 2017
To my understanding the permission "android.permission.ACCESS_MOCK_LOCATION" allows an app to *set* mock locations. This issue however deals with the fact that Chrome does always read and return the device's real location despite a mock location app has been selected in Android's debug menu. Other android apps including Google Maps would display the mock location instead if one is defined. But opening Google Maps inside Chrome would display the real location. Therefore I suspect that Chrome uses another mechanism to acquire the current geolocation as opposed to the Android APOs LocationManager / LocationListener. In fact the issue can be reproduced without external device but using any mock location app from the Store such as 'Fake GPS'.
,
Sep 13 2017
,
Sep 13 2017
Since 2017-04-20 Chrome has used the Fused Location Provider API (https://developers.google.com/location-context/fused-location-provider/) to get the best possible location data on Android when Google Play Services is available. To provide a mock location to applications using this API the application must have the ACCESS_MOCK_LOCATION permission and call FusedLocationProviderApi.setMockLocation().
,
Sep 13 2017
,
Sep 22 2017
,
Sep 22 2017
,
Nov 15 2017
I am having a similar issue with using the Trimble GNSS Status App, Trimble R1, and a mapping web app using chrome on my laptop. I have the latest version of Chrome and the accuracy reported on the GNSS Status app is not reported correctly in the web app. Is there something in the desktop version of Chrome that I need to switch off or is there some code I need to edit to get the accuracy to report properly in my web app?
,
Nov 16 2017
So am I understanding correctly that the problem may be the Trimble app if the app does not include FusedLocationProviderApi.setMockLocation()?
,
Nov 16 2017
Am I also understanding correctly that when I call the HTML5 geolocation api, in chrome, Chrome uses the fused location provider api to provide the location information?
,
Nov 16 2017
I have spoken to Trimble about the GNSS Status app. I was told that the latest version, GNSS Status 3.0.0, works with IE, MS Edge, and Firefox. The issues it has with Chrome does not stem from the GNSS Status app, but from Chrome. Something in the api. I was hoping that is would be an easy fix, such as toggling a button or something.
,
Nov 16 2017
I'm also in the process of talking with Trimble, so I appreciate the update. I'm still leaning towards what reillyg@chromium.org (comment 21) said. I believe it is due to chrome using the fused location API. However, it sounds like the GNSS Status app has to make a call to that API as that comment stated in order for Chrome to be able to access the information.
,
Nov 16 2017
#29 - Internet Explorer does not exist on Android. Edge exists, but it uses Chromium behind the scenes, so it, in theory, should have the same bug. Firefox is indeed Firefox. Sounds like you are talking about desktop. Desktop and Android are probably implemented very differently, so it does not mean much.
,
Nov 16 2017
Well here is another question for you. Is the fused location API used in Chrome for Android or both Android and Windows 10? From what it sounds in comment 21, the fused location API seems to be for Android. Hopefully the devs will see this and make it known whether or not the fused location API is for Chrome on Android and Windows. Also mention if they have made any progress in coming up with a solution to Chrome not talking to GNSS Status since you, jeastman, brought this subject up.
,
Nov 16 2017
I can verify that Firefox for android does work correctly with receiving the GPS location information from the GNSS Status App. I included a picture in the original post that shows this working.
,
Nov 16 2017
I'm doing some research to try to answer that question. It's proving difficult but I haven't given up yet. I will definitely bring that up to them in my discussion. I've mentioned the fused location API to them. Just waiting on a response right now. I've also directed them to this discussion so they can see what the devs have to say.
,
Nov 16 2017
#32 - This issue only discusses the Chrome for Android/Chromium for Android bug (it says on the left, "OS: Android"). I imagine the Windows API (if any) is completely different and unrelated here.
,
Nov 16 2017
The more research I'm doing the more I'm still leaning towards the fused location provider API being the issue. https://developers.google.com/android/guides/setup The GNSS Status app should list the following API reference com.google.android.gms:play-services-location:11.6.0 The document here (https://developer.android.com/training/location/index.html) states that " If you are currently using the Android framework location APIs, you are strongly encouraged to switch to the Google Play services location APIs as soon as possible." Maybe I'm completely off target here.
,
Nov 17 2017
Here is the response I got from Trimble: "The real problem here is not with GNSS Status. The issue is that under the hood, Chrome uses Wi-Fi positioning and reverse IP lookup to determine the user's location. Other browsers (as you point out), don't have this issue, and properly query the operating system and location manager for the current location (which in this case is getting it's data from GNSS Status). All of the research we've done points to the "problem" being contained in the black-box of Chrome. Compiling a custom version of Chrome for Android is not really a long-term solution and should be used as a workround only. The same issue exists on the desktop with Chrome. Other browsers, such as IE, Edge, and Firefox all work as one would expect, but Chrome is the odd man out here. Unfortunately this will have to be worked through with the team behind Google/Chrome. We can't help here." Doesn't sound like there is anything they can do on their end. What I've ended up doing is using Phonegap to turn my web app into a native app. As much as I wanted to avoid that, it appears to be my only solution. I've got the app running I just need to go grab another R1 unit to test it with.
,
Nov 18 2017
So interesting development. I went and borrowed another R1 unit to do some testing. And suddenly, it works in Chrome! I recently updated my phone and the external GPS is now working in Chrome. I'm currently running Chrome 62.0.3202.84 and Android 7.0. Interestingly it does not work in the application created through Phonegap. At this point I'm ok with it working in Chrome as I can make it a progressive web app and add to home screen so it acts just like a native app. What in the most recent update caused this to start working?
,
Nov 21 2017
To add on to jeastman's comment, if there has been a fix for Chrome on Android to work with external GPS receivers, does that mean there will be a fix across the board for all version of Chrome, including Chrome for Windows?
,
Dec 1 2017
Cross-reference: https://bugs.chromium.org/p/chromium/issues/detail?id=737327#c7. Additional background info: WRT the cross-referenced issue, this functionality when used with the GNSS Status app seems to work intermittently on Chrome Android. We do know with 100% certainty this functionality was working in 2016 because we were using it in the field. For now, in order for us to insure application stability we are using Cordova in conjunction with an advanced native plugin (https://github.com/Esri/cordova-plugin-advanced-geolocation)
,
Dec 3
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 5
I will be contacting Trimble to make sure that their application using the FusedLocationProviderApi.setMockLocation() API to correctly set the mock location for applications using FusedLocationProviderApi.
,
Dec 5
|
||||||||||||
►
Sign in to add a comment |
||||||||||||
Comment 1 by mcasas@chromium.org
, May 12 2017