How the Android Jelly Bean version modifies the camera service to a preemptive type

Source: Internet
Author: User
Tags android jelly bean

Implementation of a preemptive camera service, when some applications (such as flashlights) open camera in the background, when the camera app open camera can be occupied by the background app camera.


1. Modify CameraService.cpp (frameworks/av/services/camera/libcameraservice/)
The Connect () method of the file, which will
The original
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 ();
}
Modified to:

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. Modify CameraClient.cpp (frameworks/av/services/camera/libcameraservice/)
Disconnect () method of the file:
Will be the original:
if (callingpid! = Mclientpid && callingpid! = mservicepid) {
ALOGW ("Different Client-don ' t disconnect");
Return
}
Modified to:
if (callingpid! = Mclientpid && callingpid! = mservicepid) {
ALOGW ("Different client but preemptive camera service! ");
Return
}

How the Android Jelly Bean version modifies the camera service to a preemptive type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.