package com.android.internal.app;
+import java.io.*;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.ProgressDialog;
private PowerManager mPowerManager;
private PowerManager.WakeLock mWakeLock;
private Handler mHandler;
+ private static boolean mRebootReq;
private ShutdownThread() {
}
* @param confirm true if user confirmation is needed before shutting down.
*/
public static void shutdown(final Context context, boolean confirm) {
+ shutdown(context, confirm, false);
+ }
+
+ public static void shutdown(final Context context,
+ boolean confirm, boolean rebootonly) {
// ensure that only one thread is trying to power down.
// any additional calls are just returned
synchronized (sIsStartedGuard){
}
Log.d(TAG, "Notifying thread to start radio shutdown");
-
+ mRebootReq = rebootonly;
if (confirm) {
final AlertDialog dialog = new AlertDialog.Builder(context)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setTitle(com.android.internal.R.string.power_off)
- .setMessage(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();
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(rebootonly ?
+ com.android.internal.R.string.reboot :
+ com.android.internal.R.string.power_off)
+ .setMessage(rebootonly ?
+ com.android.internal.R.string.reboot_nb_confirm :
+ com.android.internal.R.string.shutdown_nb_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)) {
// throw up an indeterminate system dialog to indicate radio is
// shutting down.
ProgressDialog pd = new ProgressDialog(context);
- pd.setTitle(context.getText(com.android.internal.R.string.power_off));
- pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
+ pd.setTitle(context.getText(mRebootReq ?
+ com.android.internal.R.string.reboot :
+ com.android.internal.R.string.power_off));
+ pd.setMessage(context.getText(mRebootReq ?
+ com.android.internal.R.string.reboot_progress :
+ com.android.internal.R.string.shutdown_progress));
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
// Shutdown power
Log.i(TAG, "Performing low-level shutdown...");
- Power.shutdown();
+ if (mRebootReq)
+ try {
+ Power.reboot(null);
+ } catch (IOException e) {
+ Log.e(TAG, "can not reboot the machine " + e);
+ }
+ else
+ Power.shutdown();
}
}
<!-- Button to turn off the phone, within the Phone Options dialog -->
<string name="power_off">Power off</string>
+ <!-- Button to Reboot the device, within the power button Options dialog -->
+ <string name="reboot">Reboot</string>
+
<!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. -->
<string name="shutdown_progress">Shutting down\u2026</string>
+ <!-- Rebooting Progress Dialog. This is shown if the user chooses to reboot the device. -->
+ <string name="reboot_progress">Rebooting\u2026</string>
+
<!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, there will be a confirmation dialog. This is the message. -->
<string name="shutdown_confirm">Your phone will shut down.</string>
+ <!-- Shutdown Confirmation Dialog. When the user chooses to power off the machine, there will be a confirmation dialog. This is the message. -->
+ <string name="shutdown_nb_confirm">Your machine will shut down.</string>
+
+ <!-- Reboot Confirmation Dialog. When the user chooses to reboot the machine, there will be a confirmation dialog. This is the message. -->
+ <string name="reboot_nb_confirm">Your machine will reboot.</string>
+
<!-- Recent Tasks dialog: title -->
<string name="recent_tasks_title">Recent</string>
<!-- Recent Tasks dialog: message when there are no recent applications -->
<!-- Title of the Global Actions Dialog -->
<string name="global_actions">Phone options</string>
+ <!-- Title of the Global Actions Dialog -->
+ <string name="global_nb_actions">Power button options</string>
+
<!-- label for item that locks the phone in the phone options dialog -->
<string name="global_action_lock">Screen lock</string>
<!-- label for item that turns off power in phone options dialog -->
<string name="global_action_power_off">Power off</string>
+ <!-- label for item that reboots the device in phone options dialog -->
+ <string name="global_action_reboot">Reboot</string>
+
<!-- label for item that enables silent mode in phone options dialog -->
<string name="global_action_toggle_silent_mode">Silent mode</string>