nus-yam/ex-repair huggingface dataset:
Program: 24318
Project: 24318
Buggy source:
/** 
 * (Usually optional) Set the data for the intent along with an explicit MIME data type.  This method should very rarely be used -- it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here.
 * @param data The URI of the data this intent is now targeting.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #setData
 * @see #setType
 */
public Intent setDataAndType(Uri data,String type){
  mData=data;
  mType=type;
  return this;
}

Fixed version (ground truth):
/** 
 * (Usually optional) Set the data for the intent along with an explicit MIME data type.  This method should very rarely be used -- it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here. <p><em>Note: MIME type, Uri scheme, and host name matching in the Android framework is case-sensitive, unlike the formal RFC definitions. As a result, you should always write these elements with lower case letters, and normalize any MIME types or Uris you receive from outside of Android to ensure these elements are lower case before supplying them here.</em></p>
 * @param data The URI of the data this intent is now targeting.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #setData
 * @see #setType
 */
public Intent setDataAndType(Uri data,String type){
  mData=data;
  mType=type;
  return this;
}
Program: 24319
Project: 24319
Buggy source:
/** 
 * Set an explicit MIME data type.  This is used to create intents that only specify a type and not data, for example to indicate the type of data to return.  This method automatically clears any data that was previously set by   {@link #setData}.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getType
 * @see #setData
 * @see #setDataAndType
 */
public Intent setType(String type){
  mData=null;
  mType=type;
  return this;
}

Fixed version (ground truth):
/** 
 * Set an explicit MIME data type.  This is used to create intents that only specify a type and not data, for example to indicate the type of data to return.  This method automatically clears any data that was previously set by   {@link #setData}. <p><em>Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types.  As a result, you should always write your MIME types with lower case letters, and any MIME types you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getType
 * @see #setData
 * @see #setDataAndType
 */
public Intent setType(String type){
  mData=null;
  mType=type;
  return this;
}
Program: 24320
Project: 24320
Buggy source:
/** 
 * Add a new Intent data authority to match against.  The filter must include one or more schemes (via   {@link #addDataScheme}) for the authority to be considered.  If any authorities are included in the filter, then an Intent's data must match one of them.  If no authorities are included, then only the scheme must match.
 * @param host The host part of the authority to match.  May start with asingle '*' to wildcard the front of the host name.
 * @param port Optional port part of the authority to match.  If null, anyport is allowed.
 * @see #matchData
 * @see #addDataScheme
 */
public final void addDataAuthority(String host,String port){
  if (mDataAuthorities == null)   mDataAuthorities=new ArrayList<AuthorityEntry>();
  if (port != null)   port=port.intern();
  mDataAuthorities.add(new AuthorityEntry(host.intern(),port));
}

Fixed version (ground truth):
/** 
 * Add a new Intent data authority to match against.  The filter must include one or more schemes (via   {@link #addDataScheme}) for the authority to be considered.  If any authorities are included in the filter, then an Intent's data must match one of them.  If no authorities are included, then only the scheme must match. <p><em>Note: host name in the Android framework is case-sensitive, unlike formal RFC host names.  As a result, you should always write your host names with lower case letters, and any host names you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param host The host part of the authority to match.  May start with asingle '*' to wildcard the front of the host name.
 * @param port Optional port part of the authority to match.  If null, anyport is allowed.
 * @see #matchData
 * @see #addDataScheme
 */
public final void addDataAuthority(String host,String port){
  if (mDataAuthorities == null)   mDataAuthorities=new ArrayList<AuthorityEntry>();
  if (port != null)   port=port.intern();
  mDataAuthorities.add(new AuthorityEntry(host.intern(),port));
}
Program: 24322
Project: 24322
Buggy source:
/** 
 * Add a new Intent data scheme to match against.  If any schemes are included in the filter, then an Intent's data must be <em>either</em> one of these schemes <em>or</em> a matching data type.  If no schemes are included, then an Intent will match only if it includes no data.
 * @param scheme Name of the scheme to match, i.e. "http".
 * @see #matchData
 */
public final void addDataScheme(String scheme){
  if (mDataSchemes == null)   mDataSchemes=new ArrayList<String>();
  if (!mDataSchemes.contains(scheme)) {
    mDataSchemes.add(scheme.intern());
  }
}

Fixed version (ground truth):
/** 
 * Add a new Intent data scheme to match against.  If any schemes are included in the filter, then an Intent's data must be <em>either</em> one of these schemes <em>or</em> a matching data type.  If no schemes are included, then an Intent will match only if it includes no data. <p><em>Note: scheme matching in the Android framework is case-sensitive, unlike formal RFC schemes.  As a result, you should always write your schemes with lower case letters, and any schemes you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param scheme Name of the scheme to match, i.e. "http".
 * @see #matchData
 */
public final void addDataScheme(String scheme){
  if (mDataSchemes == null)   mDataSchemes=new ArrayList<String>();
  if (!mDataSchemes.contains(scheme)) {
    mDataSchemes.add(scheme.intern());
  }
}
Program: 24323
Project: 24323
Buggy source:
/** 
 * Add a new Intent data type to match against.  If any types are included in the filter, then an Intent's data must be <em>either</em> one of these types <em>or</em> a matching scheme.  If no data types are included, then an Intent will only match if it specifies no data. <p>Throws   {@link MalformedMimeTypeException} if the given MIME type isnot syntactically correct.
 * @param type Name of the data type to match, i.e. "vnd.android.cursor.dir/person".
 * @see #matchData
 */
public final void addDataType(String type) throws MalformedMimeTypeException {
  final int slashpos=type.indexOf('/');
  final int typelen=type.length();
  if (slashpos > 0 && typelen >= slashpos + 2) {
    if (mDataTypes == null)     mDataTypes=new ArrayList<String>();
    if (typelen == slashpos + 2 && type.charAt(slashpos + 1) == '*') {
      String str=type.substring(0,slashpos);
      if (!mDataTypes.contains(str)) {
        mDataTypes.add(str.intern());
      }
      mHasPartialTypes=true;
    }
 else {
      if (!mDataTypes.contains(type)) {
        mDataTypes.add(type.intern());
      }
    }
    return;
  }
  throw new MalformedMimeTypeException(type);
}

Fixed version (ground truth):
/** 
 * Add a new Intent data type to match against.  If any types are included in the filter, then an Intent's data must be <em>either</em> one of these types <em>or</em> a matching scheme.  If no data types are included, then an Intent will only match if it specifies no data. <p><em>Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types.  As a result, you should always write your MIME types with lower case letters, and any MIME types you receive from outside of Android should be converted to lower case before supplying them here.</em></p> <p>Throws   {@link MalformedMimeTypeException} if the given MIME type isnot syntactically correct.
 * @param type Name of the data type to match, i.e. "vnd.android.cursor.dir/person".
 * @see #matchData
 */
public final void addDataType(String type) throws MalformedMimeTypeException {
  final int slashpos=type.indexOf('/');
  final int typelen=type.length();
  if (slashpos > 0 && typelen >= slashpos + 2) {
    if (mDataTypes == null)     mDataTypes=new ArrayList<String>();
    if (typelen == slashpos + 2 && type.charAt(slashpos + 1) == '*') {
      String str=type.substring(0,slashpos);
      if (!mDataTypes.contains(str)) {
        mDataTypes.add(str.intern());
      }
      mHasPartialTypes=true;
    }
 else {
      if (!mDataTypes.contains(type)) {
        mDataTypes.add(type.intern());
      }
    }
    return;
  }
  throw new MalformedMimeTypeException(type);
}
Program: 24324
Project: 24324
Buggy source:
/** 
 * Set the data this intent is operating on.  This method automatically clears any type that was previously set by   {@link #setType}.
 * @param data The URI of the data this intent is now targeting.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getData
 * @see #setType
 * @see #setDataAndType
 */
public Intent setData(Uri data){
  mData=data;
  mType=null;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the data this intent is operating on.  This method automatically clears any type that was previously set by   {@link #setType}. <p><em>Note: scheme and host name matching in the Android framework is case-sensitive, unlike the formal RFC.  As a result, you should always ensure that you write your Uri with these elements using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme and host is lower case.</em></p>
 * @param data The URI of the data this intent is now targeting.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getData
 * @see #setType
 * @see #setDataAndType
 */
public Intent setData(Uri data){
  mData=data;
  mType=null;
  return this;
}
Program: 24325
Project: 24325
Buggy source:
/** 
 * (Usually optional) Set the data for the intent along with an explicit MIME data type.  This method should very rarely be used -- it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here.
 * @param data The URI of the data this intent is now targeting.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #setData
 * @see #setType
 */
public Intent setDataAndType(Uri data,String type){
  mData=data;
  mType=type;
  return this;
}

Fixed version (ground truth):
/** 
 * (Usually optional) Set the data for the intent along with an explicit MIME data type.  This method should very rarely be used -- it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here. <p><em>Note: MIME type, Uri scheme, and host name matching in the Android framework is case-sensitive, unlike the formal RFC definitions. As a result, you should always write these elements with lower case letters, and normalize any MIME types or Uris you receive from outside of Android to ensure these elements are lower case before supplying them here.</em></p>
 * @param data The URI of the data this intent is now targeting.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #setData
 * @see #setType
 */
public Intent setDataAndType(Uri data,String type){
  mData=data;
  mType=type;
  return this;
}
Program: 24326
Project: 24326
Buggy source:
/** 
 * Set an explicit MIME data type.  This is used to create intents that only specify a type and not data, for example to indicate the type of data to return.  This method automatically clears any data that was previously set by   {@link #setData}.
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getType
 * @see #setData
 * @see #setDataAndType
 */
public Intent setType(String type){
  mData=null;
  mType=type;
  return this;
}

Fixed version (ground truth):
/** 
 * Set an explicit MIME data type.  This is used to create intents that only specify a type and not data, for example to indicate the type of data to return.  This method automatically clears any data that was previously set by   {@link #setData}. <p><em>Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types.  As a result, you should always write your MIME types with lower case letters, and any MIME types you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param type The MIME type of the data being handled by this intent.
 * @return Returns the same Intent object, for chaining multiple callsinto a single statement.
 * @see #getType
 * @see #setData
 * @see #setDataAndType
 */
public Intent setType(String type){
  mData=null;
  mType=type;
  return this;
}
Program: 24327
Project: 24327
Buggy source:
/** 
 * Add a new Intent data authority to match against.  The filter must include one or more schemes (via   {@link #addDataScheme}) for the authority to be considered.  If any authorities are included in the filter, then an Intent's data must match one of them.  If no authorities are included, then only the scheme must match.
 * @param host The host part of the authority to match.  May start with asingle '*' to wildcard the front of the host name.
 * @param port Optional port part of the authority to match.  If null, anyport is allowed.
 * @see #matchData
 * @see #addDataScheme
 */
public final void addDataAuthority(String host,String port){
  if (mDataAuthorities == null)   mDataAuthorities=new ArrayList<AuthorityEntry>();
  if (port != null)   port=port.intern();
  mDataAuthorities.add(new AuthorityEntry(host.intern(),port));
}

Fixed version (ground truth):
/** 
 * Add a new Intent data authority to match against.  The filter must include one or more schemes (via   {@link #addDataScheme}) for the authority to be considered.  If any authorities are included in the filter, then an Intent's data must match one of them.  If no authorities are included, then only the scheme must match. <p><em>Note: host name in the Android framework is case-sensitive, unlike formal RFC host names.  As a result, you should always write your host names with lower case letters, and any host names you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param host The host part of the authority to match.  May start with asingle '*' to wildcard the front of the host name.
 * @param port Optional port part of the authority to match.  If null, anyport is allowed.
 * @see #matchData
 * @see #addDataScheme
 */
public final void addDataAuthority(String host,String port){
  if (mDataAuthorities == null)   mDataAuthorities=new ArrayList<AuthorityEntry>();
  if (port != null)   port=port.intern();
  mDataAuthorities.add(new AuthorityEntry(host.intern(),port));
}
Program: 24329
Project: 24329
Buggy source:
/** 
 * Add a new Intent data scheme to match against.  If any schemes are included in the filter, then an Intent's data must be <em>either</em> one of these schemes <em>or</em> a matching data type.  If no schemes are included, then an Intent will match only if it includes no data.
 * @param scheme Name of the scheme to match, i.e. "http".
 * @see #matchData
 */
public final void addDataScheme(String scheme){
  if (mDataSchemes == null)   mDataSchemes=new ArrayList<String>();
  if (!mDataSchemes.contains(scheme)) {
    mDataSchemes.add(scheme.intern());
  }
}

Fixed version (ground truth):
/** 
 * Add a new Intent data scheme to match against.  If any schemes are included in the filter, then an Intent's data must be <em>either</em> one of these schemes <em>or</em> a matching data type.  If no schemes are included, then an Intent will match only if it includes no data. <p><em>Note: scheme matching in the Android framework is case-sensitive, unlike formal RFC schemes.  As a result, you should always write your schemes with lower case letters, and any schemes you receive from outside of Android should be converted to lower case before supplying them here.</em></p>
 * @param scheme Name of the scheme to match, i.e. "http".
 * @see #matchData
 */
public final void addDataScheme(String scheme){
  if (mDataSchemes == null)   mDataSchemes=new ArrayList<String>();
  if (!mDataSchemes.contains(scheme)) {
    mDataSchemes.add(scheme.intern());
  }
}
Program: 24330
Project: 24330
Buggy source:
/** 
 * Add a new Intent data type to match against.  If any types are included in the filter, then an Intent's data must be <em>either</em> one of these types <em>or</em> a matching scheme.  If no data types are included, then an Intent will only match if it specifies no data. <p>Throws   {@link MalformedMimeTypeException} if the given MIME type isnot syntactically correct.
 * @param type Name of the data type to match, i.e. "vnd.android.cursor.dir/person".
 * @see #matchData
 */
public final void addDataType(String type) throws MalformedMimeTypeException {
  final int slashpos=type.indexOf('/');
  final int typelen=type.length();
  if (slashpos > 0 && typelen >= slashpos + 2) {
    if (mDataTypes == null)     mDataTypes=new ArrayList<String>();
    if (typelen == slashpos + 2 && type.charAt(slashpos + 1) == '*') {
      String str=type.substring(0,slashpos);
      if (!mDataTypes.contains(str)) {
        mDataTypes.add(str.intern());
      }
      mHasPartialTypes=true;
    }
 else {
      if (!mDataTypes.contains(type)) {
        mDataTypes.add(type.intern());
      }
    }
    return;
  }
  throw new MalformedMimeTypeException(type);
}

Fixed version (ground truth):
/** 
 * Add a new Intent data type to match against.  If any types are included in the filter, then an Intent's data must be <em>either</em> one of these types <em>or</em> a matching scheme.  If no data types are included, then an Intent will only match if it specifies no data. <p><em>Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types.  As a result, you should always write your MIME types with lower case letters, and any MIME types you receive from outside of Android should be converted to lower case before supplying them here.</em></p> <p>Throws   {@link MalformedMimeTypeException} if the given MIME type isnot syntactically correct.
 * @param type Name of the data type to match, i.e. "vnd.android.cursor.dir/person".
 * @see #matchData
 */
public final void addDataType(String type) throws MalformedMimeTypeException {
  final int slashpos=type.indexOf('/');
  final int typelen=type.length();
  if (slashpos > 0 && typelen >= slashpos + 2) {
    if (mDataTypes == null)     mDataTypes=new ArrayList<String>();
    if (typelen == slashpos + 2 && type.charAt(slashpos + 1) == '*') {
      String str=type.substring(0,slashpos);
      if (!mDataTypes.contains(str)) {
        mDataTypes.add(str.intern());
      }
      mHasPartialTypes=true;
    }
 else {
      if (!mDataTypes.contains(type)) {
        mDataTypes.add(type.intern());
      }
    }
    return;
  }
  throw new MalformedMimeTypeException(type);
}
Program: 24331
Project: 24331
Buggy source:
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called from the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);

Fixed version (ground truth):
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called within the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}. <p>The Intent filters used in   {@link android.content.Context#registerReceiver}and in application manifests are <em>not</em> guaranteed to be exclusive. They are hints to the operating system about how to find suitable recipients. It is possible for senders to force delivery to specific recipients, bypassing filter resolution.  For this reason,   {@link #onReceive(Context,Intent) onReceive()}implementations should respond only to known actions, ignoring any unexpected Intents that they may receive.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);
Program: 24332
Project: 24332
Buggy source:
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called from the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);

Fixed version (ground truth):
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called within the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}. <p>The Intent filters used in   {@link android.content.Context#registerReceiver}and in application manifests are <em>not</em> guaranteed to be exclusive. They are hints to the operating system about how to find suitable recipients. It is possible for senders to force delivery to specific recipients, bypassing filter resolution.  For this reason,   {@link #onReceive(Context,Intent) onReceive()}implementations should respond only to known actions, ignoring any unexpected Intents that they may receive.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);
Program: 24333
Project: 24333
Buggy source:
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called from the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);

Fixed version (ground truth):
/** 
 * This method is called when the BroadcastReceiver is receiving an Intent broadcast.  During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.  The function is normally called within the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive(). <p><b>If this BroadcastReceiver was launched through a &lt;receiver&gt; tag, then the object is no longer alive after returning from this function.</b>  This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use  {@link Context#startService(Intent)} instead of{@link Context#bindService(Intent,ServiceConnection,int)}.  If you wish to interact with a service that is already running, you can use  {@link #peekService}. <p>The Intent filters used in   {@link android.content.Context#registerReceiver}and in application manifests are <em>not</em> guaranteed to be exclusive. They are hints to the operating system about how to find suitable recipients. It is possible for senders to force delivery to specific recipients, bypassing filter resolution.  For this reason,   {@link #onReceive(Context,Intent) onReceive()}implementations should respond only to known actions, ignoring any unexpected Intents that they may receive.
 * @param context The Context in which the receiver is running.
 * @param intent The Intent being received.
 */
public abstract void onReceive(Context context,Intent intent);
Program: 24335
Project: 24335
Buggy source:
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && i <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}
Program: 24336
Project: 24336
Buggy source:
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && i <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}
Program: 24339
Project: 24339
Buggy source:
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && i <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name, conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string, or returning it literally if it seems safe.
 */
public static String quoteNameIfNecessary(String name){
  int len=name.length();
  for (int i=0; i < len; i++) {
    char c=name.charAt(i);
    if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == ' ')|| (c >= '0' && c <= '9'))) {
      return '"' + quoteName(name) + '"';
    }
  }
  return name;
}
Program: 24341
Project: 24341
Buggy source:
public void run(){
  try {
    if (!hasCache) {
      captureView.buildDrawingCache();
    }
    cache[0]=captureView.getDrawingCache();
  }
  finally {
    latch.countDown();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_8888,0);
  }
 catch (  OutOfMemoryError e) {
    try {
      cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_4444,0);
    }
 catch (    OutOfMemoryError e2) {
      Log.w("String_Node_Str","String_Node_Str");
    }
  }
 finally {
    latch.countDown();
  }
}
Program: 24342
Project: 24342
Buggy source:
private static void capture(View root,final OutputStream clientStream,String parameter) throws IOException {
  final View captureView=findView(root,parameter);
  if (captureView != null) {
    final CountDownLatch latch=new CountDownLatch(1);
    final Bitmap[] cache=new Bitmap[1];
    final boolean hasCache=captureView.isDrawingCacheEnabled();
    final boolean willNotCache=captureView.willNotCacheDrawing();
    if (willNotCache) {
      captureView.setWillNotCacheDrawing(false);
    }
    root.post(new Runnable(){
      public void run(){
        try {
          if (!hasCache) {
            captureView.buildDrawingCache();
          }
          cache[0]=captureView.getDrawingCache();
        }
  finally {
          latch.countDown();
        }
      }
    }
);
    try {
      latch.await(CAPTURE_TIMEOUT,TimeUnit.MILLISECONDS);
      if (cache[0] != null) {
        BufferedOutputStream out=null;
        try {
          out=new BufferedOutputStream(clientStream,32 * 1024);
          cache[0].compress(Bitmap.CompressFormat.PNG,100,out);
          out.flush();
        }
  finally {
          if (out != null) {
            out.close();
          }
        }
      }
    }
 catch (    InterruptedException e) {
      Log.w("String_Node_Str","String_Node_Str" + captureView);
      Thread.currentThread().interrupt();
    }
 finally {
      if (willNotCache) {
        captureView.setWillNotCacheDrawing(true);
      }
      if (!hasCache) {
        captureView.destroyDrawingCache();
      }
    }
  }
}

Fixed version (ground truth):
private static void capture(View root,final OutputStream clientStream,String parameter) throws IOException {
  final View captureView=findView(root,parameter);
  if (captureView != null) {
    final CountDownLatch latch=new CountDownLatch(1);
    final Bitmap[] cache=new Bitmap[1];
    root.post(new Runnable(){
      public void run(){
        try {
          cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_8888,0);
        }
 catch (        OutOfMemoryError e) {
          try {
            cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_4444,0);
          }
 catch (          OutOfMemoryError e2) {
            Log.w("String_Node_Str","String_Node_Str");
          }
        }
 finally {
          latch.countDown();
        }
      }
    }
);
    try {
      latch.await(CAPTURE_TIMEOUT,TimeUnit.MILLISECONDS);
      if (cache[0] != null) {
        BufferedOutputStream out=null;
        try {
          out=new BufferedOutputStream(clientStream,32 * 1024);
          cache[0].compress(Bitmap.CompressFormat.PNG,100,out);
          out.flush();
        }
  finally {
          if (out != null) {
            out.close();
          }
          cache[0].recycle();
        }
      }
 else {
        Log.w("String_Node_Str","String_Node_Str");
        clientStream.close();
      }
    }
 catch (    InterruptedException e) {
      Log.w("String_Node_Str","String_Node_Str" + captureView);
      Thread.currentThread().interrupt();
    }
  }
}
Program: 24343
Project: 24343
Buggy source:
/** 
 * Called when layout of the windows is finished.  After this function has returned, all windows given to layoutWindow() <em>must</em> have had a frame assigned.
 */
public void finishLayoutLw();

Fixed version (ground truth):
/** 
 * Called when layout of the windows is finished.  After this function has returned, all windows given to layoutWindow() <em>must</em> have had a frame assigned.
 * @return Return true if layout state may have changed (so that another layout will be performed).
 */
public boolean finishLayoutLw();
Program: 24345
Project: 24345
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void draw(Canvas canvas){
  super.draw(canvas);
  if (mForeground != null) {
    mForeground.draw(canvas);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void draw(Canvas canvas){
  super.draw(canvas);
  if (mForeground != null) {
    final Drawable foreground=mForeground;
    if (mForegroundBoundsChanged) {
      mForegroundBoundsChanged=false;
      if (foreground != null) {
        final Rect selfBounds=mSelfBounds;
        final Rect overlayBounds=mOverlayBounds;
        final int w=mRight - mLeft;
        final int h=mBottom - mTop;
        if (mForegroundInPadding) {
          selfBounds.set(0,0,w,h);
        }
 else {
          selfBounds.set(mPaddingLeft,mPaddingTop,w - mPaddingRight,h - mPaddingBottom);
        }
        Gravity.apply(mForegroundGravity,foreground.getIntrinsicWidth(),foreground.getIntrinsicHeight(),selfBounds,overlayBounds);
        foreground.setBounds(overlayBounds);
      }
    }
    foreground.draw(canvas);
  }
}
Program: 24346
Project: 24346
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  final Drawable foreground=mForeground;
  if (foreground != null) {
    final Rect selfBounds=mSelfBounds;
    final Rect overlayBounds=mOverlayBounds;
    if (mForegroundInPadding) {
      selfBounds.set(0,0,w,h);
    }
 else {
      selfBounds.set(mPaddingLeft,mPaddingTop,w - mPaddingRight,h - mPaddingBottom);
    }
    Gravity.apply(mForegroundGravity,foreground.getIntrinsicWidth(),foreground.getIntrinsicHeight(),selfBounds,overlayBounds);
    foreground.setBounds(overlayBounds);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  mForegroundBoundsChanged=true;
}
Program: 24347
Project: 24347
Buggy source:
private final void performLayoutLockedInner(){
  final int dw=mDisplay.getWidth();
  final int dh=mDisplay.getHeight();
  final int N=mWindows.size();
  int i;
  if (mLayoutNeeded) {
    mPolicy.beginLayoutLw(dw,dh);
    int topAttached=-1;
    for (i=N - 1; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      boolean gone=win.mViewVisibility == View.GONE || !win.mRelayoutCalled || win.mRootToken.hidden;
      if (!gone || !win.mHaveFrame) {
        if (!win.mLayoutAttached) {
          mPolicy.layoutWindowLw(win,win.mAttrs,null);
        }
 else {
          if (topAttached < 0)           topAttached=i;
        }
      }
    }
    for (i=topAttached; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      if (win.mLayoutAttached) {
        if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) {
          mPolicy.layoutWindowLw(win,win.mAttrs,win.mAttachedWindow);
        }
      }
    }
    mPolicy.finishLayoutLw();
    mLayoutNeeded=false;
  }
}

Fixed version (ground truth):
private final void performLayoutLockedInner(){
  final int dw=mDisplay.getWidth();
  final int dh=mDisplay.getHeight();
  final int N=mWindows.size();
  int repeats=0;
  int i;
  while (mLayoutNeeded) {
    mPolicy.beginLayoutLw(dw,dh);
    int topAttached=-1;
    for (i=N - 1; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      final AppWindowToken atoken=win.mAppToken;
      final boolean gone=win.mViewVisibility == View.GONE || !win.mRelayoutCalled || win.mRootToken.hidden || (atoken != null && atoken.hiddenRequested) || !win.mPolicyVisibility || win.mAttachedHidden || win.mExiting || win.mDestroying;
      if (!gone || !win.mHaveFrame) {
        if (!win.mLayoutAttached) {
          mPolicy.layoutWindowLw(win,win.mAttrs,null);
        }
 else {
          if (topAttached < 0)           topAttached=i;
        }
      }
    }
    for (i=topAttached; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      if (win.mLayoutAttached) {
        if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) {
          mPolicy.layoutWindowLw(win,win.mAttrs,win.mAttachedWindow);
        }
      }
    }
    if (!mPolicy.finishLayoutLw()) {
      mLayoutNeeded=false;
    }
 else     if (repeats > 2) {
      Log.w(TAG,"String_Node_Str");
      mLayoutNeeded=false;
    }
 else {
      repeats++;
    }
  }
}
Program: 24349
Project: 24349
Buggy source:
public void run(){
  try {
    if (!hasCache) {
      captureView.buildDrawingCache();
    }
    cache[0]=captureView.getDrawingCache();
  }
  finally {
    latch.countDown();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_8888,0);
  }
 catch (  OutOfMemoryError e) {
    try {
      cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_4444,0);
    }
 catch (    OutOfMemoryError e2) {
      Log.w("String_Node_Str","String_Node_Str");
    }
  }
 finally {
    latch.countDown();
  }
}
Program: 24350
Project: 24350
Buggy source:
private static void capture(View root,final OutputStream clientStream,String parameter) throws IOException {
  final View captureView=findView(root,parameter);
  if (captureView != null) {
    final CountDownLatch latch=new CountDownLatch(1);
    final Bitmap[] cache=new Bitmap[1];
    final boolean hasCache=captureView.isDrawingCacheEnabled();
    final boolean willNotCache=captureView.willNotCacheDrawing();
    if (willNotCache) {
      captureView.setWillNotCacheDrawing(false);
    }
    root.post(new Runnable(){
      public void run(){
        try {
          if (!hasCache) {
            captureView.buildDrawingCache();
          }
          cache[0]=captureView.getDrawingCache();
        }
  finally {
          latch.countDown();
        }
      }
    }
);
    try {
      latch.await(CAPTURE_TIMEOUT,TimeUnit.MILLISECONDS);
      if (cache[0] != null) {
        BufferedOutputStream out=null;
        try {
          out=new BufferedOutputStream(clientStream,32 * 1024);
          cache[0].compress(Bitmap.CompressFormat.PNG,100,out);
          out.flush();
        }
  finally {
          if (out != null) {
            out.close();
          }
        }
      }
    }
 catch (    InterruptedException e) {
      Log.w("String_Node_Str","String_Node_Str" + captureView);
      Thread.currentThread().interrupt();
    }
 finally {
      if (willNotCache) {
        captureView.setWillNotCacheDrawing(true);
      }
      if (!hasCache) {
        captureView.destroyDrawingCache();
      }
    }
  }
}

Fixed version (ground truth):
private static void capture(View root,final OutputStream clientStream,String parameter) throws IOException {
  final View captureView=findView(root,parameter);
  if (captureView != null) {
    final CountDownLatch latch=new CountDownLatch(1);
    final Bitmap[] cache=new Bitmap[1];
    root.post(new Runnable(){
      public void run(){
        try {
          cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_8888,0);
        }
 catch (        OutOfMemoryError e) {
          try {
            cache[0]=captureView.createSnapshot(Bitmap.Config.ARGB_4444,0);
          }
 catch (          OutOfMemoryError e2) {
            Log.w("String_Node_Str","String_Node_Str");
          }
        }
 finally {
          latch.countDown();
        }
      }
    }
);
    try {
      latch.await(CAPTURE_TIMEOUT,TimeUnit.MILLISECONDS);
      if (cache[0] != null) {
        BufferedOutputStream out=null;
        try {
          out=new BufferedOutputStream(clientStream,32 * 1024);
          cache[0].compress(Bitmap.CompressFormat.PNG,100,out);
          out.flush();
        }
  finally {
          if (out != null) {
            out.close();
          }
          cache[0].recycle();
        }
      }
 else {
        Log.w("String_Node_Str","String_Node_Str");
        clientStream.close();
      }
    }
 catch (    InterruptedException e) {
      Log.w("String_Node_Str","String_Node_Str" + captureView);
      Thread.currentThread().interrupt();
    }
  }
}
Program: 24351
Project: 24351
Buggy source:
/** 
 * Called when layout of the windows is finished.  After this function has returned, all windows given to layoutWindow() <em>must</em> have had a frame assigned.
 */
public void finishLayoutLw();

Fixed version (ground truth):
/** 
 * Called when layout of the windows is finished.  After this function has returned, all windows given to layoutWindow() <em>must</em> have had a frame assigned.
 * @return Return true if layout state may have changed (so that another layout will be performed).
 */
public boolean finishLayoutLw();
Program: 24353
Project: 24353
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void draw(Canvas canvas){
  super.draw(canvas);
  if (mForeground != null) {
    mForeground.draw(canvas);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void draw(Canvas canvas){
  super.draw(canvas);
  if (mForeground != null) {
    final Drawable foreground=mForeground;
    if (mForegroundBoundsChanged) {
      mForegroundBoundsChanged=false;
      if (foreground != null) {
        final Rect selfBounds=mSelfBounds;
        final Rect overlayBounds=mOverlayBounds;
        final int w=mRight - mLeft;
        final int h=mBottom - mTop;
        if (mForegroundInPadding) {
          selfBounds.set(0,0,w,h);
        }
 else {
          selfBounds.set(mPaddingLeft,mPaddingTop,w - mPaddingRight,h - mPaddingBottom);
        }
        Gravity.apply(mForegroundGravity,foreground.getIntrinsicWidth(),foreground.getIntrinsicHeight(),selfBounds,overlayBounds);
        foreground.setBounds(overlayBounds);
      }
    }
    foreground.draw(canvas);
  }
}
Program: 24354
Project: 24354
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  final Drawable foreground=mForeground;
  if (foreground != null) {
    final Rect selfBounds=mSelfBounds;
    final Rect overlayBounds=mOverlayBounds;
    if (mForegroundInPadding) {
      selfBounds.set(0,0,w,h);
    }
 else {
      selfBounds.set(mPaddingLeft,mPaddingTop,w - mPaddingRight,h - mPaddingBottom);
    }
    Gravity.apply(mForegroundGravity,foreground.getIntrinsicWidth(),foreground.getIntrinsicHeight(),selfBounds,overlayBounds);
    foreground.setBounds(overlayBounds);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  mForegroundBoundsChanged=true;
}