android13 Camera open()跟踪

本文深入探讨了Android 13中如何通过`Camera.java`的`native_setup`调用JNI接口,连接到`android_hardware_Camera.cpp`。接着详细介绍了`Camera::connect`方法在`framework/av/camera/Camera.cpp`中的实现,生成了`Camera`, `bnCameraClient`和`Camera2Client`等对象的过程,涉及到BnCameraClient在Binder通信中的作用。" 110453502,6779109,C++编程:深入理解static、this、assert与枚举类型,"['C++', '编程语言', '编译器', '数据类型', '编程概念']
摘要由CSDN通过智能技术生成

frameworks/base/core/java/android/hardware/Camera.java

     /**
     * Creates a new Camera object to access the first back-facing camera on the
     * device. If the device does not have a back-facing camera, this returns
     * null. Otherwise acts like the {@link #open(int)} call.
     *
     * @return a new Camera object for the first back-facing camera, or null if there is no
     *  backfacing camera
     * @see #open(int)
     */
    public static Camera open() {
        int numberOfCameras = getNumberOfCameras();
        CameraInfo cameraInfo = new CameraInfo();
        for (int i = 0; i < numberOfCameras; i++) {
            getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
                return new Camera(i);
            }
        }
        return null;
    }   
private int cameraInit(int cameraId) {
        mShutterCallback = null;
        mRawImageCallback = null;
        mJpegCallback = null;
        mPreviewCallback = null;
        mPostviewCallback = null;
        mUsingPreviewAllocation = false;
        mZoomListener = null;

        Looper looper;
        if ((looper = Looper.myLooper()) != null) {
            mEventHandler = new EventHandler(this, looper);
        } else if ((looper = Looper.getMainLooper()) != null) {
            mEventHandler = new EventHandler(this, looper);
        } else {
            mEventHandler = null;
        }

        boolean overrideToPortrait = CameraManager.shouldOverrideToPortrait(
                ActivityThread.currentApplication().getApplicationContext());
        boolean forceSlowJpegMode = shouldForceSlowJpegMode();
        return native_setup(new WeakReference<Camera>(this), cameraId,
                ActivityThread.currentOpPackageName(), overrideToPortrait, forceSlowJpegMode);
    }

    &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值