OTT机顶盒H616 android10 电源按键开关机

131 阅读1分钟

diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 8d37f097..417bf683 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -629,6 +629,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12;
private static final int MSG_POWER_DELAYED_PRESS = 13;
private static final int MSG_POWER_LONG_PRESS = 14;
+    private static final int MSG_POWER_SHUT_DOWN=29;
private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 15;
private static final int MSG_BACK_LONG_PRESS = 16;
private static final int MSG_ACCESSIBILITY_SHORTCUT = 17;
@@ -693,6 +694,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
case MSG_POWER_LONG_PRESS:
powerLongPress();
break;
+        case MSG_POWER_SHUT_DOWN:
+            mWindowManagerFuncs.shutdown(false);
+        break;
case MSG_POWER_VERY_LONG_PRESS:
powerVeryLongPress();
break;
@@ -3898,6 +3902,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mPowerKeyHandled ? 1 : 0, mPowerKeyPressCounter);
// Any activity on the power button stops the accessibility shortcut
cancelPendingAccessibilityShortcutAction();
+    /*
result &= ~ACTION_PASS_TO_USER;
isWakeKey = false; // wake-up will be handled separately
if (down) {
@@ -3906,6 +3911,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
interceptPowerKeyUp(event, interactive, canceled);
}
break;
+    */
+
+            if(down){
+                    if(mPowerManager.isScreenOn()) {
+                        Message msg = mHandler.obtainMessage(MSG_POWER_SHUT_DOWN);
+                        msg.setAsynchronous(true);
+                        mHandler.sendMessageDelayed(msg,
+                        ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
+                    } else {
+                        Log.e("GO to Wakeup--------> TTTEEE","keyCode :"+keyCode);
+                        wakeUpFromPowerKey(event.getDownTime());
+                    }
+                }            
+                break;
+
}

case KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN: