-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Update startGetLocation to only run if location is shared #1942
Conversation
try { | ||
if (!_locationController.start()) { | ||
Logging.warn("LocationManager.startGetLocation: not possible, no location dependency found") | ||
if (isShared) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend returning early instead if isShared
is false
, this keeps the code from getting to nested.
f05027b
to
ec79584
Compare
On every cold start, General question as I am not sure: what is the expected behavior when the app developer wants location to be shared with OneSignal? They must set Also, from our docs: "Whether the location is currently shared with OneSignal. (defaults to true if your app has location permission)" suggests the default is |
@nan-li really good insight! While I did test the scenarios of setting I'm also not sure what the expected behavior for the app developer should be, but it appears that the current behavior is that I'll think about this one some more! |
@nan-li I've pushed two additional commit that account for the following requirements:
Insight appreciated! |
Since isShared now defaults to false, remove early return and add logging to update isShared to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits, but everything looks like they are working as expected!
...ignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/LocationManager.kt
Outdated
Show resolved
Hide resolved
...ignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/LocationManager.kt
Outdated
Show resolved
Hide resolved
...ignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/LocationManager.kt
Outdated
Show resolved
Hide resolved
- Change log to warn vs. error - Access and save to constant PREFS_OS_LOCATION_SHARED
Fix: Update startGetLocation to only run if location is shared
Fix: Update startGetLocation to only run if location is shared
Fix: Update startGetLocation to only run if location is shared
Description
One Line Summary
Update startGetLocation to only run if location is shared
Details
Motivation
In #1910 it was reported that when
OneSignal.Location.setShared(false)
but location permission is granted through a custom UI, OneSignal is still accessing and recording the device's location. Adding a conditional beforestartGetLocation
to check whetherisShared
is true will prevent OneSignal from accessing the device's location whensetShared
is false.Testing
Manual testing
The following steps were followed on and Android 14 emulator to recreate and test the fix:
OneSignal.Location.setShared(false)
startGetLocation
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is