Buggy code:
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 ; private EdgeGestureActivationListener mEdgeGestureActivationListener = new EdgeGestureManager . EdgeGestureActivationListener ( ) { @ Override public void onEdgeGestureActivation ( int touchX , int touchY , EdgeGesturePosition position , int flags ) { } } ; private EdgeGestureManager mEdgeGestureManager = null ; private int mLastEdgePositions = 0 ; private boolean mEdgeListenerActivated = false ; private boolean mUsingEdgeGestureServiceForGestures = false ; private void updateEdgeGestureListenerState ( ) { } IStatusBarService getStatusBarService ( ) { } boolean needSensorRunningLp ( ) { } void updateOrientationListenerLp ( ) { } private void interceptPowerKeyDown ( boolean handled ) { } private boolean interceptPowerKeyUp ( boolean canceled ) { } private void cancelPendingPowerKeyAction ( ) { } private void interceptScreenshotChord ( ) { } private void interceptScreenshotLog ( ) { } private void cancelPendingScreenshotForLog ( ) { } private long getScreenshotChordLongPressDelay ( ) { } private void cancelPendingScreenshotChordAction ( ) { } private void powerShortPress ( long eventTime ) { } private final Runnable mPowerLongPress = new Runnable ( ) { @ Override public void run ( ) { } } ; private final Runnable mScreenshotRunnable = new Runnable ( ) { @ Override public void run ( ) { } } ; private final Runnable mScreenshotForLog = new Runnable ( ) { public void run ( ) { } } ; @ Override public void showGlobalActions ( ) { } Runnable mBackLongPress = new Runnable ( ) { public void run ( ) { } } ; void showGlobalActionsInternal ( ) { } boolean isDeviceProvisioned ( ) { } boolean isUserSetupComplete ( ) { } private void triggerVirtualKeypress ( final int keyCode ) { } private void launchCameraAction ( ) { } private void performKeyAction ( int behavior ) { } private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable ( ) { @ Override public void run ( ) { } } ; @ Override public void init ( Context context , IWindowManager windowManager , WindowManagerFuncs windowManagerFuncs ) { } private void updateKeyAssignments ( ) { } @ Override public void setInitialDisplaySize ( Display display , int width , int height , int density ) { } private boolean canHideNavigationBar ( ) { } @ Override public boolean isDefaultOrientationForced ( ) { } @ Override public void setDisplayOverscan ( Display display , int left , int top , int right , int bottom ) { } public void updateSettings ( ) { } private void updateWakeGestureListenerLp ( ) { } private boolean shouldEnableWakeGestureLp ( ) { } @ Override public void updateRotationStateForImmersive ( ) { int orientation = mContext . getResources ( ) . getConfiguration ( ) . orientation ; boolean shouldEnable = false ; switch ( orientation ) { case Configuration . ORIENTATION_LANDSCAPE : if ( ( mOrientationImmersiveState ) == 1 ) { shouldEnable = true ; } if ( ( mOrientationImmersiveState ) == 2 ) { shouldEnable = false ; } break ; case Configuration . ORIENTATION_PORTRAIT : if ( ( mOrientationImmersiveState ) == 2 ) { shouldEnable = true ; } if ( ( mOrientationImmersiveState ) == 1 ) { shouldEnable = false ; } break ; } if ( ( ! ( mImmersiveState ) ) || ( ! shouldEnable ) ) { mImmersiveModeBehavior = 0 ; } else { <START_BUG> mImmersiveModeBehavior = System . getIntForUser ( resolver , GLOBAL_IMMERSIVE_MODE_STYLE , 2 , USER_CURRENT ) ; <END_BUG> } if ( ( mGlobalImmersiveModeStyle ) != ( mImmersiveModeBehavior ) ) { mGlobalImmersiveModeStyle = mImmersiveModeBehavior ; } if ( ( mImmersiveModeConfirmation ) != null ) { mImmersiveModeConfirmation . loadSetting ( mCurrentUserId ) ; } } private void resetScreenHelper ( ) { } private void enablePointerLocation ( ) { } private void disablePointerLocation ( ) { } private int readRotation ( int resID ) { } @ Override public int checkAddPermission ( WindowManager . LayoutParams attrs , int [ ] outAppOp ) { } @ Override public boolean checkShowToOwnerOnly ( WindowManager . LayoutParams attrs ) { } @ Override public void adjustWindowParamsLw ( WindowManager . LayoutParams attrs ) { } void readLidState ( ) { } private void readCameraLensCoverState ( ) { } private boolean isHidden ( int accessibilityMode ) { } private boolean isBuiltInKeyboardVisible ( ) { } @ Override public void adjustConfigurationLw ( Configuration config , int keyboardPresence , int navigationPresence ) { } @ Override public int windowTypeToLayerLw ( int type ) { } @ Override public int subWindowTypeToLayerLw ( int type ) { } @ Override public int getMaxWallpaperLayer ( ) { } @ Override public int getAboveUniverseLayer ( ) { } @ Override public int getNonDecorDisplayWidth ( int fullWidth , int fullHeight , int rotation ) { } @ Override public int getNonDecorDisplayHeight ( int fullWidth , int fullHeight , int rotation ) { } @ Override public int getConfigDisplayWidth ( int fullWidth , int fullHeight , int rotation ) { } @ Override public int getConfigDisplayHeight ( int fullWidth , int fullHeight , int rotation ) { } @ Override public boolean isForceHiding ( WindowManager . LayoutParams attrs ) { } @ Override public boolean isKeyguardHostWindow ( WindowManager . LayoutParams attrs ) { } @ Override public boolean canBeForceHidden ( WindowState win , WindowManager . LayoutParams attrs ) { } @ Override public WindowState getWinShowWhenLockedLw ( ) { } @ Override public View addStartingWindow ( IBinder appToken , String packageName , int theme , CompatibilityInfo compatInfo , CharSequence nonLocalizedLabel , int labelRes , int icon , int logo , int windowFlags ) { } @ Override public void removeStartingWindow ( IBinder appToken , View window ) { } @ Override public int prepareAddWindowLw ( WindowState win , WindowManager . LayoutParams attrs ) { } @ Override public void removeWindowLw ( WindowState win ) { } static final boolean PRINT_ANIM = false ;

Fix:
mImmersiveModeBehavior = System . getIntForUser ( mContext . getContentResolver ( ) , GLOBAL_IMMERSIVE_MODE_STYLE , 2 , USER_CURRENT ) ;