Buggy code:
} if ( ( ( isAlarmBoot != null ) && ( isAlarmBoot . equals ( "true" ) ) ) && ( ( ( keyCode == ( KeyEvent . KEYCODE_HOME ) ) || ( keyCode == ( KeyEvent . KEYCODE_SEARCH ) ) ) || ( keyCode == ( KeyEvent . KEYCODE_MENU ) ) ) ) { if ( isAlarmViewTopActivity ( ) ) { return - 1 ; } else { System . putString ( mContext . getContentResolver ( ) , PhoneWindowManager . POWER_OFF_ALARM_MODE , "false" ) ; } } if ( ( mScreenshotChordEnabled ) && ( ( flags & ( KeyEvent . FLAG_FALLBACK ) ) == 0 ) ) { if ( ( mScreenshotChordVolumeDownKeyTriggered ) && ( ! ( mScreenshotChordPowerKeyTriggered ) ) ) { final long now = SystemClock . uptimeMillis ( ) ; final long timeoutTime = ( mScreenshotChordVolumeDownKeyTime ) + ( PhoneWindowManager . SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS ) ; if ( now < timeoutTime ) { return timeoutTime - now ; } } if ( ( keyCode == ( KeyEvent . KEYCODE_VOLUME_DOWN ) ) && ( mScreenshotChordVolumeDownKeyConsumed ) ) { if ( ! down ) { mScreenshotChordVolumeDownKeyConsumed = false ; } return - 1 ; } if ( ( mVolumeUpKeyTriggered ) && ( ! ( mPowerKeyTriggered ) ) ) { final long now = SystemClock . uptimeMillis ( ) ; final long timeoutTime = ( mVolumeUpKeyTime ) + ( PhoneWindowManager . SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS ) ; if ( now < timeoutTime ) { return timeoutTime - now ; } } if ( ( keyCode == ( KeyEvent . KEYCODE_VOLUME_UP ) ) && ( mVolumeUpKeyConsumedByScreenshotChord ) ) { if ( ! down ) { mVolumeUpKeyConsumedByScreenshotChord = false ; } return - 1 ; } } if ( ( mPendingMetaAction ) && ( ! ( KeyEvent . isMetaKey ( keyCode ) ) ) ) { mPendingMetaAction = false ; } if ( keyCode == ( KeyEvent . KEYCODE_HOME ) ) { if ( ( ! down ) && ( mHomePressed ) ) { if ( ( mDoubleTapOnHomeBehavior ) != ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) { cancelPreloadRecentApps ( ) ; } mHomePressed = false ; if ( mHomeConsumed ) { mHomeConsumed = false ; return - 1 ; } if ( canceled ) { Log . i ( PhoneWindowManager . TAG , "Ignoring<seq2seq4repair_space>HOME;<seq2seq4repair_space>event<seq2seq4repair_space>canceled." ) ; return - 1 ; } TelecomManager telecomManager = getTelecommService ( ) ; if ( ( telecomManager != null ) && ( telecomManager . isRinging ( ) ) ) { Log . i ( PhoneWindowManager . TAG , "Ignoring<seq2seq4repair_space>HOME;<seq2seq4repair_space>there's<seq2seq4repair_space>a<seq2seq4repair_space>ringing<seq2seq4repair_space>incoming<seq2seq4repair_space>call." ) ; return - 1 ; } if ( ( mDoubleTapOnHomeBehavior ) != ( PhoneWindowManager . KEY_ACTION_NOTHING ) ) { mHandler . removeCallbacks ( mHomeDoubleTapTimeoutRunnable ) ; mHomeDoubleTapPending = true ; mHandler . postDelayed ( mHomeDoubleTapTimeoutRunnable , ViewConfiguration . getDoubleTapTimeout ( ) ) ; return - 1 ; } handleShortPressOnHome ( ) ; return - 1 ; } WindowManager . LayoutParams attrs = ( win != null ) ? win . getAttrs ( ) : null ; if ( attrs != null ) { final int type = attrs . type ; if ( ( ( type == ( LayoutParams . LayoutParams . TYPE_KEYGUARD_SCRIM ) ) || ( type == ( LayoutParams . LayoutParams . TYPE_KEYGUARD_DIALOG ) ) ) || ( ( ( attrs . privateFlags ) & ( PRIVATE_FLAG_KEYGUARD ) ) != 0 ) ) { return 0 ; } final int typeCount = PhoneWindowManager . WINDOW_TYPES_WHERE_HOME_DOESNT_WORK . length ; for ( int i = 0 ; i < typeCount ; i ++ ) { if ( type == ( PhoneWindowManager . WINDOW_TYPES_WHERE_HOME_DOESNT_WORK [ i ] ) ) { return - 1 ; } } } if ( repeatCount == 0 ) { mHomePressed = true ; if ( mHomeDoubleTapPending ) { mHomeDoubleTapPending = false ; mHandler . removeCallbacks ( mHomeDoubleTapTimeoutRunnable ) ; performKeyAction ( mDoubleTapOnHomeBehavior ) ; <START_BUG> mHomeConsumed = true ; <END_BUG> } else if ( ( ( mLongPressOnHomeBehavior ) == ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) || ( ( mDoubleTapOnHomeBehavior ) == ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) ) { preloadRecentApps ( ) ; } } else if ( longPress ) { if ( ( ( ! keyguardOn ) && ( ! ( mHomeConsumed ) ) ) && ( ( mLongPressOnHomeBehavior ) != ( PhoneWindowManager . KEY_ACTION_NOTHING ) ) ) { if ( ( mLongPressOnHomeBehavior ) != ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) { cancelPreloadRecentApps ( ) ; } mHomePressed = true ; performHapticFeedbackLw ( null , LONG_PRESS , false ) ; performKeyAction ( mLongPressOnHomeBehavior ) ; mHomeConsumed = true ; } } return - 1 ; } else if ( keyCode == ( KeyEvent . KEYCODE_MENU ) ) { final int chordBug = KeyEvent . META_SHIFT_ON ; if ( virtualKey || keyguardOn ) { return 0 ; } if ( down ) { if ( ( ( mPressOnMenuBehavior ) == ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) || ( ( mLongPressOnMenuBehavior ) == ( PhoneWindowManager . KEY_ACTION_APP_SWITCH ) ) ) { preloadRecentApps ( ) ; } if ( repeatCount == 0 ) { mMenuPressed = true ; if ( ( mEnableShiftMenuBugReports ) && ( ( metaState & chordBug ) == chordBug ) ) { Intent intent = new Intent ( Intent . ACTION_BUG_REPORT ) ; mContext . sendOrderedBroadcastAsUser ( intent , CURRENT , null , null , null , 0 , null , null ) ; return - 1 ; } else if ( ( PhoneWindowManager . SHOW_PROCESSES_ON_ALT_MENU ) && ( ( metaState & ( KeyEvent . META_ALT_ON ) ) == ( KeyEvent . META_ALT_ON ) ) ) { Intent service = new Intent ( ) ; service . setClassName ( mContext , "com.android.server.LoadAverageService" ) ; ContentResolver res = mContext . getContentResolver ( ) ; boolean shown = ( Global . getInt ( res , SHOW_PROCESSES , 0 ) ) != 0 ; if ( ! shown ) { mContext . startService ( service ) ; } else { mContext . stopService ( service ) ; }

Fix:
mHomeConsumed = ( mDoubleTapOnHomeBehavior ) != ( PhoneWindowManager . KEY_ACTION_SLEEP ) ;