由於谷歌策略機制,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除判斷包名來進行屏蔽