How to modify the system time in Android (application obtains system privileges)
The Systemclock.setcurrenttimemillis () function is available in the Android API to modify the system time, but no matter how you call this function is useless, regardless of the emulator or the real machine, in Logcat always get "unable to Open alarm driver:permission denied ". This function needs to be rooted or run with the system process.
Originally thought there is no way in the application of this layer to change the system time, and later on the internet search for a long, know that the purpose can still be achieved.
The first method is simple, but it needs to be compiled with make in the context of the Android system source code:
1. Add the android:shareduserid= "Android.uid.system" attribute to the manifest node in the application's androidmanifest.xml.
2. Modify the Android.mk file, add local_certificate: = Platform this line
3. Using the MM command to compile, the generated apk will have the ability to modify the system time.
The second method is troublesome, but do not run the virtual machine into the source environment with make to compile:
1. Ibid., add android:shareduserid= "Android.uid.system" to this property.
2. Compile the apk file with Eclipse, but this apk file is not available.
3. Open the APK file with the compression software, delete the cert.sf and cert.rsa two files in the Meta-inf directory.
4. Use the target system's platform key to re-sign the apk file. This step is more troublesome, first find the key file, the location in my Android source directory is "Build\target\product\security", below the Platform.pk8 and Platform.x509.pem two files. Then use Android to provide the signapk tool to sign, signapk source code is under "build\tools\signapk", the use of "signapk Platform.x509.pem platform.pk8 input.apk output.apk ", the file name is best to use absolute path to prevent not found, you can also modify the source code to use directly.
The last available apk is the same as the first one.
Finally explain the principle, first add android:shareduserid= "Android.uid.system" this attribute. With the shared user ID, multiple apk with the same user ID can be configured to run in the same process. Then the UID of the program into a android.uid.system, that is, to let the program run in the system process, so that there is permission to modify the system time.
Just adding UID is not enough, if you install the APK at this time found unable to install, prompt signature does not match, because the program wants to run in the system process and the target system platform key, The second method mentioned above is the PLATFORM.PK8 and Platform.x509.pem two files. Using these two keys to sign the APK before it can actually be put into the system process. The first method adds Local_certificate: = Platform is actually signed with these two keys.
There is also a problem, that is, the generated programs can only be used in the original Android system or in their own compiled system, because such a system can get platform.pk8 and Platform.x509.pem two files. If the other company does not have the Android installed on the installation. Try the original Android key to sign, the program runs OK on the emulator, but put on the G3 to install the direct prompt "package ... has no signatures that match those in shared user Android.uid. System ", which also protects the security of the systems.
Last but not least, this Android:shareduserid property can not only put the APK into the system process, you can also configure multiple apk running in a process, so that the data can be shared, it should be useful.
Transferred from: http://www.cnblogs.com/Tiger-Dog/articles/2057917.html
Apps in Android get system permissions