diff options
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallCameraManager.java | 24 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallPresenter.java | 22 |
2 files changed, 28 insertions, 18 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallCameraManager.java b/InCallUI/src/com/android/incallui/InCallCameraManager.java index b7ec079af..53000f1dd 100644 --- a/InCallUI/src/com/android/incallui/InCallCameraManager.java +++ b/InCallUI/src/com/android/incallui/InCallCameraManager.java @@ -57,14 +57,15 @@ public class InCallCameraManager { private boolean mUseFrontFacingCamera; /** - * Aspect ratio of the front facing camera. + * Indicates whether the list of cameras has been initialized yet. Initialization is delayed + * until a video call is present. */ - private float mFrontFacingCameraAspectRatio; + private boolean mIsInitialized = false; /** - * Aspect ratio of the rear facing camera. + * The context. */ - private float mRearFacingCameraAspectRatio; + private Context mContext; /** * Initializes the InCall CameraManager. @@ -73,7 +74,7 @@ public class InCallCameraManager { */ public InCallCameraManager(Context context) { mUseFrontFacingCamera = true; - initializeCameraList(context); + mContext = context; } /** @@ -103,6 +104,8 @@ public class InCallCameraManager { * @return The active camera ID. */ public String getActiveCameraId() { + maybeInitializeCameraList(mContext); + if (mUseFrontFacingCamera) { return mFrontFacingCameraId; } else { @@ -111,15 +114,17 @@ public class InCallCameraManager { } /** - * Get the camera ID and aspect ratio for the front and rear cameras. + * Get the list of cameras available for use. * * @param context The context. */ - private void initializeCameraList(Context context) { - if (context == null) { + private void maybeInitializeCameraList(Context context) { + if (mIsInitialized || context == null) { return; } + Log.v(this, "initializeCameraList"); + CameraManager cameraManager = null; try { cameraManager = (CameraManager) context.getSystemService( @@ -160,6 +165,9 @@ public class InCallCameraManager { } } } + + mIsInitialized = true; + Log.v(this, "initializeCameraList : done"); } public void addCameraSelectionListener(Listener listener) { diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 31be7d3d3..ea0652a6d 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -489,19 +489,21 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi + " hasCallStateChanged=" + hasCallStateChanged + " isVideoMode=" + isVideoMode()); - if (!hasCallStateChanged) { return; } - - final InCallCameraManager cameraManager = InCallPresenter.getInstance(). - getInCallCameraManager(); - - String prevCameraId = cameraManager.getActiveCameraId(); + if (!hasCallStateChanged) { + return; + } - updateCameraSelection(call); + if (isVideoCall) { + final InCallCameraManager cameraManager = InCallPresenter.getInstance(). + getInCallCameraManager(); - String newCameraId = cameraManager.getActiveCameraId(); + String prevCameraId = cameraManager.getActiveCameraId(); + updateCameraSelection(call); + String newCameraId = cameraManager.getActiveCameraId(); - if (!Objects.equals(prevCameraId, newCameraId) && CallUtils.isActiveVideoCall(call)) { - enableCamera(call.getVideoCall(), true); + if (!Objects.equals(prevCameraId, newCameraId) && CallUtils.isActiveVideoCall(call)) { + enableCamera(call.getVideoCall(), true); + } } // Make sure we hide or show the video UI if needed. |