File tree Expand file tree Collapse file tree 8 files changed +28
-4
lines changed
src/main/java/dev/matinzd/healthconnect/permissions Expand file tree Collapse file tree 8 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ dependencies {
9292 implementation " com.facebook.react:react-native"
9393 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
9494 implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
95- implementation " androidx.health.connect:connect-client:1.1.0-alpha06 "
95+ implementation " androidx.health.connect:connect-client:1.1.0-alpha11 "
9696}
9797
9898if (isNewArchitectureEnabled()) {
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ class PermissionUtils {
1919 return @mapNotNull HealthPermission .PERMISSION_WRITE_EXERCISE_ROUTE
2020 }
2121
22+ if (accessType == " read" && recordType == " ReadHealthDataHistory" ) {
23+ return @mapNotNull HealthPermission .PERMISSION_READ_HEALTH_DATA_HISTORY
24+ }
25+
2226 val recordClass = reactRecordTypeToClassMap[recordType]
2327 ? : throw InvalidRecordType ()
2428
Original file line number Diff line number Diff line change 77 <uses-permission android : name =" android.permission.health.WRITE_EXERCISE" />
88 <uses-permission android : name =" android.permission.health.READ_EXERCISE_ROUTES" />
99 <uses-permission android : name =" android.permission.health.WRITE_EXERCISE_ROUTE" />
10+ <uses-permission android : name =" android.permission.health.READ_HEALTH_DATA_HISTORY" />
1011
1112 <application
1213 android : name =" .MainApplication"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ buildscript {
22 ext {
33 buildToolsVersion = " 34.0.0"
44 minSdkVersion = 26
5- compileSdkVersion = 34
5+ compileSdkVersion = 35
66 targetSdkVersion = 34
77 ndkVersion = " 25.1.8937393"
88 kotlinVersion = " 1.8.0"
Original file line number Diff line number Diff line change @@ -261,6 +261,10 @@ export default function App() {
261261 accessType : 'write' ,
262262 recordType : 'ExerciseRoute' ,
263263 } ,
264+ {
265+ accessType : 'read' ,
266+ recordType : 'ReadHealthDataHistory' ,
267+ } ,
264268 ] ) . then ( ( permissions ) => {
265269 console . log ( 'Granted permissions on request ' , { permissions } ) ;
266270 } ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type {
44 HealthConnectRecord ,
55 Permission ,
66 WriteExerciseRoutePermission ,
7+ ReadHealthDataHistoryPermission ,
78} from './types' ;
89import type { ExerciseRoute } from './types/base.types' ;
910
@@ -23,7 +24,11 @@ export interface Spec extends TurboModule {
2324 openHealthConnectSettings : ( ) => void ;
2425 openHealthConnectDataManagement : ( providerPackageName ?: string ) => void ;
2526 requestPermission (
26- permissions : ( Permission | WriteExerciseRoutePermission ) [ ]
27+ permissions : (
28+ | Permission
29+ | WriteExerciseRoutePermission
30+ | ReadHealthDataHistoryPermission
31+ ) [ ]
2732 ) : Promise < Permission [ ] > ;
2833 requestExerciseRoute ( recordId : string ) : Promise < ExerciseRoute > ;
2934 getGrantedPermissions ( ) : Promise < Permission [ ] > ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import type {
1616 GetChangesRequest ,
1717 GetChangesResults ,
1818 WriteExerciseRoutePermission ,
19+ ReadHealthDataHistoryPermission ,
1920} from './types' ;
2021import type { ExerciseRoute , TimeRangeFilter } from './types/base.types' ;
2122
@@ -98,7 +99,11 @@ export function openHealthConnectDataManagement(
9899 * @returns granted permissions
99100 */
100101export function requestPermission (
101- permissions : ( Permission | WriteExerciseRoutePermission ) [ ]
102+ permissions : (
103+ | Permission
104+ | WriteExerciseRoutePermission
105+ | ReadHealthDataHistoryPermission
106+ ) [ ]
102107) : Promise < Permission [ ] > {
103108 return HealthConnect . requestPermission ( permissions ) ;
104109}
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ export interface WriteExerciseRoutePermission {
1010 recordType : 'ExerciseRoute' ;
1111}
1212
13+ export interface ReadHealthDataHistoryPermission {
14+ accessType : 'read' ;
15+ recordType : 'ReadHealthDataHistory' ;
16+ }
17+
1318export * from './records.types' ;
1419export * from './results.types' ;
1520export * from './aggregate.types' ;
You can’t perform that action at this time.
0 commit comments