From 22795b02c6c6fdbfcd90b0a5683462e84e4d98bd Mon Sep 17 00:00:00 2001 From: Valentin Iftime Date: Fri, 18 Nov 2022 14:49:10 +0100 Subject: [PATCH] Update HW toggle state on boot only if enabled Do not notify HW toggle changes on device boot unless enabled (muted), otherwise the software privacy toggles will be disabled. Test: Disable HW mic toggle (unmute) > Mute mic via software toggle > Reboot device > Mic is still muted via SW toggles Bug: 258070117 Change-Id: I6cbabac476cdbf6c16bb7a8eaa9d1850d7239e83 --- .../com/android/server/input/InputManagerService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 8497dfb58ba6c..81a74215adf7e 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -369,7 +369,7 @@ public class InputManagerService extends IInputManager.Stub /** Switch code: Camera lens cover. When set the lens is covered. */ public static final int SW_CAMERA_LENS_COVER = 0x09; - /** Switch code: Microphone. When set it is off. */ + /** Switch code: Microphone. When set, the mic is muted. */ public static final int SW_MUTE_DEVICE = 0x0e; public static final int SW_LID_BIT = 1 << SW_LID; @@ -536,14 +536,14 @@ public class InputManagerService extends IInputManager.Stub // Set the HW mic toggle switch state final int micMuteState = getSwitchState(-1 /* deviceId */, InputDevice.SOURCE_ANY, SW_MUTE_DEVICE); - if (micMuteState != InputManager.SWITCH_STATE_UNKNOWN) { - setSensorPrivacy(Sensors.MICROPHONE, micMuteState != InputManager.SWITCH_STATE_OFF); + if (micMuteState == InputManager.SWITCH_STATE_ON) { + setSensorPrivacy(Sensors.MICROPHONE, true); } // Set the HW camera toggle switch state final int cameraMuteState = getSwitchState(-1 /* deviceId */, InputDevice.SOURCE_ANY, SW_CAMERA_LENS_COVER); - if (cameraMuteState != InputManager.SWITCH_STATE_UNKNOWN) { - setSensorPrivacy(Sensors.CAMERA, cameraMuteState != InputManager.SWITCH_STATE_OFF); + if (cameraMuteState == InputManager.SWITCH_STATE_ON) { + setSensorPrivacy(Sensors.CAMERA, true); } IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);