From 3ab94db67aadd1a2c2afb2bed4e840ec902fa1bf Mon Sep 17 00:00:00 2001 From: karthik bharadwaj Date: Wed, 24 Mar 2021 01:52:13 -0700 Subject: [PATCH] Refactor Global Mic Disable This CL changes the setting propagation of the user microphone privacy setting to imply if CHRE can access the microphone, as opposed to piping down the raw setting. Bug: 183416485 Test: Toggle the setting, verify that the setting change notification is handled as expected, toggle the microphone privacy setting to verify correct behavior. Change-Id: I1cbbe6cc6312ed91eba15759836e588b4cd70cad --- .../server/location/contexthub/ContextHubService.java | 2 +- .../server/location/contexthub/IContextHubWrapper.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubService.java b/services/core/java/com/android/server/location/contexthub/ContextHubService.java index f173fc7386bae..c3b45892ec5a1 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java @@ -298,7 +298,7 @@ public class ContextHubService extends IContextHubService.Stub { mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers( SensorPrivacyManager.Sensors.MICROPHONE, (userId, enabled) -> { if (userId == getCurrentUserId()) { - Log.d(TAG, "User: " + userId + " enabled: " + enabled); + Log.d(TAG, "User: " + userId + "mic privacy: " + enabled); sendMicrophoneDisableSettingUpdate(enabled); } }); diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java index 3245fdfaebd60..7be47a4e52a89 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -324,8 +324,11 @@ public abstract class IContextHubWrapper { } public void onMicrophoneDisableSettingChanged(boolean enabled) { - sendSettingChanged(android.hardware.contexthub.V1_2.Setting.GLOBAL_MIC_DISABLE, - enabled ? SettingValue.ENABLED : SettingValue.DISABLED); + // The SensorPrivacyManager reports if microphone privacy was enabled, + // which translates to microphone access being disabled (and vice-versa). + // With this in mind, we flip the argument before piping it to CHRE. + sendSettingChanged(android.hardware.contexthub.V1_2.Setting.MICROPHONE, + enabled ? SettingValue.DISABLED : SettingValue.ENABLED); } private void sendSettingChanged(byte setting, byte newValue) {