Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit daad73d8 authored by Steve Kondik's avatar Steve Kondik Committed by Diogo Ferreira
Browse files

framework: Add reboot menu and reboot options

This is a collection of changes from several people, forward
ported to gingerbread.

Steve Kondik <shade@chemlab.org>
Adds a reboot option to the power menu.

Eddie Ringle <eddie@eringle.net>
Froyo's ShutdownThread wants a reboot reason (we use null to just reboot)

Eddie Ringle <eddie@eringle.net>
Add Reboot string for phone options dialog

Diogo Ferreira <diogo@underdev.org>
Add recovery and bootloader popup options to reboot dialog.

Steve Kondik <shade@chemlab.org>
Add strings for reboot option on power menu.

Eddie Ringle <eddie.ringle@gmail.com>
Use the reboot strings during a reboot
parent 483395d8
Loading
Loading
Loading
Loading
+45 −13
Original line number Diff line number Diff line
@@ -98,7 +98,33 @@ public final class ShutdownThread extends Thread {
        Log.d(TAG, "Notifying thread to start radio shutdown");

        if (confirm) {
            final AlertDialog dialog = new AlertDialog.Builder(context)
            final AlertDialog dialog;
            // Set different dialog message based on whether or not we're rebooting
            if (mReboot) {
                dialog = new AlertDialog.Builder(context)
                        .setIcon(android.R.drawable.ic_dialog_alert)
                        .setTitle(com.android.internal.R.string.reboot_system)
                        .setSingleChoiceItems(com.android.internal.R.array.shutdown_reboot_options, 0, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                if (which < 0)
                                    return;

                                String actions[] = context.getResources().getStringArray(com.android.internal.R.array.shutdown_reboot_actions);

                                if (actions != null && which < actions.length)
                                    mRebootReason = actions[which];
                            }
                        })
                        .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                               mReboot = true;
                                beginShutdownSequence(context);
                            }
                        })
                        .setNegativeButton(com.android.internal.R.string.no, null)
                        .create();
            } else {
                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)
@@ -109,6 +135,7 @@ public final class ShutdownThread extends Thread {
                        })
                        .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)) {
@@ -147,8 +174,13 @@ public final class ShutdownThread extends Thread {
        // throw up an indeterminate system dialog to indicate radio is
        // shutting down.
        ProgressDialog pd = new ProgressDialog(context);
        if (mReboot) {
            pd.setTitle(context.getText(com.android.internal.R.string.reboot_system));
            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));
        }
        pd.setIndeterminate(true);
        pd.setCancelable(false);
        pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
+15 −0
Original line number Diff line number Diff line
@@ -106,4 +106,19 @@
        <item>3</item>
    </integer-array>

    <!-- Defines the shutdown options shown in the reboot dialog. -->
    <array name="shutdown_reboot_options">
        <item>Reboot</item>
        <item>Recovery</item>
        <item>Bootloader</item>
    </array>

    <!-- Do not translate. Defines the shutdown actions passed to the kernel.
         The first item should be empty for regular reboot. -->
    <string-array name="shutdown_reboot_actions">
        <item></item>
        <item>recovery</item>
        <item>bootloader</item>
    </string-array>

</resources>
+11 −0
Original line number Diff line number Diff line
@@ -276,13 +276,21 @@
    <string name="screen_lock">Screen lock</string>
    <!-- Button to turn off the phone, within the Phone Options dialog -->
    <string name="power_off">Power off</string>
    <!-- Button to reboot the phone, within the Phone Options dialog -->
    <string name="reboot_system">Reboot phone</string>

    <!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. -->
    <string name="shutdown_progress">Shutting down\u2026</string>

    <!-- Reboot Progress Dialog. This is shown if the user chooses to reboot the phone. -->
    <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>

    <!-- Reboot Confirmation Dialog.  When the user chooses to reboot the phone, there will be a confirmation dialog.  This is the message. -->
    <string name="reboot_confirm">Your phone will reboot.</string>

    <!-- Recent Tasks dialog: title -->
    <string name="recent_tasks_title">Recent</string>
    <!-- Recent Tasks dialog: message when there are no recent applications -->
@@ -297,6 +305,9 @@
    <!-- 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 phone 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>

+14 −0
Original line number Diff line number Diff line
@@ -197,6 +197,20 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                mSilentModeToggle,
                // next: airplane mode
                mAirplaneModeOn,
                // next: reboot
                new SinglePressAction(com.android.internal.R.drawable.ic_lock_power_off, R.string.global_action_reboot) {
                    public void onPress() {
                        ShutdownThread.reboot(mContext, null, true);
                    }

                    public boolean showDuringKeyguard() {
                        return true;
                    }

                    public boolean showBeforeProvisioning() {
                        return true;
                    }
                },
                // last: power off
                new SinglePressAction(
                        com.android.internal.R.drawable.ic_lock_power_off,