The Android system shuts down camera camera sounds in mute mode _android
Source: Internet
Author: User
In order to prevent candid camera, the industry has unwritten rules, mobile phone companies in doing camera, click on the camera and video button, must have a beep. As a result, Google is also very user-friendly to play the function of the sound of the camera, placed in the cameraservice, to prevent developers can not develop the camera, so long as the call camera function, it will ring, this is written dead in the framework.
This rule is a bit out of date today, this is not, today I received a test to mention a bug, said the company's new requirements, the request in the silent mode of the sound of the camera must also be canceled. Such shameless demand, perhaps in our China's largest mobile phone company will be mentioned. Don't say much nonsense, see how to change.
The first thought was to invoke the Audiomanager service, but it would involve interprocess communication, rather cumbersome. So I used the systemproperity. Want to add a property in the app monitor click event, will then Aduio state write in, if the mute mode, then write 1, then Cameraservice call PlaySound also take this property, to determine whether PlaySound.
About writing Systemprperty in app, I'd like to quote the Great God blog, blog address http://www.cnblogs.com/eustoma/archive/2011/05/28/2415859.html.
The following posts are referenced:
---------------------------------------------------------------------------------------------------------start
To make an application have a Aid_system uid
So how do you make the application's UID 1000?
Since I can compile with make in the Android system source environment, there are a few steps to take:
L Add attributes to the manifest node in the application's Androidmanifest.xml file:
Android:shareduserid= "Android.uid.system";
With the shared user ID, multiple apk with the same user ID can be configured to run in the same process. Then the UID of the program is Android.uid.system, that is to let the program run in the system process, so there is the right to set the prefix to the properties of HW.
L Modify android.mk file and add local_certificate: = platform;
Adding UID is not enough, if the installation apk can not be installed, prompted the signature does not match, because the program wants to run in the system process also has the target system's platform. Key, is the PLATFORM.PK8 and Platform.x509.pem two files. This setting allows the system to get the PLATFORM.PK8 and Platform.x509.pem two files. After using these two key signatures, apk can actually be put into the system process.
The APK is then compiled with the MM command, and the generated UID becomes 1000. In going to call Property_set ("Hw.jpeg.path", "/data/test.jpg"); there will be no problem.
--------------------------------------------------------------------------------------------------------------- ------------------------------End
Busy day to find its real Audiomanager.java file, a Key-value value has been written to the systemproperity:
Then in the CameraService.cpp file, add the following judgment about the place where the PlaySound () function is invoked:
Note: the Property_get () function requires the introduction of a header file,<cutils/properties.h>
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.