openCameraDeviceUserAsync 函数创建的 CameraDeviceImpl

android.hardware.camera2.impl.CameraDeviceImpl deviceImpl =

    new android.hardware.camera2.impl.CameraDeviceImpl(

      cameraId,

      callback, ------------------------->mDeviceCallback

      executor,

      characteristics,

      mContext.getApplicationInfo().targetSdkVersion);

  private final CameraDeviceCallbacks mCallbacks = new CameraDeviceCallbacks();


  private final StateCallback mDeviceCallback;

  private volatile StateCallbackKK mSessionStateCallback;

ICameraDeviceCallbacks callbacks = deviceImpl.getCallbacks();

ICameraService cameraService = CameraManagerGlobal.get().getCameraService();

 cameraUser = cameraService.connectDevice(callbacks, cameraId,

     mContext.getOpPackageName(), uid);

 deviceImpl.setRemoteDevice(cameraUser);

 device = deviceImpl;


//cameraUser 映射到CPP层对应的CameraDevice

mRemoteDevice = new ICameraDeviceUserWrapper(remoteDevice); 对应的是cameraservice去


  private final Runnable mCallOnOpened = new Runnable() {

    @Override

    public void run() {

      StateCallbackKK sessionCallback = null;

      synchronized(mInterfaceLock) {

        if (mRemoteDevice == null) return; // Camera already closed


        sessionCallback = mSessionStateCallback; //目前是空,是app 创建的

      }

      if (sessionCallback != null) {

        sessionCallback.onOpened(CameraDeviceImpl.this);

      }

      mDeviceCallback.onOpened(CameraDeviceImpl.this);//回调到APP 层的onOpened

    }

  };

CameraDeviceImpl.java

CameraDeviceImpl.java

2019-03-30 09:55:53 0 76
这里是评论

相关推荐