Loading InCallUI/src/com/android/incallui/InCallCameraManager.java +16 −8 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -73,7 +74,7 @@ public class InCallCameraManager { */ public InCallCameraManager(Context context) { mUseFrontFacingCamera = true; initializeCameraList(context); mContext = context; } /** Loading Loading @@ -103,6 +104,8 @@ public class InCallCameraManager { * @return The active camera ID. */ public String getActiveCameraId() { maybeInitializeCameraList(mContext); if (mUseFrontFacingCamera) { return mFrontFacingCameraId; } else { Loading @@ -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( Loading Loading @@ -160,6 +165,9 @@ public class InCallCameraManager { } } } mIsInitialized = true; Log.v(this, "initializeCameraList : done"); } public void addCameraSelectionListener(Listener listener) { Loading InCallUI/src/com/android/incallui/VideoCallPresenter.java +12 −10 Original line number Diff line number Diff line Loading @@ -489,20 +489,22 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi + " hasCallStateChanged=" + hasCallStateChanged + " isVideoMode=" + isVideoMode()); if (!hasCallStateChanged) { return; } if (!hasCallStateChanged) { return; } if (isVideoCall) { final InCallCameraManager cameraManager = InCallPresenter.getInstance(). getInCallCameraManager(); String prevCameraId = cameraManager.getActiveCameraId(); updateCameraSelection(call); String newCameraId = cameraManager.getActiveCameraId(); if (!Objects.equals(prevCameraId, newCameraId) && CallUtils.isActiveVideoCall(call)) { enableCamera(call.getVideoCall(), true); } } // Make sure we hide or show the video UI if needed. showVideoUi(call.getVideoState(), call.getState()); Loading Loading
InCallUI/src/com/android/incallui/InCallCameraManager.java +16 −8 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -73,7 +74,7 @@ public class InCallCameraManager { */ public InCallCameraManager(Context context) { mUseFrontFacingCamera = true; initializeCameraList(context); mContext = context; } /** Loading Loading @@ -103,6 +104,8 @@ public class InCallCameraManager { * @return The active camera ID. */ public String getActiveCameraId() { maybeInitializeCameraList(mContext); if (mUseFrontFacingCamera) { return mFrontFacingCameraId; } else { Loading @@ -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( Loading Loading @@ -160,6 +165,9 @@ public class InCallCameraManager { } } } mIsInitialized = true; Log.v(this, "initializeCameraList : done"); } public void addCameraSelectionListener(Listener listener) { Loading
InCallUI/src/com/android/incallui/VideoCallPresenter.java +12 −10 Original line number Diff line number Diff line Loading @@ -489,20 +489,22 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi + " hasCallStateChanged=" + hasCallStateChanged + " isVideoMode=" + isVideoMode()); if (!hasCallStateChanged) { return; } if (!hasCallStateChanged) { return; } if (isVideoCall) { final InCallCameraManager cameraManager = InCallPresenter.getInstance(). getInCallCameraManager(); String prevCameraId = cameraManager.getActiveCameraId(); updateCameraSelection(call); String newCameraId = cameraManager.getActiveCameraId(); if (!Objects.equals(prevCameraId, newCameraId) && CallUtils.isActiveVideoCall(call)) { enableCamera(call.getVideoCall(), true); } } // Make sure we hide or show the video UI if needed. showVideoUi(call.getVideoState(), call.getState()); Loading