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;
It is not enough to add UID. If the APK cannot be installed at this time, the system prompts that the signature is inconsistent because the program wants to run in the system process and has the target system's platform. 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>