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

Commit 06be2e55 authored by Guang Zhu's avatar Guang Zhu Committed by Automerger Merge Worker
Browse files

Merge "prevent Monkey from reboot or shutdown the device" into udc-dev am: 579d3d08

parents 4a1348fc 579d3d08
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -788,6 +788,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        @Override
        public boolean onLongPress() {
            // don't actually trigger the reboot if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
                return false;
            }
            mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_LONG_PRESS);
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
                mWindowManagerFuncs.reboot(true);
@@ -808,6 +813,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        @Override
        public void onPress() {
            // don't actually trigger the shutdown if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
                return;
            }
            mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_PRESS);
            // shutdown by making sure radio and power are handled accordingly.
            mWindowManagerFuncs.shutdown();
@@ -919,6 +929,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        @Override
        public boolean onLongPress() {
            // don't actually trigger the reboot if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
                return false;
            }
            mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_LONG_PRESS);
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
                mWindowManagerFuncs.reboot(true);
@@ -939,6 +954,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        @Override
        public void onPress() {
            // don't actually trigger the reboot if we are running stability
            // tests via monkey
            if (ActivityManager.isUserAMonkey()) {
                return;
            }
            mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_PRESS);
            mWindowManagerFuncs.reboot(false);
        }
+5 −0
Original line number Diff line number Diff line
@@ -1247,6 +1247,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case LONG_PRESS_POWER_SHUT_OFF:
            case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
                mPowerKeyHandled = true;
                // don't actually trigger the shutdown if we are running stability
                // tests via monkey
                if (ActivityManager.isUserAMonkey()) {
                    break;
                }
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,
                        "Power - Long Press - Shut Off");
                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.server.policy;

import android.app.ActivityManager;
import android.content.Context;
import android.os.UserManager;
import com.android.internal.globalactions.LongPressAction;
@@ -35,6 +36,11 @@ public final class PowerAction extends SinglePressAction implements LongPressAct

    @Override
    public boolean onLongPress() {
        // don't actually trigger the reboot if we are running stability
        // tests via monkey
        if (ActivityManager.isUserAMonkey()) {
            return false;
        }
        UserManager um = mContext.getSystemService(UserManager.class);
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            mWindowManagerFuncs.rebootSafeMode(true);
@@ -55,6 +61,11 @@ public final class PowerAction extends SinglePressAction implements LongPressAct

    @Override
    public void onPress() {
        // don't actually trigger the shutdown if we are running stability
        // tests via monkey
        if (ActivityManager.isUserAMonkey()) {
            return;
        }
        // shutdown by making sure radio and power are handled accordingly.
        mWindowManagerFuncs.shutdown(false /* confirm */);
    }
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.server.policy;

import android.app.ActivityManager;
import android.content.Context;
import android.os.UserManager;
import com.android.internal.globalactions.LongPressAction;
@@ -35,6 +36,11 @@ public final class RestartAction extends SinglePressAction implements LongPressA

    @Override
    public boolean onLongPress() {
        // don't actually trigger the reboot if we are running stability
        // tests via monkey
        if (ActivityManager.isUserAMonkey()) {
            return false;
        }
        UserManager um = mContext.getSystemService(UserManager.class);
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            mWindowManagerFuncs.rebootSafeMode(true);
@@ -55,6 +61,11 @@ public final class RestartAction extends SinglePressAction implements LongPressA

    @Override
    public void onPress() {
        // don't actually trigger the reboot if we are running stability
        // tests via monkey
        if (ActivityManager.isUserAMonkey()) {
            return;
        }
        mWindowManagerFuncs.reboot(false /* confirm */);
    }
}