How to achieve brightness adjustment using the Android hidden API _android

Source: Internet
Author: User

The API to adjust brightness after Android 1.5 is hidden, but there are still ways to do it in the Android source code, as follows:

Copy Code code as follows:

Ipowermanager power = IPowerManager.Stub.asInterface (ServiceManager

. GetService ("power"));

if (power!= null) {

Power.setbacklightbrightness (brightness);

The code above cannot be invoked directly in the official SDK, prompting the Ipowermanager and I servicemanager to download the Android source, which will be compiled in the Android Code environment.

The compilation method is as follows, creating the Android.mk file under the engineering root that invokes the method:

Copy Code code 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 addition, you need to add the android:shareduserid= "Android.uid.system" attribute to the manifest node in the application's androidmanifest.xml. (correction, this property does not need to be added)

Copy the engineering directory to/packages/apps/and perform MMM compilation. Will be in the out directory to generate APK files, where the APK can not be used directly, will prompt the signature does not match, because the program wants to run in the system process also has the target system platform key.

Next, use the platform key to sign the APK:

1. Use the compression software to open the apk file, delete the cert.sf and cert.rsa two 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, in my Android source directory where the location is "build\target\product\security", the following platform.pk8 and Platform.x509.pem two files. Then use the SIGNAPK tool provided by Android to sign, signapk source code is under "build\tools\signapk", the usage is "Java–jar Signapk.jar Platform.x509.pem Platform.pk8 input.apk output.apk "

The APK can be used after signing, and other hidden APIs can be used in this way.

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.