How to adjust the brightness by using the android hidden API

Source: Internet
Author: User

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.

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.