From bec9be8b8bcba56b32a5ce834b4926a527a0b247 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 19 Oct 2018 13:09:39 -0700 Subject: CameraServiceProxy: Notify audio service of camera facing When a camera is opened, notify the audio service which way the camera faces. This can be used by the audio system to select microphone tuning for the CAMCORDER option that's dependent on camera direction. External facing is treated the same as front-facing. Bug: 118022272 Test: Manual Change-Id: I0a89d82a015f371580d335b232013ece80bfa4d3 (cherry picked from commit 06075ee67318ce505d95b93820c54fbd544a0675) --- .../java/com/android/server/camera/CameraServiceProxy.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java index 0ee55ed2e832..527539d8ce0d 100644 --- a/services/core/java/com/android/server/camera/CameraServiceProxy.java +++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.hardware.ICameraService; import android.hardware.ICameraServiceProxy; +import android.media.AudioManager; import android.metrics.LogMaker; import android.nfc.INfcAdapter; import android.os.Binder; @@ -393,6 +394,19 @@ public class CameraServiceProxy extends SystemService boolean wasEmpty = mActiveCameraUsage.isEmpty(); switch (newCameraState) { case ICameraServiceProxy.CAMERA_STATE_OPEN: + // Notify the audio subsystem about the facing of the most-recently opened + // camera This can be used to select the best audio tuning in case video + // recording with that camera will happen. Since only open events are used, if + // multiple cameras are opened at once, the one opened last will be used to + // select audio tuning. + AudioManager audioManager = getContext().getSystemService(AudioManager.class); + if (audioManager != null) { + // Map external to front for audio tuning purposes + String facingStr = (facing == ICameraServiceProxy.CAMERA_FACING_BACK) ? + "back" : "front"; + String facingParameter = "cameraFacing=" + facingStr; + audioManager.setParameters(facingParameter); + } break; case ICameraServiceProxy.CAMERA_STATE_ACTIVE: CameraUsageEvent newEvent = new CameraUsageEvent(facing, clientName, apiLevel); -- cgit v1.2.3