From 81c08f1d014049cafeada98739315835b3428076 Mon Sep 17 00:00:00 2001 From: Evan Severson Date: Fri, 30 Jul 2021 11:12:06 -0700 Subject: [PATCH] Restrict the mic and cam phone call ops when toggle is muted This way other systems can see that the op is IGNORED and not ALLOWED which will help with other privacy features when showing the mic accesses. Test: Make phone call, observe, flash with fix, make phone call, observe Fixes: 195084844 Change-Id: I01bca852a9798e3de1aec6dfa7cd1ae8fdd6c87c --- .../android/server/SensorPrivacyService.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/SensorPrivacyService.java b/services/core/java/com/android/server/SensorPrivacyService.java index ecd620e78c3c1..40e63dac72ea6 100644 --- a/services/core/java/com/android/server/SensorPrivacyService.java +++ b/services/core/java/com/android/server/SensorPrivacyService.java @@ -21,7 +21,6 @@ import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_CAMERA; import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; import static android.app.ActivityManager.RunningServiceInfo; import static android.app.ActivityManager.RunningTaskInfo; -import static android.app.AppOpsManager.MODE_ALLOWED; import static android.app.AppOpsManager.MODE_IGNORED; import static android.app.AppOpsManager.OP_CAMERA; import static android.app.AppOpsManager.OP_PHONE_CALL_CAMERA; @@ -382,17 +381,9 @@ public final class SensorPrivacyService extends SystemService { int sensor; if (result == MODE_IGNORED) { - if (code == OP_RECORD_AUDIO) { + if (code == OP_RECORD_AUDIO || code == OP_PHONE_CALL_MICROPHONE) { sensor = MICROPHONE; - } else if (code == OP_CAMERA) { - sensor = CAMERA; - } else { - return; - } - } else if (result == MODE_ALLOWED) { - if (code == OP_PHONE_CALL_MICROPHONE) { - sensor = MICROPHONE; - } else if (code == OP_PHONE_CALL_CAMERA) { + } else if (code == OP_CAMERA || code == OP_PHONE_CALL_CAMERA) { sensor = CAMERA; } else { return; @@ -1276,10 +1267,14 @@ public final class SensorPrivacyService extends SystemService { case MICROPHONE: mAppOpsManagerInternal.setGlobalRestriction(OP_RECORD_AUDIO, enabled, mAppOpsRestrictionToken); + mAppOpsManagerInternal.setGlobalRestriction(OP_PHONE_CALL_MICROPHONE, enabled, + mAppOpsRestrictionToken); break; case CAMERA: mAppOpsManagerInternal.setGlobalRestriction(OP_CAMERA, enabled, mAppOpsRestrictionToken); + mAppOpsManagerInternal.setGlobalRestriction(OP_PHONE_CALL_CAMERA, enabled, + mAppOpsRestrictionToken); break; } }