欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 会展 > Android14 AOSP支持短按关机

Android14 AOSP支持短按关机

2024/12/22 1:53:16 来源:https://blog.csdn.net/qq_28347599/article/details/144459365  浏览:    关键词:Android14 AOSP支持短按关机

修改frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java 

diff --git a/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 044da84e7..3cd9cf5f0 100644
--- a/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -697,6 +697,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {private static final int MSG_LOG_KEYBOARD_SYSTEM_EVENT = 26;//----rk-code----private static final int MSG_SLEEP_SHOW_DREAM = 27;
+    //add by donggua
+    private static final int MSG_POWER_SHUT_DOWN = 28; //支持短按关机private int screenWidth;private int screenHeight;
@@ -822,6 +824,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {case MSG_LOG_KEYBOARD_SYSTEM_EVENT:handleKeyboardSystemEvent(KeyboardLogEvent.from(msg.arg1), (KeyEvent) msg.obj);break;
+                case MSG_POWER_SHUT_DOWN://add by donggua,支持短按关机
+                    mWindowManagerFuncs.shutdown(false);
+                    break;}}}
@@ -4526,19 +4531,32 @@ public class PhoneWindowManager implements WindowManagerPolicy {}case KeyEvent.KEYCODE_POWER: {
-                logKeyboardSystemsEventOnActionUp(event, KeyboardLogEvent.TOGGLE_POWER);
-                EventLogTags.writeInterceptPower(
-                        KeyEvent.actionToString(event.getAction()),
-                        mPowerKeyHandled ? 1 : 0,
-                        mSingleKeyGestureDetector.getKeyPressCounter(KeyEvent.KEYCODE_POWER));
-                // Any activity on the power button stops the accessibility shortcut
-                result &= ~ACTION_PASS_TO_USER;
-                isWakeKey = false; // wake-up will be handled separately
-                if (down) {
-                    interceptPowerKeyDown(event, interactiveAndOn);
-                } else {
-                    interceptPowerKeyUp(event, canceled);
-                }
+                // logKeyboardSystemsEventOnActionUp(event, KeyboardLogEvent.TOGGLE_POWER);
+                // EventLogTags.writeInterceptPower(
+                //         KeyEvent.actionToString(event.getAction()),
+                //         mPowerKeyHandled ? 1 : 0,
+                //         mSingleKeyGestureDetector.getKeyPressCounter(KeyEvent.KEYCODE_POWER));
+                // // Any activity on the power button stops the accessibility shortcut
+                // result &= ~ACTION_PASS_TO_USER;
+                // isWakeKey = false; // wake-up will be handled separately
+                // if (down) {
+                //     interceptPowerKeyDown(event, interactiveAndOn);
+                // } else {
+                //     interceptPowerKeyUp(event, canceled);
+                // }
+                // add my donggua
+                // 支持短按电源事件关机
+                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;}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com