Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4379a4cb authored by varun's avatar varun
Browse files

Add tristate permission support for body sensor permission

Currently only states supported for body sensor permissions are allow
and deny. This change adds support for allowing the permission only
while the app is in foreground by adding a new permission only for
background. This structure is similar to the current state for location
permissions.

BYPASS_INCLUSIVE_LANGUAGE_REASON=Referring to an existing method failing
the inclusive language check.

Test: Manual atest
Change-Id: I8fcab6c0c884b79291586f64fd221e40982bc4c5
Bug: 208305481
parent 5505530a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ package android {
    field public static final String BLUETOOTH_PRIVILEGED = "android.permission.BLUETOOTH_PRIVILEGED";
    field public static final String BLUETOOTH_SCAN = "android.permission.BLUETOOTH_SCAN";
    field public static final String BODY_SENSORS = "android.permission.BODY_SENSORS";
    field public static final String BODY_SENSORS_BACKGROUND = "android.permission.BODY_SENSORS_BACKGROUND";
    field public static final String BROADCAST_PACKAGE_REMOVED = "android.permission.BROADCAST_PACKAGE_REMOVED";
    field public static final String BROADCAST_SMS = "android.permission.BROADCAST_SMS";
    field public static final String BROADCAST_STICKY = "android.permission.BROADCAST_STICKY";
+18 −0
Original line number Diff line number Diff line
@@ -1481,8 +1481,26 @@
        android:permissionGroup="android.permission-group.UNDEFINED"
        android:label="@string/permlab_bodySensors"
        android:description="@string/permdesc_bodySensors"
        android:backgroundPermission="android.permission.BODY_SENSORS_BACKGROUND"
        android:protectionLevel="dangerous" />

    <!-- Allows an application to access data from sensors that the user uses to measure what is
         happening inside their body, such as heart rate. If you're requesting this permission, you
         must also request {@link #BODY_SENSORS}. Requesting this permission by itself doesn't give
         you Body sensors access.
         <p>Protection level: dangerous

         <p> This is a hard restricted permission which cannot be held by an app until
         the installer on record whitelists the permission. For more details see
         {@link android.content.pm.PackageInstaller.SessionParams#setWhitelistedRestrictedPermissions(Set)}.
    -->
    <permission android:name="android.permission.BODY_SENSORS_BACKGROUND"
        android:permissionGroup="android.permission-group.UNDEFINED"
        android:label="@string/permlab_bodySensors_background"
        android:description="@string/permdesc_bodySensors_background"
        android:protectionLevel="dangerous"
        android:permissionFlags="hardRestricted" />

    <!-- Allows an app to use fingerprint hardware.
         <p>Protection level: normal
         @deprecated Applications should request {@link
+5 −2
Original line number Diff line number Diff line
@@ -1237,8 +1237,11 @@
    <string name="permlab_bodySensors">access body sensors (like heart rate monitors)
    </string>
    <!-- Description of the body sensors permission, listed so the user can decide whether to allow the application to access data from body sensors. [CHAR LIMIT=NONE] -->
    <string name="permdesc_bodySensors" product="default">Allows the app to access data from sensors
    that monitor your physical condition, such as your heart rate.</string>
    <string name="permdesc_bodySensors" product="default">Access to data from body sensors such as heart rate, temperature, blood oxygen percentage, etc.</string>
    <!-- Title of the background body sensors permission, listed so the user can decide whether to allow the application to access body sensor data in the background. [CHAR LIMIT=80] -->
    <string name="permlab_bodySensors_background">access body sensors (like heart rate monitors) while in the background</string>
    <!-- Description of the background body sensors permission, listed so the user can decide whether to allow the application to access data from body sensors in the background. [CHAR LIMIT=NONE] -->
    <string name="permdesc_bodySensors_background" product="default">Access to data from body sensors such as heart rate, temperature, blood oxygen percentage, etc. while in the background.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_readCalendar">Read calendar events and details</string>
+4 −0
Original line number Diff line number Diff line
@@ -222,6 +222,10 @@
                      targetSdk="29">
        <new-permission name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    </split-permission>
    <split-permission name="android.permission.BODY_SENSORS"
                      targetSdk="33">
        <new-permission name="android.permission.BODY_SENSORS_BACKGROUND" />
    </split-permission>
    <split-permission name="android.permission.READ_EXTERNAL_STORAGE"
                      targetSdk="29">
        <new-permission name="android.permission.ACCESS_MEDIA_LOCATION" />
+1 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ final class DefaultPermissionGrantPolicy {
    private static final Set<String> SENSORS_PERMISSIONS = new ArraySet<>();
    static {
        SENSORS_PERMISSIONS.add(Manifest.permission.BODY_SENSORS);
        SENSORS_PERMISSIONS.add(Manifest.permission.BODY_SENSORS_BACKGROUND);
    }

    private static final Set<String> STORAGE_PERMISSIONS = new ArraySet<>();
Loading