nus-yam/ex-repair huggingface dataset:
Program: 22222
Project: 22222
Buggy source:
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
if ((mCurrX == mFinalX) && (mCurrY == mFinalY)) {
mFinished=true;
}
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
if (mCurrX == mFinalX && mCurrY == mFinalY) {
mFinished=true;
}
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}

Fixed version (ground truth):
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}
Program: 22224
Project: 22224
Buggy source:
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
if ((mCurrX == mFinalX) && (mCurrY == mFinalY)) {
mFinished=true;
}
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
if (mCurrX == mFinalX && mCurrY == mFinalY) {
mFinished=true;
}
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}

Fixed version (ground truth):
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}
Program: 22225
Project: 22225
Buggy source:
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
if ((mCurrX == mFinalX) && (mCurrY == mFinalY)) {
mFinished=true;
}
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
if (mCurrX == mFinalX && mCurrY == mFinalY) {
mFinished=true;
}
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}

Fixed version (ground truth):
/** 
 * Call this when you want to know the new location.  If it returns true, the animation is not yet finished.  loc will be altered to provide the new location.
 */
public boolean computeScrollOffset(){
  if (mFinished) {
    return false;
  }
  int timePassed=(int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
  if (timePassed < mDuration) {
switch (mMode) {
case SCROLL_MODE:
      float x=(float)timePassed * mDurationReciprocal;
    if (mInterpolator == null)     x=viscousFluid(x);
 else     x=mInterpolator.getInterpolation(x);
  mCurrX=mStartX + Math.round(x * mDeltaX);
mCurrY=mStartY + Math.round(x * mDeltaY);
break;
case FLING_MODE:
float timePassedSeconds=timePassed / 1000.0f;
float distance=(mVelocity * timePassedSeconds) - (mDeceleration * timePassedSeconds * timePassedSeconds / 2.0f);
mCurrX=mStartX + Math.round(distance * mCoeffX);
mCurrX=Math.min(mCurrX,mMaxX);
mCurrX=Math.max(mCurrX,mMinX);
mCurrY=mStartY + Math.round(distance * mCoeffY);
mCurrY=Math.min(mCurrY,mMaxY);
mCurrY=Math.max(mCurrY,mMinY);
break;
}
}
 else {
mCurrX=mFinalX;
mCurrY=mFinalY;
mFinished=true;
}
return true;
}
Program: 22227
Project: 22227
Buggy source:
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      onVisibilityChanged(visible);
    }
  }
}

Fixed version (ground truth):
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      if (visible) {
        updateSurface(false,false);
      }
      onVisibilityChanged(visible);
    }
  }
}
Program: 22228
Project: 22228
Buggy source:
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
  final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
  final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
  final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
  final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
  onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}

Fixed version (ground truth):
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (mSurfaceCreated) {
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
    final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
    final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
    final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
    final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
    onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  }
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 22229
Project: 22229
Buggy source:
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}

Fixed version (ground truth):
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  reportSurfaceDestroyed();
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}
Program: 22231
Project: 22231
Buggy source:
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      onVisibilityChanged(visible);
    }
  }
}

Fixed version (ground truth):
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      if (visible) {
        updateSurface(false,false);
      }
      onVisibilityChanged(visible);
    }
  }
}
Program: 22232
Project: 22232
Buggy source:
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
  final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
  final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
  final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
  final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
  onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}

Fixed version (ground truth):
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (mSurfaceCreated) {
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
    final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
    final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
    final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
    final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
    onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  }
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 22233
Project: 22233
Buggy source:
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}

Fixed version (ground truth):
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  reportSurfaceDestroyed();
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}
Program: 22242
Project: 22242
Buggy source:
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}

Fixed version (ground truth):
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true,false);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}
Program: 22243
Project: 22243
Buggy source:
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      onVisibilityChanged(visible);
    }
  }
}

Fixed version (ground truth):
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      if (visible) {
        updateSurface(false,false);
      }
      onVisibilityChanged(visible);
    }
  }
}
Program: 22244
Project: 22244
Buggy source:
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
  final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
  final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
  final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
  final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
  onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}

Fixed version (ground truth):
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (mSurfaceCreated) {
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
    final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
    final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
    final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
    final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
    onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  }
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 22245
Project: 22245
Buggy source:
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}

Fixed version (ground truth):
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  reportSurfaceDestroyed();
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}
Program: 22254
Project: 22254
Buggy source:
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}

Fixed version (ground truth):
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true,false);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}
Program: 22262
Project: 22262
Buggy source:
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}

Fixed version (ground truth):
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true,false);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}
Program: 22270
Project: 22270
Buggy source:
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}

Fixed version (ground truth):
private void updateSettingsLI(PackageParser.Package newPackage,String installerPackageName,PackageInstalledInfo res){
  String pkgName=newPackage.packageName;
synchronized (mPackages) {
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_INCOMPLETE);
    mSettings.writeLP();
  }
  if ((res.returnCode=moveDexFilesLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    return;
  }
  if ((res.returnCode=setPermissionsLI(newPackage)) != PackageManager.INSTALL_SUCCEEDED) {
    if (mInstaller != null) {
      mInstaller.rmdex(newPackage.mScanPath);
    }
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str" + newPackage.mPath);
  }
synchronized (mPackages) {
    updatePermissionsLP(newPackage.packageName,newPackage,newPackage.permissions.size() > 0,true,false);
    res.name=pkgName;
    res.uid=newPackage.applicationInfo.uid;
    res.pkg=newPackage;
    mSettings.setInstallStatus(pkgName,PKG_INSTALL_COMPLETE);
    mSettings.setInstallerPackageName(pkgName,installerPackageName);
    res.returnCode=PackageManager.INSTALL_SUCCEEDED;
    mSettings.writeLP();
  }
}
Program: 22272
Project: 22272
Buggy source:
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
synchronized (mCmdQueue) {
    if (mCmdQueue.size() == 0) {
synchronized (mCompletionHandlingLock) {
        if (mLooper != null) {
          mLooper.quit();
        }
        mCompletionThread=null;
      }
    }
  }
}
Program: 22273
Project: 22273
Buggy source:
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
mLooper.quit();
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}

Fixed version (ground truth):
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
  mLooper.quit();
}
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}
Program: 22274
Project: 22274
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
synchronized (mCompletionHandlingLock) {
      if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
        mLooper.quit();
      }
      mCompletionThread=new CreationAndCompletionThread(cmd);
synchronized (mCompletionThread) {
        mCompletionThread.start();
        mCompletionThread.wait();
      }
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22275
Project: 22275
Buggy source:
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      onVisibilityChanged(visible);
    }
  }
}

Fixed version (ground truth):
void reportVisibility(){
  if (!mDestroyed) {
    boolean visible=mVisible && mScreenOn;
    if (mReportedVisible != visible) {
      mReportedVisible=visible;
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + visible + "String_Node_Str"+ this);
      if (visible) {
        updateSurface(false,false);
      }
      onVisibilityChanged(visible);
    }
  }
}
Program: 22276
Project: 22276
Buggy source:
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
  final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
  final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
  final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
  final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
  onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}

Fixed version (ground truth):
void doOffsetsChanged(){
  if (mDestroyed) {
    return;
  }
  float xOffset;
  float yOffset;
  float xOffsetStep;
  float yOffsetStep;
  boolean sync;
synchronized (mLock) {
    xOffset=mPendingXOffset;
    yOffset=mPendingYOffset;
    xOffsetStep=mPendingXOffsetStep;
    yOffsetStep=mPendingYOffsetStep;
    sync=mPendingSync;
    mPendingSync=false;
    mOffsetMessageEnqueued=false;
  }
  if (mSurfaceCreated) {
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ xOffset+ "String_Node_Str"+ yOffset);
    final int availw=mIWallpaperEngine.mReqWidth - mCurWidth;
    final int xPixels=availw > 0 ? -(int)(availw * xOffset + .5f) : 0;
    final int availh=mIWallpaperEngine.mReqHeight - mCurHeight;
    final int yPixels=availh > 0 ? -(int)(availh * yOffset + .5f) : 0;
    onOffsetsChanged(xOffset,yOffset,xOffsetStep,yOffsetStep,xPixels,yPixels);
  }
  if (sync) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str");
      mSession.wallpaperOffsetsComplete(mWindow.asBinder());
    }
 catch (    RemoteException e) {
    }
  }
}
Program: 22277
Project: 22277
Buggy source:
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}

Fixed version (ground truth):
void detach(){
  if (mDestroyed) {
    return;
  }
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  reportSurfaceDestroyed();
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  unregisterReceiver(mReceiver);
  if (mCreated) {
    try {
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + mSurfaceHolder.getSurface() + "String_Node_Str"+ this);
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}
Program: 22279
Project: 22279
Buggy source:
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
synchronized (mCmdQueue) {
    if (mCmdQueue.size() == 0) {
synchronized (mCompletionHandlingLock) {
        if (mLooper != null) {
          mLooper.quit();
        }
        mCompletionThread=null;
      }
    }
  }
}
Program: 22280
Project: 22280
Buggy source:
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
mLooper.quit();
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}

Fixed version (ground truth):
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
  mLooper.quit();
}
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}
Program: 22281
Project: 22281
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
synchronized (mCompletionHandlingLock) {
      if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
        mLooper.quit();
      }
      mCompletionThread=new CreationAndCompletionThread(cmd);
synchronized (mCompletionThread) {
        mCompletionThread.start();
        mCompletionThread.wait();
      }
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22282
Project: 22282
Buggy source:
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
synchronized (mCmdQueue) {
    if (mCmdQueue.size() == 0) {
synchronized (mCompletionHandlingLock) {
        if (mLooper != null) {
          mLooper.quit();
        }
        mCompletionThread=null;
      }
    }
  }
}
Program: 22283
Project: 22283
Buggy source:
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
mLooper.quit();
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}

Fixed version (ground truth):
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
  mLooper.quit();
}
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}
Program: 22284
Project: 22284
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
synchronized (mCompletionHandlingLock) {
      if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
        mLooper.quit();
      }
      mCompletionThread=new CreationAndCompletionThread(cmd);
synchronized (mCompletionThread) {
        mCompletionThread.start();
        mCompletionThread.wait();
      }
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22285
Project: 22285
Buggy source:
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer mp){
  if (mAudioManager != null) {
    mAudioManager.abandonAudioFocus(null);
  }
synchronized (mCmdQueue) {
    if (mCmdQueue.size() == 0) {
synchronized (mCompletionHandlingLock) {
        if (mLooper != null) {
          mLooper.quit();
        }
        mCompletionThread=null;
      }
    }
  }
}
Program: 22286
Project: 22286
Buggy source:
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
mLooper.quit();
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}

Fixed version (ground truth):
public void run(){
  while (true) {
    Command cmd=null;
synchronized (mCmdQueue) {
      if (mDebug)       Log.d(mTag,"String_Node_Str");
      cmd=mCmdQueue.removeFirst();
    }
switch (cmd.code) {
case PLAY:
      if (mDebug)       Log.d(mTag,"String_Node_Str");
    startSound(cmd);
  break;
case STOP:
if (mDebug) Log.d(mTag,"String_Node_Str");
if (mPlayer != null) {
long delay=SystemClock.uptimeMillis() - cmd.requestTime;
if (delay > 1000) {
  Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
}
mPlayer.stop();
mPlayer.release();
mPlayer=null;
mAudioManager.abandonAudioFocus(null);
mAudioManager=null;
if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
  mLooper.quit();
}
}
 else {
Log.w(mTag,"String_Node_Str");
}
break;
}
synchronized (mCmdQueue) {
if (mCmdQueue.size() == 0) {
mThread=null;
releaseWakeLock();
return;
}
}
}
}
Program: 22287
Project: 22287
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
synchronized (mCompletionHandlingLock) {
      if ((mLooper != null) && (mLooper.getThread().getState() != Thread.State.TERMINATED)) {
        mLooper.quit();
      }
      mCompletionThread=new CreationAndCompletionThread(cmd);
synchronized (mCompletionThread) {
        mCompletionThread.start();
        mCompletionThread.wait();
      }
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}