Program: 116818
Project: 116818
Buggy source:
/** 
 * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar, hide the system tray, and make the video player take up the full size of the display. The developer who is using this function must ensure the following: <p>1) Inside the android manifest, the activity that uses the video player has the attribute android:configChanges="orientation". <p>2) Other views in the activity (or fragment) are hidden (or made visible) when this method is called.
 */
public void doToggleFullscreen(){
  if (fullscreenCallback == null) {
    return;
  }
  PlayerControl playerControl=getLayerManager().getControl();
  if (playerControl == null) {
    return;
  }
  Activity activity=getLayerManager().getActivity();
  FrameLayout container=getLayerManager().getContainer();
  if (isFullscreen) {
    fullscreenCallback.onReturnFromFullscreen();
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    activity.getWindow().getDecorView().setSystemUiVisibility(0);
    container.setLayoutParams(originalContainerLayoutParams);
    fullscreenButton.setImageResource(R.drawable.ic_action_full_screen);
    isFullscreen=false;
  }
 else {
    fullscreenCallback.onGoToFullscreen();
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
    activity.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener(){
      @Override public void onSystemUiVisibilityChange(      int i){
        if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
          show();
        }
      }
    }
);
    container.setLayoutParams(Util.getLayoutParamsBasedOnParent(container,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
    fullscreenButton.setImageResource(R.drawable.ic_action_return_from_full_screen);
    isFullscreen=true;
  }
}

Fixed version (ground truth):
/** 
 * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar, hide the system tray, and make the video player take up the full size of the display. The developer who is using this function must ensure the following: <p>1) Inside the android manifest, the activity that uses the video player has the attribute android:configChanges="orientation". <p>2) Other views in the activity (or fragment) are hidden (or made visible) when this method is called.
 */
public void doToggleFullscreen(){
  if (fullscreenCallback == null) {
    return;
  }
  PlayerControl playerControl=getLayerManager().getControl();
  if (playerControl == null) {
    return;
  }
  Activity activity=getLayerManager().getActivity();
  FrameLayout container=getLayerManager().getContainer();
  if (isFullscreen) {
    fullscreenCallback.onReturnFromFullscreen();
    activity.setRequestedOrientation(savedOrientation);
    activity.getWindow().getDecorView().setSystemUiVisibility(0);
    container.setLayoutParams(originalContainerLayoutParams);
    fullscreenButton.setImageResource(R.drawable.ic_action_full_screen);
    isFullscreen=false;
  }
 else {
    fullscreenCallback.onGoToFullscreen();
    savedOrientation=activity.getResources().getConfiguration().orientation;
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
    activity.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener(){
      @Override public void onSystemUiVisibilityChange(      int i){
        if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
          show();
        }
      }
    }
);
    container.setLayoutParams(Util.getLayoutParamsBasedOnParent(container,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
    fullscreenButton.setImageResource(R.drawable.ic_action_return_from_full_screen);
    isFullscreen=true;
  }
}