android電源添加重啟項
首先找到按電源彈出的選項的源文件,也就是freamwork/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
再找到private AlertDialog createDialog() 方法,裏麵有一個mItems的添加選項,在裏麵加入
//add by xxnan 2012-9-13
new SinglePressAction(
com.android.internal.R.drawable.ic_lock_power_off,
R.string.global_action_reboot) {
public void onPress() {
// reboot
ShutdownThread.reboot(mContext,null,false);
}
public boolean showDuringKeyguard() {
return true; freamwork/base/policy/src/com
}
public boolean showBeforeProvisioning() {
return true;
}
//add by xxnan 2012-9-13
代碼即可,添加重啟選項,但是R.string.global_action_reboot必須在資源文件下添加,再編譯資源文件。。。
在 base/core/res/res/values/string.xml和base/core/res/res/values-zh-rCN/string.xml下添加
<string name="global_action_reboot">reboot</string>
<string name="reboot_progress">rebooting...</string>
然後找到freamwork/base/policy/src/com/android/internal/app/Shutdown.java的private static void beginShutdownSequence(Context context)
方法,將pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
改為if(mReboot){ // reboot progress
pd.setTitle(context.getText(com.android.internal.R.string.global_action_reboot));
pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress));
}
else
{
pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
}
然後就是編譯了,先編譯源碼下的framework/base/core/res
再編譯base,最後編譯policy(按順序,不然會報錯)
最後將編譯好的out下的system/framework/framework.jar和framework-res.apk和android.policy.jar替換你機器裏system/framework的三個文件,重啟,ok完成了,感興趣的人
趕緊試一下吧。。。。(好像android硬件不支持重啟,所以隻能關機之後並不能重啟)。
最後更新:2017-04-04 07:03:34