cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
550 stars 678 forks source link

health 11.0.0 cannot requestAuthorization for write workout without including extra read permissions #1056

Open Olster1 opened 1 month ago

Olster1 commented 1 month ago

health 11.0.0

Device / Emulator and OS

Google Pixel 6 - Android

Describe the bug

I'm calling requestAuthorization with WORKOUT & WRITE . It only returns true if I also include READ_EXERCISE, READ_DISTANCE, READ_TOTAL_CALORIES_BURNED & READ_ACTIVE_CALORIES_BURNED in my Android Manifest. But am not asking to read anything.

List<HealthDataType> types = [
      HealthDataType.WORKOUT
    ];
    List<HealthDataAccess> permissions = [
      HealthDataAccess.WRITE,
    ];

    bool requested = await Health()
        .requestAuthorization(types,
            permissions: permissions);

ANDROID Manifest - have to include all these to get it to return true.

 <uses-permission android:name="android.permission.health.READ_EXERCISE"/>
<uses-permission android:name="android.permission.health.READ_DISTANCE"/> 
<uses-permission android:name="android.permission.health.READ_TOTAL_CALORIES_BURNED"/> 
    <uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED"/>

    <uses-permission android:name="android.permission.health.WRITE_EXERCISE"/>
    <uses-permission android:name="android.permission.health.WRITE_DISTANCE"/>
    <uses-permission android:name="android.permission.health.WRITE_TOTAL_CALORIES_BURNED"/>
    <uses-permission android:name="android.permission.health.WRITE_ACTIVE_CALORIES_BURNED"/>

To Reproduce

call requestAuthorization with the type & permission WORKOUT & WRITE. If You do not include READ_EXERCISE, READ_DISTANCE, READ_TOTAL_CALORIES_BURNED, READ_ACTIVE_CALORIES_BURNED, WRITE_EXERCISE, WRITE_DISTANCE, WRITE_TOTAL_CALORIES_BURNED & WRITE_TOTAL_CALORIES_BURNED it will return false.

Expected behavior

I expect to only include WRITE_EXERCISE, WRITE_DISTANCE, WRITE_TOTAL_CALORIES_BURNED & WRITE_TOTAL_CALORIES_BURNED in my android manifest.