{"id":1009,"date":"2024-03-28T15:47:23","date_gmt":"2024-03-28T07:47:23","guid":{"rendered":"https:\/\/swordofmorning.com\/?p=1009"},"modified":"2025-10-09T13:55:02","modified_gmt":"2025-10-09T05:55:02","slug":"t820-03","status":"publish","type":"post","link":"https:\/\/swordofmorning.com\/index.php\/2024\/03\/28\/t820-03\/","title":{"rendered":"T820 Dev 03 Power Long Press"},"content":{"rendered":"<p>&emsp;&emsp;\u5728<code>frameworks\/base\/services\/core\/java\/com\/android\/server\/policy\/PhoneWindowManger.java<\/code>\u4e2d\u5b9a\u4e49\u4e86\u5982\u4e0b\u957f\u6309\u4e8b\u4ef6\uff1a<\/p>\n<ol>\n<li><code>LONG_PRESS_POWER_ASSISTANT<\/code>: \u5524\u9192\u52a9\u624b\u754c\u9762<\/li>\n<li><code>LONG_PRESS_POWER_GO_TO_VOICE_ASSIST<\/code>: \u5524\u9192\u8bed\u97f3\u52a9\u624b<\/li>\n<li><code>LONG_PRESS_POWER_GLOBAL_ACTIONS<\/code>: \u5f39\u51fa\u5173\u673a\u3001\u91cd\u542f\u7b49\u9009\u9879\u5bf9\u8bdd\u6846<\/li>\n<li><code>LONG_PRESS_POWER_SHUT_OFF<\/code>: \u5173\u95ed\u6240\u6709\u7a97\u53e3\u5e76\u5173\u673a<\/li>\n<\/ol>\n<p>\u6211\u4eec\u5f00\u673a\u540e\u8fde\u4e0aadb\uff0c\u957f\u6309\u5e76\u8bfb\u53d6\u8c03\u8bd5\u4fe1\u606f\uff1a\u53d1\u73b0\u5b83\u9ed8\u8ba4\u7684\u8f93\u51fa\u603b\u662f<code>LONG_PRESS_POWER_ASSISTANT<\/code>\u3002\u6211\u4eec\u9009\u62e9\u5c06\u5176\u6ce8\u91ca\uff0c\u5e76\u79fb\u52a8\u5230<code>case LONG_PRESS_POWER_GLOBAL_ACTIONS:<\/code>\u4e0b\uff0c\u4ee5\u5b9e\u73b0\u957f\u6309\u5f39\u51fa\u5173\u673a\u9009\u9879\u3002\u5982\u679c\u60f3\u8981\u5b9e\u73b0\u76f4\u63a5\u5173\u673a\uff0c\u5219\u53ef\u4ee5\u79fb\u52a8\u5230<code>LONG_PRESS_POWER_SHUT_OFF<\/code>\u7684\u4f4d\u7f6e\u3002<\/p>\n<pre><code class=\"language-java\">switch (behavior) {\n    case LONG_PRESS_POWER_NOTHING:\n        break;\n    case LONG_PRESS_POWER_GLOBAL_ACTIONS:\n    case LONG_PRESS_POWER_ASSISTANT:\n        mPowerKeyHandled = true;\n        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,\n                &quot;Power - Long Press - Global Actions&quot;);\n        showGlobalActions();\n        break;\n    case LONG_PRESS_POWER_SHUT_OFF:\n    case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:\n        mPowerKeyHandled = true;\n        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,\n                &quot;Power - Long Press - Shut Off&quot;);\n        sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);\n        mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF);\n        break;\n    case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST:\n        mPowerKeyHandled = true;\n        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,\n                &quot;Power - Long Press - Go To Voice Assist&quot;);\n        \/\/ Some devices allow the voice assistant intent during setup (and use that intent\n        \/\/ to launch something else, like Settings). So we explicitly allow that via the\n        \/\/ config_allowStartActivityForLongPressOnPowerInSetup resource in config.xml.\n        launchVoiceAssist(mAllowStartActivityForLongPressOnPowerDuringSetup);\n        break;\n    \/\/ case LONG_PRESS_POWER_ASSISTANT:\n    \/\/     mPowerKeyHandled = true;\n    \/\/     performHapticFeedback(HapticFeedbackConstants.ASSISTANT_BUTTON, false,\n    \/\/             &quot;Power - Long Press - Go To Assistant&quot;);\n    \/\/     final int powerKeyDeviceId = Integer.MIN_VALUE;\n    \/\/     launchAssistAction(null, powerKeyDeviceId, eventTime,\n    \/\/             AssistUtils.INVOCATION_TYPE_POWER_BUTTON_LONG_PRESS);\n    \/\/     break;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&emsp;&emsp;\u5728frameworks\/base\/services\/core\/java\/com\/android\/serve &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[240],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1009"}],"collection":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/comments?post=1009"}],"version-history":[{"count":1,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1009\/revisions"}],"predecessor-version":[{"id":1010,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/1009\/revisions\/1010"}],"wp:attachment":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/media?parent=1009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/categories?post=1009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/tags?post=1009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}