How to disable the camera sound of camera in mute mode in android

Source: Internet
Author: User

There are unwritten rules in the industry that phone companies must have a prompt when they click the photo and video keys for camera. Therefore, google also put the function of playing the photo sound in the cameraService to prevent developers from developing a non-audible camera. Therefore, as long as the camera function is called, it will surely sound, this is written to the framework.

This rule is a bit out of date today. This is not the case. Today I received a BUG mentioned in the test, saying that it is a new requirement of the company and that the photo sound must be canceled in the mute mode. This shameless demand may be mentioned by our largest fake mobile phone company in China. Let's talk a little bit about it. Let's see how it is changed.

The first thought was to call the service of audiomanager, but this involved inter-process communication, which was cumbersome. So SystemProperity is used. Add a property when the APP listens to the Click Event and write the current aduio status into it. If it is in the mute mode, write 1. Then cameraservice also obtains this property when playsound is called, to determine whether playsound is used.

For more information about how to write systemprperty to an app, refer to the blog address http://www.cnblogs.com/eustoma/archive/2011/05/28/2415859.html.
The following is a reference blog post:
--------------------------------------------------------------------------------------------------------- Start
Make the application have the UID of AID_SYSTEM
So how can I change the uid of an application to 1000?
Since I can use make to compile the Android system source code environment, the following steps are required:
L add attributes to the manifest node in the AndroidManifest. xml file of the application:
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, assign the UID of the program to android. uid. system, that is, to allow the program to run in the system process, so that you have the permission to set the attribute prefixed with hw.
L modify the Android. mk file and add LOCAL_CERTIFICATE: = platform;
Adding UID is not enough. If you cannot install APK at this time, the system prompts that the signature is inconsistent because the program wants to run in the system process and has a platform of the target system. key, Which is platform. pk8 and platform. x509.pem files. With this setting, the system can get two files: platform. pk8 and platform. x509.pem. The apk can be put into the system process only after the two keys are signed.
Then use the mm command to compile and the uid of the generated apk will become 1000. Call property_set ("hsf-jpeg. path", "/data/test.jpg.
Else -------------- end
I found that in the AudioManager. java file, a KEY-VALUE has been written to SystemProperity:
 
Then, in the CameraService. cpp file, add the following judgment on the place where the playsound () function is called:

Note: The property_get () function needs to introduce the header file, <cutils/properties. h>

Related Article

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.