当前位置: 代码迷 >> 综合 >> camera进入后台被关闭问题
  详细解决方案

camera进入后台被关闭问题

热度:49   发布时间:2024-01-21 19:25:39.0

由于谷歌策略机制,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 timesint 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除判断包名来进行屏蔽