nus-yam/ex-repair huggingface dataset:
Program: 184365
Project: 184365
Buggy source:
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  int drawableHeight=drawable.getIntrinsicHeight();
  int drawableWidth=drawable.getIntrinsicWidth();
  if (drawableWidth == 0 || drawableHeight == 0) {
    return;
  }
  final int available=getHeight() - getPaddingTop() - getPaddingBottom()- drawableHeight;
  if (mAnimationStartTime != NO_ANIMATION) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    int deltaTime=(int)(time - mAnimationStartTime);
    mPosition=mAnimationStartPosition + ANIMATION_SPEED * (mSwitch ? deltaTime : -deltaTime) / 1000;
    if (mPosition < 0)     mPosition=0;
    if (mPosition > available)     mPosition=available;
    boolean done=(mPosition == (mSwitch ? available : 0));
    if (!done) {
      invalidate();
    }
 else {
      mAnimationStartTime=NO_ANIMATION;
    }
  }
 else {
    mPosition=mSwitch ? available : 0;
  }
  int offsetTop=getPaddingTop() + mPosition;
  int offsetLeft=(getWidth() - drawableWidth - getPaddingLeft()- getPaddingRight()) / 2;
  int saveCount=canvas.getSaveCount();
  canvas.save();
  canvas.translate(offsetLeft,offsetTop);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  int drawableHeight=drawable.getIntrinsicHeight();
  int drawableWidth=drawable.getIntrinsicWidth();
  if (drawableWidth == 0 || drawableHeight == 0) {
    return;
  }
  final int available=getHeight() - getPaddingTop() - getPaddingBottom()- drawableHeight;
  if (mAnimationStartTime != NO_ANIMATION) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    int deltaTime=(int)(time - mAnimationStartTime);
    mPosition=mAnimationStartPosition + ANIMATION_SPEED * (mSwitch ? deltaTime : -deltaTime) / 1000;
    if (mPosition < 0)     mPosition=0;
    if (mPosition > available)     mPosition=available;
    boolean done=(mPosition == (mSwitch ? available : 0));
    if (!done) {
      invalidate();
    }
 else {
      mAnimationStartTime=NO_ANIMATION;
    }
  }
 else   if (!isPressed()) {
    mPosition=mSwitch ? available : 0;
  }
  int offsetTop=getPaddingTop() + mPosition;
  int offsetLeft=(getWidth() - drawableWidth - getPaddingLeft()- getPaddingRight()) / 2;
  int saveCount=canvas.getSaveCount();
  canvas.save();
  canvas.translate(offsetLeft,offsetTop);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}
Program: 184366
Project: 184366
Buggy source:
public void run(){
  mHeadUpDisplay.restorePreferences();
}

Fixed version (ground truth):
public void run(){
  mHeadUpDisplay.restorePreferences(mParameters);
}
Program: 184367
Project: 184367
Buggy source:
protected void onRestorePreferencesClicked(){
  if (mPausing)   return;
  Runnable runnable=new Runnable(){
    public void run(){
      mHeadUpDisplay.restorePreferences();
    }
  }
;
  MenuHelper.confirmAction(this,getString(R.string.confirm_restore_title),getString(R.string.confirm_restore_message),runnable);
}

Fixed version (ground truth):
protected void onRestorePreferencesClicked(){
  if (mPausing)   return;
  Runnable runnable=new Runnable(){
    public void run(){
      mHeadUpDisplay.restorePreferences(mParameters);
    }
  }
;
  MenuHelper.confirmAction(this,getString(R.string.confirm_restore_title),getString(R.string.confirm_restore_message),runnable);
}
Program: 184368
Project: 184368
Buggy source:
public void run(){
  mHeadUpDisplay.restorePreferences();
}

Fixed version (ground truth):
public void run(){
  mHeadUpDisplay.restorePreferences(mParameters);
}
Program: 184369
Project: 184369
Buggy source:
private void onRestorePreferencesClicked(){
  Runnable runnable=new Runnable(){
    public void run(){
      mHeadUpDisplay.restorePreferences();
    }
  }
;
  MenuHelper.confirmAction(this,getString(R.string.confirm_restore_title),getString(R.string.confirm_restore_message),runnable);
}

Fixed version (ground truth):
private void onRestorePreferencesClicked(){
  Runnable runnable=new Runnable(){
    public void run(){
      mHeadUpDisplay.restorePreferences(mParameters);
    }
  }
;
  MenuHelper.confirmAction(this,getString(R.string.confirm_restore_title),getString(R.string.confirm_restore_message),runnable);
}
Program: 184370
Project: 184370
Buggy source:
public void restorePreferences(){
  getGLRootView().runInGLThread(new Runnable(){
    public void run(){
      OnSharedPreferenceChangeListener l=mSharedPreferenceChangeListener;
      mSharedPrefs.unregisterOnSharedPreferenceChangeListener(l);
synchronized (mSharedPrefs) {
        Editor editor=mSharedPrefs.edit();
        editor.clear();
        editor.commit();
      }
      CameraSettings.upgradePreferences(mSharedPrefs);
      reloadPreferences();
      if (mListener != null) {
        mListener.onSharedPreferencesChanged();
      }
      mSharedPrefs.registerOnSharedPreferenceChangeListener(l);
    }
  }
);
}

Fixed version (ground truth):
public void restorePreferences(final Parameters param){
  getGLRootView().runInGLThread(new Runnable(){
    public void run(){
      OnSharedPreferenceChangeListener l=mSharedPreferenceChangeListener;
      mSharedPrefs.unregisterOnSharedPreferenceChangeListener(l);
      Context context=getGLRootView().getContext();
synchronized (mSharedPrefs) {
        Editor editor=mSharedPrefs.edit();
        editor.clear();
        editor.commit();
      }
      CameraSettings.upgradePreferences(mSharedPrefs);
      CameraSettings.initialCameraPictureSize(context,param);
      reloadPreferences();
      if (mListener != null) {
        mListener.onSharedPreferencesChanged();
      }
      mSharedPrefs.registerOnSharedPreferenceChangeListener(l);
    }
  }
);
}
Program: 184371
Project: 184371
Buggy source:
public void run(){
  OnSharedPreferenceChangeListener l=mSharedPreferenceChangeListener;
  mSharedPrefs.unregisterOnSharedPreferenceChangeListener(l);
synchronized (mSharedPrefs) {
    Editor editor=mSharedPrefs.edit();
    editor.clear();
    editor.commit();
  }
  CameraSettings.upgradePreferences(mSharedPrefs);
  reloadPreferences();
  if (mListener != null) {
    mListener.onSharedPreferencesChanged();
  }
  mSharedPrefs.registerOnSharedPreferenceChangeListener(l);
}

Fixed version (ground truth):
public void run(){
  OnSharedPreferenceChangeListener l=mSharedPreferenceChangeListener;
  mSharedPrefs.unregisterOnSharedPreferenceChangeListener(l);
  Context context=getGLRootView().getContext();
synchronized (mSharedPrefs) {
    Editor editor=mSharedPrefs.edit();
    editor.clear();
    editor.commit();
  }
  CameraSettings.upgradePreferences(mSharedPrefs);
  CameraSettings.initialCameraPictureSize(context,param);
  reloadPreferences();
  if (mListener != null) {
    mListener.onSharedPreferencesChanged();
  }
  mSharedPrefs.registerOnSharedPreferenceChangeListener(l);
}
Program: 184372
Project: 184372
Buggy source:
/** 
 * Called when the OpenGL surface is recreated without destroying the context.
 */
public void onSurfaceChanged(GL10 gl1,int width,int height){
  Log.v(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ gl1.toString());
  GL11 gl=(GL11)gl1;
  mGL=gl;
  gl.glMatrixMode(GL11.GL_PROJECTION);
  gl.glLoadIdentity();
  GLU.gluOrtho2D(gl,0,width,0,height);
  Matrix matrix=mTransformation.getMatrix();
  matrix.reset();
  matrix.preTranslate(0,getHeight());
  matrix.preScale(1,-1);
}

Fixed version (ground truth):
/** 
 * Called when the OpenGL surface is recreated without destroying the context.
 */
public void onSurfaceChanged(GL10 gl1,int width,int height){
  Log.v(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ gl1.toString());
  GL11 gl=(GL11)gl1;
  mGL=gl;
  gl.glViewport(0,0,width,height);
  gl.glMatrixMode(GL11.GL_PROJECTION);
  gl.glLoadIdentity();
  GLU.gluOrtho2D(gl,0,width,0,height);
  Matrix matrix=mTransformation.getMatrix();
  matrix.reset();
  matrix.preTranslate(0,getHeight());
  matrix.preScale(1,-1);
}
Program: 184373
Project: 184373
Buggy source:
private void initializeZoom(){
  if (!mParameters.isZoomSupported())   return;
  mParameters=mCameraDevice.getParameters();
  mZoomMax=mParameters.getMaxZoom();
  mSmoothZoomSupported=mParameters.isSmoothZoomSupported();
  mGestureDetector=new GestureDetector(this,new ZoomGestureListener());
  mCameraDevice.setZoomCallback(mZoomCallback);
  mHeadUpDisplay.setZoomRatios(getZoomRatios());
  mHeadUpDisplay.setZoomListener(new ZoomController.ZoomListener(){
    public void onZoomChanged(    final int index,    float ratio,    boolean isMoving){
      mHandler.post(new Runnable(){
        public void run(){
          onZoomValueChanged(index);
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
private void initializeZoom(){
  if (!mParameters.isZoomSupported())   return;
  mParameters=mCameraDevice.getParameters();
  mZoomMax=mParameters.getMaxZoom();
  mSmoothZoomSupported=mParameters.isSmoothZoomSupported();
  mGestureDetector=new GestureDetector(this,new ZoomGestureListener());
  mCameraDevice.setZoomCallback(mZoomCallback);
  mHeadUpDisplay.setZoomRatios(getZoomRatios());
  mHeadUpDisplay.setZoomIndex(mZoomValue);
  mHeadUpDisplay.setZoomListener(new ZoomController.ZoomListener(){
    public void onZoomChanged(    final int index,    float ratio,    boolean isMoving){
      mHandler.post(new Runnable(){
        public void run(){
          onZoomValueChanged(index);
        }
      }
);
    }
  }
);
}
Program: 184374
Project: 184374
Buggy source:
@Override protected void onResume(){
  super.onResume();
  mGLRootView.onResume();
  mPausing=false;
  mJpegPictureCallbackTime=0;
  mZoomValue=0;
  mImageCapture=new ImageCapture();
  resetExposureCompensation();
  if (!mPreviewing && !mStartPreviewFail) {
    try {
      startPreview();
    }
 catch (    CameraHardwareException e) {
      showCameraErrorAndFinish();
      return;
    }
  }
  if (mSurfaceHolder != null) {
    if (!mFirstTimeInitialized) {
      mHandler.sendEmptyMessage(FIRST_TIME_INIT);
    }
 else {
      initializeSecondTime();
    }
  }
  keepScreenOnAwhile();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mGLRootView.onResume();
  mPausing=false;
  mJpegPictureCallbackTime=0;
  mZoomValue=0;
  if (mHeadUpDisplay != null) {
    mHeadUpDisplay.setZoomIndex(mZoomValue);
  }
  mImageCapture=new ImageCapture();
  resetExposureCompensation();
  if (!mPreviewing && !mStartPreviewFail) {
    try {
      startPreview();
    }
 catch (    CameraHardwareException e) {
      showCameraErrorAndFinish();
      return;
    }
  }
  if (mSurfaceHolder != null) {
    if (!mFirstTimeInitialized) {
      mHandler.sendEmptyMessage(FIRST_TIME_INIT);
    }
 else {
      initializeSecondTime();
    }
  }
  keepScreenOnAwhile();
}
Program: 184375
Project: 184375
Buggy source:
@Override protected boolean bind(GLRootView root,GL11 gl){
  if (mLastWidth != mWidth || mLastHeight != mHeight) {
    if (mDelegate != null)     mDelegate.deleteFromGL(gl);
    mDelegate=new MyTexture(mWidth,mHeight);
    mLastWidth=mWidth;
    mLastHeight=mHeight;
  }
  return mDelegate.bind(root,gl);
}

Fixed version (ground truth):
@Override protected boolean bind(GLRootView root,GL11 gl){
  if (mLastWidth != mWidth || mLastHeight != mHeight) {
    if (mDelegate != null)     mDelegate.deleteFromGL();
    mDelegate=new MyTexture(mWidth,mHeight);
    mLastWidth=mWidth;
    mLastHeight=mHeight;
  }
  return mDelegate.bind(root,gl);
}
Program: 184376
Project: 184376
Buggy source:
public void deleteFromGL(GL11 gl){
  gl.glDeleteTextures(1,new int[]{mId},0);
  mState=STATE_UNLOADED;
}

Fixed version (ground truth):
public void deleteFromGL(){
  if (mState == STATE_LOADED) {
    mGL.glDeleteTextures(1,new int[]{mId},0);
  }
  mState=STATE_UNLOADED;
}
Program: 184377
Project: 184377
Buggy source:
public void onZoomChanged(int index,float value,boolean isMoving){
  if (mZoomListener != null) {
    mZoomListener.onZoomChanged(index,value,isMoving);
  }
  if (mZoom != value) {
    mZoom=value;
    mTitle=StringTexture.newInstance(sZoomFormat.format(value),mFontSize,Color.WHITE);
    invalidate();
  }
}

Fixed version (ground truth):
public void onZoomChanged(int index,float value,boolean isMoving){
  if (mZoomListener != null) {
    mZoomListener.onZoomChanged(index,value,isMoving);
  }
  if (mZoomIndex != index)   onZoomIndexChanged(index);
}
Program: 184378
Project: 184378
Buggy source:
public void setZoomIndex(int index){
  if (mZoomController != null) {
    mZoomController.setZoomIndex(index);
  }
  mZoomIndex=index;
}

Fixed version (ground truth):
public void setZoomIndex(int index){
  if (mZoomIndex == index)   return;
  if (mZoomController != null) {
    mZoomController.setZoomIndex(index);
  }
 else {
    onZoomIndexChanged(index);
  }
}
Program: 184379
Project: 184379
Buggy source:
public void setZoomRatios(float[] ratios){
  mZoomRatios=ratios;
}

Fixed version (ground truth):
public void setZoomRatios(float[] ratios){
  mZoomRatios=ratios;
  requestLayout();
}
Program: 184380
Project: 184380
Buggy source:
public ZoomIndicator(Context context){
  super(context);
  mFontSize=GLRootView.dpToPixel(context,FONT_SIZE);
  mTitle=StringTexture.newInstance(sZoomFormat.format(mZoom),mFontSize,FONT_COLOR);
}

Fixed version (ground truth):
public ZoomIndicator(Context context){
  super(context);
  mFontSize=GLRootView.dpToPixel(context,FONT_SIZE);
}
Program: 184381
Project: 184381
Buggy source:
@Override protected void onMeasure(int widthSpec,int heightSpec){
  new MeasureHelper(this).setPreferredContentSize(mTitle.getWidth(),mTitle.getHeight()).measure(widthSpec,heightSpec);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthSpec,int heightSpec){
  int maxWidth=0;
  int maxHeight=0;
  for (int i=0, n=mZoomRatios.length; i < n; ++i) {
    float value=mZoomRatios[i];
    Texture tex=StringTexture.newInstance(sZoomFormat.format(value),mFontSize,FONT_COLOR);
    if (maxWidth < tex.getWidth())     maxWidth=tex.getWidth();
    if (maxHeight < tex.getHeight())     maxHeight=tex.getHeight();
  }
  new MeasureHelper(this).setPreferredContentSize(maxWidth,maxHeight).measure(widthSpec,heightSpec);
}
Program: 184382
Project: 184382
Buggy source:
@Override protected Texture getIcon(){
  return mTitle;
}

Fixed version (ground truth):
@Override protected Texture getIcon(){
  if (mDrawIndex != mZoomIndex) {
    mDrawIndex=mZoomIndex;
    if (mTitle != null)     mTitle.deleteFromGL();
    float value=mZoomRatios == null ? 0 : mZoomRatios[mZoomIndex];
    mTitle=StringTexture.newInstance(sZoomFormat.format(value),mFontSize,FONT_COLOR);
  }
  return mTitle;
}
Program: 184383
Project: 184383
Buggy source:
/** 
 * Called when the OpenGL surface is recreated without destroying the context.
 */
public void onSurfaceChanged(GL10 gl1,int width,int height){
  Log.v(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ gl1.toString());
  GL11 gl=(GL11)gl1;
  mGL=gl;
  gl.glMatrixMode(GL11.GL_PROJECTION);
  gl.glLoadIdentity();
  GLU.gluOrtho2D(gl,0,width,0,height);
  Matrix matrix=mTransformation.getMatrix();
  matrix.reset();
  matrix.preTranslate(0,getHeight());
  matrix.preScale(1,-1);
}

Fixed version (ground truth):
/** 
 * Called when the OpenGL surface is recreated without destroying the context.
 */
public void onSurfaceChanged(GL10 gl1,int width,int height){
  Log.v(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ gl1.toString());
  GL11 gl=(GL11)gl1;
  mGL=gl;
  gl.glViewport(0,0,width,height);
  gl.glMatrixMode(GL11.GL_PROJECTION);
  gl.glLoadIdentity();
  GLU.gluOrtho2D(gl,0,width,0,height);
  Matrix matrix=mTransformation.getMatrix();
  matrix.reset();
  matrix.preTranslate(0,getHeight());
  matrix.preScale(1,-1);
}
Program: 184384
Project: 184384
Buggy source:
public void onPictureTaken(final byte[] jpegData,final android.hardware.Camera camera){
  if (mPausing) {
    return;
  }
  mJpegPictureCallbackTime=System.currentTimeMillis();
  if (mPostViewPictureCallbackTime != 0) {
    mShutterToPictureDisplayedTime=mPostViewPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
  }
 else {
    mShutterToPictureDisplayedTime=mRawPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mRawPictureCallbackTime;
  }
  Log.v(TAG,"String_Node_Str" + mPictureDisplayedToJpegCallbackTime + "String_Node_Str");
  if (!mIsImageCaptureIntent) {
    long delay=1200 - mPictureDisplayedToJpegCallbackTime;
    if (delay < 0 || mQuickCapture) {
      restartPreview();
    }
 else {
      mHandler.sendEmptyMessageDelayed(RESTART_PREVIEW,delay);
    }
  }
  mImageCapture.storeImage(jpegData,camera,mLocation);
  calculatePicturesRemaining();
}

Fixed version (ground truth):
public void onPictureTaken(final byte[] jpegData,final android.hardware.Camera camera){
  if (mPausing) {
    return;
  }
  mJpegPictureCallbackTime=System.currentTimeMillis();
  if (mPostViewPictureCallbackTime != 0) {
    mShutterToPictureDisplayedTime=mPostViewPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
  }
 else {
    mShutterToPictureDisplayedTime=mRawPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mRawPictureCallbackTime;
  }
  Log.v(TAG,"String_Node_Str" + mPictureDisplayedToJpegCallbackTime + "String_Node_Str");
  if (!mIsImageCaptureIntent) {
    long delay=1200 - mPictureDisplayedToJpegCallbackTime;
    if (delay < 0 || mQuickCapture) {
      restartPreview();
    }
 else {
      mHandler.sendEmptyMessageDelayed(RESTART_PREVIEW,delay);
    }
  }
  mImageCapture.storeImage(jpegData,camera,mLocation);
  calculatePicturesRemaining();
  if (mPicturesRemaining < 1) {
    updateStorageHint(mPicturesRemaining);
  }
}
Program: 184385
Project: 184385
Buggy source:
public void onSnap(){
  if (mPausing || mStatus == SNAPSHOT_IN_PROGRESS) {
    return;
  }
  mCaptureStartTime=System.currentTimeMillis();
  mPostViewPictureCallbackTime=0;
  if (mPicturesRemaining < 1) {
    updateStorageHint(mPicturesRemaining);
    return;
  }
  mStatus=SNAPSHOT_IN_PROGRESS;
  mImageCapture.initiate();
}

Fixed version (ground truth):
public void onSnap(){
  if (mPausing || mStatus == SNAPSHOT_IN_PROGRESS) {
    return;
  }
  mCaptureStartTime=System.currentTimeMillis();
  mPostViewPictureCallbackTime=0;
  mStatus=SNAPSHOT_IN_PROGRESS;
  mImageCapture.initiate();
}
Program: 184386
Project: 184386
Buggy source:
public void onPictureTaken(final byte[] jpegData,final android.hardware.Camera camera){
  if (mPausing) {
    return;
  }
  mJpegPictureCallbackTime=System.currentTimeMillis();
  if (mPostViewPictureCallbackTime != 0) {
    mShutterToPictureDisplayedTime=mPostViewPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
  }
 else {
    mShutterToPictureDisplayedTime=mRawPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mRawPictureCallbackTime;
  }
  Log.v(TAG,"String_Node_Str" + mPictureDisplayedToJpegCallbackTime + "String_Node_Str");
  if (!mIsImageCaptureIntent) {
    long delay=1200 - mPictureDisplayedToJpegCallbackTime;
    if (delay < 0 || mQuickCapture) {
      restartPreview();
    }
 else {
      mHandler.sendEmptyMessageDelayed(RESTART_PREVIEW,delay);
    }
  }
  mImageCapture.storeImage(jpegData,camera,mLocation);
  calculatePicturesRemaining();
}

Fixed version (ground truth):
public void onPictureTaken(final byte[] jpegData,final android.hardware.Camera camera){
  if (mPausing) {
    return;
  }
  mJpegPictureCallbackTime=System.currentTimeMillis();
  if (mPostViewPictureCallbackTime != 0) {
    mShutterToPictureDisplayedTime=mPostViewPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
  }
 else {
    mShutterToPictureDisplayedTime=mRawPictureCallbackTime - mShutterCallbackTime;
    mPictureDisplayedToJpegCallbackTime=mJpegPictureCallbackTime - mRawPictureCallbackTime;
  }
  Log.v(TAG,"String_Node_Str" + mPictureDisplayedToJpegCallbackTime + "String_Node_Str");
  if (!mIsImageCaptureIntent) {
    long delay=1200 - mPictureDisplayedToJpegCallbackTime;
    if (delay < 0 || mQuickCapture) {
      restartPreview();
    }
 else {
      mHandler.sendEmptyMessageDelayed(RESTART_PREVIEW,delay);
    }
  }
  mImageCapture.storeImage(jpegData,camera,mLocation);
  calculatePicturesRemaining();
  if (mPicturesRemaining < 1) {
    updateStorageHint(mPicturesRemaining);
  }
}
Program: 184387
Project: 184387
Buggy source:
public void onSnap(){
  if (mPausing || mStatus == SNAPSHOT_IN_PROGRESS) {
    return;
  }
  mCaptureStartTime=System.currentTimeMillis();
  mPostViewPictureCallbackTime=0;
  if (mPicturesRemaining < 1) {
    updateStorageHint(mPicturesRemaining);
    return;
  }
  mStatus=SNAPSHOT_IN_PROGRESS;
  mImageCapture.initiate();
}

Fixed version (ground truth):
public void onSnap(){
  if (mPausing || mStatus == SNAPSHOT_IN_PROGRESS) {
    return;
  }
  mCaptureStartTime=System.currentTimeMillis();
  mPostViewPictureCallbackTime=0;
  mStatus=SNAPSHOT_IN_PROGRESS;
  mImageCapture.initiate();
}
Program: 184388
Project: 184388
Buggy source:
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  if (drawable == null)   return;
  Rect bounds=drawable.getBounds();
  int w=bounds.right - bounds.left;
  int h=bounds.bottom - bounds.top;
  if (w == 0 || h == 0)   return;
  if (mCurrentDegree != mTargetDegree) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    if (time < mAnimationEndTime) {
      int deltaTime=(int)(time - mAnimationStartTime);
      int degree=mStartDegree + ANIMATION_SPEED * (mClockwise ? deltaTime : -deltaTime) / 1000;
      degree=degree >= 0 ? degree % 360 : degree % 360 + 360;
      mCurrentDegree=degree;
      invalidate();
    }
 else {
      mCurrentDegree=mTargetDegree;
    }
  }
  int saveCount=canvas.getSaveCount();
  canvas.rotate(-mCurrentDegree,w / 2,h / 2);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  if (drawable == null)   return;
  Rect bounds=drawable.getBounds();
  int w=bounds.right - bounds.left;
  int h=bounds.bottom - bounds.top;
  if (w == 0 || h == 0)   return;
  if (mCurrentDegree != mTargetDegree) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    if (time < mAnimationEndTime) {
      int deltaTime=(int)(time - mAnimationStartTime);
      int degree=mStartDegree + ANIMATION_SPEED * (mClockwise ? deltaTime : -deltaTime) / 1000;
      degree=degree >= 0 ? degree % 360 : degree % 360 + 360;
      mCurrentDegree=degree;
      invalidate();
    }
 else {
      mCurrentDegree=mTargetDegree;
    }
  }
  int saveCount=canvas.getSaveCount();
  canvas.translate(getPaddingLeft(),getPaddingTop());
  canvas.rotate(-mCurrentDegree,w / 2,h / 2);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}
Program: 184389
Project: 184389
Buggy source:
private void updateThumb(Bitmap original){
  if (original == null) {
    mThumb=null;
    mThumbs=null;
    return;
  }
  final int PADDING_WIDTH=2;
  final int PADDING_HEIGHT=2;
  LayoutParams param=mButton.getLayoutParams();
  final int miniThumbWidth=param.width - 2 * PADDING_WIDTH;
  final int miniThumbHeight=param.height - 2 * PADDING_HEIGHT;
  mThumb=ThumbnailUtil.extractMiniThumb(original,miniThumbWidth,miniThumbHeight,ThumbnailUtil.NO_RECYCLE_INPUT);
  Drawable drawable;
  if (mThumbs == null) {
    mThumbs=new Drawable[2];
    mThumbs[1]=new BitmapDrawable(mResources,mThumb);
    drawable=mThumbs[1];
    mShouldAnimateThumb=false;
  }
 else {
    mThumbs[0]=mThumbs[1];
    mThumbs[1]=new BitmapDrawable(mResources,mThumb);
    mThumbTransition=new TransitionDrawable(mThumbs);
    drawable=mThumbTransition;
    mShouldAnimateThumb=true;
  }
  mButton.setImageDrawable(drawable);
}

Fixed version (ground truth):
private void updateThumb(Bitmap original){
  if (original == null) {
    mThumb=null;
    mThumbs=null;
    return;
  }
  LayoutParams param=mButton.getLayoutParams();
  final int miniThumbWidth=param.width - mButton.getPaddingLeft() - mButton.getPaddingRight();
  final int miniThumbHeight=param.height - mButton.getPaddingTop() - mButton.getPaddingBottom();
  mThumb=ThumbnailUtil.extractMiniThumb(original,miniThumbWidth,miniThumbHeight,ThumbnailUtil.NO_RECYCLE_INPUT);
  Drawable drawable;
  if (mThumbs == null) {
    mThumbs=new Drawable[2];
    mThumbs[1]=new BitmapDrawable(mResources,mThumb);
    drawable=mThumbs[1];
    mShouldAnimateThumb=false;
  }
 else {
    mThumbs[0]=mThumbs[1];
    mThumbs[1]=new BitmapDrawable(mResources,mThumb);
    mThumbTransition=new TransitionDrawable(mThumbs);
    drawable=mThumbTransition;
    mShouldAnimateThumb=true;
  }
  mButton.setImageDrawable(drawable);
}
Program: 184392
Project: 184392
Buggy source:
private void initializeSecondTime(){
  mOrientationListener.enable();
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  keepMediaProviderInstance();
  checkStorage();
  if (mZoomButtons != null) {
    mCameraDevice.setZoomCallback(mZoomCallback);
  }
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}

Fixed version (ground truth):
private void initializeSecondTime(){
  mOrientationListener.enable();
  mRecordLocation=RecordLocationPreference.get(mPreferences,getContentResolver());
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  keepMediaProviderInstance();
  checkStorage();
  if (mZoomButtons != null) {
    mCameraDevice.setZoomCallback(mZoomCallback);
  }
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}
Program: 184394
Project: 184394
Buggy source:
private void restorePreferences(){
  mPreferences.unregisterOnSharedPreferenceChangeListener(this);
  mSettings.clearSettings();
  CameraSettings.upgradePreferences(mPreferences);
  setCameraParameters();
  mSettings.setPreferenceGroup(new CameraSettings(this,mParameters).getPreferenceGroup(R.xml.camera_preferences));
  mPreferences.registerOnSharedPreferenceChangeListener(this);
}

Fixed version (ground truth):
private void restorePreferences(){
  mPreferences.unregisterOnSharedPreferenceChangeListener(this);
  mSettings.clearSettings();
  CameraSettings.upgradePreferences(mPreferences);
  setCameraParameters();
  mPreferences.registerOnSharedPreferenceChangeListener(this);
}
Program: 184395
Project: 184395
Buggy source:
public void setPreferenceGroup(PreferenceGroup group){
  ArrayList<CameraPreference> list=new ArrayList<CameraPreference>();
  for (int i=0, n=group.size(); i < n; ++i) {
    addPreference(group.get(i),list);
  }
  mMainAdapter=new MainMenuAdapter(mContext,list);
  mMainMenu.setAdapter(mMainAdapter);
  mMainMenu.setOnItemClickListener(mMainAdapter);
}

Fixed version (ground truth):
public void setPreferenceGroup(PreferenceGroup group){
  this.mPreferenceGroup=group;
  ArrayList<CameraPreference> list=new ArrayList<CameraPreference>();
  for (int i=0, n=group.size(); i < n; ++i) {
    addPreference(group.get(i),list);
  }
  mMainAdapter=new MainMenuAdapter(mContext,list);
  mMainMenu.setAdapter(mMainAdapter);
  mMainMenu.setOnItemClickListener(mMainAdapter);
}
Program: 184396
Project: 184396
Buggy source:
public void clearSettings(){
  SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mContext).edit();
  editor.clear();
  editor.commit();
  mOverride.clear();
}

Fixed version (ground truth):
public void clearSettings(){
  SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(mContext).edit();
  editor.clear();
  editor.commit();
  mPreferenceGroup.reloadValue();
  if (mMainAdapter != null) {
    mMainAdapter.notifyDataSetChanged();
  }
  mOverride.clear();
}
Program: 184397
Project: 184397
Buggy source:
private void restorePreferences(){
  mPreferences.unregisterOnSharedPreferenceChangeListener(this);
  mSettings.clearSettings();
  CameraSettings.upgradePreferences(mPreferences);
  readVideoPreferences();
  resetCameraParameters();
  mHandler.post(new Runnable(){
    public void run(){
      mSettings.setPreferenceGroup(new CameraSettings(VideoCamera.this,mParameters).getPreferenceGroup(R.xml.video_preferences));
    }
  }
);
  mPreferences.registerOnSharedPreferenceChangeListener(this);
}

Fixed version (ground truth):
private void restorePreferences(){
  mPreferences.unregisterOnSharedPreferenceChangeListener(this);
  mSettings.clearSettings();
  CameraSettings.upgradePreferences(mPreferences);
  readVideoPreferences();
  resetCameraParameters();
  mPreferences.registerOnSharedPreferenceChangeListener(this);
}
Program: 184399
Project: 184399
Buggy source:
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetChanged();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}

Fixed version (ground truth):
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetInvalidated();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}
Program: 184400
Project: 184400
Buggy source:
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetChanged();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}

Fixed version (ground truth):
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetInvalidated();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}
Program: 184401
Project: 184401
Buggy source:
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetChanged();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}

Fixed version (ground truth):
public void setVisible(boolean visible){
  mHandler.removeMessages(MSG_POST_SET_VISIBLE);
  if (visible) {
    if (mOwnerView.getWindowToken() == null) {
      mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
      return;
    }
  }
  if (mIsVisible == visible) {
    return;
  }
  mIsVisible=visible;
  if (visible) {
    if (mMainAdapter != null)     mMainAdapter.notifyDataSetInvalidated();
    if (mContainerLayoutParams.token == null) {
      mContainerLayoutParams.token=mOwnerView.getWindowToken();
    }
    mSubMenu.setVisibility(View.INVISIBLE);
    mMainMenu.setVisibility(View.VISIBLE);
    mWindowManager.addView(mContainer,mContainerLayoutParams);
    updateLayout();
  }
 else {
    mWindowManager.removeView(mContainer);
  }
  if (mVisibilityListener != null) {
    mVisibilityListener.onVisibilityChanged(mIsVisible);
  }
}
Program: 184402
Project: 184402
Buggy source:
private void initializeFirstTime(){
  if (mFirstTimeInitialized)   return;
  mOrientationListener=new OrientationEventListener(Camera.this){
    @Override public void onOrientationChanged(    int orientation){
      if (orientation != ORIENTATION_UNKNOWN) {
        mLastOrientation=orientation;
      }
    }
  }
;
  mOrientationListener.enable();
  mLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  checkStorage();
  mContentResolver=getContentResolver();
  if (!mIsImageCaptureIntent) {
    findViewById(R.id.camera_switch).setOnClickListener(this);
    mLastPictureButton=(ImageView)findViewById(R.id.review_thumbnail);
    mLastPictureButton.setOnClickListener(this);
    mThumbController=new ThumbnailController(getResources(),mLastPictureButton,mContentResolver);
    mThumbController.loadData(ImageManager.getLastImageThumbPath());
    updateThumbnailButton();
  }
  mShutterButton=(ShutterButton)findViewById(R.id.shutter_button);
  mShutterButton.setOnShutterButtonListener(this);
  mShutterButton.setVisibility(View.VISIBLE);
  mFocusRectangle=(FocusRectangle)findViewById(R.id.focus_rectangle);
  updateFocusIndicator();
  mGpsIndicator=(IconIndicator)findViewById(R.id.gps_icon);
  ImageManager.ensureOSXCompatibleFolder();
  installIntentFilter();
  initializeFocusTone();
  initializeZoom();
  mFirstTimeInitialized=true;
}

Fixed version (ground truth):
private void initializeFirstTime(){
  if (mFirstTimeInitialized)   return;
  mOrientationListener=new OrientationEventListener(Camera.this){
    @Override public void onOrientationChanged(    int orientation){
      if (orientation != ORIENTATION_UNKNOWN) {
        mLastOrientation=orientation;
      }
    }
  }
;
  mOrientationListener.enable();
  mLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  keepMediaProviderInstance();
  checkStorage();
  mContentResolver=getContentResolver();
  if (!mIsImageCaptureIntent) {
    findViewById(R.id.camera_switch).setOnClickListener(this);
    mLastPictureButton=(ImageView)findViewById(R.id.review_thumbnail);
    mLastPictureButton.setOnClickListener(this);
    mThumbController=new ThumbnailController(getResources(),mLastPictureButton,mContentResolver);
    mThumbController.loadData(ImageManager.getLastImageThumbPath());
    updateThumbnailButton();
  }
  mShutterButton=(ShutterButton)findViewById(R.id.shutter_button);
  mShutterButton.setOnShutterButtonListener(this);
  mShutterButton.setVisibility(View.VISIBLE);
  mFocusRectangle=(FocusRectangle)findViewById(R.id.focus_rectangle);
  updateFocusIndicator();
  mGpsIndicator=(IconIndicator)findViewById(R.id.gps_icon);
  ImageManager.ensureOSXCompatibleFolder();
  installIntentFilter();
  initializeFocusTone();
  initializeZoom();
  mFirstTimeInitialized=true;
}
Program: 184403
Project: 184403
Buggy source:
private void initializeSecondTime(){
  mOrientationListener.enable();
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  checkStorage();
  if (mZoomButtons != null) {
    mCameraDevice.setZoomCallback(mZoomCallback);
  }
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}

Fixed version (ground truth):
private void initializeSecondTime(){
  mOrientationListener.enable();
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  keepMediaProviderInstance();
  checkStorage();
  if (mZoomButtons != null) {
    mCameraDevice.setZoomCallback(mZoomCallback);
  }
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}
Program: 184404
Project: 184404
Buggy source:
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  mParameters.setZoom(zoomValue);
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}
Program: 184405
Project: 184405
Buggy source:
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  mParameters.setZoom(zoomValue);
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}
Program: 184406
Project: 184406
Buggy source:
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  mParameters.setZoom(zoomValue);
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}
Program: 184407
Project: 184407
Buggy source:
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  mParameters.setZoom(zoomValue);
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}
Program: 184408
Project: 184408
Buggy source:
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomValue,boolean stopped,android.hardware.Camera camera){
  Log.v(TAG,"String_Node_Str" + zoomValue + "String_Node_Str"+ stopped);
  mZoomValue=zoomValue;
  mParameters.setZoom(zoomValue);
  if (stopped)   mZooming=false;
  updateZoomButtonsEnabled();
}
Program: 184409
Project: 184409
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || supported.size() <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}
Program: 184410
Project: 184410
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || supported.size() <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}