首页 > 代码库 > android Jelly Bean版本如何将camera service修改为强占式
android Jelly Bean版本如何将camera service修改为强占式
实现强占式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;
}
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修改为强占式
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。