To prevent videotaping, 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.
Saying that this rule is a bit out of date today, this is not, today I received a test to mention a bug, said that 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.
is just beginning to think of the service that invokes Audiomanager, but this involves interprocess communication, which is 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
Make the application have a Aid_system uid
How do you make the application's UID 1000?
because I can compile with make in the Android system source environment, I need to do the following:
L Add properties to the Manifest node in the application's Androidmanifest.xml file:
Android: Shareduserid= "Android.uid.system";
with a 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 into Android.uid.system, which is to let the program runIn the system process, this has the right to set the attribute prefixed by HW.
L Modify android.mk file, join local_certificate: = platform;
Adding UID is not enough, if you install apk at this time found that can not install, prompt signature does not match, The reason is that the program wants to run in the system process and have the platform of the target system. 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
is then compiled with the MM command, and the generated apk's 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 true Audiomanager.java file, a Key-value value has been written to the systemproperity:
& nbsp
then in the CameraService.cpp file, add the following judgment about the place where the PlaySound () function is invoked: