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

Commit c89cb6ab authored by DvTonder's avatar DvTonder Committed by Gerrit Code Review
Browse files

Merge "Framework: Add Advanced reboot (2 of 2)" into cm-10.1

parents 7961a0fc d7f95579
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -4858,6 +4858,12 @@ public final class Settings {
         */
        public static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";

        /**
         * Whether to include options in power menu for rebooting into recovery or bootloader
         * @hide
         */
        public static final String ADVANCED_REBOOT = "advanced_reboot";

        /**
         * This are the settings to be backed up.
         *
@@ -4900,7 +4906,8 @@ public final class Settings {
            MOUNT_UMS_NOTIFY_ENABLED,
            UI_NIGHT_MODE,
            LOCK_SCREEN_OWNER_INFO,
            LOCK_SCREEN_OWNER_INFO_ENABLED
            LOCK_SCREEN_OWNER_INFO_ENABLED,
            ADVANCED_REBOOT
        };

        /**
+60 −42
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 The Android Open Source Project
 * Copyright (C) 2013 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -14,13 +15,13 @@
 * limitations under the License.
 */

 
package com.android.server.power;

import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.IActivityManager;
import android.app.KeyguardManager;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.IBluetoothManager;
@@ -42,6 +43,7 @@ import android.os.Vibrator;
import android.os.SystemVibrator;
import android.os.storage.IMountService;
import android.os.storage.IMountShutdownObserver;
import android.provider.Settings;

import com.android.internal.telephony.ITelephony;

@@ -123,16 +125,31 @@ public final class ShutdownThread extends Thread {
                        ? com.android.internal.R.string.shutdown_confirm_question
                        : com.android.internal.R.string.shutdown_confirm);

        final int titleResourceId = mRebootSafeMode
                ? com.android.internal.R.string.reboot_safemode_title
                : (mReboot
                        ? com.android.internal.R.string.reboot_system
                        : com.android.internal.R.string.power_off);

        Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);

        if (confirm) {
            final CloseDialogReceiver closer = new CloseDialogReceiver(context);
            if (sConfirmDialog != null) {
                sConfirmDialog.dismiss();
                sConfirmDialog = null;
            }
            if (mReboot && !mRebootSafeMode) {
                // See if the advanced reboot menu is enabled and check the keyguard state
                boolean advancedReboot = Settings.Secure.getInt(context.getContentResolver(),
                        Settings.Secure.ADVANCED_REBOOT, 0) == 1;
                KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
                boolean locked = km.inKeyguardRestrictedInputMode();

                if (advancedReboot && !locked) {
                    // Include options in power menu for rebooting into recovery or bootloader
                    sConfirmDialog = new AlertDialog.Builder(context)
                        .setTitle(com.android.internal.R.string.reboot_system)
                            .setTitle(titleResourceId)
                            .setSingleChoiceItems(com.android.internal.R.array.shutdown_reboot_options, 0, new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    if (which < 0)
@@ -166,11 +183,12 @@ public final class ShutdownThread extends Thread {
                                    return true;
                                }
                            });
            } else {
                }
            }

            if (sConfirmDialog == null) {
                sConfirmDialog = new AlertDialog.Builder(context)
                        .setTitle(mRebootSafeMode
                                ? com.android.internal.R.string.reboot_safemode_title
                                : com.android.internal.R.string.power_off)
                        .setTitle(titleResourceId)
                        .setMessage(resourceId)
                        .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {