Caller doesn't have android.permission.health.WRITE_EXERCISE_ROUTE
Closed this issue · 3 comments
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:
- 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)
ExerciseRoute
permission has a different contract which is not implemented yet. I would be happy if you are willing to contribute.
Yes for both read and write.