From 815fda395dce047e34a33dc035322a4a184100a1 Mon Sep 17 00:00:00 2001 From: Anthony Hugh Date: Fri, 7 May 2021 20:26:41 -0700 Subject: [PATCH] Use correct UserId when checking for lock state Update API to include userId rather than using the default Context userId. Fixes: 187344132 Test: Toggling muted mic works Change-Id: I2771117d97f89e961a6fb9949d28f0edbb4b5591 --- .../core/java/com/android/server/SensorPrivacyService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/SensorPrivacyService.java b/services/core/java/com/android/server/SensorPrivacyService.java index 7763ad9ea3856..a05eb6818b17a 100644 --- a/services/core/java/com/android/server/SensorPrivacyService.java +++ b/services/core/java/com/android/server/SensorPrivacyService.java @@ -469,7 +469,7 @@ public final class SensorPrivacyService extends SystemService { @Override public void setIndividualSensorPrivacy(@UserIdInt int userId, int sensor, boolean enable) { enforceManageSensorPrivacyPermission(); - if (!canChangeIndividualSensorPrivacy(sensor)) { + if (!canChangeIndividualSensorPrivacy(userId, sensor)) { return; } @@ -500,14 +500,14 @@ public final class SensorPrivacyService extends SystemService { mHandler.onSensorPrivacyChanged(userId, sensor, enable); } - private boolean canChangeIndividualSensorPrivacy(int sensor) { + private boolean canChangeIndividualSensorPrivacy(@UserIdInt int userId, int sensor) { if (sensor == MICROPHONE && mEmergencyCallHelper.isInEmergencyCall()) { // During emergency call the microphone toggle managed automatically Log.i(TAG, "Can't change mic toggle during an emergency call"); return false; } - if (mKeyguardManager != null && mKeyguardManager.isDeviceLocked()) { + if (mKeyguardManager != null && mKeyguardManager.isDeviceLocked(userId)) { Log.i(TAG, "Can't change mic/cam toggle while device is locked"); return false; }