After Android 1.5, the brightness adjustment API is hidden, but the android source code can still be implemented as follows:
CopyCode The Code is as follows: ipowermanager power = ipowermanager. stub. asinterface (servicemanager
. Getservice ("power "));
If (power! = NULL ){
Power. setbacklightbrightness (brightness );
The above Code cannot be called directly in the official SDK. It will prompt that ipowermanager and I servicemanager cannot be found. You need to download the android source code and compile the project that calls this method in the android source code environment.
The compilation method is as follows. Create the Android. mk file under the project root directory that calls this method:
Copy code The Code is as follows: local_path :=$ (call my-DIR)
Include $ (clear_vars)
Local_module_tags: = user
Local_src_files: = $ (call all-subdir-Java-files)
Local_package_name: = myproject
Local_certificate: = Platform
Include $ (build_package)
In additionProgramAndroid: shareduserid = "android. uid. System" is added to the manifest node in androidmanifest. xml. (Correct. This attribute does not need to be added)
Copy the project directory to/packages/apps/and execute Mmm compilation. The APK file is generated in the out directory. The APK file cannot be directly used here. A message indicating that the signature is invalid is displayed because the program wants to run in the system process and the target system's platform key is required.
Next, use the platform key to sign the APK:
1. Open the APK file with the compression software, and delete the CERT. SF and cert. RSA files under the META-INF directory.
2. Use the platform key of the target system to re-sign the APK file. First, find the key file. The location in my android source code directory is "build \ target \ product \ Security", and the following two files are platform. pk8 and platform. x509.pem. Then use the signapk tool provided by Android to sign the signapkSource codeIn "build \ tools \ signapk", the usage is "Java-jar signapk. Jar platform. x509.pem platform. pk8 input.apk output.apk"
the signed APK can be used. Other hidden APIs can be used in this way.