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

Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE #128

Closed
gabrielgouv opened this issue Aug 1, 2024 · 3 comments · Fixed by #167
Closed

Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE #128

gabrielgouv opened this issue Aug 1, 2024 · 3 comments · Fixed by #167

Comments

@gabrielgouv
Copy link
Contributor

Describe the bug
I'm trying to insert a ExerciseSession with ExerciseRoute on Health Connect but when I execute insertion I receive the error below. I've set permission for android.permission.health.WRITE_EXERCISE_ROUTE on my app.json file and the error persists.

Error inserting exercise: [Error: android.health.connect.HealthConnectException: java.lang.SecurityException: Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE to write to record type class android.health.connect.datatypes.ExerciseSessionRecord]

My permissions:

"permissions": [
        "android.permission.health.WRITE_EXERCISE_ROUTE",
        "android.permission.health.WRITE_EXERCISE",
        "android.permission.health.READ_EXERCISE_ROUTES",
        "android.permission.health.READ_EXERCISE",
]

My code:

const grantedPermissions = await requestPermission([
    { accessType: "write", recordType: "ExerciseSession" },
    { accessType: "read", recordType: "ExerciseSession" },
]);

To Reproduce
Steps to reproduce the behavior:

  1. Try to insert a exercise session with route using code below

Expected behavior
Should insert exercise with route

Minimal Reproducible

async function insertExerciseWithRoute() {
  const sessionStartTime = new Date();
  const sessionEndTime = new Date(sessionStartTime.getTime() + 2 * 60 * 1000);

  const routeStartTime = new Date(sessionStartTime.getTime() + 100);
  const routeEndTime = new Date(sessionEndTime.getTime() - 100);
  
  return await insertRecords([
    {
      recordType: "ExerciseSession",
      exerciseType: 8,
      title: "Insert Route Test 5",
      startTime: sessionStartTime.toISOString(),
      endTime: sessionEndTime.toISOString(),
      exerciseRoute: {
        route: [
          {
            time: routeStartTime.toISOString(),
            latitude: 6.5483,
            longitude: 0.5488,
            horizontalAccuracy: { value: 2.0, unit: "meters" },
            verticalAccuracy: { value: 2.0, unit: "meters" },
            altitude: { value: 9.0, unit: "meters" },
          },
          {
            time: routeEndTime.toISOString(),
            latitude: 6.4578,
            longitude: 0.6577,
            horizontalAccuracy: { value: 2.0, unit: "meters" },
            verticalAccuracy: { value: 2.0, unit: "meters" },
            altitude: { value: 9.2, unit: "meters" },
          },
        ],
      },
    },
  ]);
}

Insert without route works normally with this code.

Environment:

  • Health Connect Version: 2024.07.11.00.release
  • React Native Version: 0.74.3
  • New architecture enabled: No
  • Using Expo: Prebuild(Dev Client)
@gabrielgouv gabrielgouv changed the title Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE on Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE Aug 1, 2024
@matinzd
Copy link
Owner

matinzd commented Aug 2, 2024

ExerciseRoute permission has a different contract which is not implemented yet. I would be happy if you are willing to contribute.

#34

@gabrielgouv
Copy link
Contributor Author

@matinzd this contract is necessary to reading too (#127)?

@matinzd
Copy link
Owner

matinzd commented Aug 2, 2024

Yes for both read and write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants