Skip to content

Commit 76256ad

Browse files
jbhayanaAndroid (Google) Code Review
authored andcommitted
Revert^2 "Implement camera privacy allowlist."
9b2f930 Change-Id: I384077bc05d7685347783adb406f8b29800e3b3b
1 parent 9b2f930 commit 76256ad

7 files changed

Lines changed: 91 additions & 3 deletions

File tree

libs/sensorprivacy/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ cc_library_shared {
5757
filegroup {
5858
name: "libsensorprivacy_aidl",
5959
srcs: [
60+
"aidl/android/hardware/CameraPrivacyAllowlistEntry.aidl",
6061
"aidl/android/hardware/ISensorPrivacyListener.aidl",
6162
"aidl/android/hardware/ISensorPrivacyManager.aidl",
6263
],

libs/sensorprivacy/SensorPrivacyManager.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ bool SensorPrivacyManager::isSensorPrivacyEnabled()
108108

109109
bool SensorPrivacyManager::isToggleSensorPrivacyEnabled(int sensor)
110110
{
111-
sp<hardware::ISensorPrivacyManager> service = getService();
111+
sp<hardware::ISensorPrivacyManager> service = getService();
112112
if (service != nullptr) {
113113
bool result;
114114
service->isCombinedToggleSensorPrivacyEnabled(sensor, &result);
@@ -143,6 +143,39 @@ status_t SensorPrivacyManager::isToggleSensorPrivacyEnabled(int toggleType, int
143143
return UNKNOWN_ERROR;
144144
}
145145

146+
int SensorPrivacyManager::getToggleSensorPrivacyState(int toggleType, int sensor)
147+
{
148+
sp<hardware::ISensorPrivacyManager> service = getService();
149+
if (service != nullptr) {
150+
int result;
151+
service->getToggleSensorPrivacyState(toggleType, sensor, &result);
152+
return result;
153+
}
154+
// if the SensorPrivacyManager is not available then assume sensor privacy is disabled
155+
return DISABLED;
156+
}
157+
158+
std::vector<hardware::CameraPrivacyAllowlistEntry>
159+
SensorPrivacyManager::getCameraPrivacyAllowlist(){
160+
sp<hardware::ISensorPrivacyManager> service = getService();
161+
std::vector<hardware::CameraPrivacyAllowlistEntry> result;
162+
if (service != nullptr) {
163+
service->getCameraPrivacyAllowlist(&result);
164+
return result;
165+
}
166+
return result;
167+
}
168+
169+
bool SensorPrivacyManager::isCameraPrivacyEnabled(String16 packageName){
170+
sp<hardware::ISensorPrivacyManager> service = getService();
171+
if (service != nullptr) {
172+
bool result;
173+
service->isCameraPrivacyEnabled(packageName, &result);
174+
return result;
175+
}
176+
return false;
177+
}
178+
146179
status_t SensorPrivacyManager::linkToDeath(const sp<IBinder::DeathRecipient>& recipient)
147180
{
148181
sp<hardware::ISensorPrivacyManager> service = getService();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2024, 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.hardware;
18+
19+
parcelable CameraPrivacyAllowlistEntry {
20+
String packageName;
21+
boolean isMandatory;
22+
}

libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ package android.hardware;
2121
*/
2222
oneway interface ISensorPrivacyListener {
2323
void onSensorPrivacyChanged(int toggleType, int sensor, boolean enabled);
24+
void onSensorPrivacyStateChanged(int toggleType, int sensor, int state);
2425
}

libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package android.hardware;
1818

19+
import android.hardware.CameraPrivacyAllowlistEntry;
1920
import android.hardware.ISensorPrivacyListener;
2021

2122
/** @hide */
@@ -41,4 +42,15 @@ interface ISensorPrivacyManager {
4142
void setToggleSensorPrivacy(int userId, int source, int sensor, boolean enable);
4243

4344
void setToggleSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable);
45+
46+
List<CameraPrivacyAllowlistEntry> getCameraPrivacyAllowlist();
47+
48+
int getToggleSensorPrivacyState(int toggleType, int sensor);
49+
50+
void setToggleSensorPrivacyState(int userId, int source, int sensor, int state);
51+
52+
void setToggleSensorPrivacyStateForProfileGroup(int userId, int source, int sensor, int state);
53+
54+
boolean isCameraPrivacyEnabled(String packageName);
55+
4456
}

libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ class SensorPrivacyManager
3232
public:
3333
enum {
3434
TOGGLE_SENSOR_MICROPHONE = 1,
35-
TOGGLE_SENSOR_CAMERA = 2
35+
TOGGLE_SENSOR_CAMERA = 2,
36+
TOGGLE_SENSOR_UNKNOWN = -1
3637
};
3738

3839
enum {
3940
TOGGLE_TYPE_SOFTWARE = 1,
40-
TOGGLE_TYPE_HARDWARE = 2
41+
TOGGLE_TYPE_HARDWARE = 2,
42+
TOGGLE_TYPE_UNKNOWN = -1
43+
};
44+
45+
enum {
46+
ENABLED = 1,
47+
DISABLED = 2,
48+
AUTOMOTIVE_DRIVER_ASSISTANCE_HELPFUL_APPS = 3,
49+
AUTOMOTIVE_DRIVER_ASSISTANCE_REQUIRED_APPS = 4,
50+
AUTOMOTIVE_DRIVER_ASSISTANCE_APPS = 5
4151
};
4252

4353
SensorPrivacyManager();
@@ -51,6 +61,9 @@ class SensorPrivacyManager
5161
bool isToggleSensorPrivacyEnabled(int sensor);
5262
bool isToggleSensorPrivacyEnabled(int toggleType, int sensor);
5363
status_t isToggleSensorPrivacyEnabled(int toggleType, int sensor, bool &result);
64+
int getToggleSensorPrivacyState(int toggleType, int sensor);
65+
std::vector<hardware::CameraPrivacyAllowlistEntry> getCameraPrivacyAllowlist();
66+
bool isCameraPrivacyEnabled(String16 packageName);
5467

5568
status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
5669
status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);

services/sensorservice/SensorService.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ class SensorService :
340340
binder::Status onSensorPrivacyChanged(int toggleType, int sensor,
341341
bool enabled);
342342

343+
// This callback is used for additional automotive-specific states for sensor privacy
344+
// such as AUTO_DRIVER_ASSISTANCE_APPS. The newly defined states will only be valid
345+
// for camera privacy on automotive devices. onSensorPrivacyChanged() will still be
346+
// invoked whenever the enabled status of a toggle changes.
347+
binder::Status onSensorPrivacyStateChanged(int, int, int) {return binder::Status::ok();}
348+
343349
protected:
344350
std::atomic_bool mSensorPrivacyEnabled;
345351
wp<SensorService> mService;

0 commit comments

Comments
 (0)