由于谷歌策略机制,camera无法在后台长时间运行,activity在判断camera进入后台后,会调用到
frameworks/av/services/camera/libcameraservice/common
template <typename TClientBase>
binder::Status Camera2ClientBase<TClientBase>::disconnect() {
ATRACE_CALL();
Mutex::Autolock icl(mBinderSerializationLock);
binder::Status res = binder::Status::ok();
// Allow both client and the media server to disconnect at all times
int callingPid = getCallingPid();
if (callingPid != TClientBase::mClientPid &&
callingPid != TClientBase::mServicePid) return res;
ALOGV("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
detachDevice();
CameraService::BasicClient::disconnect();
ALOGV("Camera %s: Shut down complete complete", TClientBase::mCameraIdStr.string());
return res;
}
可以在这里修改,判断pid等于0,则直接返回。
但是正规方法还是应该在blockClientsForUid除判断包名来进行屏蔽