在APK中重启Android系统

来源:互联网 发布:英语词汇书籍推荐知乎 编辑:程序博客网 时间:2024/06/06 00:17

在自己的APK中重启Android系统,

相应代码:

Intent reboot = new Intent(Intent.ACTION_REBOOT);reboot.putExtra("nowait", 1);reboot.putExtra("interval", 1);reboot.putExtra("window", 0);sendBroadcast(reboot);

添加权限:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"      package="com.himi.edittext"      android:versionCode="1"      android:versionName="1.0"      android:sharedUserId="android.uid.system"><uses-permission android:name="android.permission.REBOOT" />
可能会报错,Project-->Clean下就可以了。

最关键的是APK的签名,需要跟系统一致,否则不能安装:

android\build\target\product\security下找到文件platform.pk8和platform.x509.pem

android\out\host\linux-x86\framework下找到文件signapk.jar

使用命令:

java -jar signapk.jar platform.x509.pem platform.pk8 OLD.apk NEW.apk

之后NEW.apk就可以安装了。

相关code:

android\frameworks\base\services\java\com\android\server\watchdog.java

原创粉丝点击