android添加reboot选项
1,GlobalAction.java中mItems = Lists.newArrayList(处添加new SinglePressAction(
com.android.internal.R.drawable.ic_lock_power_off,
R.string.global_action_power_reboot) {
public void onPress() {
ShutdownThread.reboot(mContext, null, true);
}
public boolean showDuringKeyguard() {
return true;
}
public boolean showBeforeProvisioning() {
return true;
}
});
2,在ShutdownThread.java中新增加一个方法
public static void shutdown(final Context context, boolean confirm,boolean isReboot) {
mReboot = isReboot ;
// ensure that only one thread is trying to power down.
// any additional calls are just returned
synchronized (sIsStartedGuard) {
if (sIsStarted) {
Log.d(TAG, "Request to shutdown already running, returning.");
return;
}
}
Log.d(TAG, "Notifying thread to start radio shutdown");
if (confirm) {
final AlertDialog dialog = new AlertDialog.Builder(context)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(mReboot?com.android.internal.R.string.global_action_power_reboot:com.android.internal.R.string.global_action_power_off)
.setMessage(mReboot?com.android.internal.R.string.reboot_confirm:com.android.internal.R.string.shutdown_confirm)
.setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
beginShutdownSequence(context);
}
})
.setNegativeButton(com.android.internal.R.string.no, null)
.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_sf_slowBlur)) {
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
dialog.show();
} else {
beginShutdownSequence(context);
}
}