frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java
/*** Rule for single power key gesture.*/private final class PowerKeyRule extends SingleKeyGestureDetector.SingleKeyRule {PowerKeyRule() {super(KEYCODE_POWER);}@Overrideboolean supportLongPress() {return hasLongPressOnPowerBehavior();}@Overrideboolean supportVeryLongPress() {return hasVeryLongPressOnPowerBehavior();}@Overrideint getMaxMultiPressCount() {return getMaxMultiPressPowerCount();}@Overridevoid onPress(long downTime) {if ("true".equals(SystemProperties.get(Properties.PROPERTY_DISABLE_SHORT_POWER)) &&mPowerManager.isScreenPowerOn()) {Slog.d(TAG, "ignore short power key");return;}powerPress(downTime, 1 /*count*/,mSingleKeyGestureDetector.beganFromNonInteractive());}@Overridelong getLongPressTimeoutMs() {if (getResolvedLongPressOnPowerBehavior() == LONG_PRESS_POWER_ASSISTANT) {return mLongPressOnPowerAssistantTimeoutMs;} else {return super.getLongPressTimeoutMs();}}@Overridevoid onLongPress(long eventTime) {if (mSingleKeyGestureDetector.beganFromNonInteractive()&& !mSupportLongPressPowerWhenNonInteractive) {Slog.v(TAG, "Not support long press power when device is not interactive.");return;}powerLongPress(eventTime);}@Overridevoid onVeryLongPress(long eventTime) {mActivityManagerInternal.prepareForPossibleShutdown();powerVeryLongPress();}@Overridevoid onMultiPress(long downTime, int count) {powerPress(downTime, count, mSingleKeyGestureDetector.beganFromNonInteractive());}}/*** Rule for single back key gesture.*/private final class BackKeyRule extends SingleKeyGestureDetector.SingleKeyRule {BackKeyRule() {super(KEYCODE_BACK);}@Overrideboolean supportLongPress() {return hasLongPressOnBackBehavior();}@Overrideint getMaxMultiPressCount() {return 1;}@Overridevoid onPress(long downTime) {mBackKeyHandled |= backKeyPress();}@Overridevoid onLongPress(long downTime) {backLongPress();}}/*** Rule for single stem primary key gesture.*/private final class StemPrimaryKeyRule extends SingleKeyGestureDetector.SingleKeyRule {StemPrimaryKeyRule() {super(KeyEvent.KEYCODE_STEM_PRIMARY);}@Overrideboolean supportLongPress() {return hasLongPressOnStemPrimaryBehavior();}@Overrideint getMaxMultiPressCount() {return getMaxMultiPressStemPrimaryCount();}@Overridevoid onPress(long downTime) {stemPrimaryPress(1 /*count*/);}@Overridevoid onLongPress(long eventTime) {stemPrimaryLongPress();}@Overridevoid onMultiPress(long downTime, int count) {stemPrimaryPress(count);}}