Use the android hide API to adjust the brightness

Source: Internet
Author: User

Footfall original, reprinted please indicate the source.

After Android 1.5, the brightness adjustment API is hidden, but the android source code can still be implemented 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:

 

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 must add the Android: shareduserid = "android. uid. System" attribute to the manifest node in androidmanifest. xml of the application. (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 signapk. The source code of signapk is under "build \ tools \ signapk" and its 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.

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.