Android P Camera App(一)

主要Activity:

CameraActivity继承自QuickActivity,QuickActivity主要是为了解决在锁屏中的double resume问题;

 

主要的类/接口:

OneCameraOpener,是一个接口,里面就定义了一个open方法,用来打开相机设备;
Camera2OneCameraOpenerImpl实现了OneCameraOpener接口,其主要职能是通过CameraManager打开一个camera设备;

 

OneCameraManager,是一个接口,负责提供有关当前设备上可用摄像机硬件的详细信息;
Camera2OneCameraManagerImpl实现了OneCameraManager接口,也是通过CameraManager实现了接口中定义的方法;

 

CameraController,实现了两个接口分别是CameraAgent.CameraOpenCallback和CameraProvider;
CameraAgent,是一个抽象类,定义在frameworks/ex/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java,提供可能的相机设备操作的接口;
CameraOpenCallback是CameraAgent的一个内部接口。打开或关闭相机设备时的任何事件都会调用此接口,其中的错误回调与框架{@linkandroid.hardware.Camera.ErrorCallback}中定义的错误回调不同,后者在打开相机后使用。

public static interface CameraOpenCallback {
    /**
     * Callback when camera open succeeds.
     */
    public void onCameraOpened(CameraProxy camera);

    /**
     * Callback when {@link com.android.camera.CameraDisabledException} is
     * caught.
     *
     * @param cameraId The disabled camera.
     */
    public void onCameraDisabled(int cameraId);

    /**
     * Callback when {@link com.android.camera.CameraHardwareException} is
     * caught.
     *
     * @param cameraId The camera with the hardware failure.
     * @param info The extra info regarding this failure.
     */
    public void onDeviceOpenFailure(int cameraId, String info);

    /**
     * Callback when trying to open the camera which is already opened.
     *
     *@param cameraId The camera which is causing the open error.
     */
    public void onDeviceOpenedAlready(int cameraId, String info);

    /**
     * Callback when {@link java.io.IOException} is caught during
     * {@link android.hardware.Camera#reconnect()}.
     *
     * @param mgr The {@link CameraAgent}
     *            with the reconnect failure.
     */
    public void onReconnectionFailure(CameraAgent mgr, String info);
}

CameraProvider是Camera App内部定义的一个接口,定义相机提供者;
也就是说CameraController实现了打开和关闭设备时的回调接口&相机提供者接口;传入其中的CameraAgent通过CameraAgentFactory创建;
CameraAgentFactory定义在frameworks/ex/camera2/portability/src/com/android/ex/camera2/portability/CameraAgentFactory.java;

 

 

ModuleManager,模块管理器接口维护{@link ModuleManagerImpl.ModuleAgent};
ModuleManagerImpl,ModuleManager接口实现;内里有一组ModuleAgent数据;

private final SparseArray mRegisteredModuleAgents = new
            SparseArray(2);

ModuleAgent,ModuleManager的一个内部接口,负责维护静态特性和模块的创建。
ModulesInfo,一个包含模块信息的类,并将它们注册到{@link com.android.camera.app.ModuleManager};其内的setupModules方法中注册了各种module,如PhotoModule、VideoModule等;


0
1
2
3
4
5
6




    @integer/camera_mode_photo
    @integer/camera_mode_video
    @integer/camera_mode_refocus
    @integer/camera_mode_photosphere
    @integer/camera_mode_panorama
    @integer/camera_mode_gcam
    @integer/camera_mode_capture_intent

 

CameraAppUI,CameraAppUI集中控制跨模块共享的视图,而模块特定视图将在每个模块UI中处理;

你可能感兴趣的:(Android,Camera)