Define health permissions in the health connect sdk.
Bug: 249471388
Test: ./gradlew :health:connect:connect-client:test
Change-Id: Icc845ff300c297a250256d53efc2f2fc01b34802
diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt
index d08c1f1..445924c 100644
--- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt
+++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/PermissionController.kt
@@ -41,7 +41,8 @@
* Filters and returns a subset of permissions granted by the user to the calling app, out of
* the input permissions set.
*
- * @param permissions set of permissions to filter
+ * @param permissions set of permissions to filter. Each permission should be one of the list
+ * defined in [HealthPermission]
* @return filtered set of granted permissions.
*
* @throws android.os.RemoteException For any IPC transportation failures.
diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt
index f1dc8174..b3a6483 100644
--- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt
+++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/permission/HealthPermission.kt
@@ -15,6 +15,7 @@
*/
package androidx.health.connect.client.permission
+import androidx.annotation.RestrictTo
import androidx.health.connect.client.records.Record
import kotlin.reflect.KClass
@@ -52,6 +53,183 @@
public fun createWritePermission(recordType: KClass<out Record>): HealthPermission {
return HealthPermission(recordType, AccessTypes.WRITE)
}
+
+ // Read permissions for ACTIVITY.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_ACTIVE_CALORIES_BURNED =
+ "android.permission.health.READ_ACTIVE_CALORIES_BURNED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_DISTANCE = "android.permission.health.READ_DISTANCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_ELEVATION_GAINED = "android.permission.health.READ_ELEVATION_GAINED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_EXERCISE = "android.permission.health.READ_EXERCISE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_FLOORS_CLIMBED = "android.permission.health.READ_FLOORS_CLIMBED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_STEPS = "android.permission.health.READ_STEPS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_TOTAL_CALORIES_BURNED =
+ "android.permission.health.READ_TOTAL_CALORIES_BURNED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_VO2_MAX = "android.permission.health.READ_VO2_MAX"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_WHEELCHAIR_PUSHES = "android.permission.health.READ_WHEELCHAIR_PUSHES"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_POWER = "android.permission.health.READ_POWER"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_SPEED = "android.permission.health.READ_SPEED"
+
+ // Read permissions for BODY_MEASUREMENTS.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BASAL_METABOLIC_RATE = "android.permission.health.READ_BASAL_METABOLIC_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BODY_FAT = "android.permission.health.READ_BODY_FAT"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BODY_WATER_MASS = "android.permission.health.READ_BODY_WATER_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BONE_MASS = "android.permission.health.READ_BONE_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_HEIGHT = "android.permission.health.READ_HEIGHT"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_HIP_CIRCUMFERENCE = "android.permission.health.READ_HIP_CIRCUMFERENCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_LEAN_BODY_MASS = "android.permission.health.READ_LEAN_BODY_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_WAIST_CIRCUMFERENCE = "android.permission.health.READ_WAIST_CIRCUMFERENCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_WEIGHT = "android.permission.health.READ_WEIGHT"
+
+ // Read permissions for CYCLE_TRACKING.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_CERVICAL_MUCUS = "android.permission.health.READ_CERVICAL_MUCUS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_MENSTRUATION = "android.permission.health.READ_MENSTRUATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_OVULATION_TEST = "android.permission.health.READ_OVULATION_TEST"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_SEXUAL_ACTIVITY = "android.permission.health.READ_SEXUAL_ACTIVITY"
+
+ // Read permissions for NUTRITION.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_HYDRATION = "android.permission.health.READ_HYDRATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_NUTRITION = "android.permission.health.READ_NUTRITION"
+
+ // Read permissions for SLEEP.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_SLEEP = "android.permission.health.READ_SLEEP"
+
+ // Read permissions for VITALS.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BASAL_BODY_TEMPERATURE =
+ "android.permission.health.READ_BASAL_BODY_TEMPERATURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BLOOD_GLUCOSE = "android.permission.health.READ_BLOOD_GLUCOSE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BLOOD_PRESSURE = "android.permission.health.READ_BLOOD_PRESSURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_BODY_TEMPERATURE = "android.permission.health.READ_BODY_TEMPERATURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_HEART_RATE = "android.permission.health.READ_HEART_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_HEART_RATE_VARIABILITY =
+ "android.permission.health.READ_HEART_RATE_VARIABILITY"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_OXYGEN_SATURATION = "android.permission.health.READ_OXYGEN_SATURATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_RESPIRATORY_RATE = "android.permission.health.READ_RESPIRATORY_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val READ_RESTING_HEART_RATE = "android.permission.health.READ_RESTING_HEART_RATE"
+
+ // Write permissions for ACTIVITY.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_ACTIVE_CALORIES_BURNED =
+ "android.permission.health.WRITE_ACTIVE_CALORIES_BURNED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_DISTANCE = "android.permission.health.WRITE_DISTANCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_ELEVATION_GAINED = "android.permission.health.WRITE_ELEVATION_GAINED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_EXERCISE = "android.permission.health.WRITE_EXERCISE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_FLOORS_CLIMBED = "android.permission.health.WRITE_FLOORS_CLIMBED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_STEPS = "android.permission.health.WRITE_STEPS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_TOTAL_CALORIES_BURNED =
+ "android.permission.health.WRITE_TOTAL_CALORIES_BURNED"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_VO2_MAX = "android.permission.health.WRITE_VO2_MAX"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_WHEELCHAIR_PUSHES = "android.permission.health.WRITE_WHEELCHAIR_PUSHES"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_POWER = "android.permission.health.WRITE_POWER"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_SPEED = "android.permission.health.WRITE_SPEED"
+
+ // Write permissions for BODY_MEASUREMENTS.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BASAL_METABOLIC_RATE =
+ "android.permission.health.WRITE_BASAL_METABOLIC_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BODY_FAT = "android.permission.health.WRITE_BODY_FAT"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BODY_WATER_MASS = "android.permission.health.WRITE_BODY_WATER_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BONE_MASS = "android.permission.health.WRITE_BONE_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_HEIGHT = "android.permission.health.WRITE_HEIGHT"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_HIP_CIRCUMFERENCE = "android.permission.health.WRITE_HIP_CIRCUMFERENCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_LEAN_BODY_MASS = "android.permission.health.WRITE_LEAN_BODY_MASS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_WAIST_CIRCUMFERENCE = "android.permission.health.WRITE_WAIST_CIRCUMFERENCE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_WEIGHT = "android.permission.health.WRITE_WEIGHT"
+
+ // Write permissions for CYCLE_TRACKING.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_CERVICAL_MUCUS = "android.permission.health.WRITE_CERVICAL_MUCUS"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_MENSTRUATION = "android.permission.health.WRITE_MENSTRUATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_OVULATION_TEST = "android.permission.health.WRITE_OVULATION_TEST"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_SEXUAL_ACTIVITY = "android.permission.health.WRITE_SEXUAL_ACTIVITY"
+
+ // Write permissions for NUTRITION.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_HYDRATION = "android.permission.health.WRITE_HYDRATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_NUTRITION = "android.permission.health.WRITE_NUTRITION"
+
+ // Write permissions for SLEEP.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_SLEEP = "android.permission.health.WRITE_SLEEP"
+
+ // Write permissions for VITALS.
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BASAL_BODY_TEMPERATURE =
+ "android.permission.health.WRITE_BASAL_BODY_TEMPERATURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BLOOD_GLUCOSE = "android.permission.health.WRITE_BLOOD_GLUCOSE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BLOOD_PRESSURE = "android.permission.health.WRITE_BLOOD_PRESSURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_BODY_TEMPERATURE = "android.permission.health.WRITE_BODY_TEMPERATURE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_HEART_RATE = "android.permission.health.WRITE_HEART_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_HEART_RATE_VARIABILITY =
+ "android.permission.health.WRITE_HEART_RATE_VARIABILITY"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_OXYGEN_SATURATION = "android.permission.health.WRITE_OXYGEN_SATURATION"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_RESPIRATORY_RATE = "android.permission.health.WRITE_RESPIRATORY_RATE"
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ const val WRITE_RESTING_HEART_RATE = "android.permission.health.WRITE_RESTING_HEART_RATE"
}
override fun equals(other: Any?): Boolean {