Program: 38172
Project: 38172
Buggy source:
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mOrientationManager=new OrientationManager(activity);
  mCaptureState=CAPTURE_STATE_VIEWFINDER;
  mUI=new WideAnglePanoramaUI(mActivity,this,(ViewGroup)mRootView);
  mUI.setCaptureProgressOnDirectionChangeListener(new PanoProgressBar.OnDirectionChangeListener(){
    @Override public void onDirectionChange(    int direction){
      if (mDirectionChanged) {
        stopCapture(false);
        return;
      }
      if (mCaptureState == CAPTURE_STATE_MOSAIC) {
        mUI.showDirectionIndicators(direction);
      }
      if (direction != PanoProgressBar.DIRECTION_NONE) {
        mDirectionChanged=true;
      }
    }
  }
);
  mContentResolver=mActivity.getContentResolver();
  mOnFrameAvailableRunnable=new Runnable(){
    @Override public void run(){
      if (mPaused)       return;
      MosaicPreviewRenderer renderer=null;
synchronized (mRendererLock) {
        if (mMosaicPreviewRenderer == null) {
          return;
        }
        renderer=mMosaicPreviewRenderer;
      }
      if (mRootView.getVisibility() != View.VISIBLE) {
        renderer.showPreviewFrameSync();
        mRootView.setVisibility(View.VISIBLE);
      }
 else {
        if (mCaptureState == CAPTURE_STATE_VIEWFINDER) {
          if (mPreviewLayoutChanged) {
            boolean isLandscape=(mDeviceOrientation / 90) % 2 == 1;
            renderer.previewReset(mPreviewUIWidth,mPreviewUIHeight,isLandscape,mDeviceOrientation);
            mPreviewLayoutChanged=false;
          }
          renderer.showPreviewFrame();
        }
 else {
          renderer.alignFrameSync();
          mMosaicFrameProcessor.processFrame();
        }
      }
    }
  }
;
  PowerManager pm=(PowerManager)mActivity.getSystemService(Context.POWER_SERVICE);
  mPartialWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  mOrientationEventListener=new PanoOrientationEventListener(mActivity);
  mMosaicFrameProcessor=MosaicFrameProcessor.getInstance();
  Resources appRes=mActivity.getResources();
  mPreparePreviewString=appRes.getString(R.string.pano_dialog_prepare_preview);
  mDialogTitle=appRes.getString(R.string.pano_dialog_title);
  mDialogOkString=appRes.getString(R.string.dialog_ok);
  mDialogPanoramaFailedString=appRes.getString(R.string.pano_dialog_panorama_failed);
  mDialogWaitingPreviousString=appRes.getString(R.string.pano_dialog_waiting_previous);
  mPreferences=new ComboPreferences(mActivity);
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mLocationManager=new LocationManager(mActivity,null);
  mMainHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
switch (msg.what) {
case MSG_LOW_RES_FINAL_MOSAIC_READY:
        onBackgroundThreadFinished();
      saveFinalMosaic((Bitmap)msg.obj);
    saveHighResMosaic();
  break;
case MSG_GENERATE_FINAL_MOSAIC_ERROR:
onBackgroundThreadFinished();
if (mPaused) {
resetToPreviewIfPossible();
}
 else {
mUI.showAlertDialog(mDialogTitle,mDialogPanoramaFailedString,mDialogOkString,new Runnable(){
  @Override public void run(){
    resetToPreviewIfPossible();
  }
}
);
}
clearMosaicFrameProcessorIfNeeded();
break;
case MSG_END_DIALOG_RESET_TO_PREVIEW:
onBackgroundThreadFinished();
resetToPreviewIfPossible();
clearMosaicFrameProcessorIfNeeded();
break;
case MSG_CLEAR_SCREEN_DELAY:
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
break;
case MSG_RESET_TO_PREVIEW:
resetToPreviewIfPossible();
break;
}
}
}
;
}

Fixed version (ground truth):
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mOrientationManager=new OrientationManager(activity);
  mCaptureState=CAPTURE_STATE_VIEWFINDER;
  mUI=new WideAnglePanoramaUI(mActivity,this,(ViewGroup)mRootView);
  mUI.setCaptureProgressOnDirectionChangeListener(new PanoProgressBar.OnDirectionChangeListener(){
    @Override public void onDirectionChange(    int direction){
      if (mDirectionChanged) {
        stopCapture(false);
        return;
      }
      if (mCaptureState == CAPTURE_STATE_MOSAIC) {
        mUI.showDirectionIndicators(direction);
      }
      if (direction != PanoProgressBar.DIRECTION_NONE) {
        mDirectionChanged=true;
      }
    }
  }
);
  mContentResolver=mActivity.getContentResolver();
  mOnFrameAvailableRunnable=new Runnable(){
    @Override public void run(){
      if (mPaused)       return;
      MosaicPreviewRenderer renderer=null;
synchronized (mRendererLock) {
        if (mMosaicPreviewRenderer == null) {
          return;
        }
        renderer=mMosaicPreviewRenderer;
      }
      if (mRootView.getVisibility() != View.VISIBLE) {
        renderer.showPreviewFrameSync();
        mRootView.setVisibility(View.VISIBLE);
      }
 else {
        if (mCaptureState == CAPTURE_STATE_VIEWFINDER) {
          if (mPreviewLayoutChanged) {
            boolean isLandscape=(mDeviceOrientation / 90) % 2 == 1;
            renderer.previewReset(mPreviewUIWidth,mPreviewUIHeight,isLandscape,mDeviceOrientation);
            mPreviewLayoutChanged=false;
          }
          renderer.showPreviewFrame();
        }
 else {
          renderer.alignFrameSync();
          mMosaicFrameProcessor.processFrame();
        }
      }
    }
  }
;
  PowerManager pm=(PowerManager)mActivity.getSystemService(Context.POWER_SERVICE);
  mPartialWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"String_Node_Str");
  mOrientationEventListener=new PanoOrientationEventListener(mActivity);
  mMosaicFrameProcessor=MosaicFrameProcessor.getInstance();
  Resources appRes=mActivity.getResources();
  mPreparePreviewString=appRes.getString(R.string.pano_dialog_prepare_preview);
  mDialogTitle=appRes.getString(R.string.pano_dialog_title);
  mDialogOkString=appRes.getString(R.string.dialog_ok);
  mDialogPanoramaFailedString=appRes.getString(R.string.pano_dialog_panorama_failed);
  mDialogWaitingPreviousString=appRes.getString(R.string.pano_dialog_waiting_previous);
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mLocationManager=new LocationManager(mActivity,null);
  mMainHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
switch (msg.what) {
case MSG_LOW_RES_FINAL_MOSAIC_READY:
        onBackgroundThreadFinished();
      saveFinalMosaic((Bitmap)msg.obj);
    saveHighResMosaic();
  break;
case MSG_GENERATE_FINAL_MOSAIC_ERROR:
onBackgroundThreadFinished();
if (mPaused) {
resetToPreviewIfPossible();
}
 else {
mUI.showAlertDialog(mDialogTitle,mDialogPanoramaFailedString,mDialogOkString,new Runnable(){
  @Override public void run(){
    resetToPreviewIfPossible();
  }
}
);
}
clearMosaicFrameProcessorIfNeeded();
break;
case MSG_END_DIALOG_RESET_TO_PREVIEW:
onBackgroundThreadFinished();
resetToPreviewIfPossible();
clearMosaicFrameProcessorIfNeeded();
break;
case MSG_CLEAR_SCREEN_DELAY:
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
break;
case MSG_RESET_TO_PREVIEW:
resetToPreviewIfPossible();
break;
}
}
}
;
}