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

Commit de2e36ef authored by maxwen's avatar maxwen Committed by Łukasz Patron
Browse files

SystemUI: Add reboot fastboot to power menu

Change-Id: I88f00a273f4a0be1355158c58a24db78cb8e684e
parent b6b24828
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -614,6 +614,13 @@ public final class PowerManager {
     */
    public static final String REBOOT_DOWNLOAD = "download";

    /**
     * The value to pass as the 'reason' argument to reboot() to
     * reboot into fastboot mode
     * @hide
     */
    public static final String REBOOT_FASTBOOT = "fastboot";

    /**
     * The value to pass as the 'reason' argument to reboot() when device owner requests a reboot on
     * the device.
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2019 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:pathData="M 22 9 L 22 7 L 20 7 L 20 5 C 20 4.47 19.789 3.961 19.414 3.586 C 19.039 3.211 18.53 3 18 3 L 4 3 C 3.47 3 2.961 3.211 2.586 3.586 C 2.211 3.961 2 4.47 2 5 L 2 19 C 2 19.53 2.211 20.039 2.586 20.414 C 2.961 20.789 3.47 21 4 21 L 18 21 C 18.53 21 19.039 20.789 19.414 20.414 C 19.789 20.039 20 19.53 20 19 L 20 17 L 22 17 L 22 15 L 20 15 L 20 13 L 22 13 L 22 11 L 20 11 L 20 9 L 22 9 M 18 19 L 4 19 L 4 5 L 18 5 L 18 19 M 6 13 L 11 13 L 11 17 L 6 17 L 6 13 M 12 7 L 16 7 L 16 10 L 12 10 L 12 7 M 6 7 L 11 7 L 11 12 L 6 12 L 6 7 M 12 11 L 16 11 L 16 17 L 12 17 L 12 11 Z"
        android:fillColor="#000000" />
</vector>
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
    <string name="global_action_restart_bootloader">Bootloader</string>
    <!-- Button to restart the device into download mode, within the Restart Options dialog -->
    <string name="global_action_restart_download">Download</string>
    <!-- Button to restart the device into fastboot mode, within the Restart Options dialog -->
    <string name="global_action_restart_fastboot">Fastbootd</string>

    <!-- Restart progress dialog. This is shown if the user chooses to restart the device. -->
    <string name="global_action_restart_progress">Restarting\u2026</string>
@@ -36,6 +38,8 @@
    <string name="global_action_restart_bootloader_progress">Restarting to bootloader mode\u2026</string>
    <!-- Restart to download mode progress dialog. This is shown if the user chooses to restart the device. -->
    <string name="global_action_restart_download_progress">Restarting to download mode\u2026</string>
    <!-- Restart to fastboot mode progress dialog. This is shown if the user chooses to restart the device. -->
    <string name="global_action_restart_fastboot_progress">Restarting to fastbootd mode\u2026</string>

    <!-- Label for current user in power menu options dialog -->
    <string name="global_action_current_user">Current</string>
+27 −0
Original line number Diff line number Diff line
@@ -314,6 +314,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                items.add(new RestartBootloaderAction());
            } else if (GLOBAL_ACTION_KEY_RESTART_DOWNLOAD.equals(actionKey)) {
                items.add(new RestartDownloadAction());
            } else if (GLOBAL_ACTION_KEY_RESTART_FASTBOOT.equals(actionKey)) {
                items.add(new RestartFastbootAction());
            }
        }
        return items;
@@ -447,6 +449,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            } else if (GLOBAL_ACTION_KEY_RESTART_DOWNLOAD.equals(actionKey) &&
                    PowerMenuUtils.isAdvancedRestartPossible(mContext)) {
                mItems.add(new RestartDownloadAction());
            } else if (GLOBAL_ACTION_KEY_RESTART_FASTBOOT.equals(actionKey) &&
                    PowerMenuUtils.isAdvancedRestartPossible(mContext)) {
                mItems.add(new RestartFastbootAction());
            } else if (GLOBAL_ACTION_KEY_SCREENSHOT.equals(actionKey)) {
                mItems.add(new ScreenshotAction());
            } else if (GLOBAL_ACTION_KEY_LOGOUT.equals(actionKey)) {
@@ -751,6 +756,28 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        }
    }

    private final class RestartFastbootAction extends SinglePressAction {
        private RestartFastbootAction() {
            super(com.android.systemui.R.drawable.ic_lock_restart_fastboot,
                    com.android.systemui.R.string.global_action_restart_fastboot);
        }

        @Override
        public boolean showDuringKeyguard() {
            return true;
        }

        @Override
        public boolean showBeforeProvisioning() {
            return true;
        }

        @Override
        public void onPress() {
            mWindowManagerFuncs.reboot(false, PowerManager.REBOOT_FASTBOOT);
        }
    }

    private class ScreenshotAction extends SinglePressAction implements LongPressAction {
        public ScreenshotAction() {
            super(R.drawable.ic_screenshot, R.string.global_action_screenshot);
+3 −0
Original line number Diff line number Diff line
@@ -137,6 +137,9 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
                } else if (PowerManager.REBOOT_DOWNLOAD.equals(reason)) {
                    message.setText(
                            com.android.systemui.R.string.global_action_restart_download_progress);
                } else if (PowerManager.REBOOT_FASTBOOT.equals(reason)) {
                    message.setText(
                            com.android.systemui.R.string.global_action_restart_fastboot_progress);
                }
            } else {
                message.setText(com.android.systemui.R.string.global_action_restart_progress);