nus-yam/ex-repair huggingface dataset:
Program: 181225
Project: 181225
Buggy source:
private boolean isPositionVisible(){
  if (mIsDragging) {
    return true;
  }
  final int extendedPaddingTop=getExtendedPaddingTop();
  final int extendedPaddingBottom=getExtendedPaddingBottom();
  final int compoundPaddingLeft=getCompoundPaddingLeft();
  final int compoundPaddingRight=getCompoundPaddingRight();
  final TextView hostView=TextView.this;
  final int left=0;
  final int right=hostView.getWidth();
  final int top=0;
  final int bottom=hostView.getHeight();
  if (mTempRect == null) {
    mTempRect=new Rect();
  }
  final Rect clip=mTempRect;
  clip.left=left + compoundPaddingLeft;
  clip.top=top + extendedPaddingTop;
  clip.right=right - compoundPaddingRight;
  clip.bottom=bottom - extendedPaddingBottom;
  final ViewParent parent=hostView.getParent();
  if (parent == null || !parent.getChildVisibleRect(hostView,clip,null)) {
    return false;
  }
  final int[] coords=mTempCoords;
  hostView.getLocationInWindow(coords);
  final int posX=coords[0] + mPositionX + (int)mHotspotX;
  final int posY=coords[1] + mPositionY + (int)mHotspotY;
  return posX >= clip.left && posX <= clip.right && posY >= clip.top && posY <= clip.bottom;
}

Fixed version (ground truth):
private boolean isPositionVisible(){
  if (mIsDragging) {
    return true;
  }
  if (isInBatchEditMode()) {
    return false;
  }
  final int extendedPaddingTop=getExtendedPaddingTop();
  final int extendedPaddingBottom=getExtendedPaddingBottom();
  final int compoundPaddingLeft=getCompoundPaddingLeft();
  final int compoundPaddingRight=getCompoundPaddingRight();
  final TextView hostView=TextView.this;
  final int left=0;
  final int right=hostView.getWidth();
  final int top=0;
  final int bottom=hostView.getHeight();
  if (mTempRect == null) {
    mTempRect=new Rect();
  }
  final Rect clip=mTempRect;
  clip.left=left + compoundPaddingLeft;
  clip.top=top + extendedPaddingTop;
  clip.right=right - compoundPaddingRight;
  clip.bottom=bottom - extendedPaddingBottom;
  final ViewParent parent=hostView.getParent();
  if (parent == null || !parent.getChildVisibleRect(hostView,clip,null)) {
    return false;
  }
  final int[] coords=mTempCoords;
  hostView.getLocationInWindow(coords);
  final int posX=coords[0] + mPositionX + (int)mHotspotX;
  final int posY=coords[1] + mPositionY + (int)mHotspotY;
  return posX >= clip.left && posX <= clip.right && posY >= clip.top && posY <= clip.bottom;
}
Program: 181226
Project: 181226
Buggy source:
private void startTextSelectionMode(){
  if (!mIsInTextSelectionMode) {
    if (mSelectionModifierCursorController == null) {
      Log.w(LOG_TAG,"String_Node_Str");
      return;
    }
    if (!requestFocus()) {
      return;
    }
    selectCurrentWord();
    mSelectionModifierCursorController.show();
    mIsInTextSelectionMode=true;
  }
}

Fixed version (ground truth):
private void startTextSelectionMode(){
  if (!mIsInTextSelectionMode) {
    if (!hasSelectionController()) {
      Log.w(LOG_TAG,"String_Node_Str");
      return;
    }
    if (!requestFocus()) {
      return;
    }
    selectCurrentWord();
    mIsInTextSelectionMode=true;
  }
}
Program: 181227
Project: 181227
Buggy source:
public void beginBatchEdit(){
  final InputMethodState ims=mInputMethodState;
  if (ims != null) {
    int nesting=++ims.mBatchEditNesting;
    if (nesting == 1) {
      ims.mCursorChanged=false;
      ims.mChangedDelta=0;
      if (ims.mContentChanged) {
        ims.mChangedStart=0;
        ims.mChangedEnd=mText.length();
      }
 else {
        ims.mChangedStart=EXTRACT_UNKNOWN;
        ims.mChangedEnd=EXTRACT_UNKNOWN;
        ims.mContentChanged=false;
      }
      onBeginBatchEdit();
    }
  }
}

Fixed version (ground truth):
public void beginBatchEdit(){
  mInBatchEditControllers=true;
  final InputMethodState ims=mInputMethodState;
  if (ims != null) {
    int nesting=++ims.mBatchEditNesting;
    if (nesting == 1) {
      ims.mCursorChanged=false;
      ims.mChangedDelta=0;
      if (ims.mContentChanged) {
        ims.mChangedStart=0;
        ims.mChangedEnd=mText.length();
      }
 else {
        ims.mChangedStart=EXTRACT_UNKNOWN;
        ims.mChangedEnd=EXTRACT_UNKNOWN;
        ims.mContentChanged=false;
      }
      onBeginBatchEdit();
    }
  }
}
Program: 181229
Project: 181229
Buggy source:
private void onTapUpEvent(int prevStart,int prevEnd){
  final int start=getSelectionStart();
  final int end=getSelectionEnd();
  if (start == end) {
    if (start >= prevStart && start < prevEnd) {
      Selection.setSelection((Spannable)mText,prevStart,prevEnd);
      if (mSelectionModifierCursorController != null && !mSelectionModifierCursorController.isShowing()) {
        mSelectionModifierCursorController.show();
      }
 else {
        showContextMenu();
      }
      return;
    }
 else {
      stopTextSelectionMode();
      if (mInsertionPointCursorController != null && mText.length() > 0) {
        mInsertionPointCursorController.show();
      }
    }
  }
 else   if (hasSelection() && mSelectionModifierCursorController != null) {
    mSelectionModifierCursorController.show();
  }
}

Fixed version (ground truth):
private void onTapUpEvent(int prevStart,int prevEnd){
  final int start=getSelectionStart();
  final int end=getSelectionEnd();
  if (start == end) {
    if (start >= prevStart && start < prevEnd) {
      Selection.setSelection((Spannable)mText,prevStart,prevEnd);
      if (hasSelectionController() && !getSelectionController().isShowing()) {
        getSelectionController().show();
      }
 else {
        showContextMenu();
      }
      return;
    }
 else {
      stopTextSelectionMode();
      if (hasInsertionController() && mText.length() > 0) {
        getInsertionController().show();
      }
    }
  }
 else   if (hasSelection() && hasSelectionController()) {
    getSelectionController().show();
  }
}
Program: 181230
Project: 181230
Buggy source:
public void show(){
  mIsShowing=true;
  updatePosition();
  mStartHandle.show();
  mEndHandle.show();
  hideInsertionPointCursorController();
  hideDelayed(DELAY_BEFORE_FADE_OUT);
}

Fixed version (ground truth):
public void show(){
  if (isInBatchEditMode()) {
    return;
  }
  mIsShowing=true;
  updatePosition();
  mStartHandle.show();
  mEndHandle.show();
  hideInsertionPointCursorController();
  hideDelayed(DELAY_BEFORE_FADE_OUT);
}
Program: 181231
Project: 181231
Buggy source:
public void endBatchEdit(){
  final InputMethodState ims=mInputMethodState;
  if (ims != null) {
    int nesting=--ims.mBatchEditNesting;
    if (nesting == 0) {
      finishBatchEdit(ims);
    }
  }
}

Fixed version (ground truth):
public void endBatchEdit(){
  mInBatchEditControllers=false;
  final InputMethodState ims=mInputMethodState;
  if (ims != null) {
    int nesting=--ims.mBatchEditNesting;
    if (nesting == 0) {
      finishBatchEdit(ims);
    }
  }
}
Program: 181232
Project: 181232
Buggy source:
private void prepareCursorControllers(){
  boolean windowSupportsHandles=false;
  ViewGroup.LayoutParams params=getRootView().getLayoutParams();
  if (params instanceof WindowManager.LayoutParams) {
    WindowManager.LayoutParams windowParams=(WindowManager.LayoutParams)params;
    windowSupportsHandles=windowParams.type < WindowManager.LayoutParams.FIRST_SUB_WINDOW || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
  }
  if (windowSupportsHandles && mCursorVisible && mLayout != null) {
    if (mInsertionPointCursorController == null) {
      mInsertionPointCursorController=new InsertionPointCursorController();
    }
  }
 else {
    mInsertionPointCursorController=null;
  }
  if (windowSupportsHandles && textCanBeSelected() && mLayout != null) {
    if (mSelectionModifierCursorController == null) {
      mSelectionModifierCursorController=new SelectionModifierCursorController();
    }
  }
 else {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}

Fixed version (ground truth):
private void prepareCursorControllers(){
  boolean windowSupportsHandles=false;
  ViewGroup.LayoutParams params=getRootView().getLayoutParams();
  if (params instanceof WindowManager.LayoutParams) {
    WindowManager.LayoutParams windowParams=(WindowManager.LayoutParams)params;
    windowSupportsHandles=windowParams.type < WindowManager.LayoutParams.FIRST_SUB_WINDOW || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
  }
  mInsertionControllerEnabled=windowSupportsHandles && mCursorVisible && mLayout != null;
  mSelectionControllerEnabled=windowSupportsHandles && textCanBeSelected() && mLayout != null;
  if (!mInsertionControllerEnabled) {
    mInsertionPointCursorController=null;
  }
  if (!mSelectionControllerEnabled) {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}
Program: 181233
Project: 181233
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean onPreDraw(){
  if (mPreDrawState != PREDRAW_PENDING) {
    return true;
  }
  if (mLayout == null) {
    assumeLayout();
  }
  boolean changed=false;
  SelectionModifierCursorController selectionController=null;
  if (mSelectionModifierCursorController != null) {
    selectionController=(SelectionModifierCursorController)mSelectionModifierCursorController;
  }
  if (mMovement != null) {
    int curs=getSelectionEnd();
    if (selectionController != null && selectionController.isSelectionStartDragged()) {
      curs=getSelectionStart();
    }
    if (curs < 0 && (mGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
      curs=mText.length();
    }
    if (curs >= 0) {
      changed=bringPointIntoView(curs);
    }
  }
 else {
    changed=bringTextIntoView();
  }
  if (selectionController != null && hasSelection()) {
    startTextSelectionMode();
  }
  mPreDrawState=PREDRAW_DONE;
  return !changed;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public boolean onPreDraw(){
  if (mPreDrawState != PREDRAW_PENDING) {
    return true;
  }
  if (mLayout == null) {
    assumeLayout();
  }
  boolean changed=false;
  SelectionModifierCursorController selectionController=null;
  if (mSelectionModifierCursorController != null) {
    selectionController=(SelectionModifierCursorController)mSelectionModifierCursorController;
  }
  if (mMovement != null) {
    int curs=getSelectionEnd();
    if (selectionController != null && selectionController.isSelectionStartDragged()) {
      curs=getSelectionStart();
    }
    if (curs < 0 && (mGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
      curs=mText.length();
    }
    if (curs >= 0) {
      changed=bringPointIntoView(curs);
    }
  }
 else {
    changed=bringTextIntoView();
  }
  if (this instanceof ExtractEditText && selectionController != null && hasSelection()) {
    startTextSelectionMode();
  }
  mPreDrawState=PREDRAW_DONE;
  return !changed;
}
Program: 181234
Project: 181234
Buggy source:
public void updatePosition(){
  final int selectionStart=getSelectionStart();
  final int selectionEnd=getSelectionEnd();
  if ((selectionStart < 0) || (selectionEnd < 0)) {
    Log.w(LOG_TAG,"String_Node_Str");
    hide();
    return;
  }
  mStartHandle.positionAtCursor(selectionStart,true);
  mEndHandle.positionAtCursor(selectionEnd,true);
  hideDelayed(DELAY_BEFORE_FADE_OUT);
}

Fixed version (ground truth):
public void updatePosition(){
  if (!isShowing()) {
    return;
  }
  final int selectionStart=getSelectionStart();
  final int selectionEnd=getSelectionEnd();
  if ((selectionStart < 0) || (selectionEnd < 0)) {
    Log.w(LOG_TAG,"String_Node_Str");
    hide();
    return;
  }
  mStartHandle.positionAtCursor(selectionStart,true);
  mEndHandle.positionAtCursor(selectionEnd,true);
  hideDelayed(DELAY_BEFORE_FADE_OUT);
}
Program: 181235
Project: 181235
Buggy source:
private boolean isPositionVisible(){
  if (mIsDragging) {
    return true;
  }
  final int extendedPaddingTop=getExtendedPaddingTop();
  final int extendedPaddingBottom=getExtendedPaddingBottom();
  final int compoundPaddingLeft=getCompoundPaddingLeft();
  final int compoundPaddingRight=getCompoundPaddingRight();
  final TextView hostView=TextView.this;
  final int left=0;
  final int right=hostView.getWidth();
  final int top=0;
  final int bottom=hostView.getHeight();
  if (mTempRect == null) {
    mTempRect=new Rect();
  }
  final Rect clip=mTempRect;
  clip.left=left + compoundPaddingLeft;
  clip.top=top + extendedPaddingTop;
  clip.right=right - compoundPaddingRight;
  clip.bottom=bottom - extendedPaddingBottom;
  final ViewParent parent=hostView.getParent();
  if (parent == null || !parent.getChildVisibleRect(hostView,clip,null)) {
    return false;
  }
  final int[] coords=mTempCoords;
  hostView.getLocationInWindow(coords);
  final int posX=coords[0] + mPositionX + (int)mHotspotX;
  final int posY=coords[1] + mPositionY + (int)mHotspotY;
  return posX >= clip.left && posX <= clip.right && posY >= clip.top && posY <= clip.bottom;
}

Fixed version (ground truth):
private boolean isPositionVisible(){
  if (mIsDragging) {
    return true;
  }
  if (isInBatchEditMode()) {
    return false;
  }
  final int extendedPaddingTop=getExtendedPaddingTop();
  final int extendedPaddingBottom=getExtendedPaddingBottom();
  final int compoundPaddingLeft=getCompoundPaddingLeft();
  final int compoundPaddingRight=getCompoundPaddingRight();
  final TextView hostView=TextView.this;
  final int left=0;
  final int right=hostView.getWidth();
  final int top=0;
  final int bottom=hostView.getHeight();
  if (mTempRect == null) {
    mTempRect=new Rect();
  }
  final Rect clip=mTempRect;
  clip.left=left + compoundPaddingLeft;
  clip.top=top + extendedPaddingTop;
  clip.right=right - compoundPaddingRight;
  clip.bottom=bottom - extendedPaddingBottom;
  final ViewParent parent=hostView.getParent();
  if (parent == null || !parent.getChildVisibleRect(hostView,clip,null)) {
    return false;
  }
  final int[] coords=mTempCoords;
  hostView.getLocationInWindow(coords);
  final int posX=coords[0] + mPositionX + (int)mHotspotX;
  final int posY=coords[1] + mPositionY + (int)mHotspotY;
  return posX >= clip.left && posX <= clip.right && posY >= clip.top && posY <= clip.bottom;
}
Program: 181240
Project: 181240
Buggy source:
/** 
 * Called when the application is stopping.  There are no more application objects running and the process will exit.  <em>Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code.</em> If you override this method, be sure to call super.onTerminate().
 */
public void onTerminate(){
}

Fixed version (ground truth):
/** 
 * This method is for use in emulated process environments.  It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so.
 */
public void onTerminate(){
}
Program: 181241
Project: 181241
Buggy source:
/** 
 * Called when the application is stopping.  There are no more application objects running and the process will exit.  <em>Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code.</em> If you override this method, be sure to call super.onTerminate().
 */
public void onTerminate(){
}

Fixed version (ground truth):
/** 
 * This method is for use in emulated process environments.  It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so.
 */
public void onTerminate(){
}
Program: 181242
Project: 181242
Buggy source:
/** 
 * Resolves the value of a resource, if the value references a theme or resource value. <p/> This method ensures that it returns a   {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return a new instance of IResourceValue that contains the input value.
 * @param type the type of the resource
 * @param name the name of the attribute containing this value.
 * @param value the resource value, or reference to resolve
 * @return the resolved resource value or <code>null</code> if it failed to resolve it.
 */
private IResourceValue resolveValue(String type,String name,String value){
  if (value == null) {
    return null;
  }
  IResourceValue resValue=findResValue(value);
  if (resValue == null) {
    return new ResourceValue(type,name,value);
  }
  return resolveResValue(resValue);
}

Fixed version (ground truth):
/** 
 * Resolves the value of a resource, if the value references a theme or resource value. <p/> This method ensures that it returns a   {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return a new instance of IResourceValue that contains the input value.
 * @param type the type of the resource
 * @param name the name of the attribute containing this value.
 * @param value the resource value, or reference to resolve
 * @return the resolved resource value or <code>null</code> if it failed to resolve it.
 */
private IResourceValue resolveValue(String type,String name,String value){
  if (value == null) {
    return null;
  }
  IResourceValue resValue=findResValue(value,false);
  if (resValue == null) {
    return new ResourceValue(type,name,value);
  }
  return resolveResValue(resValue);
}
Program: 181244
Project: 181244
Buggy source:
/** 
 * Returns the   {@link IResourceValue} referenced by the value of <var>value</var>.<p/> This method ensures that it returns a  {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return the input value.
 * @param value the value containing the reference to resolve.
 * @return a {@link IResourceValue} object or <code>null</code>
 */
IResourceValue resolveResValue(IResourceValue value){
  if (value == null) {
    return null;
  }
  if (value instanceof IStyleResourceValue) {
    return value;
  }
  IResourceValue resolvedValue=findResValue(value.getValue());
  if (resolvedValue == null) {
    return value;
  }
  return resolveResValue(resolvedValue);
}

Fixed version (ground truth):
/** 
 * Returns the   {@link IResourceValue} referenced by the value of <var>value</var>.<p/> This method ensures that it returns a  {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return the input value.
 * @param value the value containing the reference to resolve.
 * @return a {@link IResourceValue} object or <code>null</code>
 */
IResourceValue resolveResValue(IResourceValue value){
  if (value == null) {
    return null;
  }
  if (value instanceof IStyleResourceValue) {
    return value;
  }
  IResourceValue resolvedValue=findResValue(value.getValue(),value.isFramework());
  if (resolvedValue == null) {
    return value;
  }
  return resolveResValue(resolvedValue);
}
Program: 181245
Project: 181245
Buggy source:
private int resolveResourceValue(String value,int defaultValue){
  IResourceValue resource=mContext.resolveResValue(mContext.findResValue(value));
  if (resource != null) {
    Integer id=null;
    if (mPlatformFile || resource.isFramework()) {
      id=Bridge.getResourceValue(resource.getType(),resource.getName());
    }
 else {
      id=mContext.getProjectCallback().getResourceValue(resource.getType(),resource.getName());
    }
    if (id != null) {
      return id;
    }
  }
  return defaultValue;
}

Fixed version (ground truth):
private int resolveResourceValue(String value,int defaultValue){
  IResourceValue resource=mContext.resolveResValue(mContext.findResValue(value,mPlatformFile));
  if (resource != null) {
    Integer id=null;
    if (mPlatformFile || resource.isFramework()) {
      id=Bridge.getResourceValue(resource.getType(),resource.getName());
    }
 else {
      id=mContext.getProjectCallback().getResourceValue(resource.getType(),resource.getName());
    }
    if (id != null) {
      return id;
    }
  }
  return defaultValue;
}
Program: 181247
Project: 181247
Buggy source:
/** 
 * Resolves the value of a resource, if the value references a theme or resource value. <p/> This method ensures that it returns a   {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return a new instance of IResourceValue that contains the input value.
 * @param type the type of the resource
 * @param name the name of the attribute containing this value.
 * @param value the resource value, or reference to resolve
 * @return the resolved resource value or <code>null</code> if it failed to resolve it.
 */
private IResourceValue resolveValue(String type,String name,String value){
  if (value == null) {
    return null;
  }
  IResourceValue resValue=findResValue(value);
  if (resValue == null) {
    return new ResourceValue(type,name,value);
  }
  return resolveResValue(resValue);
}

Fixed version (ground truth):
/** 
 * Resolves the value of a resource, if the value references a theme or resource value. <p/> This method ensures that it returns a   {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return a new instance of IResourceValue that contains the input value.
 * @param type the type of the resource
 * @param name the name of the attribute containing this value.
 * @param value the resource value, or reference to resolve
 * @return the resolved resource value or <code>null</code> if it failed to resolve it.
 */
private IResourceValue resolveValue(String type,String name,String value){
  if (value == null) {
    return null;
  }
  IResourceValue resValue=findResValue(value,false);
  if (resValue == null) {
    return new ResourceValue(type,name,value);
  }
  return resolveResValue(resValue);
}
Program: 181249
Project: 181249
Buggy source:
/** 
 * Returns the   {@link IResourceValue} referenced by the value of <var>value</var>.<p/> This method ensures that it returns a  {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return the input value.
 * @param value the value containing the reference to resolve.
 * @return a {@link IResourceValue} object or <code>null</code>
 */
IResourceValue resolveResValue(IResourceValue value){
  if (value == null) {
    return null;
  }
  if (value instanceof IStyleResourceValue) {
    return value;
  }
  IResourceValue resolvedValue=findResValue(value.getValue());
  if (resolvedValue == null) {
    return value;
  }
  return resolveResValue(resolvedValue);
}

Fixed version (ground truth):
/** 
 * Returns the   {@link IResourceValue} referenced by the value of <var>value</var>.<p/> This method ensures that it returns a  {@link IResourceValue} object that does notreference another resource. If the resource cannot be resolved, it returns <code>null</code>. <p/> If a value that does not need to be resolved is given, the method will return the input value.
 * @param value the value containing the reference to resolve.
 * @return a {@link IResourceValue} object or <code>null</code>
 */
IResourceValue resolveResValue(IResourceValue value){
  if (value == null) {
    return null;
  }
  if (value instanceof IStyleResourceValue) {
    return value;
  }
  IResourceValue resolvedValue=findResValue(value.getValue(),value.isFramework());
  if (resolvedValue == null) {
    return value;
  }
  return resolveResValue(resolvedValue);
}
Program: 181250
Project: 181250
Buggy source:
private int resolveResourceValue(String value,int defaultValue){
  IResourceValue resource=mContext.resolveResValue(mContext.findResValue(value));
  if (resource != null) {
    Integer id=null;
    if (mPlatformFile || resource.isFramework()) {
      id=Bridge.getResourceValue(resource.getType(),resource.getName());
    }
 else {
      id=mContext.getProjectCallback().getResourceValue(resource.getType(),resource.getName());
    }
    if (id != null) {
      return id;
    }
  }
  return defaultValue;
}

Fixed version (ground truth):
private int resolveResourceValue(String value,int defaultValue){
  IResourceValue resource=mContext.resolveResValue(mContext.findResValue(value,mPlatformFile));
  if (resource != null) {
    Integer id=null;
    if (mPlatformFile || resource.isFramework()) {
      id=Bridge.getResourceValue(resource.getType(),resource.getName());
    }
 else {
      id=mContext.getProjectCallback().getResourceValue(resource.getType(),resource.getName());
    }
    if (id != null) {
      return id;
    }
  }
  return defaultValue;
}
Program: 181253
Project: 181253
Buggy source:
private final void handlePauseActivity(IBinder token,boolean finished,boolean userLeaving,int configChanges){
  ActivityClientRecord r=mActivities.get(token);
  if (r != null) {
    if (userLeaving) {
      performUserLeavingActivity(r);
    }
    r.activity.mConfigChangeFlags|=configChanges;
    Bundle state=performPauseActivity(token,finished,true);
    try {
      ActivityManagerNative.getDefault().activityPaused(token,state);
    }
 catch (    RemoteException ex) {
    }
  }
}

Fixed version (ground truth):
private final void handlePauseActivity(IBinder token,boolean finished,boolean userLeaving,int configChanges){
  ActivityClientRecord r=mActivities.get(token);
  if (r != null) {
    if (userLeaving) {
      performUserLeavingActivity(r);
    }
    r.activity.mConfigChangeFlags|=configChanges;
    Bundle state=performPauseActivity(token,finished,true);
    QueuedWork.waitToFinish();
    try {
      ActivityManagerNative.getDefault().activityPaused(token,state);
    }
 catch (    RemoteException ex) {
    }
  }
}
Program: 181254
Project: 181254
Buggy source:
public void setAudioMode(){
  Context context=getContext();
  if (context == null)   return;
  AudioManager audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  int mode=AudioManager.MODE_NORMAL;
switch (getState()) {
case RINGING:
    mode=AudioManager.MODE_RINGTONE;
  break;
case OFFHOOK:
Phone fgPhone=getFgPhone();
if (!(fgPhone instanceof SipPhone)) {
mode=AudioManager.MODE_IN_CALL;
}
break;
}
if (audioManager.getMode() != mode) audioManager.setMode(mode);
}

Fixed version (ground truth):
public void setAudioMode(){
  Context context=getContext();
  if (context == null)   return;
  AudioManager audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  int mode=AudioManager.MODE_NORMAL;
switch (getState()) {
case RINGING:
    mode=AudioManager.MODE_RINGTONE;
  break;
case OFFHOOK:
Phone fgPhone=getFgPhone();
if (hasActiveFgCall() && !(fgPhone instanceof SipPhone)) {
mode=AudioManager.MODE_IN_CALL;
}
break;
}
if (audioManager.getMode() != mode) audioManager.setMode(mode);
}
Program: 181255
Project: 181255
Buggy source:
public void setAudioMode(){
  Context context=getContext();
  if (context == null)   return;
  AudioManager audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  int mode=AudioManager.MODE_NORMAL;
switch (getState()) {
case RINGING:
    mode=AudioManager.MODE_RINGTONE;
  break;
case OFFHOOK:
Phone fgPhone=getFgPhone();
if (!(fgPhone instanceof SipPhone)) {
mode=AudioManager.MODE_IN_CALL;
}
break;
}
if (audioManager.getMode() != mode) audioManager.setMode(mode);
}

Fixed version (ground truth):
public void setAudioMode(){
  Context context=getContext();
  if (context == null)   return;
  AudioManager audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  int mode=AudioManager.MODE_NORMAL;
switch (getState()) {
case RINGING:
    mode=AudioManager.MODE_RINGTONE;
  break;
case OFFHOOK:
Phone fgPhone=getFgPhone();
if (hasActiveFgCall() && !(fgPhone instanceof SipPhone)) {
mode=AudioManager.MODE_IN_CALL;
}
break;
}
if (audioManager.getMode() != mode) audioManager.setMode(mode);
}
Program: 181256
Project: 181256
Buggy source:
/** 
 * {@inheritDoc}
 */
public void onClick(DialogInterface dialog,int which){
  if (which == POSITIVE_BUTTON) {
    IMountService mountService=IMountService.Stub.asInterface(ServiceManager.getService("String_Node_Str"));
    if (mountService != null) {
      try {
        mountService.formatVolume(Environment.getExternalStorageDirectory().toString());
      }
 catch (      RemoteException e) {
      }
    }
  }
  finish();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void onClick(DialogInterface dialog,int which){
  if (which == POSITIVE_BUTTON) {
    Intent intent=new Intent(ExternalStorageFormatter.FORMAT_ONLY);
    intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
    startService(intent);
  }
  finish();
}
Program: 181257
Project: 181257
Buggy source:
/** 
 * {@inheritDoc}
 */
public void onClick(DialogInterface dialog,int which){
  if (which == POSITIVE_BUTTON) {
    IMountService mountService=IMountService.Stub.asInterface(ServiceManager.getService("String_Node_Str"));
    if (mountService != null) {
      try {
        mountService.formatVolume(Environment.getExternalStorageDirectory().toString());
      }
 catch (      RemoteException e) {
      }
    }
  }
  finish();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void onClick(DialogInterface dialog,int which){
  if (which == POSITIVE_BUTTON) {
    Intent intent=new Intent(ExternalStorageFormatter.FORMAT_ONLY);
    intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
    startService(intent);
  }
  finish();
}
Program: 181261
Project: 181261
Buggy source:
private void doDrag(int deltaX,int deltaY){
  if ((deltaX | deltaY) != 0) {
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int rangeX=computeMaxScrollX();
    final int rangeY=computeMaxScrollY();
    if (mEdgeGlowTop != null) {
      mOverscrollDeltaX=deltaX;
      mOverscrollDeltaY=deltaY;
    }
    overScrollBy(deltaX,deltaY,oldX,oldY,rangeX,rangeY,mOverscrollDistance,mOverscrollDistance,true);
  }
  if (!getSettings().getBuiltInZoomControls()) {
    boolean showPlusMinus=mMinZoomScale < mMaxZoomScale;
    if (mZoomControls != null && showPlusMinus) {
      if (mZoomControls.getVisibility() == View.VISIBLE) {
        mPrivateHandler.removeCallbacks(mZoomControlRunnable);
      }
 else {
        mZoomControls.show(showPlusMinus,false);
      }
      mPrivateHandler.postDelayed(mZoomControlRunnable,ZOOM_CONTROLS_TIMEOUT);
    }
  }
}

Fixed version (ground truth):
private void doDrag(int deltaX,int deltaY){
  if ((deltaX | deltaY) != 0) {
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int rangeX=computeMaxScrollX();
    final int rangeY=computeMaxScrollY();
    if (mEdgeGlowTop != null) {
      mOverscrollDeltaX=deltaX;
      mOverscrollDeltaY=deltaY;
    }
    overScrollBy(deltaX,deltaY,oldX,oldY,rangeX,rangeY,mOverscrollDistance,mOverscrollDistance,true);
    if (mEdgeGlowTop != null && (!mEdgeGlowTop.isFinished() || !mEdgeGlowBottom.isFinished() || !mEdgeGlowLeft.isFinished()|| !mEdgeGlowRight.isFinished())) {
      invalidate();
    }
  }
  if (!getSettings().getBuiltInZoomControls()) {
    boolean showPlusMinus=mMinZoomScale < mMaxZoomScale;
    if (mZoomControls != null && showPlusMinus) {
      if (mZoomControls.getVisibility() == View.VISIBLE) {
        mPrivateHandler.removeCallbacks(mZoomControlRunnable);
      }
 else {
        mZoomControls.show(showPlusMinus,false);
      }
      mPrivateHandler.postDelayed(mZoomControlRunnable,ZOOM_CONTROLS_TIMEOUT);
    }
  }
}
Program: 181264
Project: 181264
Buggy source:
private void doDrag(int deltaX,int deltaY){
  if ((deltaX | deltaY) != 0) {
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int rangeX=computeMaxScrollX();
    final int rangeY=computeMaxScrollY();
    if (mEdgeGlowTop != null) {
      mOverscrollDeltaX=deltaX;
      mOverscrollDeltaY=deltaY;
    }
    overScrollBy(deltaX,deltaY,oldX,oldY,rangeX,rangeY,mOverscrollDistance,mOverscrollDistance,true);
  }
  if (!getSettings().getBuiltInZoomControls()) {
    boolean showPlusMinus=mMinZoomScale < mMaxZoomScale;
    if (mZoomControls != null && showPlusMinus) {
      if (mZoomControls.getVisibility() == View.VISIBLE) {
        mPrivateHandler.removeCallbacks(mZoomControlRunnable);
      }
 else {
        mZoomControls.show(showPlusMinus,false);
      }
      mPrivateHandler.postDelayed(mZoomControlRunnable,ZOOM_CONTROLS_TIMEOUT);
    }
  }
}

Fixed version (ground truth):
private void doDrag(int deltaX,int deltaY){
  if ((deltaX | deltaY) != 0) {
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int rangeX=computeMaxScrollX();
    final int rangeY=computeMaxScrollY();
    if (mEdgeGlowTop != null) {
      mOverscrollDeltaX=deltaX;
      mOverscrollDeltaY=deltaY;
    }
    overScrollBy(deltaX,deltaY,oldX,oldY,rangeX,rangeY,mOverscrollDistance,mOverscrollDistance,true);
    if (mEdgeGlowTop != null && (!mEdgeGlowTop.isFinished() || !mEdgeGlowBottom.isFinished() || !mEdgeGlowLeft.isFinished()|| !mEdgeGlowRight.isFinished())) {
      invalidate();
    }
  }
  if (!getSettings().getBuiltInZoomControls()) {
    boolean showPlusMinus=mMinZoomScale < mMaxZoomScale;
    if (mZoomControls != null && showPlusMinus) {
      if (mZoomControls.getVisibility() == View.VISIBLE) {
        mPrivateHandler.removeCallbacks(mZoomControlRunnable);
      }
 else {
        mZoomControls.show(showPlusMinus,false);
      }
      mPrivateHandler.postDelayed(mZoomControlRunnable,ZOOM_CONTROLS_TIMEOUT);
    }
  }
}
Program: 181271
Project: 181271
Buggy source:
private void prepareCursorControllers(){
  if (mCursorVisible && mLayout != null) {
    if (mInsertionPointCursorController == null) {
      mInsertionPointCursorController=new InsertionPointCursorController();
    }
  }
 else {
    mInsertionPointCursorController=null;
  }
  if (textCanBeSelected() && mLayout != null) {
    if (mSelectionModifierCursorController == null) {
      mSelectionModifierCursorController=new SelectionModifierCursorController();
    }
  }
 else {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}

Fixed version (ground truth):
private void prepareCursorControllers(){
  boolean windowSupportsHandles=false;
  ViewGroup.LayoutParams params=getRootView().getLayoutParams();
  if (params instanceof WindowManager.LayoutParams) {
    WindowManager.LayoutParams windowParams=(WindowManager.LayoutParams)params;
    windowSupportsHandles=windowParams.type < WindowManager.LayoutParams.FIRST_SUB_WINDOW || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
  }
  if (windowSupportsHandles && mCursorVisible && mLayout != null) {
    if (mInsertionPointCursorController == null) {
      mInsertionPointCursorController=new InsertionPointCursorController();
    }
  }
 else {
    mInsertionPointCursorController=null;
  }
  if (windowSupportsHandles && textCanBeSelected() && mLayout != null) {
    if (mSelectionModifierCursorController == null) {
      mSelectionModifierCursorController=new SelectionModifierCursorController();
    }
  }
 else {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}
Program: 181272
Project: 181272
Buggy source:
private void prepareCursorControllers(){
  if (mCursorVisible && mLayout != null) {
    if (mInsertionPointCursorController == null) {
      mInsertionPointCursorController=new InsertionPointCursorController();
    }
  }
 else {
    mInsertionPointCursorController=null;
  }
  if (textCanBeSelected() && mLayout != null) {
    if (mSelectionModifierCursorController == null) {
      mSelectionModifierCursorController=new SelectionModifierCursorController();
    }
  }
 else {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}

Fixed version (ground truth):
private void prepareCursorControllers(){
  boolean windowSupportsHandles=false;
  ViewGroup.LayoutParams params=getRootView().getLayoutParams();
  if (params instanceof WindowManager.LayoutParams) {
    WindowManager.LayoutParams windowParams=(WindowManager.LayoutParams)params;
    windowSupportsHandles=windowParams.type < WindowManager.LayoutParams.FIRST_SUB_WINDOW || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
  }
  if (windowSupportsHandles && mCursorVisible && mLayout != null) {
    if (mInsertionPointCursorController == null) {
      mInsertionPointCursorController=new InsertionPointCursorController();
    }
  }
 else {
    mInsertionPointCursorController=null;
  }
  if (windowSupportsHandles && textCanBeSelected() && mLayout != null) {
    if (mSelectionModifierCursorController == null) {
      mSelectionModifierCursorController=new SelectionModifierCursorController();
    }
  }
 else {
    stopTextSelectionMode();
    mSelectionModifierCursorController=null;
  }
}
Program: 181273
Project: 181273
Buggy source:
public void commitPendingDataToDisk(){
  Parcel next;
synchronized (this) {
    next=mPendingWrite;
    mPendingWrite=null;
    mWriteLock.lock();
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile.chooseForWrite());
    stream.write(next.marshall());
    stream.flush();
    stream.close();
    mFile.commit();
  }
 catch (  IOException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    mFile.rollback();
  }
 finally {
    next.recycle();
    mWriteLock.unlock();
  }
}

Fixed version (ground truth):
public void commitPendingDataToDisk(){
  final Parcel next;
synchronized (this) {
    next=mPendingWrite;
    mPendingWrite=null;
    if (next == null) {
      return;
    }
    mWriteLock.lock();
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile.chooseForWrite());
    stream.write(next.marshall());
    stream.flush();
    stream.close();
    mFile.commit();
  }
 catch (  IOException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    mFile.rollback();
  }
 finally {
    next.recycle();
    mWriteLock.unlock();
  }
}
Program: 181274
Project: 181274
Buggy source:
public void commitPendingDataToDisk(){
  Parcel next;
synchronized (this) {
    next=mPendingWrite;
    mPendingWrite=null;
    mWriteLock.lock();
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile.chooseForWrite());
    stream.write(next.marshall());
    stream.flush();
    stream.close();
    mFile.commit();
  }
 catch (  IOException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    mFile.rollback();
  }
 finally {
    next.recycle();
    mWriteLock.unlock();
  }
}

Fixed version (ground truth):
public void commitPendingDataToDisk(){
  final Parcel next;
synchronized (this) {
    next=mPendingWrite;
    mPendingWrite=null;
    if (next == null) {
      return;
    }
    mWriteLock.lock();
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile.chooseForWrite());
    stream.write(next.marshall());
    stream.flush();
    stream.close();
    mFile.commit();
  }
 catch (  IOException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    mFile.rollback();
  }
 finally {
    next.recycle();
    mWriteLock.unlock();
  }
}
Program: 181275
Project: 181275
Buggy source:
/** 
 * <p>Generate the layout parameters for the popup window.</p>
 * @param token the window token used to bind the popup's window
 * @return the layout parameters to pass to the window manager
 */
private WindowManager.LayoutParams createPopupLayout(IBinder token){
  WindowManager.LayoutParams p=new WindowManager.LayoutParams();
  p.gravity=Gravity.LEFT | Gravity.TOP;
  p.width=mLastWidth=mWidth;
  p.height=mLastHeight=mHeight;
  if (mBackground != null) {
    p.format=mBackground.getOpacity();
  }
 else {
    p.format=PixelFormat.TRANSLUCENT;
  }
  p.flags=computeFlags(p.flags);
  p.type=WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
  p.token=token;
  p.softInputMode=mSoftInputMode;
  p.setTitle("String_Node_Str" + Integer.toHexString(hashCode()));
  return p;
}

Fixed version (ground truth):
/** 
 * <p>Generate the layout parameters for the popup window.</p>
 * @param token the window token used to bind the popup's window
 * @return the layout parameters to pass to the window manager
 */
private WindowManager.LayoutParams createPopupLayout(IBinder token){
  WindowManager.LayoutParams p=new WindowManager.LayoutParams();
  p.gravity=Gravity.LEFT | Gravity.TOP;
  p.width=mLastWidth=mWidth;
  p.height=mLastHeight=mHeight;
  if (mBackground != null) {
    p.format=mBackground.getOpacity();
  }
 else {
    p.format=PixelFormat.TRANSLUCENT;
  }
  p.flags=computeFlags(p.flags);
  p.type=mWindowLayoutType;
  p.token=token;
  p.softInputMode=mSoftInputMode;
  p.setTitle("String_Node_Str" + Integer.toHexString(hashCode()));
  return p;
}
Program: 181276
Project: 181276
Buggy source:
public HandleView(CursorController controller,int pos){
  super(TextView.this.mContext);
  mController=controller;
  mContainer=new PopupWindow(TextView.this.mContext,null,com.android.internal.R.attr.textSelectHandleWindowStyle);
  mContainer.setSplitTouchEnabled(true);
  mContainer.setClippingEnabled(false);
  setOrientation(pos);
}

Fixed version (ground truth):
public HandleView(CursorController controller,int pos){
  super(TextView.this.mContext);
  mController=controller;
  mContainer=new PopupWindow(TextView.this.mContext,null,com.android.internal.R.attr.textSelectHandleWindowStyle);
  mContainer.setSplitTouchEnabled(true);
  mContainer.setClippingEnabled(false);
  mContainer.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);
  setOrientation(pos);
}
Program: 181277
Project: 181277
Buggy source:
public HandleView(CursorController controller,Drawable handle){
  super(TextView.this.mContext);
  mController=controller;
  mDrawable=handle;
  mContainer=new PopupWindow(TextView.this.mContext,null,com.android.internal.R.attr.textSelectHandleWindowStyle);
  mContainer.setSplitTouchEnabled(true);
  mContainer.setClippingEnabled(false);
  final int handleWidth=mDrawable.getIntrinsicWidth();
  final int handleHeight=mDrawable.getIntrinsicHeight();
  mHotspotX=handleWidth * 0.5f;
  mHotspotY=-handleHeight * 0.2f;
}

Fixed version (ground truth):
public HandleView(CursorController controller,int pos){
  super(TextView.this.mContext);
  mController=controller;
  mContainer=new PopupWindow(TextView.this.mContext,null,com.android.internal.R.attr.textSelectHandleWindowStyle);
  mContainer.setSplitTouchEnabled(true);
  mContainer.setClippingEnabled(false);
  setOrientation(pos);
}
Program: 181278
Project: 181278
Buggy source:
private void moveTo(int x,int y){
  mPositionX=x - TextView.this.mScrollX;
  mPositionY=y - TextView.this.mScrollY;
  if (isPositionVisible()) {
    int[] coords=null;
    if (mContainer.isShowing()) {
      coords=mTempCoords;
      TextView.this.getLocationInWindow(coords);
      mContainer.update(coords[0] + mPositionX,coords[1] + mPositionY,mRight - mLeft,mBottom - mTop);
    }
 else {
      show();
    }
    if (mIsDragging) {
      if (coords == null) {
        coords=mTempCoords;
        TextView.this.getLocationInWindow(coords);
      }
      if (coords[0] != mLastParentX || coords[1] != mLastParentY) {
        mOffsetX+=coords[0] - mLastParentX;
        mOffsetY+=coords[1] - mLastParentY;
        mLastParentX=coords[0];
        mLastParentY=coords[1];
      }
    }
  }
 else {
    hide();
  }
}

Fixed version (ground truth):
private void moveTo(int x,int y){
  mPositionX=x - TextView.this.mScrollX;
  mPositionY=y - TextView.this.mScrollY;
  if (isPositionVisible()) {
    int[] coords=null;
    if (mContainer.isShowing()) {
      coords=mTempCoords;
      TextView.this.getLocationInWindow(coords);
      mContainer.update(coords[0] + mPositionX,coords[1] + mPositionY,mRight - mLeft,mBottom - mTop);
    }
 else {
      show();
    }
    if (mIsDragging) {
      if (coords == null) {
        coords=mTempCoords;
        TextView.this.getLocationInWindow(coords);
      }
      if (coords[0] != mLastParentX || coords[1] != mLastParentY) {
        mTouchToWindowOffsetX+=coords[0] - mLastParentX;
        mTouchToWindowOffsetY+=coords[1] - mLastParentY;
        mLastParentX=coords[0];
        mLastParentY=coords[1];
      }
    }
  }
 else {
    hide();
  }
}
Program: 181279
Project: 181279
Buggy source:
void positionAtCursor(final int offset,boolean bottom){
  final int width=mDrawable.getIntrinsicWidth();
  final int height=mDrawable.getIntrinsicHeight();
  final int line=mLayout.getLineForOffset(offset);
  final int lineTop=mLayout.getLineTop(line);
  final int lineBottom=mLayout.getLineBottom(line);
  final Rect bounds=sCursorControllerTempRect;
  bounds.left=(int)(mLayout.getPrimaryHorizontal(offset) - width / 2.0) + TextView.this.mScrollX;
  bounds.top=(bottom ? lineBottom : lineTop) + TextView.this.mScrollY;
  bounds.right=bounds.left + width;
  bounds.bottom=bounds.top + height;
  convertFromViewportToContentCoordinates(bounds);
  moveTo(bounds.left,bounds.top);
}

Fixed version (ground truth):
void positionAtCursor(final int offset,boolean bottom){
  final int width=mDrawable.getIntrinsicWidth();
  final int height=mDrawable.getIntrinsicHeight();
  final int line=mLayout.getLineForOffset(offset);
  final int lineTop=mLayout.getLineTop(line);
  final int lineBottom=mLayout.getLineBottom(line);
  final Rect bounds=sCursorControllerTempRect;
  bounds.left=(int)(mLayout.getPrimaryHorizontal(offset) - mHotspotX) + TextView.this.mScrollX;
  bounds.top=(bottom ? lineBottom : lineTop - mHeight) + TextView.this.mScrollY;
  bounds.right=bounds.left + width;
  bounds.bottom=bounds.top + height;
  convertFromViewportToContentCoordinates(bounds);
  moveTo(bounds.left,bounds.top);
}
Program: 181280
Project: 181280
Buggy source:
int getHysteresisOffset(int x,int y,int previousOffset){
  final Layout layout=getLayout();
  if (layout == null)   return -1;
  y-=getTotalPaddingTop();
  y=Math.max(0,y);
  y=Math.min(getHeight() - getTotalPaddingBottom() - 1,y);
  y+=getScrollY();
  int line=getLayout().getLineForVertical(y);
  final int previousLine=layout.getLineForOffset(previousOffset);
  final int previousLineTop=layout.getLineTop(previousLine);
  final int previousLineBottom=layout.getLineBottom(previousLine);
  final int hysteresisThreshold=(previousLineBottom - previousLineTop) / 6;
  if (((line == previousLine + 1) && ((y - previousLineBottom) < hysteresisThreshold)) || ((line == previousLine - 1) && ((previousLineTop - y) < hysteresisThreshold))) {
    line=previousLine;
  }
  return getOffsetForHorizontal(line,x);
}

Fixed version (ground truth):
int getHysteresisOffset(int x,int y,int previousOffset){
  final Layout layout=getLayout();
  if (layout == null)   return -1;
  y-=getTotalPaddingTop();
  y=Math.max(0,y);
  y=Math.min(getHeight() - getTotalPaddingBottom() - 1,y);
  y+=getScrollY();
  int line=getLayout().getLineForVertical(y);
  final int previousLine=layout.getLineForOffset(previousOffset);
  final int previousLineTop=layout.getLineTop(previousLine);
  final int previousLineBottom=layout.getLineBottom(previousLine);
  final int hysteresisThreshold=(previousLineBottom - previousLineTop) / 8;
  if (((line == previousLine + 1) && ((y - previousLineBottom) < hysteresisThreshold)) || ((line == previousLine - 1) && ((previousLineTop - y) < hysteresisThreshold))) {
    line=previousLine;
  }
  return getOffsetForHorizontal(line,x);
}
Program: 181281
Project: 181281
Buggy source:
InsertionPointCursorController(){
  Resources res=mContext.getResources();
  mHandle=new HandleView(this,res.getDrawable(mTextSelectHandleRes));
}

Fixed version (ground truth):
InsertionPointCursorController(){
  mHandle=new HandleView(this,HandleView.CENTER);
}