当前位置:   article > 正文

android 13长按power键没有关机菜单

android 13长按power键没有关机菜单

android 13集成GMS全家桶后长按power按键没有关机菜单出来。查看源码

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager

  1. private void powerLongPress(long eventTime) {
  2. final int behavior = getResolvedLongPressOnPowerBehavior();
  3. Slog.d(TAG, "powerLongPress: eventTime=" + eventTime
  4. + " mLongPressOnPowerBehavior=" + mLongPressOnPowerBehavior);
  5. switch (behavior) {
  6. case LONG_PRESS_POWER_NOTHING:
  7. break;
  8. case LONG_PRESS_POWER_GLOBAL_ACTIONS:
  9. mPowerKeyHandled = true;
  10. performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,
  11. "Power - Long Press - Global Actions");
  12. showGlobalActions();
  13. break;
  14. case LONG_PRESS_POWER_SHUT_OFF:
  15. case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
  16. mPowerKeyHandled = true;
  17. performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,
  18. "Power - Long Press - Shut Off");
  19. sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
  20. mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF);
  21. break;
  22. case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST:
  23. mPowerKeyHandled = true;
  24. performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, false,
  25. "Power - Long Press - Go To Voice Assist");
  26. launchVoiceAssist(mAllowStartActivityForLongPressOnPowerDuringSetup);
  27. break;
  28. case LONG_PRESS_POWER_ASSISTANT:
  29. mPowerKeyHandled = true;
  30. performHapticFeedback(HapticFeedbackConstants.ASSISTANT_BUTTON, false,
  31. "Power - Long Press - Go To Assistant");
  32. final int powerKeyDeviceId = Integer.MIN_VALUE;
  33. launchAssistAction(null, powerKeyDeviceId, eventTime,
  34. AssistUtils.INVOCATION_TYPE_POWER_BUTTON_LONG_PRESS);
  35. break;
  36. }
  37. }

在log中查找mLongPressOnPowerBehavior字段

WindowManager: powerLongPress: eventTime=198019 mLongPressOnPowerBehavior=5

  1. private int getResolvedLongPressOnPowerBehavior() {
  2. if (FactoryTest.isLongPressOnPowerOffEnabled()) {
  3. return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
  4. }
  5. // If the config indicates the assistant behavior but the device isn't yet provisioned, show
  6. // global actions instead.
  7. if (mLongPressOnPowerBehavior == LONG_PRESS_POWER_ASSISTANT && !isDeviceProvisioned()) {
  8. return LONG_PRESS_POWER_GLOBAL_ACTIONS;
  9. }
  10. // If long press to launch assistant is disabled in settings, do nothing.
  11. if (mLongPressOnPowerBehavior == LONG_PRESS_POWER_GO_TO_VOICE_ASSIST
  12. && !isLongPressToAssistantEnabled(mContext)) {
  13. return LONG_PRESS_POWER_NOTHING;
  14. }
  15. return mLongPressOnPowerBehavior;
  16. }

  1. mLongPressOnPowerBehavior = mContext.getResources().getInteger(
  2. com.android.internal.R.integer.config_longPressOnPowerBehavior);

修改vendor/google/overlay/gms_overlay/frameworks/base/core/res/res/values/config.xml

<integer name="config_longPressOnPowerBehavior">5</integer>

这里改成1就可以了

<integer name="config_longPressOnPowerBehavior">1</integer>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/326523?site
推荐阅读
相关标签
  

闽ICP备14008679号