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

Commit fd94f6fe authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "QuickBoot: switch normal power off to quickboot"

parents a2d8e54d 1fd45a9a
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.internal.R;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -235,6 +236,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac

        mItems = new ArrayList<Action>();

        final boolean quickbootEnabled = Settings.System.getInt(
                mContext.getContentResolver(), "enable_quickboot", 0) == 1;
        // first: power off
        mItems.add(
            new SinglePressAction(
@@ -242,6 +245,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                    R.string.global_action_power_off) {

                public void onPress() {
                    // goto quickboot mode
                    if (quickbootEnabled) {
                        startQuickBoot();
                        return;
                    }

                    // shutdown by making sure radio and power are handled accordingly.
                    mWindowManagerFuncs.shutdown(true);
                }
@@ -933,6 +942,16 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        }
    }

    private void startQuickBoot() {

        Intent intent = new Intent("qualcomm.intent.action.QUICKBOOT");
        intent.putExtra("mode", 0);
        try {
            mContext.startActivityAsUser(intent,UserHandle.CURRENT);
        } catch (ActivityNotFoundException e) {
        }
    }

    private static final class GlobalActionsDialog extends Dialog implements DialogInterface {
        private final Context mContext;
        private final int mWindowTouchSlop;