forked from RattlesnakeOS/community_patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
00002-global-sensors-permission-toggle.patch
124 lines (115 loc) · 7.33 KB
/
00002-global-sensors-permission-toggle.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From 4258d64a3a6d8f72a9566ae982aa851a1adeff0c Mon Sep 17 00:00:00 2001
From: Steve Soltys <[email protected]>
Date: Thu, 11 Oct 2018 00:05:56 -0400
Subject: [PATCH] Add sensors permission
---
frameworks/base/core/java/android/content/pm/PackageParser.java | 2 ++
frameworks/base/core/res/AndroidManifest.xml | 14 ++++++++++++++
frameworks/base/core/res/res/values/strings.xml | 12 ++++++++++++
frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java | 2 +-
4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/frameworks/base/core/java/android/content/pm/PackageParser.java b/frameworks/base/core/java/android/content/pm/PackageParser.java
index 2da2cb4c928..531bbca8fc6 100644
--- a/frameworks/base/core/java/android/content/pm/PackageParser.java
+++ b/frameworks/base/core/java/android/content/pm/PackageParser.java
@@ -278,6 +278,8 @@ public class PackageParser {
*/
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,
diff --git a/frameworks/base/core/res/AndroidManifest.xml b/frameworks/base/core/res/AndroidManifest.xml
index c31b3b4989c..5b6026db0c2 100644
--- a/frameworks/base/core/res/AndroidManifest.xml
+++ b/frameworks/base/core/res/AndroidManifest.xml
@@ -1129,6 +1129,20 @@
android:description="@string/permdesc_useFingerprint"
android:protectionLevel="normal" />
+ <!-- @hide -->
+ <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" />
+
+ <!-- @hide -->
+ <permission android:name="android.permission.OTHER_SENSORS"
+ android:permissionGroup="android.permission-group.OTHER_SENSORS"
+ android:label="@string/permlab_otherSensors"
+ android:description="@string/permdesc_otherSensors"
+ android:protectionLevel="dangerous" />
+
<!-- Allows an app to use device supported biometric modalities.
<p>Protection level: normal
-->
diff --git a/frameworks/base/core/res/res/values/strings.xml b/frameworks/base/core/res/res/values/strings.xml
index 15d1187afa0..00c644f470d 100644
--- a/frameworks/base/core/res/res/values/strings.xml
+++ b/frameworks/base/core/res/res/values/strings.xml
@@ -747,6 +747,11 @@
<string name="permgrouprequest_sensors">Allow
<b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g></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 for the capability of an accessibility service to retrieve window content. -->
<string name="capability_title_canRetrieveWindowContent">Retrieve window content</string>
<!-- Description for the capability of an accessibility service to retrieve window content. -->
@@ -1056,6 +1061,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. -->
diff --git a/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 8cc0de8e322..9615e1f408f 100644
--- a/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -1333,7 +1333,7 @@ public class PermissionManagerService {
}
public static boolean isAlwaysRuntimePermission(final String permission) {
- return Manifest.permission.INTERNET.equals(permission);
+ return Manifest.permission.INTERNET.equals(permission) || Manifest.permission.OTHER_SENSORS.equals(permission);
}
private void grantRequestedRuntimePermissionsForUser(PackageParser.Package pkg, int userId,
diff --git a/frameworks/native/libs/sensor/Sensor.cpp b/frameworks/native/libs/sensor/Sensor.cpp
index a0e368c7e..4f3fe88b8 100644
--- a/frameworks/native/libs/sensor/Sensor.cpp
+++ b/frameworks/native/libs/sensor/Sensor.cpp
@@ -52,6 +52,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi
mMinDelay = hwSensor.minDelay;
mFlags = 0;
mUuid = uuid;
+ mRequiredPermission = "android.permission.OTHER_SENSORS";
// Set fifo event count zero for older devices which do not support batching. Fused
// sensors also have their fifo counts set to zero.
diff --git a/packages/apps/F-Droid/app/src/main/java/org/fdroid/fdroid/installer/ApkVerifier.java b/packages/apps/F-Droid/app/src/main/java/org/fdroid/fdroid/installer/ApkVerifier.java
index e59ba367..c6edd542 100644
--- a/packages/apps/F-Droid/app/src/main/java/org/fdroid/fdroid/installer/ApkVerifier.java
+++ b/packages/apps/F-Droid/app/src/main/java/org/fdroid/fdroid/installer/ApkVerifier.java
@@ -113,10 +113,8 @@ class ApkVerifier {
if (expected == null || actual == null) {
return false;
}
- if (expected.length != actual.length) {
- return false;
- }
HashSet<String> expectedSet = new HashSet<>(Arrays.asList(expected));
+ expectedSet.add("android.permission.OTHER_SENSORS");
HashSet<String> actualSet = new HashSet<>(Arrays.asList(actual));
return expectedSet.equals(actualSet);
}
--
2.16.4