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

Commit b7dbe042 authored by Kun Liang's avatar Kun Liang Committed by Linux Build Service Account
Browse files

QuickBoot: switch normal power off to quickboot

Handle power off button when quickboot mode enabled.

Change-Id: If317441a611e5bfed69c1a3c7ee4045b49a36d86
parent 2256fcf0
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.app.ActivityManager;
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;
@@ -353,6 +354,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac

        @Override
        public void onPress() {
            final boolean quickbootEnabled = Settings.System.getInt(
                    mContext.getContentResolver(), "enable_quickboot", 0) == 1;
            // go to quickboot mode if enabled
            if (quickbootEnabled) {
                startQuickBoot();
                return;
            }
            // shutdown by making sure radio and power are handled accordingly.
            mWindowManagerFuncs.shutdown(false /* confirm */);
        }
@@ -1072,6 +1080,16 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        }
    }

    private void startQuickBoot() {

        Intent intent = new Intent("org.codeaurora.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;