1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.health.connect;
18 
19 import static com.android.healthfitness.flags.Flags.FLAG_MINDFULNESS;
20 
21 import android.annotation.FlaggedApi;
22 import android.annotation.IntDef;
23 import android.annotation.SystemApi;
24 import android.health.connect.datatypes.ActiveCaloriesBurnedRecord;
25 import android.health.connect.datatypes.BasalMetabolicRateRecord;
26 import android.health.connect.datatypes.DistanceRecord;
27 import android.health.connect.datatypes.ElevationGainedRecord;
28 import android.health.connect.datatypes.HeartRateRecord;
29 import android.health.connect.datatypes.MindfulnessSessionRecord;
30 import android.health.connect.datatypes.PowerRecord;
31 import android.health.connect.datatypes.Record;
32 import android.health.connect.datatypes.SpeedRecord;
33 import android.health.connect.datatypes.StepsRecord;
34 
35 import java.lang.annotation.Retention;
36 import java.lang.annotation.RetentionPolicy;
37 
38 /**
39  * Represents the permission category of a {@link Record}. A record can only belong to one and only
40  * one {@link HealthPermissionCategory}
41  *
42  * @hide
43  */
44 @SystemApi
45 public class HealthPermissionCategory {
46     public static final int UNKNOWN = 0;
47 
48     // ACTIVITY
49     /** Permission category for {@link ActiveCaloriesBurnedRecord} */
50     public static final int ACTIVE_CALORIES_BURNED = 1;
51 
52     /** Permission category for {@link DistanceRecord} */
53     public static final int DISTANCE = 2;
54 
55     /** Permission category for {@link ElevationGainedRecord} */
56     public static final int ELEVATION_GAINED = 3;
57 
58     /**
59      * Permission category for {@link android.health.connect.datatypes.ExerciseSessionRecord} and
60      * {@link android.health.connect.datatypes.ExerciseLap}
61      */
62     public static final int EXERCISE = 4;
63 
64     /** Permission category for {FloorsClimbedRecord} */
65     public static final int FLOORS_CLIMBED = 5;
66 
67     /** Permission category for {@link StepsRecord} */
68     public static final int STEPS = 6;
69 
70     // BODY_MEASUREMENTS
71     /** Permission category for {@link BasalMetabolicRateRecord} */
72     public static final int BASAL_METABOLIC_RATE = 9;
73 
74     /** Permission category for {BodyFatRecord} */
75     public static final int BODY_FAT = 10;
76 
77     /** Permission category for {BodyWaterMassRecord} */
78     public static final int BODY_WATER_MASS = 11;
79 
80     /** Permission category for {BoneMassRecord} */
81     public static final int BONE_MASS = 12;
82 
83     /** Permission category for {HeightRecord} */
84     public static final int HEIGHT = 13;
85 
86     /** Permission category for {LeanBodyMassRecord} */
87     public static final int LEAN_BODY_MASS = 15;
88 
89     /** Permission category for {@link PowerRecord} */
90     public static final int POWER = 36;
91 
92     /** Permission category for {@link SpeedRecord} */
93     public static final int SPEED = 37;
94 
95     /** Permission category for {TotalCaloriesBurnedRecord} */
96     public static final int TOTAL_CALORIES_BURNED = 35;
97 
98     /** Permission category for {Vo2MaxRecord} */
99     public static final int VO2_MAX = 7;
100 
101     /** Permission category for {WeightRecord} */
102     public static final int WEIGHT = 17;
103 
104     /** Permission category for {WheelChairPushesRecord} */
105     public static final int WHEELCHAIR_PUSHES = 8;
106 
107     // CYCLE_TRACKING
108     /** Permission category for {CervicalMucusRecord} */
109     public static final int CERVICAL_MUCUS = 18;
110 
111     /** Permission category for {IntermenstrualBleedingRecord} */
112     public static final int INTERMENSTRUAL_BLEEDING = 38;
113 
114     /** Permission category for {MenstruationRecord} */
115     public static final int MENSTRUATION = 20;
116 
117     /** Permission category for {OvulationTestRecord} */
118     public static final int OVULATION_TEST = 21;
119 
120     /** Permission category for {SexualActivityRecord} */
121     public static final int SEXUAL_ACTIVITY = 22;
122 
123     // NUTRITION
124     /** Permission category for {HydrationRecord} */
125     public static final int HYDRATION = 23;
126 
127     /** Permission category for {NutritionRecord} */
128     public static final int NUTRITION = 24;
129 
130     // SLEEP
131     /** Permission category for {BasalBodyTemperatureRecord} */
132     public static final int BASAL_BODY_TEMPERATURE = 33;
133 
134     /** Permission category for {SleepRecord} */
135     public static final int SLEEP = 25;
136 
137     // VITALS
138     /** Permission category for {BloodGlucose} */
139     public static final int BLOOD_GLUCOSE = 26;
140 
141     /** Permission category for {BloodPressure} */
142     public static final int BLOOD_PRESSURE = 27;
143 
144     /** Permission category for {BodyTemperature} */
145     public static final int BODY_TEMPERATURE = 28;
146 
147     /** Permission category for {@link HeartRateRecord} */
148     public static final int HEART_RATE = 29;
149 
150     /** Permission category for {HeartRateVariability} */
151     public static final int HEART_RATE_VARIABILITY = 30;
152 
153     /** Permission category for {OxygenSaturation} */
154     public static final int OXYGEN_SATURATION = 31;
155 
156     /** Permission category for {RespiratoryRate} */
157     public static final int RESPIRATORY_RATE = 32;
158 
159     /** Permission category for {RestingHeartRate} */
160     public static final int RESTING_HEART_RATE = 34;
161 
162     /** Permission category for {SkinTemperature} */
163     @FlaggedApi("com.android.healthconnect.flags.skin_temperature")
164     public static final int SKIN_TEMPERATURE = 39;
165 
166     /** Permission category for {PlannedExerciseSession} */
167     @FlaggedApi("com.android.healthconnect.flags.training_plans")
168     public static final int PLANNED_EXERCISE = 40;
169 
170     // WELLNESS
171     /** Permission category for {@link MindfulnessSessionRecord}. */
172     @FlaggedApi(FLAG_MINDFULNESS)
173     public static final int MINDFULNESS = 41;
174 
HealthPermissionCategory()175     private HealthPermissionCategory() {}
176 
177     /** @hide */
178     @IntDef({
179         UNKNOWN,
180         ACTIVE_CALORIES_BURNED,
181         DISTANCE,
182         ELEVATION_GAINED,
183         EXERCISE,
184         FLOORS_CLIMBED,
185         STEPS,
186         TOTAL_CALORIES_BURNED,
187         VO2_MAX,
188         WHEELCHAIR_PUSHES,
189         POWER,
190         SPEED,
191         BASAL_METABOLIC_RATE,
192         BODY_FAT,
193         BODY_WATER_MASS,
194         BONE_MASS,
195         HEIGHT,
196         LEAN_BODY_MASS,
197         WEIGHT,
198         CERVICAL_MUCUS,
199         MENSTRUATION,
200         OVULATION_TEST,
201         SEXUAL_ACTIVITY,
202         INTERMENSTRUAL_BLEEDING,
203         HYDRATION,
204         NUTRITION,
205         SLEEP,
206         BASAL_BODY_TEMPERATURE,
207         BLOOD_GLUCOSE,
208         BLOOD_PRESSURE,
209         BODY_TEMPERATURE,
210         HEART_RATE,
211         HEART_RATE_VARIABILITY,
212         OXYGEN_SATURATION,
213         RESPIRATORY_RATE,
214         RESTING_HEART_RATE,
215         SKIN_TEMPERATURE,
216         PLANNED_EXERCISE,
217         MINDFULNESS
218     })
219     @Retention(RetentionPolicy.SOURCE)
220     public @interface Type {}
221 }
222