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

Commit de95ec6e 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:...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21910222



Change-Id: I1db2b91ad8950b1ab98f04912f12655437c4c5f4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7b8e6351 3ed99294
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -788,6 +788,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene


        @Override
        @Override
        public boolean onLongPress() {
        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);
            mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_LONG_PRESS);
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
                mWindowManagerFuncs.reboot(true);
                mWindowManagerFuncs.reboot(true);
@@ -808,6 +813,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene


        @Override
        @Override
        public void onPress() {
        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);
            mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_PRESS);
            // shutdown by making sure radio and power are handled accordingly.
            // shutdown by making sure radio and power are handled accordingly.
            mWindowManagerFuncs.shutdown();
            mWindowManagerFuncs.shutdown();
@@ -919,6 +929,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene


        @Override
        @Override
        public boolean onLongPress() {
        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);
            mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_LONG_PRESS);
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
                mWindowManagerFuncs.reboot(true);
                mWindowManagerFuncs.reboot(true);
@@ -939,6 +954,11 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene


        @Override
        @Override
        public void onPress() {
        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);
            mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_PRESS);
            mWindowManagerFuncs.reboot(false);
            mWindowManagerFuncs.reboot(false);
        }
        }
+5 −0
Original line number Original line Diff line number Diff line
@@ -1249,6 +1249,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case LONG_PRESS_POWER_SHUT_OFF:
            case LONG_PRESS_POWER_SHUT_OFF:
            case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
            case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
                mPowerKeyHandled = true;
                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,
                performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,
                        "Power - Long Press - Shut Off");
                        "Power - Long Press - Shut Off");
                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
+11 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */
package com.android.server.policy;
package com.android.server.policy;


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


    @Override
    @Override
    public boolean onLongPress() {
    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);
        UserManager um = mContext.getSystemService(UserManager.class);
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            mWindowManagerFuncs.rebootSafeMode(true);
            mWindowManagerFuncs.rebootSafeMode(true);
@@ -55,6 +61,11 @@ public final class PowerAction extends SinglePressAction implements LongPressAct


    @Override
    @Override
    public void onPress() {
    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.
        // shutdown by making sure radio and power are handled accordingly.
        mWindowManagerFuncs.shutdown(false /* confirm */);
        mWindowManagerFuncs.shutdown(false /* confirm */);
    }
    }
+11 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */
package com.android.server.policy;
package com.android.server.policy;


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


    @Override
    @Override
    public boolean onLongPress() {
    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);
        UserManager um = mContext.getSystemService(UserManager.class);
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
        if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
            mWindowManagerFuncs.rebootSafeMode(true);
            mWindowManagerFuncs.rebootSafeMode(true);
@@ -55,6 +61,11 @@ public final class RestartAction extends SinglePressAction implements LongPressA


    @Override
    @Override
    public void onPress() {
    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 */);
        mWindowManagerFuncs.reboot(false /* confirm */);
    }
    }
}
}