Skip to content
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

Add allow-mock-accuracy for non-default geopoint and geoshape/geotrace #4857

Merged
merged 44 commits into from
Oct 22, 2021

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Oct 13, 2021

Closes #4768
Blocked by #4842

Every kind of geo/location widget should now support allow-mock-accuracy. Again, the refactor here (moving the geo code to geo) is nice and gradual so going through commit by commit is a good idea.

What has been done to verify that this works as intended?

New tests.

Why is this the best possible solution? Were any other approaches considered?

This takes the same approach as the last PR so not a lot to discuss here. This time most of the work is focused on moving GeoPointMapActivity and then adding support for the allow-mock-accuracy param in the same way we did for GeoPointActivity.

It's feeling to me like there's probably a maps module to be extracted at some point that contains the MapFragment, MapPoint and the providers/implementations (or possibly multiple modules for different implementations). That feels like an extra step we could take next time we're playing around in this area however.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Good to check the map appearances of geopoint with the different map providers - Mapbox should require special attention because it uses a different code path for grabbing the device's location. geoshape and geotrace need checked as well.

Do we need any specific form for testing your changes? If so, please attach one.

The form used in the previous PR is a good starting point. Testing the specific support in this PR can be done by adding the map appearances to the form.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@seadowg seadowg changed the title Add allow-mock-accuracy for geopoint with maps and placement-map appearances Add allow-mock-accuracy for non-default geopoint and geoshape/geotrace Oct 14, 2021
@seadowg seadowg force-pushed the external-gps-2 branch 2 times, most recently from eea0b73 to 1d0afa7 Compare October 19, 2021 09:27
@seadowg seadowg removed the blocked label Oct 19, 2021
@seadowg seadowg marked this pull request as ready for review October 19, 2021 10:08
@seadowg seadowg requested a review from grzesiek2010 October 19, 2021 10:08
@@ -70,8 +68,16 @@
public static final String LOCATION_STATUS_VISIBILITY_KEY = "location_status_visibility";
public static final String LOCATION_INFO_VISIBILITY_KEY = "location_info_visibility";

public static final String EXTRA_LOCATION = "gp";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you didn't move this one to geo/Constants.kt too like EXTRA_READ_ONLY and EXTRA_DRAGGABLE_ONLY?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is only relevant to GeoPointMapActivity. I tried to keep it so Constants was only defining the shared ones.

tools:replace="android:theme"/>
<activity android:name=".activities.GeoPointMapActivity" />
<activity android:name=".activities.GeoPolyActivity" />
tools:replace="android:theme" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's need so that the build tools now which android:theme to use. Otherwise, there is a conflict between the geo and the collect_app manifests.

internal object GeoActivityUtils {

@JvmStatic
fun requireLocationPermissions(activity: Activity) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we check this in the Activity and in ActivityGeoDataRequester. However, I don't want to get into untangling the interaction with WaitingForDataRegistry here to make sure that it's safe to just check this in the Activity.

/**
* Should use {@link org.odk.collect.android.externaldata.ExternalAppsUtils} instead
*/
@Deprecated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to add the work/risk of replacing current usages of ANSWER_KEY in this PR but also wanted to make it clear we have a better option now.

@kkrawczyk123
Copy link
Contributor

@seadowg I can see a problem with the display of Google Maps when using all Geo widgets (point, trace, shape) on all of my devices. It loads properly for display points on map. Issue does not occur for Mapbox and OSM. See gif:
ezgif com-gif-maker (7)

The issue does not occur on master.

@seadowg
Copy link
Member Author

seadowg commented Oct 21, 2021

@kkrawczyk123 I'll look into that

@seadowg
Copy link
Member Author

seadowg commented Oct 21, 2021

@kkrawczyk123 fixed!

@grzesiek2010 it looks like the MapProvider needs to be a singleton. I've noted this on the class now to hopefully avoid the same mistake being made again, but you might want to take a look and see if there's anything you think we need to address there.

@kkrawczyk123
Copy link
Contributor

@seadowg I have tried that form https://test.getodk.cloud/#/projects/308/forms/external_device_geopoint/versions with Fake GPS app and my understanding is that fake location should be used only in the first question where mock accuracy=true but I can see that it is used also in the second question where mock accuracy=false. Is it an issue or did I misunderstand something?

@seadowg
Copy link
Member Author

seadowg commented Oct 21, 2021

@kkrawczyk123 the fake location will still be used, but its accuracy should be zero when allow-mock-accuracy is false (or absent). Is that not what you're seeing? The idea is just to remove accuracy from fake locations but allow people that have to use fake locations to be able to keep it if they trust it.

@kkrawczyk123
Copy link
Contributor

@seadowg I can see accuracy 0 for both when allow-mock-accuracy is true and false:

Screenshot (Oct 22, 2021 9_13_45 AM) Screenshot (Oct 22, 2021 9_13_54 AM)

I assumed that there should be a difference but maybe I am wrong.

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

@kkrawczyk123 is this for all the geo widgets or just one of them? I'll check this out my side as well as it sounds like something it wrong.

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

@kkrawczyk123 I'm seeing the correct behaviour using mock the GPS Connector app in simulation mode for geopoint (and maps appearances) and geotrace - I get points with 0 accuracy when allow-mock-accuracy is false and non zero when it's true.

Are you potentially testing with manual placement (moving the map to somewhere and then placing a point)? This always results in zero accuracy as the location doesn't come from gps.

@kkrawczyk123
Copy link
Contributor

@seadowg I agree that accuracy difference is visible between both questions for geopoint with map view, geotrace and geoshape widgets but my question was about geopoint without map view - exact form that was attached in PR.

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

@kkrawczyk123 yeah I'm using that as well and still getting accuracy in the "Location (allows mock)" question. Is that happening every time? And it doesn't happen for the other geo widgets? What app are you using to fake the location? I'm wondering if the app is maybe giving you zero accuracy - I just got a 0.01m out of the simulation in the one I was using.

@kkrawczyk123
Copy link
Contributor

@seadowg I can see accuracy 0 for both questions. It is happening every time for me. @mmarciniak90 Are you seeing the same thing on your devices? I am using the same app "Fake GPS" for that widget and others and there is a difference as I mentioned above it works for widgets with map view. I have set accuracy in the app to be different than 0 - I have 1 on one device and 20 on another and the same results - accuracy 0 for questions with and without allow-mock accuracy when filling a form.

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

@kkrawczyk123 could link me to the exact app?

@kkrawczyk123
Copy link
Contributor

sure, https://play.google.com/store/apps/details?id=com.lexa.fakegps&hl=en&gl=US

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

@kkrawczyk123 I get accuracy with that app. Changing its "Accuracy" setting is reflected in Collect as well (although never exactly for some reason, but that could be the app).

@mmarciniak90
Copy link
Contributor

Are you seeing the same thing on your devices?

Unfortunately, I have the same result. I also use the same app to generate fake GPS.

@kkrawczyk123
Copy link
Contributor

@seadowg That's weird. What app have you been using before? We could try with it

@seadowg
Copy link
Member Author

seadowg commented Oct 22, 2021

Ok turns out I'd got myself confused about the release state of the allow-mock-accuracy changes in pyxform. It's out on https://getodk.org/xlsform/ but not released for Central yet. My bad! I've shared a form created with the newest pyxform with QA for them to test with.

@kkrawczyk123
Copy link
Contributor

Finally tested with success!
Verified on Androids 5.1 and 11.

Verified cases:

regression checks on:

  • Geo widgets with/without map
  • GeoTrace, GeoShape widgets
  • placement by tapping, manual mode, automatic mode
  • display submissions on map
  • submissions with different statuses
  • Google maps
  • OSM
  • Mapbox
  • offline layers
  • light mode, dark mode
  • Audit location in the background
  • screen rotation
  • minimize app

@mmarciniak90
Copy link
Contributor

Tested with success on Android 8.1, 9.0, 10.0

@grzesiek2010 grzesiek2010 merged commit 2aa071a into getodk:master Oct 22, 2021
@seadowg seadowg deleted the external-gps-2 branch October 22, 2021 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a path for external gps sensors to report accuracy
4 participants