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

fix: fixes incorrectly mapping from granted permissions to record types #142

Closed
wants to merge 4 commits into from

Conversation

ugurakin1
Copy link
Contributor

@ugurakin1 ugurakin1 commented Aug 31, 2024

Summary

How we infer Record types from permission names after calling PermissionController.getGrantedPermissions doesn't work for all permissions - not all record names overlap with snake cased version of the permission names. For example, the code block:

val perm1 = HealthPermission.getReadPermission(MenstruationFlowRecord::class)
      val perm2 = HealthPermission.getReadPermission(MenstruationPeriodRecord::class)
      val perm3 = HealthPermission.getReadPermission(ExerciseSessionRecord::class)
      listOf(perm1, perm2, perm3).forEach {
        Log.d("PermissionUtils", it)
      }

will output:

2024-08-31 14:00:59.844 21940-22030 PermissionUtils         com.healthconnectexample             D  android.permission.health.READ_MENSTRUATION
2024-08-31 14:00:59.844 21940-22030 PermissionUtils         com.healthconnectexample             D  android.permission.health.READ_MENSTRUATION
2024-08-31 14:00:59.844 21940-22030 PermissionUtils         com.healthconnectexample             D  android.permission.health.READ_EXERCISE

The only way to extract the exact set of React RecordTypes an app has permissions for would be to run through the record classes supported by the library and run its read/write permission against the list of granted permissions returned by the PermissionController which is what this PR aims to do.

Testing

Manually tested the example app and the granted permissions worked as usual.

Related Issues

Should fix #63 as the record name for sleep is SleepSession (ref) while the permission name is READ_/WRITE_SLEEP (ref).

@matinzd
Copy link
Owner

matinzd commented Sep 4, 2024

Thanks for the PR. When I find some time to test it I will start reviewing it as well.

@matinzd
Copy link
Owner

matinzd commented Sep 10, 2024

I couldn't update your fork due to permission issues. I am gonna close this one in favor of #153.

Thanks for the help!

@matinzd matinzd closed this Sep 10, 2024
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.

Sleep recordType value mismatch between methods
2 participants