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.