標籤:android ar 檔案 sp on log amp bs as
實現強佔式camera service,當某些應用(如手電筒)在後台開啟camera後,當camera app open camera時可以強佔被後台應用佔有的camera.
1. 修改CameraService.cpp (frameworks/av/services/camera/libcameraservice/)
檔案的connect()方法,將
原來的
Mutex::Autolock lock(mServiceLock);
if (mClient[cameraId] != 0) {
client = mClient[cameraId].promote();
if (client != 0) {
if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
LOG1("CameraService::connect X (pid %d) (the same client)",
callingPid);
return client;
} else {
ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
callingPid);
return NULL;
}
}
mClient[cameraId].clear();
}
修改為:
if (mClient[cameraId] != 0) {
client = mClient[cameraId].promote();
if (client != 0) {
LOG1("CameraService::connect X (pid %d) disconnect the old client", callingPid);
client->disconnect();
}
mClient[cameraId].clear();
}
Mutex::Autolock lock(mServiceLock);
2. 修改CameraClient.cpp(frameworks/av/services/camera/libcameraservice/)
檔案的disconnect()方法:
將原來的:
if (callingPid != mClientPid && callingPid != mServicePid) {
ALOGW("different client - don‘t disconnect");
return;
}
修改為:
if (callingPid != mClientPid && callingPid != mServicePid) {
ALOGW("different client but preemptive camera service! ");
//return;
}
android Jelly Bean版本如何將camera service修改為強佔式