1 /**
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * ```
8 * http://www.apache.org/licenses/LICENSE-2.0
9 * ```
10 *
11 * Unless required by applicable law or agreed to in writing, software distributed under the License
12 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing permissions and limitations under
14 * the License.
15 */
16 package com.android.healthconnect.controller.permissions.data
17
18 import android.health.connect.HealthPermissionCategory
19
20 // TODO (b/299880830) possibly rename "category" to something else
21 enum class HealthPermissionType(val category: Int) {
22 // ACTIVITY
23 ACTIVE_CALORIES_BURNED(HealthPermissionCategory.ACTIVE_CALORIES_BURNED),
24 DISTANCE(HealthPermissionCategory.DISTANCE),
25 ELEVATION_GAINED(HealthPermissionCategory.ELEVATION_GAINED),
26 EXERCISE(HealthPermissionCategory.EXERCISE),
27 PLANNED_EXERCISE(HealthPermissionCategory.PLANNED_EXERCISE),
28 FLOORS_CLIMBED(HealthPermissionCategory.FLOORS_CLIMBED),
29 STEPS(HealthPermissionCategory.STEPS),
30 TOTAL_CALORIES_BURNED(HealthPermissionCategory.TOTAL_CALORIES_BURNED),
31 VO2_MAX(HealthPermissionCategory.VO2_MAX),
32 WHEELCHAIR_PUSHES(HealthPermissionCategory.WHEELCHAIR_PUSHES),
33 POWER(HealthPermissionCategory.POWER),
34 SPEED(HealthPermissionCategory.SPEED),
35 EXERCISE_ROUTE(HealthPermissionCategory.EXERCISE),
36
37 // BODY_MEASUREMENTS
38 BASAL_METABOLIC_RATE(HealthPermissionCategory.BASAL_METABOLIC_RATE),
39 BODY_FAT(HealthPermissionCategory.BODY_FAT),
40 BODY_WATER_MASS(HealthPermissionCategory.BODY_WATER_MASS),
41 BONE_MASS(HealthPermissionCategory.BONE_MASS),
42 HEIGHT(HealthPermissionCategory.HEIGHT),
43 LEAN_BODY_MASS(HealthPermissionCategory.LEAN_BODY_MASS),
44 WEIGHT(HealthPermissionCategory.WEIGHT),
45
46 // CYCLE_TRACKING
47 CERVICAL_MUCUS(HealthPermissionCategory.CERVICAL_MUCUS),
48 MENSTRUATION(HealthPermissionCategory.MENSTRUATION),
49 OVULATION_TEST(HealthPermissionCategory.OVULATION_TEST),
50 SEXUAL_ACTIVITY(HealthPermissionCategory.SEXUAL_ACTIVITY),
51 INTERMENSTRUAL_BLEEDING(HealthPermissionCategory.INTERMENSTRUAL_BLEEDING),
52
53 // NUTRITION
54 HYDRATION(HealthPermissionCategory.HYDRATION),
55 NUTRITION(HealthPermissionCategory.NUTRITION),
56
57 // SLEEP
58 SLEEP(HealthPermissionCategory.SLEEP),
59
60 // VITALS
61 BASAL_BODY_TEMPERATURE(HealthPermissionCategory.BASAL_BODY_TEMPERATURE),
62 BLOOD_GLUCOSE(HealthPermissionCategory.BLOOD_GLUCOSE),
63 BLOOD_PRESSURE(HealthPermissionCategory.BLOOD_PRESSURE),
64 BODY_TEMPERATURE(HealthPermissionCategory.BODY_TEMPERATURE),
65 HEART_RATE(HealthPermissionCategory.HEART_RATE),
66 HEART_RATE_VARIABILITY(HealthPermissionCategory.HEART_RATE_VARIABILITY),
67 OXYGEN_SATURATION(HealthPermissionCategory.OXYGEN_SATURATION),
68 RESPIRATORY_RATE(HealthPermissionCategory.RESPIRATORY_RATE),
69 RESTING_HEART_RATE(HealthPermissionCategory.RESTING_HEART_RATE),
70 SKIN_TEMPERATURE(HealthPermissionCategory.SKIN_TEMPERATURE),
71 }
72
fromHealthPermissionCategorynull73 fun fromHealthPermissionCategory(healthPermissionCategory: Int): HealthPermissionType {
74 return when (healthPermissionCategory) {
75 HealthPermissionCategory.UNKNOWN ->
76 throw IllegalArgumentException("PermissionType is UNKNOWN.")
77 // ACTIVITY
78 HealthPermissionCategory.ACTIVE_CALORIES_BURNED ->
79 HealthPermissionType.ACTIVE_CALORIES_BURNED
80 HealthPermissionCategory.DISTANCE -> HealthPermissionType.DISTANCE
81 HealthPermissionCategory.ELEVATION_GAINED -> HealthPermissionType.ELEVATION_GAINED
82 HealthPermissionCategory.EXERCISE -> HealthPermissionType.EXERCISE
83 HealthPermissionCategory.PLANNED_EXERCISE -> HealthPermissionType.PLANNED_EXERCISE
84 HealthPermissionCategory.FLOORS_CLIMBED -> HealthPermissionType.FLOORS_CLIMBED
85 HealthPermissionCategory.STEPS -> HealthPermissionType.STEPS
86 HealthPermissionCategory.TOTAL_CALORIES_BURNED -> HealthPermissionType.TOTAL_CALORIES_BURNED
87 HealthPermissionCategory.VO2_MAX -> HealthPermissionType.VO2_MAX
88 HealthPermissionCategory.WHEELCHAIR_PUSHES -> HealthPermissionType.WHEELCHAIR_PUSHES
89 HealthPermissionCategory.POWER -> HealthPermissionType.POWER
90 HealthPermissionCategory.SPEED -> HealthPermissionType.SPEED
91 // BODY_MEASUREMENTS
92 HealthPermissionCategory.BASAL_METABOLIC_RATE -> HealthPermissionType.BASAL_METABOLIC_RATE
93 HealthPermissionCategory.BODY_FAT -> HealthPermissionType.BODY_FAT
94 HealthPermissionCategory.BODY_WATER_MASS -> HealthPermissionType.BODY_WATER_MASS
95 HealthPermissionCategory.BONE_MASS -> HealthPermissionType.BONE_MASS
96 HealthPermissionCategory.HEIGHT -> HealthPermissionType.HEIGHT
97 HealthPermissionCategory.LEAN_BODY_MASS -> HealthPermissionType.LEAN_BODY_MASS
98 HealthPermissionCategory.WEIGHT -> HealthPermissionType.WEIGHT
99 // CYCLE_TRACKING
100 HealthPermissionCategory.CERVICAL_MUCUS -> HealthPermissionType.CERVICAL_MUCUS
101 HealthPermissionCategory.MENSTRUATION -> HealthPermissionType.MENSTRUATION
102 HealthPermissionCategory.OVULATION_TEST -> HealthPermissionType.OVULATION_TEST
103 HealthPermissionCategory.SEXUAL_ACTIVITY -> HealthPermissionType.SEXUAL_ACTIVITY
104 HealthPermissionCategory.INTERMENSTRUAL_BLEEDING ->
105 HealthPermissionType.INTERMENSTRUAL_BLEEDING
106 // NUTRITION
107 HealthPermissionCategory.HYDRATION -> HealthPermissionType.HYDRATION
108 HealthPermissionCategory.NUTRITION -> HealthPermissionType.NUTRITION
109 // SLEEP
110 HealthPermissionCategory.SLEEP -> HealthPermissionType.SLEEP
111 // VITALS
112 HealthPermissionCategory.BASAL_BODY_TEMPERATURE ->
113 HealthPermissionType.BASAL_BODY_TEMPERATURE
114 HealthPermissionCategory.BLOOD_GLUCOSE -> HealthPermissionType.BLOOD_GLUCOSE
115 HealthPermissionCategory.BLOOD_PRESSURE -> HealthPermissionType.BLOOD_PRESSURE
116 HealthPermissionCategory.BODY_TEMPERATURE -> HealthPermissionType.BODY_TEMPERATURE
117 HealthPermissionCategory.HEART_RATE -> HealthPermissionType.HEART_RATE
118 HealthPermissionCategory.HEART_RATE_VARIABILITY ->
119 HealthPermissionType.HEART_RATE_VARIABILITY
120 HealthPermissionCategory.OXYGEN_SATURATION -> HealthPermissionType.OXYGEN_SATURATION
121 HealthPermissionCategory.RESPIRATORY_RATE -> HealthPermissionType.RESPIRATORY_RATE
122 HealthPermissionCategory.RESTING_HEART_RATE -> HealthPermissionType.RESTING_HEART_RATE
123 HealthPermissionCategory.SKIN_TEMPERATURE -> HealthPermissionType.SKIN_TEMPERATURE
124 else -> throw IllegalArgumentException("PermissionType is not supported.")
125 }
126 }
127