In development often encounter the use of the Android hidden API, the usual practice is to call through reflection, but the reflection of the performance of the impact, the code is not intuitive, I prefer to directly use those APIs.
So this is the beginning of this article, self-transformation of a android.jar, so that it contains the hidden API
In fact, the steps are very simple, because the Framework.jar in the Android system already contains the hidden API, just extract it and put it inside the Android.jar, just sort it out:
1) Get Framework.jar from the specified version of ROM
2) Unzip the Android.jar in Framework.jar and Android SDK
3) Framework.jar The solution out of the things android.jar out of the things, to cover
4) RePack
5) Replace the original with the new Android.jar
For convenience, write a script to complete the above work, where the solution Framework.jar use the Dex2jar tool, please download and configure the environment variables yourself
#!/bin/sh
Dex=$1
Ajar=$2
Out=$3
d2j-dex2jar.sh $DEX-O Framework-dex.jar
MV Framework-dex.jar Framework-dex.zip
unzip-d Framework-dex Framework-dex.zip
CP $AJAR Android-sdk.zip
unzip-d ANDROID-SDK Android-sdk.zip
Cp-r-F framework-dex/* android-sdk/
CD ANDROID-SDK
Zip-r Android-new.zip *
Cd..
MV Android-sdk/android-new.zip Android-new.zip
MV Android-new.zip Android-new.jar
RM Android-sdk.zip
RM Framework-dex.zip
RM-FR android-sdk/
RM-FR framework-dex/
MV Android-new.jar $OUT
echo "Done"
It's also easy to use, save the script as a makesdk.sh and give the executable permission, then use the
$ makesdk.sh Framework.jar Android.jar ~/desktop/
After execution, you can see a file named Android-new.jar on your desktop, which is the SDK that contains the hidden API.
Modify the Android.jar itself to include the hidden API