转载自:http://www.eoeandroid.com/thread-233670-1-1.html
首先找到按电源弹出的选项的源文件,也就是freamwork/base/policy/src/com/android/internal/policy/impl/GlobalActions.java
再找到private AlertDialog createDialog() 方法,里面有一个mItems的添加选项,在里面加入
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
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
;
}
|
代码即可,添加重启选项,但是R.string.global_action_reboot必须在资源文件下添加,再编译资源文件。。。
在 base/core/res/res/values/string.xml和base/core/res/res/values-zh-rCN/string.xml下添加
01
02
|
<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));
01
02
03
04
05
06
07
08
09
10
11
|
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完成了