nus-yam/ex-repair huggingface dataset:
Program: 181185
Project: 181185
Buggy source:
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int metaState,int repeatCount,int policyFlags);

Fixed version (ground truth):
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int scanCode,int metaState,int repeatCount,int policyFlags);
Program: 181186
Project: 181186
Buggy source:
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param keyCode The key code.
 * @param down True if the key is down.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int keyCode,boolean down,int policyFlags,boolean isScreenOn);

Fixed version (ground truth):
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int action,int flags,int keyCode,int scanCode,int policyFlags,boolean isScreenOn);
Program: 181187
Project: 181187
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      ss.position=mFirstPosition;
      ss.firstId=mAdapter.getItemId(mFirstPosition);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}
Program: 181188
Project: 181188
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      ss.position=mFirstPosition;
      ss.firstId=mAdapter.getItemId(mFirstPosition);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}
Program: 181189
Project: 181189
Buggy source:
private Intent newGrantCredentialsPermissionIntent(Account account,int uid,AccountAuthenticatorResponse response,String authTokenType,String authTokenLabel){
  RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo=mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(account.type));
  if (serviceInfo == null) {
    throw new IllegalArgumentException("String_Node_Str" + account.type);
  }
  final Context authContext;
  try {
    authContext=mContext.createPackageContext(serviceInfo.type.packageName,0);
  }
 catch (  PackageManager.NameNotFoundException e) {
    throw new IllegalArgumentException("String_Node_Str" + account.type);
  }
  Intent intent=new Intent(mContext,GrantCredentialsPermissionActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addCategory(String.valueOf(getCredentialPermissionNotificationId(account,authTokenType,uid)));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT,account);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_LABEL,authTokenLabel);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_TYPE,authTokenType);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_RESPONSE,response);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT_TYPE_LABEL,authContext.getString(serviceInfo.type.labelId));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_PACKAGES,mContext.getPackageManager().getPackagesForUid(uid));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_REQUESTING_UID,uid);
  return intent;
}

Fixed version (ground truth):
private Intent newGrantCredentialsPermissionIntent(Account account,int uid,AccountAuthenticatorResponse response,String authTokenType,String authTokenLabel){
  Intent intent=new Intent(mContext,GrantCredentialsPermissionActivity.class);
  intent.addCategory(String.valueOf(getCredentialPermissionNotificationId(account,authTokenType,uid)));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT,account);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_TYPE,authTokenType);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_RESPONSE,response);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_REQUESTING_UID,uid);
  return intent;
}
Program: 181191
Project: 181191
Buggy source:
public void onClick(View v){
  final AccountManagerService accountManagerService=AccountManagerService.getSingleton();
switch (v.getId()) {
case R.id.allow_button:
    accountManagerService.grantAppPermission(mAccount,mAuthTokenType,mUid);
  Intent result=new Intent();
result.putExtra("String_Node_Str",true);
setResult(RESULT_OK,result);
setAccountAuthenticatorResult(result.getExtras());
break;
case R.id.deny_button:
accountManagerService.revokeAppPermission(mAccount,mAuthTokenType,mUid);
setResult(RESULT_CANCELED);
break;
}
finish();
}

Fixed version (ground truth):
public void onClick(View v){
switch (v.getId()) {
case R.id.allow_button:
    accountManagerService.grantAppPermission(mAccount,mAuthTokenType,mUid);
  Intent result=new Intent();
result.putExtra("String_Node_Str",true);
setResult(RESULT_OK,result);
setAccountAuthenticatorResult(result.getExtras());
break;
case R.id.deny_button:
accountManagerService.revokeAppPermission(mAccount,mAuthTokenType,mUid);
setResult(RESULT_CANCELED);
break;
}
finish();
}
Program: 181192
Project: 181192
Buggy source:
/** 
 * Lists all the installed packages.
 */
private void runListPackages(boolean showApplicationPackage){
  try {
    String opt;
    while ((opt=nextOption()) != null) {
      if (opt.equals("String_Node_Str")) {
      }
 else       if (opt.equals("String_Node_Str")) {
        showApplicationPackage=true;
      }
 else       if (opt.equals("String_Node_Str")) {
        showApplicationPackage=true;
      }
 else {
        System.err.println("String_Node_Str" + opt);
        showUsage();
        return;
      }
    }
  }
 catch (  RuntimeException ex) {
    System.err.println("String_Node_Str" + ex.toString());
    showUsage();
    return;
  }
  try {
    List<PackageInfo> packages=mPm.getInstalledPackages(0);
    int count=packages.size();
    for (int p=0; p < count; p++) {
      PackageInfo info=packages.get(p);
      System.out.print("String_Node_Str");
      if (showApplicationPackage) {
        System.out.print(info.applicationInfo.sourceDir);
        System.out.print("String_Node_Str");
      }
      System.out.println(info.packageName);
    }
  }
 catch (  RemoteException e) {
    System.err.println(e.toString());
    System.err.println(PM_NOT_RUNNING_ERR);
  }
}

Fixed version (ground truth):
/** 
 * Lists all the installed packages.
 */
private void runListPackages(boolean showApplicationPackage){
  int getFlags=0;
  boolean listDisabled=false, listEnabled=false;
  try {
    String opt;
    while ((opt=nextOption()) != null) {
      if (opt.equals("String_Node_Str")) {
      }
 else       if (opt.equals("String_Node_Str")) {
        showApplicationPackage=true;
      }
 else       if (opt.equals("String_Node_Str")) {
        showApplicationPackage=true;
      }
 else       if (opt.equals("String_Node_Str")) {
        listDisabled=true;
      }
 else       if (opt.equals("String_Node_Str")) {
        listEnabled=true;
      }
 else       if (opt.equals("String_Node_Str")) {
        getFlags|=PackageManager.GET_UNINSTALLED_PACKAGES;
      }
 else {
        System.err.println("String_Node_Str" + opt);
        showUsage();
        return;
      }
    }
  }
 catch (  RuntimeException ex) {
    System.err.println("String_Node_Str" + ex.toString());
    showUsage();
    return;
  }
  String filter=nextArg();
  try {
    List<PackageInfo> packages=mPm.getInstalledPackages(getFlags);
    int count=packages.size();
    for (int p=0; p < count; p++) {
      PackageInfo info=packages.get(p);
      if (filter != null && !info.packageName.contains(filter)) {
        continue;
      }
      if ((!listDisabled || !info.applicationInfo.enabled) && (!listEnabled || info.applicationInfo.enabled)) {
        System.out.print("String_Node_Str");
        if (showApplicationPackage) {
          System.out.print(info.applicationInfo.sourceDir);
          System.out.print("String_Node_Str");
        }
        System.out.println(info.packageName);
      }
    }
  }
 catch (  RemoteException e) {
    System.err.println(e.toString());
    System.err.println(PM_NOT_RUNNING_ERR);
  }
}
Program: 181193
Project: 181193
Buggy source:
/** 
 * Execute the list sub-command. pm list [package | packages] pm list permission-groups pm list permissions pm list features pm list instrumentation
 */
private void runList(){
  String type=nextArg();
  if (type == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  if ("String_Node_Str".equals(type) || "String_Node_Str".equals(type)) {
    runListPackages(false);
  }
 else   if ("String_Node_Str".equals(type)) {
    runListPermissionGroups();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListPermissions();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListFeatures();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListInstrumentation();
  }
 else {
    System.err.println("String_Node_Str" + type + "String_Node_Str");
    showUsage();
  }
}

Fixed version (ground truth):
/** 
 * Execute the list sub-command. pm list [package | packages] pm list permission-groups pm list permissions pm list features pm list libraries pm list instrumentation
 */
private void runList(){
  String type=nextArg();
  if (type == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  if ("String_Node_Str".equals(type) || "String_Node_Str".equals(type)) {
    runListPackages(false);
  }
 else   if ("String_Node_Str".equals(type)) {
    runListPermissionGroups();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListPermissions();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListFeatures();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListLibraries();
  }
 else   if ("String_Node_Str".equals(type)) {
    runListInstrumentation();
  }
 else {
    System.err.println("String_Node_Str" + type + "String_Node_Str");
    showUsage();
  }
}
Program: 181196
Project: 181196
Buggy source:
@SuppressWarnings("String_Node_Str") public void dumpCheckinLocked(PrintWriter pw,String[] args){
  boolean isUnpluggedOnly=false;
  for (  String arg : args) {
    if ("String_Node_Str".equals(arg)) {
      if (LOCAL_LOGV)       Log.v("String_Node_Str","String_Node_Str");
      isUnpluggedOnly=true;
    }
  }
  if (isUnpluggedOnly) {
    dumpCheckinLocked(pw,STATS_SINCE_UNPLUGGED,-1);
  }
 else {
    dumpCheckinLocked(pw,STATS_SINCE_CHARGED,-1);
    dumpCheckinLocked(pw,STATS_SINCE_UNPLUGGED,-1);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void dumpCheckinLocked(PrintWriter pw,String[] args,List<ApplicationInfo> apps){
  boolean isUnpluggedOnly=false;
  for (  String arg : args) {
    if ("String_Node_Str".equals(arg)) {
      if (LOCAL_LOGV)       Log.v("String_Node_Str","String_Node_Str");
      isUnpluggedOnly=true;
    }
  }
  if (apps != null) {
    SparseArray<ArrayList<String>> uids=new SparseArray<ArrayList<String>>();
    for (int i=0; i < apps.size(); i++) {
      ApplicationInfo ai=apps.get(i);
      ArrayList<String> pkgs=uids.get(ai.uid);
      if (pkgs == null) {
        pkgs=new ArrayList<String>();
        uids.put(ai.uid,pkgs);
      }
      pkgs.add(ai.packageName);
    }
    SparseArray<? extends Uid> uidStats=getUidStats();
    final int NU=uidStats.size();
    String[] lineArgs=new String[2];
    for (int i=0; i < NU; i++) {
      int uid=uidStats.keyAt(i);
      ArrayList<String> pkgs=uids.get(uid);
      if (pkgs != null) {
        for (int j=0; j < pkgs.size(); j++) {
          lineArgs[0]=Integer.toString(uid);
          lineArgs[1]=pkgs.get(j);
          dumpLine(pw,0,"String_Node_Str",UID_DATA,(Object[])lineArgs);
        }
      }
    }
  }
  if (isUnpluggedOnly) {
    dumpCheckinLocked(pw,STATS_SINCE_UNPLUGGED,-1);
  }
 else {
    dumpCheckinLocked(pw,STATS_SINCE_CHARGED,-1);
    dumpCheckinLocked(pw,STATS_SINCE_UNPLUGGED,-1);
  }
}
Program: 181197
Project: 181197
Buggy source:
/** 
 * Gets the SIP URI string of this profile.
 * @return the SIP URI string of this profile
 */
public String getUriString(){
  return mAddress.getURI().toString();
}

Fixed version (ground truth):
/** 
 * Gets the SIP URI string of this profile.
 * @return the SIP URI string of this profile
 */
public String getUriString(){
  if (!TextUtils.isEmpty(mProxyAddress)) {
    return "String_Node_Str" + getUserName() + "String_Node_Str"+ mDomain;
  }
  return getUri().toString();
}
Program: 181198
Project: 181198
Buggy source:
/** 
 * Sets the protocol used to connect to the SIP server. Currently, only "UDP" and "TCP" are supported.
 * @param protocol the protocol string
 * @return this builder object
 * @throws IllegalArgumentException if the protocol is not recognized
 */
public Builder setProtocol(String protocol) throws IllegalArgumentException {
  if (protocol == null) {
    throw new NullPointerException("String_Node_Str");
  }
  protocol=protocol.toUpperCase();
  if (!protocol.equals("String_Node_Str") && !protocol.equals("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str" + protocol);
  }
  mProfile.mProtocol=protocol;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the protocol used to connect to the SIP server. Currently, only "UDP" and "TCP" are supported.
 * @param protocol the protocol string
 * @return this builder object
 * @throws IllegalArgumentException if the protocol is not recognized
 */
public Builder setProtocol(String protocol) throws IllegalArgumentException {
  if (protocol == null) {
    throw new NullPointerException("String_Node_Str");
  }
  protocol=protocol.toUpperCase();
  if (!protocol.equals(UDP) && !protocol.equals(TCP)) {
    throw new IllegalArgumentException("String_Node_Str" + protocol);
  }
  mProfile.mProtocol=protocol;
  return this;
}
Program: 181199
Project: 181199
Buggy source:
/** 
 * Sets the port number of the server. By default, it is 5060.
 * @param port port number of the server
 * @return this builder object
 * @throws IllegalArgumentException if the port number is out of range
 */
public Builder setPort(int port) throws IllegalArgumentException {
  try {
    mUri.setPort(port);
    return this;
  }
 catch (  InvalidArgumentException e) {
    throw new IllegalArgumentException(e);
  }
}

Fixed version (ground truth):
/** 
 * Sets the port number of the server. By default, it is 5060.
 * @param port port number of the server
 * @return this builder object
 * @throws IllegalArgumentException if the port number is out of range
 */
public Builder setPort(int port) throws IllegalArgumentException {
  if ((port > 65535) || (port < 1000)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  mProfile.mPort=port;
  return this;
}
Program: 181200
Project: 181200
Buggy source:
private SipProfile(Parcel in){
  mAddress=(Address)in.readSerializable();
  mProxyAddress=in.readString();
  mPassword=in.readString();
  mDomain=in.readString();
  mProtocol=in.readString();
  mProfileName=in.readString();
  mSendKeepAlive=(in.readInt() == 0) ? false : true;
  mAutoRegistration=(in.readInt() == 0) ? false : true;
  mCallingUid=in.readInt();
}

Fixed version (ground truth):
private SipProfile(Parcel in){
  mAddress=(Address)in.readSerializable();
  mProxyAddress=in.readString();
  mPassword=in.readString();
  mDomain=in.readString();
  mProtocol=in.readString();
  mProfileName=in.readString();
  mSendKeepAlive=(in.readInt() == 0) ? false : true;
  mAutoRegistration=(in.readInt() == 0) ? false : true;
  mCallingUid=in.readInt();
  mPort=in.readInt();
}
Program: 181201
Project: 181201
Buggy source:
/** 
 * Gets the port number of the SIP server.
 * @return the port number of the SIP server
 */
public int getPort(){
  int port=getUri().getPort();
  return (port == -1) ? DEFAULT_PORT : port;
}

Fixed version (ground truth):
/** 
 * Gets the port number of the SIP server.
 * @return the port number of the SIP server
 */
public int getPort(){
  return mPort;
}
Program: 181202
Project: 181202
Buggy source:
/** 
 * Builds and returns the SIP profile object.
 * @return the profile object created
 */
public SipProfile build(){
  mProfile.mPassword=mUri.getUserPassword();
  mUri.setUserPassword(null);
  try {
    mProfile.mAddress=mAddressFactory.createAddress(mDisplayName,mUri);
    if (!TextUtils.isEmpty(mProxyAddress)) {
      SipURI uri=(SipURI)mAddressFactory.createURI(fix(mProxyAddress));
      mProfile.mProxyAddress=uri.getHost();
    }
  }
 catch (  ParseException e) {
    throw new RuntimeException(e);
  }
  return mProfile;
}

Fixed version (ground truth):
/** 
 * Builds and returns the SIP profile object.
 * @return the profile object created
 */
public SipProfile build(){
  mProfile.mPassword=mUri.getUserPassword();
  mUri.setUserPassword(null);
  try {
    if (!TextUtils.isEmpty(mProxyAddress)) {
      SipURI uri=(SipURI)mAddressFactory.createURI(fix(mProxyAddress));
      mProfile.mProxyAddress=uri.getHost();
    }
 else {
      if (!mProfile.mProtocol.equals(UDP)) {
        mUri.setTransportParam(mProfile.mProtocol);
      }
      if (mProfile.mPort != DEFAULT_PORT) {
        mUri.setPort(mProfile.mPort);
      }
    }
    mProfile.mAddress=mAddressFactory.createAddress(mDisplayName,mUri);
  }
 catch (  InvalidArgumentException e) {
    throw new RuntimeException(e);
  }
catch (  ParseException e) {
    throw new RuntimeException(e);
  }
  return mProfile;
}
Program: 181203
Project: 181203
Buggy source:
@Override public void writeToParcel(Parcel out,int flags){
  out.writeSerializable(mAddress);
  out.writeString(mProxyAddress);
  out.writeString(mPassword);
  out.writeString(mDomain);
  out.writeString(mProtocol);
  out.writeString(mProfileName);
  out.writeInt(mSendKeepAlive ? 1 : 0);
  out.writeInt(mAutoRegistration ? 1 : 0);
  out.writeInt(mCallingUid);
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel out,int flags){
  out.writeSerializable(mAddress);
  out.writeString(mProxyAddress);
  out.writeString(mPassword);
  out.writeString(mDomain);
  out.writeString(mProtocol);
  out.writeString(mProfileName);
  out.writeInt(mSendKeepAlive ? 1 : 0);
  out.writeInt(mAutoRegistration ? 1 : 0);
  out.writeInt(mCallingUid);
  out.writeInt(mPort);
}
Program: 181204
Project: 181204
Buggy source:
private Request createRequest(String requestType,SipProfile userProfile,String tag) throws ParseException, SipException {
  FromHeader fromHeader=createFromHeader(userProfile,tag);
  ToHeader toHeader=createToHeader(userProfile);
  SipURI requestURI=mAddressFactory.createSipURI("String_Node_Str" + userProfile.getSipDomain());
  List<ViaHeader> viaHeaders=createViaHeaders();
  CallIdHeader callIdHeader=createCallIdHeader();
  CSeqHeader cSeqHeader=createCSeqHeader(requestType);
  MaxForwardsHeader maxForwards=createMaxForwardsHeader();
  Request request=mMessageFactory.createRequest(requestURI,requestType,callIdHeader,cSeqHeader,fromHeader,toHeader,viaHeaders,maxForwards);
  Header userAgentHeader=mHeaderFactory.createHeader("String_Node_Str","String_Node_Str");
  request.addHeader(userAgentHeader);
  return request;
}

Fixed version (ground truth):
private Request createRequest(String requestType,SipProfile userProfile,String tag) throws ParseException, SipException {
  FromHeader fromHeader=createFromHeader(userProfile,tag);
  ToHeader toHeader=createToHeader(userProfile);
  SipURI requestURI=mAddressFactory.createSipURI(userProfile.getUriString().replaceFirst(userProfile.getUserName() + "String_Node_Str","String_Node_Str"));
  List<ViaHeader> viaHeaders=createViaHeaders();
  CallIdHeader callIdHeader=createCallIdHeader();
  CSeqHeader cSeqHeader=createCSeqHeader(requestType);
  MaxForwardsHeader maxForwards=createMaxForwardsHeader();
  Request request=mMessageFactory.createRequest(requestURI,requestType,callIdHeader,cSeqHeader,fromHeader,toHeader,viaHeaders,maxForwards);
  Header userAgentHeader=mHeaderFactory.createHeader("String_Node_Str","String_Node_Str");
  request.addHeader(userAgentHeader);
  return request;
}
Program: 181205
Project: 181205
Buggy source:
private Intent newGrantCredentialsPermissionIntent(Account account,int uid,AccountAuthenticatorResponse response,String authTokenType,String authTokenLabel){
  RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo=mAuthenticatorCache.getServiceInfo(AuthenticatorDescription.newKey(account.type));
  if (serviceInfo == null) {
    throw new IllegalArgumentException("String_Node_Str" + account.type);
  }
  final Context authContext;
  try {
    authContext=mContext.createPackageContext(serviceInfo.type.packageName,0);
  }
 catch (  PackageManager.NameNotFoundException e) {
    throw new IllegalArgumentException("String_Node_Str" + account.type);
  }
  Intent intent=new Intent(mContext,GrantCredentialsPermissionActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addCategory(String.valueOf(getCredentialPermissionNotificationId(account,authTokenType,uid)));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT,account);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_LABEL,authTokenLabel);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_TYPE,authTokenType);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_RESPONSE,response);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT_TYPE_LABEL,authContext.getString(serviceInfo.type.labelId));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_PACKAGES,mContext.getPackageManager().getPackagesForUid(uid));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_REQUESTING_UID,uid);
  return intent;
}

Fixed version (ground truth):
private Intent newGrantCredentialsPermissionIntent(Account account,int uid,AccountAuthenticatorResponse response,String authTokenType,String authTokenLabel){
  Intent intent=new Intent(mContext,GrantCredentialsPermissionActivity.class);
  intent.addCategory(String.valueOf(getCredentialPermissionNotificationId(account,authTokenType,uid)));
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_ACCOUNT,account);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_AUTH_TOKEN_TYPE,authTokenType);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_RESPONSE,response);
  intent.putExtra(GrantCredentialsPermissionActivity.EXTRAS_REQUESTING_UID,uid);
  return intent;
}
Program: 181207
Project: 181207
Buggy source:
public void onClick(View v){
  final AccountManagerService accountManagerService=AccountManagerService.getSingleton();
switch (v.getId()) {
case R.id.allow_button:
    accountManagerService.grantAppPermission(mAccount,mAuthTokenType,mUid);
  Intent result=new Intent();
result.putExtra("String_Node_Str",true);
setResult(RESULT_OK,result);
setAccountAuthenticatorResult(result.getExtras());
break;
case R.id.deny_button:
accountManagerService.revokeAppPermission(mAccount,mAuthTokenType,mUid);
setResult(RESULT_CANCELED);
break;
}
finish();
}

Fixed version (ground truth):
public void onClick(View v){
switch (v.getId()) {
case R.id.allow_button:
    accountManagerService.grantAppPermission(mAccount,mAuthTokenType,mUid);
  Intent result=new Intent();
result.putExtra("String_Node_Str",true);
setResult(RESULT_OK,result);
setAccountAuthenticatorResult(result.getExtras());
break;
case R.id.deny_button:
accountManagerService.revokeAppPermission(mAccount,mAuthTokenType,mUid);
setResult(RESULT_CANCELED);
break;
}
finish();
}
Program: 181208
Project: 181208
Buggy source:
/** 
 * Gets the SIP URI string of this profile.
 * @return the SIP URI string of this profile
 */
public String getUriString(){
  return mAddress.getURI().toString();
}

Fixed version (ground truth):
/** 
 * Gets the SIP URI string of this profile.
 * @return the SIP URI string of this profile
 */
public String getUriString(){
  if (!TextUtils.isEmpty(mProxyAddress)) {
    return "String_Node_Str" + getUserName() + "String_Node_Str"+ mDomain;
  }
  return getUri().toString();
}
Program: 181209
Project: 181209
Buggy source:
/** 
 * Sets the protocol used to connect to the SIP server. Currently, only "UDP" and "TCP" are supported.
 * @param protocol the protocol string
 * @return this builder object
 * @throws IllegalArgumentException if the protocol is not recognized
 */
public Builder setProtocol(String protocol) throws IllegalArgumentException {
  if (protocol == null) {
    throw new NullPointerException("String_Node_Str");
  }
  protocol=protocol.toUpperCase();
  if (!protocol.equals("String_Node_Str") && !protocol.equals("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str" + protocol);
  }
  mProfile.mProtocol=protocol;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the protocol used to connect to the SIP server. Currently, only "UDP" and "TCP" are supported.
 * @param protocol the protocol string
 * @return this builder object
 * @throws IllegalArgumentException if the protocol is not recognized
 */
public Builder setProtocol(String protocol) throws IllegalArgumentException {
  if (protocol == null) {
    throw new NullPointerException("String_Node_Str");
  }
  protocol=protocol.toUpperCase();
  if (!protocol.equals(UDP) && !protocol.equals(TCP)) {
    throw new IllegalArgumentException("String_Node_Str" + protocol);
  }
  mProfile.mProtocol=protocol;
  return this;
}
Program: 181210
Project: 181210
Buggy source:
/** 
 * Sets the port number of the server. By default, it is 5060.
 * @param port port number of the server
 * @return this builder object
 * @throws IllegalArgumentException if the port number is out of range
 */
public Builder setPort(int port) throws IllegalArgumentException {
  try {
    mUri.setPort(port);
    return this;
  }
 catch (  InvalidArgumentException e) {
    throw new IllegalArgumentException(e);
  }
}

Fixed version (ground truth):
/** 
 * Sets the port number of the server. By default, it is 5060.
 * @param port port number of the server
 * @return this builder object
 * @throws IllegalArgumentException if the port number is out of range
 */
public Builder setPort(int port) throws IllegalArgumentException {
  if ((port > 65535) || (port < 1000)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  mProfile.mPort=port;
  return this;
}
Program: 181211
Project: 181211
Buggy source:
private SipProfile(Parcel in){
  mAddress=(Address)in.readSerializable();
  mProxyAddress=in.readString();
  mPassword=in.readString();
  mDomain=in.readString();
  mProtocol=in.readString();
  mProfileName=in.readString();
  mSendKeepAlive=(in.readInt() == 0) ? false : true;
  mAutoRegistration=(in.readInt() == 0) ? false : true;
  mCallingUid=in.readInt();
}

Fixed version (ground truth):
private SipProfile(Parcel in){
  mAddress=(Address)in.readSerializable();
  mProxyAddress=in.readString();
  mPassword=in.readString();
  mDomain=in.readString();
  mProtocol=in.readString();
  mProfileName=in.readString();
  mSendKeepAlive=(in.readInt() == 0) ? false : true;
  mAutoRegistration=(in.readInt() == 0) ? false : true;
  mCallingUid=in.readInt();
  mPort=in.readInt();
}
Program: 181212
Project: 181212
Buggy source:
/** 
 * Gets the port number of the SIP server.
 * @return the port number of the SIP server
 */
public int getPort(){
  int port=getUri().getPort();
  return (port == -1) ? DEFAULT_PORT : port;
}

Fixed version (ground truth):
/** 
 * Gets the port number of the SIP server.
 * @return the port number of the SIP server
 */
public int getPort(){
  return mPort;
}
Program: 181213
Project: 181213
Buggy source:
/** 
 * Builds and returns the SIP profile object.
 * @return the profile object created
 */
public SipProfile build(){
  mProfile.mPassword=mUri.getUserPassword();
  mUri.setUserPassword(null);
  try {
    mProfile.mAddress=mAddressFactory.createAddress(mDisplayName,mUri);
    if (!TextUtils.isEmpty(mProxyAddress)) {
      SipURI uri=(SipURI)mAddressFactory.createURI(fix(mProxyAddress));
      mProfile.mProxyAddress=uri.getHost();
    }
  }
 catch (  ParseException e) {
    throw new RuntimeException(e);
  }
  return mProfile;
}

Fixed version (ground truth):
/** 
 * Builds and returns the SIP profile object.
 * @return the profile object created
 */
public SipProfile build(){
  mProfile.mPassword=mUri.getUserPassword();
  mUri.setUserPassword(null);
  try {
    if (!TextUtils.isEmpty(mProxyAddress)) {
      SipURI uri=(SipURI)mAddressFactory.createURI(fix(mProxyAddress));
      mProfile.mProxyAddress=uri.getHost();
    }
 else {
      if (!mProfile.mProtocol.equals(UDP)) {
        mUri.setTransportParam(mProfile.mProtocol);
      }
      if (mProfile.mPort != DEFAULT_PORT) {
        mUri.setPort(mProfile.mPort);
      }
    }
    mProfile.mAddress=mAddressFactory.createAddress(mDisplayName,mUri);
  }
 catch (  InvalidArgumentException e) {
    throw new RuntimeException(e);
  }
catch (  ParseException e) {
    throw new RuntimeException(e);
  }
  return mProfile;
}
Program: 181214
Project: 181214
Buggy source:
@Override public void writeToParcel(Parcel out,int flags){
  out.writeSerializable(mAddress);
  out.writeString(mProxyAddress);
  out.writeString(mPassword);
  out.writeString(mDomain);
  out.writeString(mProtocol);
  out.writeString(mProfileName);
  out.writeInt(mSendKeepAlive ? 1 : 0);
  out.writeInt(mAutoRegistration ? 1 : 0);
  out.writeInt(mCallingUid);
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel out,int flags){
  out.writeSerializable(mAddress);
  out.writeString(mProxyAddress);
  out.writeString(mPassword);
  out.writeString(mDomain);
  out.writeString(mProtocol);
  out.writeString(mProfileName);
  out.writeInt(mSendKeepAlive ? 1 : 0);
  out.writeInt(mAutoRegistration ? 1 : 0);
  out.writeInt(mCallingUid);
  out.writeInt(mPort);
}
Program: 181215
Project: 181215
Buggy source:
private Request createRequest(String requestType,SipProfile userProfile,String tag) throws ParseException, SipException {
  FromHeader fromHeader=createFromHeader(userProfile,tag);
  ToHeader toHeader=createToHeader(userProfile);
  SipURI requestURI=mAddressFactory.createSipURI("String_Node_Str" + userProfile.getSipDomain());
  List<ViaHeader> viaHeaders=createViaHeaders();
  CallIdHeader callIdHeader=createCallIdHeader();
  CSeqHeader cSeqHeader=createCSeqHeader(requestType);
  MaxForwardsHeader maxForwards=createMaxForwardsHeader();
  Request request=mMessageFactory.createRequest(requestURI,requestType,callIdHeader,cSeqHeader,fromHeader,toHeader,viaHeaders,maxForwards);
  Header userAgentHeader=mHeaderFactory.createHeader("String_Node_Str","String_Node_Str");
  request.addHeader(userAgentHeader);
  return request;
}

Fixed version (ground truth):
private Request createRequest(String requestType,SipProfile userProfile,String tag) throws ParseException, SipException {
  FromHeader fromHeader=createFromHeader(userProfile,tag);
  ToHeader toHeader=createToHeader(userProfile);
  SipURI requestURI=mAddressFactory.createSipURI(userProfile.getUriString().replaceFirst(userProfile.getUserName() + "String_Node_Str","String_Node_Str"));
  List<ViaHeader> viaHeaders=createViaHeaders();
  CallIdHeader callIdHeader=createCallIdHeader();
  CSeqHeader cSeqHeader=createCSeqHeader(requestType);
  MaxForwardsHeader maxForwards=createMaxForwardsHeader();
  Request request=mMessageFactory.createRequest(requestURI,requestType,callIdHeader,cSeqHeader,fromHeader,toHeader,viaHeaders,maxForwards);
  Header userAgentHeader=mHeaderFactory.createHeader("String_Node_Str","String_Node_Str");
  request.addHeader(userAgentHeader);
  return request;
}
Program: 181216
Project: 181216
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: 181217
Project: 181217
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: 181219
Project: 181219
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: 181220
Project: 181220
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: 181221
Project: 181221
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: 181222
Project: 181222
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: 181223
Project: 181223
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: 181224
Project: 181224
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);
}