Android app only updating location when other apps using location on Marshmallow - android

So I have an app that works flawlessly on many devices. The problem is on one specific phone with Android 6.
The location for our app only works when another app uses the GPS.
For example, starting our app, the GPS icon starts as if the GPS was active but location updates on the app do not appear or refresh. Then, we start Google Maps and only then locations on our app start getting refreshed. As soon as we close Google Maps, our locations stop being received.
I actually tested the app on another phone with Android 6 with no problems.
I think there might be some kind of issue with Google Play Services or with the new the permissions schema. Or maybe with BroadcastReceiver receiving the position updates.
Key information:
Our app es compiled for SDK 22 with Google API.
Google Play Services version on the phone with the issue is 8.4.92
The app uses this version of play services:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-location:7.+'
compile 'com.google.android.gms:play-services-maps:7.+'
compile 'com.google.android.gms:play-services-gcm:7.+'
All permissions are activated for our app on that phone.
The phone with the problem was working fine before it got updated to Android 6.0
We tested on another device with Android 6.0 and had no issues.
The phone is in a client in another continent so we don't have access to debugging or logs. No errors occur though because we would receive those on Fabric.io.
We use a Broadcast to dispatch new positions to a service and an activity so the problem might be there.
Im running out of options and tests.
Any ideas?
Thanks,
EDIT
The problem is that on that version of Android, getSpeed from Location is always 0.0, unless another app is using the location, then we get updates with the speed included.
This really sounds like a bug. Why would legacy apps not get the speed in the location? Assuming its because we use API 22.
On a side note, we use speed to filter out positions and stop updating location when the phone is standing still. Thats why we did not see location updates.
I guess we will have to calculate our own speed.

Related

How to create automotive application to trigger notifation for overspeed in android studio

I want to create first application to listen car speed without open this application.
It is possible to monitor car speed in background
To listen to Car speed you need to create an object of CarPropertyManager and register for change in Car Speed Property value.(PERF_VEHICLE_SPEED) using method registerCallback() present in CarPropertyManager
registerCallback() method requires a Callback in which to receive speed updates, proprty id of Speed(Constant Value: 291504647 (0x11600207) which is mentioned for PERF_VEHICLE_SPEED in above mentioned link) and rate at which to receive these updates.
Put all code in a service to receive updates in the background.
You can find samples for the Android Automotive application at https://android.googlesource.com/platform/packages/services/Car/+/master/tests/EmbeddedKitchenSinkApp
I have tested sample apk with automotive emulator.
My apk contains some services to run some code on background.
when my app is open in emulator, services are running successfully. But I try to minimize the app services are stopped automatically.
there any restrictions in automotive os or we need to follow any procedure to use services in our app.

Missing Google Services permissions in logcat

We have a weather app for Android that also provides a widget.
The widget displays the current time and weather for the current user location.
We update the widget clock every minute (via AlarmManager) if the display is active, the weather data at longer intervals. Sometimes the widget "freezes". We were able to track that down to the alarm for the next check not being set but don't have a clue why, yet.
Now we noticed the following warning in the device logs of an affected device:
03-12 10:15:44.803 771 4958 W ActivityManager: Permission Denial: opening provider com.google.android.gsf.gservices.GservicesProvider from ProcessRecord{41a4d028 25012:com.my.app/u0a88} (pid=25012, uid=10088) requires com.google.android.providers.gsf.permission.READ_GSERVICES or com.google.android.providers.gsf.permission.WRITE_GSERVICES
This starts to appear exactly at the time where the clock should have been updated. The message is then repeated several times until the ActivityManager terminates the process.
We use the Google Play Location Services to get the current (or last known) location of the user. I found references to a bug in version 4.2 of the services (here and https://stackoverflow.com/questions/22682538/when-to-use-read-gservices-permission) that could cause this error, but the device has version 6.7.76 installed.
One more thing to consider is that the device is running Cyanogenmod, though the stuck widget problem also happens on devices with "regular" Android.
Any hints what could cause this permission error are very much appreciated. Thanks!
Edit: The widget and app work fine on that and many other devices until the warning appears. Also the Google documentation is not mentioning that you need to get those permissions. In fact the only mention of those is here in this document according to the on site search, but no mention of READ_GSERVICES on the page itself.
The two permissions it is asking for:
<uses-permission android:name="com.google.android.providers.gsf.permisson.READ_GSERVICES"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.WRITE_GSERVICES"/>
Something to remember just because this issue was reported in Google Play Location Services in 4.2 does not mean it has been fixed. It may be worth looking through the Google bug reported to see if anyone has any issues. I found a few issues raised running much newer Google Play Services.
Upon doing a quick Google search myself it seems like the major problem phones are the Moto X and the Nexus 5. Which is rather interesting as they are both Android Open Source Project bugs (i.e phones running stock Android with no skin!)
Just a few questions:
Can you confirm what phone you have and which version of Android you
are running please?
Also what is your target SDK?
What version of play services are included in your APK?

Location request with/out play services

At first I made a location request app without the play services package. The APK weighed 357kb. At first the location was OK but suddenly it started to be inaccurate and on a different device I got a lot of "service not available" error for the geocoder.
I started reading about it and got to the point where I changed everything to work with the play services mechanism. It's still giving me the inaccurate address (I wish I knew why) and I still didn't work with the other device to see if the "service not available" problem happens there but the APK now weighs 1.7mb! for the same exact thing!
Is there any benefit for using the play services mechanism for the location request?
Thanks!
the major benefit is that you dont have to manage all the different location providers it is done for you

Android Force Location of Apps

I work in QA for an company that helps market applications. Currently I have been tasked to ensure location dependent apps function if correctly (ie if im in russia the app displays the russian content and if i change to us the app updates to the us content)
I have tried numerous items to accomplish this but get no where.
What i have tried:
Proxy. Setting this up via wifi to several locations. Both the app and the device still show my current location.
Apps: I have tried all of the following apps and they all give the same result as above.
Fake Location
AutoProxy
Fake GPS
I have enabled developer mode on the devices, and have ensured that "Mock Locations" is checked.
Use case 1:
A developer whats us to test his app which is only available in england. Google Play still sees me in US
Use case 2:
A developer releases a game where the background changes based on your location if i cant force the location change I cant verify this feature works.
Im guessing the fails so far are due to the fact that the location being called in our test apps is network location not GPS?
Any help would be awesome. Even if you could just point me in a direction.
Thank you Greatly
J
Update:
Ok, Thanks to the answers about google play and mock locations. So with those in mind lets think about it from another perspective. If the app is not calling for mock location, Is there anyway to force a mock location override? im trying to cover all the bases here, One app for sure does not use this method, so I still need to find a way around.
depending on how they are calling for the location, I would think (remember im knew here) that using a proxy would work, however as stated above, i'm not getting anywhere there either. Did try a few free proxy's from hidemyass but even the browser wouldn't work with them.
Yes, network location does not get faked by mock location providers. I don't know why not, but it only fakes GPS. In addition, your app has to request the MOCK permission to get it. If it doesn't have this permission, setting a mock location will not actually fake anything to the app. This is for security purposes, so a malicious app can't start broadcasting the wrong location to the phone.

Activity Recognition Api Not working in some devices

Does the location access have any dependency on activity recognition process?
In some devices i could get my activity recognition sample working only after turning on my location setting
This issue is fixed in latest update of Google Play services(4.3.23 (1069729-030)). All we need to do is replace library project "google-play-services_lib" with latest version(4.3.23 (1069729-030)). I noticed a delay of about 1 minute in AR updates if we toggle location settings, but it works.
The Activity Recognition is part of the Google Play Location API. See the docs here:
Recognizing the User's Current Activity
You can see that this is part of the Location Services offered by Play. Internally there needs to be some way to determine the speed of movement of the device - and that requires location based calculations.
Below is an extract from the Class Overview paragraph of the ActivityRecognitionClient documentation:
It only makes use of low power sensors in order to keep the power usage to a minimum.
This suggests (as the OP pointed out) that the API relies on network location, and not GPS location.
So it would make sense from a security aspect.
If I, as a user, decide I don't want to let any apps see or use my location, then I would expect the Play API to obey that decision.
Anything else, and the security is lost.

Categories

Resources