CameraCaptureSession.SetRepeatingRequest
App 调用该方法开始预览流程,通过层层调用最终会调用到Framework中的submitCaptureRequest方法,该方法主要作了两件事:
-
首先调用CameraService层CameraDeviceUser的submitRequestList方法,将此次Request下发到Cameraervice中
-
其次App通过参数传入的CameraCaptureSession.CaptureCallback对象存到CameraDeviceImpl对象中
/*CameraCaptureSession.java*/
public abstract int setRepeatingRequest(CaptureRequest request, CaptureCallback listener, Handler handler) throws CameraAccessException;
/*CameraCaptureSessionImpl.java*/
public synchronized int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException{
...
handler = CameraDeviceImpl.checkHandler(handler, callback);//获取Looper并创建handler
return this.addPendingSequence(this.mDeviceImpl.setRepeatingRequest(request, this.createCaptureCallbackProxy(handler, callback), this.mDeviceHandler));
}
/*CameraDeviceImpl.java*/
public int setRepeatingRequest(CaptureRequest request, CameraDeviceImpl.CaptureCallback callback, Executor executor) throws CameraAccessException{
List<CaptureRequest> requestList = new ArrayList();
requestList.add(request);
return this.submitCaptureRequest(requestList, callback, executor, true);
}
private int submitCaptureRequest(List<CaptureRequest> requestList, CameraDeviceImpl.CaptureCallback callback, Executor executor, boolean repeating) throws CameraAccessException{
...
synchronized(this.mInterfaceLock){
...
SubmitInfo requestInfo = this.mRemoteDevice.submitRequestList(requestArray, repeating);
...
if(this.mIdle){
this.mDeviceExector.execute(this.mCallOnActive);
}
this.mIdle = false;
return requestInfo.getRequestId();
}
}
/*ICameraDeviceUserWrapper.java*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws CameraAccessExceotion{
try{
return this.mRemoteDevice.submitRequestList(requestList, streaming);//ICameraDeviceUser mRemoteDevice
} catch(Throwable var4){
CameraManager.throwAsPublicException(var4);
throw new UnsupportedOperationException("UnExpected exception", var4);
}
}
/*ICameraDeviceUser.java*/
//ICameraDeviceUser是一个接口(interface),有三个类实现了这个接口,分别如下
/*ICameraDeviceUser.Stub.Proxy.submitRequestList 匿名内部类的匿名内部类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws RemoteException{
Parcel _data = Parcel.obtain()
SubmitInfo _result;
...
if(!_status && ICameraDeviceUser.Stub.getDefaultImpl() != null){
SubmitInfo var6 = ICameraDeviceUser.Stub.getDefaultImpl().submitRequestList(requestList, streaming);
}
...
if(0 != _reply.readInt()){
_result = (SubmitInfo)SubmitInfo.CREATOR.createFromParcel(_reply);
}
}
/*ICameraDeviceUser.Default.submitRequestList 匿名内部类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean streaming) throws RemoteException{
return null;
}
/*CameraDeviceUserShim.java 具体类的实现*/
public SubmitInfo submitRequestList(CaptureRequest[] request, boolean streaming){
...
return this.mLegacyDevice.submitRequestList(request, streaming);
}
/*LegacyCameraDevice.java*/
public SubmitInfo submitRequestList(CaptureRequest[] requestList, boolean repeating){
...
return this.mRequestThreadManager.submitCaptureRequests(requestList, repeating);
}
/*RequestThreadManager.java*/
public SubmitInfo submitCaptureRequests(CaptureRequest[] requests, boolean repeating){
Handler handler = this.mRequestThread.waitAndGetHandler();
synchronized(this.mIdleLock){
SubmitInfo info = this.mRequestQueue.submit(requests, repeating);
handler.sendEmptyMessage(2);
return info;
}
}