Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

Product Description

Passing GPS coordinate in the start configuration call
https://dimagi.atlassian.net/browse/CCCT-1081

Taking reference from the GeoPointActivity

Technical Summary

Feature Flag

Safety Assurance

Safety story

Automated test coverage

QA Plan

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

OrangeAndGreen and others added 30 commits March 14, 2025 11:45
Fix sync buttons in learn and delivery progress pages
Fixed a bad translation (across languages) involving malformed escape XML.
…re-android into connect_qa

Removed a stale (empty) override function in SqlStorage.
… into dv/token_exceptions

Resolved conflicts in ApiConnectId and ConnectSsoHelper.
Handling thrown token exceptions throughout the code and reporting to UI where appropriate.
Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

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

Lot of things seems wrong with the PR and don't think we have tested various scenarios this PR is trying to handle at all. This PR needs a detailed safety story along with a video on UX behaviour in different scenarios -

  • Behavior when we don't have location permission and on showing location dialogue user denies the permission
  • Behavior when we don't have location permission and on showing location dialogue user accepts the permission
  • We already have location permission but location is turned off in device settings
  • We already have location permission but device is not able to get location due to no network and no gps.

<string name="camera_permission_title">Permission for camera</string>
<string name="camera_permission_msg">In order to take a picture, CommCare needs permission to use your device camera.</string>
<string name="capture_photo">Capture Photo</string>
<string name="location_permission_denied">Location permission denied</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

should prefix it with personalid_


View.OnClickListener cancelButtonListener = v -> {
location = null;
requireActivity().finish();
Copy link
Contributor

Choose a reason for hiding this comment

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

we should not finish but show a blocking error message using message fragment.

Comment on lines 234 to 243
locationDialog = new GeoProgressDialog(requireActivity(),
StringUtils.getStringRobust(requireActivity(), R.string.found_location),
StringUtils.getStringRobust(requireActivity(), R.string.finding_location));
locationDialog.setImage(getResources().getDrawable(R.drawable.green_check_mark));
locationDialog.setMessage(StringUtils.getStringRobust(requireActivity(), R.string.please_wait_long));
locationDialog.setOKButton(StringUtils.getStringRobust(requireActivity(), R.string.accept_location),
okButtonListener);
locationDialog.setCancelButton(StringUtils.getStringRobust(requireActivity(), R.string.cancel_location),
cancelButtonListener);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we want to show a user visible dialog here, but we should directly check for requestLocationPermission instead on startup and once granted capture the location in background.

private static final int LOCATION_SETTING_REQ = 102;
private CommCareLocationController locationController;
private static final String[] REQUIRED_PERMISSIONS = new String[]{
Manifest.permission.ACCESS_FINE_LOCATION,
Copy link
Contributor

Choose a reason for hiding this comment

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

think we only need approximate location and using ACCESS_COARSE_LOCATION should be enough here ?

Comment on lines 111 to 113
if (locationController != null) {
locationController.stop();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

start and stop should correspond to mirroring Activitiy lifecycle methods . If we are starting in onCreate , stopping should be done in onDestroy instead.

body.put("phone_number", phone);
body.put("application_id",requireContext().getPackageName());
body.put("application_id", requireContext().getPackageName());
body.put("gps_location", location.getLatitude() + " " + location.getLongitude());
Copy link
Contributor

Choose a reason for hiding this comment

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

we should send accuracy and altitude as well here for sake of completeness and in separate fields.

Comment on lines +275 to +282
Exception exception = ((CommCareLocationListener.Failure.ApiException)failure).getException();
if (exception instanceof ResolvableApiException) {
try {
((ResolvableApiException)exception).startResolutionForResult(requireActivity(),
LOCATION_SETTING_REQ);
} catch (IntentSender.SendIntentException e) {
Logger.log("Location Error", e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

abstract as handleResolvableLocationException and resue.


@Override
public void requestNeededPermissions(int requestCode) {
missingPermissions();
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to requestLocationPermission

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these functions are overidded from the CommCareLocationListener

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant missingPermissions -> requestLocationPermission

integrityTokenApiRequestHelper = new IntegrityTokenApiRequestHelper(getViewLifecycleOwner());
initializeUi();
setupLocationDialog();
requestLocationPermission();
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to checkLocationPermission

Comment on lines 373 to 376
ActivityCompat.requestPermissions(requireActivity(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION},
LOCATION_SETTING_REQ);
Copy link
Contributor

Choose a reason for hiding this comment

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

where are we handling result from permission changes here ? Have you tested this ?

jaypanchal-13 and others added 24 commits June 11, 2025 12:01
…android into pm_ccct_1081_fix

# Conflicts:
#	app/res/values/strings.xml
#	app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java
@pm-dimagi
Copy link
Contributor Author

stale pr

@pm-dimagi pm-dimagi closed this Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants