Buggy code:
private boolean mAllowTheaterModeWakeFromCameraLens ; private boolean mAllowTheaterModeWakeFromLidSwitch ; private boolean mAllowTheaterModeWakeFromWakeGesture ; private boolean mGoToSleepOnButtonPressTheaterMode ; private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150 ; private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5F ; private boolean mScreenshotChordEnabled ; private boolean mVolumeDownKeyTriggered ; private long mVolumeDownKeyTime ; private boolean mVolumeDownKeyConsumedByScreenshotChord ; private boolean mVolumeUpKeyTriggered ; private boolean mVolumeWakeScreen ; private boolean mPowerKeyTriggered ; private long mVolumeUpKeyTime ; private boolean mVolumeUpKeyConsumedByScreenshotChord ; private long mPowerKeyTime ; private boolean mScreenshotChordVolumeDownKeyTriggered ; private long mScreenshotChordVolumeDownKeyTime ; private boolean mScreenshotChordVolumeDownKeyConsumed ; private boolean mScreenshotChordVolumeUpKeyTriggered ; private boolean mScreenshotChordPowerKeyTriggered ; private long mScreenshotChordPowerKeyTime ; private static final int BRIGHTNESS_STEPS = 10 ; PhoneWindowManager . SettingsObserver mSettingsObserver ; PhoneWindowManager . HwKeySettingsObserver mHwKeySettingsObserver ; ShortcutManager mShortcutManager ; WakeLock mBroadcastWakeLock ; WakeLock mQuickBootWakeLock ; WakeLock mPowerKeyWakeLock ; boolean mHavePendingMediaKeyRepeatWithWakeLock ; private int mCurrentUserId ; private GlobalKeyManager mGlobalKeyManager ; private final SparseArray < KeyCharacterMap . FallbackAction > mFallbackActions = new SparseArray < KeyCharacterMap . FallbackAction > ( ) ; private final LogDecelerateInterpolator mLogDecelerateInterpolator = new LogDecelerateInterpolator ( 100 , 0 ) ; private static final int MSG_ENABLE_POINTER_LOCATION = 1 ; private static final int MSG_DISABLE_POINTER_LOCATION = 2 ; private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3 ; private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4 ; private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5 ; private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6 ; private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7 ; private static final int MSG_DISPATCH_SHOW_RECENTS = 9 ; private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10 ; private static final int MSG_HIDE_BOOT_MESSAGE = 11 ; private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12 ; boolean mWifiDisplayConnected = false ; int mWifiDisplayCustomRotation = - 1 ; private static final int MSG_POWER_DELAYED_PRESS = 13 ; private static final int MSG_POWER_LONG_PRESS = 14 ; private boolean mClearedBecauseOfForceShow ; private boolean mTopWindowIsKeyguard ; private class PolicyHandler extends Handler { @ Override public void handleMessage ( Message msg ) { } } private UEventObserver mHDMIObserver = new UEventObserver ( ) { @ Override public void onUEvent ( UEventObserver . UEvent event ) { } } ; class SettingsObserver extends ContentObserver { SettingsObserver ( Handler handler ) { } void observe ( ) { } @ Override public void onChange ( boolean selfChange ) { } } class MyWakeGestureListener extends WakeGestureListener { MyWakeGestureListener ( Context context , Handler handler ) { } @ Override public void onWakeUp ( ) { } } class HwKeySettingsObserver extends ContentObserver { HwKeySettingsObserver ( Handler handler ) { } void observe ( ) { } @ Override public void onChange ( boolean selfChange ) { } } class MyOrientationListener extends WindowOrientationListener { MyOrientationListener ( Context context , Handler handler ) { } @ Override public void onProposedRotationChanged ( int rotation ) { } } PhoneWindowManager . MyOrientationListener mOrientationListener ; private final BarController mStatusBarController = new BarController ( "StatusBar" , View . STATUS_BAR_TRANSIENT , View . STATUS_BAR_UNHIDE , View . STATUS_BAR_TRANSLUCENT , StatusBarManager . WINDOW_STATUS_BAR , LayoutParams . LayoutParams . FLAG_TRANSLUCENT_STATUS ) ; private final BarController mNavigationBarController = new BarController ( "NavigationBar" , View . NAVIGATION_BAR_TRANSIENT , View . NAVIGATION_BAR_UNHIDE , View . NAVIGATION_BAR_TRANSLUCENT , StatusBarManager . WINDOW_NAVIGATION_BAR , LayoutParams . LayoutParams . FLAG_TRANSLUCENT_NAVIGATION ) ; private ImmersiveModeConfirmation mImmersiveModeConfirmation ; private SystemGesturesPointerEventListener mSystemGestures ; IStatusBarService getStatusBarService ( ) { } boolean needSensorRunningLp ( ) { } void updateOrientationListenerLp ( ) { } private void interceptPowerKeyDown ( KeyEvent event , boolean interactive ) { if ( ! ( mPowerKeyWakeLock . isHeld ( ) ) ) { mPowerKeyWakeLock . acquire ( ) ; } if ( ( mPowerKeyPressCounter ) != 0 ) { mHandler . removeMessages ( PhoneWindowManager . MSG_POWER_DELAYED_PRESS ) ; } boolean panic = mImmersiveModeConfirmation . onPowerKeyDown ( interactive , event . getDownTime ( ) , isImmersiveMode ( mLastSystemUiFlags ) ) ; <START_BUG> if ( panic && ( ! ( PolicyControl . isImmersiveFiltersActive ( ) ) ) ) { <END_BUG> mHandler . post ( mRequestTransientNav ) ; } if ( ( interactive && ( ! ( mScreenshotChordPowerKeyTriggered ) ) ) && ( ( ( event . getFlags ( ) ) & ( KeyEvent . FLAG_FALLBACK ) ) == 0 ) ) { mScreenshotChordPowerKeyTriggered = true ; mScreenshotChordPowerKeyTime = event . getDownTime ( ) ; interceptScreenshotChord ( ) ; } TelecomManager telecomManager = getTelecommService ( ) ; boolean hungUp = false ; if ( telecomManager != null ) { if ( telecomManager . isRinging ( ) ) { telecomManager . silenceRinger ( ) ; } else if ( ( ( ( ( mIncallPowerBehavior ) & ( Secure . INCALL_POWER_BUTTON_BEHAVIOR_HANGUP ) ) != 0 ) && ( telecomManager . isInCall ( ) ) ) && interactive ) { hungUp = telecomManager . endCall ( ) ; } } mPowerKeyHandled = ( hungUp || ( mScreenshotChordVolumeDownKeyTriggered ) ) || ( mScreenshotChordVolumeUpKeyTriggered ) ; if ( ! ( mPowerKeyHandled ) ) { if ( interactive ) { if ( hasLongPressOnPowerBehavior ( ) ) { Message msg = mHandler . obtainMessage ( PhoneWindowManager . MSG_POWER_LONG_PRESS ) ; msg . setAsynchronous ( true ) ; mHandler . sendMessageDelayed ( msg , ViewConfiguration . get ( mContext ) . getDeviceGlobalActionKeyTimeout ( ) ) ; } } else { wakeUpFromPowerKey ( event . getDownTime ( ) ) ; final int maxCount = getMaxMultiPressPowerCount ( ) ; if ( maxCount <= 1 ) { mPowerKeyHandled = true ; } else { mBeganFromNonInteractive = true ; } } } } private void interceptPowerKeyUp ( KeyEvent event , boolean interactive , boolean canceled ) { } private void finishPowerKeyPress ( ) { } private void cancelPendingPowerKeyAction ( ) { } private void powerPress ( long eventTime , boolean interactive , int count ) { } private void powerMultiPressAction ( long eventTime , boolean interactive , int behavior ) { } private int getMaxMultiPressPowerCount ( ) { } private void powerLongPress ( ) { } private int getResolvedLongPressOnPowerBehavior ( ) { } private boolean hasLongPressOnPowerBehavior ( ) { } private void interceptScreenshotChord ( ) { } private void interceptScreenshotLog ( ) { } private void cancelPendingScreenshotForLog ( ) { } private long getScreenshotChordLongPressDelay ( ) { }

Fix:
if ( panic && ( ! ( WindowManagerPolicyControl . isImmersiveFiltersActive ( ) ) ) ) {