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

Commit 3ab94db6 authored by karthik bharadwaj's avatar karthik bharadwaj
Browse files

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
parent f4315edf
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -298,7 +298,7 @@ public class ContextHubService extends IContextHubService.Stub {
            mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers(
            mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers(
                    SensorPrivacyManager.Sensors.MICROPHONE, (userId, enabled) -> {
                    SensorPrivacyManager.Sensors.MICROPHONE, (userId, enabled) -> {
                        if (userId == getCurrentUserId()) {
                        if (userId == getCurrentUserId()) {
                            Log.d(TAG, "User: " + userId + " enabled: " + enabled);
                            Log.d(TAG, "User: " + userId + "mic privacy: " + enabled);
                            sendMicrophoneDisableSettingUpdate(enabled);
                            sendMicrophoneDisableSettingUpdate(enabled);
                        }
                        }
                });
                });
+5 −2
Original line number Original line Diff line number Diff line
@@ -324,8 +324,11 @@ public abstract class IContextHubWrapper {
        }
        }


        public void onMicrophoneDisableSettingChanged(boolean enabled) {
        public void onMicrophoneDisableSettingChanged(boolean enabled) {
            sendSettingChanged(android.hardware.contexthub.V1_2.Setting.GLOBAL_MIC_DISABLE,
            // The SensorPrivacyManager reports if microphone privacy was enabled,
                    enabled ? SettingValue.ENABLED : SettingValue.DISABLED);
            // 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) {
        private void sendSettingChanged(byte setting, byte newValue) {