Skip to content

Commit

Permalink
add special runtime permission for other sensors
Browse files Browse the repository at this point in the history
This covers sensors not included in the existing runtime permission for
body sensors.
  • Loading branch information
thestinger committed Nov 4, 2019
1 parent 7c8a972 commit caca47c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ package android {
field public static final String MOUNT_UNMOUNT_FILESYSTEMS = "android.permission.MOUNT_UNMOUNT_FILESYSTEMS";
field public static final String NFC = "android.permission.NFC";
field public static final String NFC_TRANSACTION_EVENT = "android.permission.NFC_TRANSACTION_EVENT";
field public static final String OTHER_SENSORS = "android.permission.OTHER_SENSORS";
field public static final String PACKAGE_USAGE_STATS = "android.permission.PACKAGE_USAGE_STATS";
field @Deprecated public static final String PERSISTENT_ACTIVITY = "android.permission.PERSISTENT_ACTIVITY";
field @Deprecated public static final String PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS";
Expand Down Expand Up @@ -177,6 +178,7 @@ package android {
field public static final String LOCATION = "android.permission-group.LOCATION";
field public static final String MICROPHONE = "android.permission-group.MICROPHONE";
field public static final String NETWORK = "android.permission-group.NETWORK";
field public static final String OTHER_SENSORS = "android.permission-group.OTHER_SENSORS";
field public static final String PHONE = "android.permission-group.PHONE";
field public static final String SENSORS = "android.permission-group.SENSORS";
field public static final String SMS = "android.permission-group.SMS";
Expand Down
2 changes: 2 additions & 0 deletions core/java/android/content/pm/PackageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ public NewPermissionInfo(String name, int sdkVersion, int fileVersion) {
@UnsupportedAppUsage
public static final PackageParser.NewPermissionInfo NEW_PERMISSIONS[] =
new PackageParser.NewPermissionInfo[] {
new PackageParser.NewPermissionInfo(android.Manifest.permission.OTHER_SENSORS,
android.os.Build.VERSION_CODES.CUR_DEVELOPMENT + 1, 0),
new PackageParser.NewPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.os.Build.VERSION_CODES.DONUT, 0),
new PackageParser.NewPermissionInfo(android.Manifest.permission.READ_PHONE_STATE,
Expand Down
12 changes: 12 additions & 0 deletions core/res/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,18 @@
android:description="@string/permdesc_useBiometric"
android:protectionLevel="normal" />

<permission-group android:name="android.permission-group.OTHER_SENSORS"
android:icon="@drawable/perm_group_location"
android:label="@string/permgrouplab_otherSensors"
android:description="@string/permgroupdesc_otherSensors"
android:priority="1000" />

<permission android:name="android.permission.OTHER_SENSORS"
android:permissionGroup="android.permission-group.UNDEFINED"
android:label="@string/permlab_otherSensors"
android:description="@string/permdesc_otherSensors"
android:protectionLevel="dangerous" />

<!-- ====================================================================== -->
<!-- REMOVED PERMISSIONS -->
<!-- ====================================================================== -->
Expand Down
12 changes: 12 additions & 0 deletions core/res/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@
<string name="permgrouprequest_sensors">Allow
&lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to access sensor data about your vital signs?</string>

<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_otherSensors">Sensors</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgroupdesc_otherSensors">access sensor data about orientation, movement, etc.</string>

<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permgrouplab_network">Network</string>
<!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
Expand Down Expand Up @@ -1103,6 +1108,13 @@
<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>

<!-- Title of the sensors permission, listed so the user can decide whether to allow the application to access sensor data. [CHAR LIMIT=80] -->
<string name="permlab_otherSensors">access sensors (like the compass)
</string>
<!-- Description of the sensors permission, listed so the user can decide whether to allow the application to access data from sensors. [CHAR LIMIT=NONE] -->
<string name="permdesc_otherSensors" product="default">Allows the app to access data from sensors
monitoring orientation, movement, vibration (including low frequency sound) and environmental data</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>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ private void removeDynamicPermission(
}

public static boolean isSpecialRuntimePermission(final String permission) {
return Manifest.permission.INTERNET.equals(permission);
return Manifest.permission.INTERNET.equals(permission) || Manifest.permission.OTHER_SENSORS.equals(permission);
}

/**
Expand Down

0 comments on commit caca47c

Please sign in to comment.