nus-yam/ex-repair huggingface dataset:
Program: 183195
Project: 183195
Buggy source:
/** 
 * Assign the contact uri that this fasttrack badge should be associated with. Note that this is only used for displaying the fasttrack window and won't bind the contact's photo for you.
 * @param conatctUri Either a {Contacts.CONTENT_URI} or {Contacts.CONTENT_LOOKUP_URI}style URI.
 */
public void assignContactUri(Uri contactUri){
  mContactUri=contactUri;
}

Fixed version (ground truth):
/** 
 * Assign the contact uri that this fasttrack badge should be associated with. Note that this is only used for displaying the fasttrack window and won't bind the contact's photo for you.
 * @param contactUri Either a {@link Contacts#CONTENT_URI} or{@link Contacts#CONTENT_LOOKUP_URI} style URI.
 */
public void assignContactUri(Uri contactUri){
  mContactUri=contactUri;
}
Program: 183196
Project: 183196
Buggy source:
/** 
 * Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.
 * @param phoneNumber The phone number of the contact.
 * @param lazyLookup If this is true, the lookup query will not be performeduntil this view is clicked.
 */
public void assignContactFromPhone(String phoneNumber,boolean lazyLookup){
  mContactPhone=phoneNumber;
  if (!lazyLookup) {
    mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP,null,Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,mContactPhone),PHONE_LOOKUP_PROJECTION,null,null,null);
  }
}

Fixed version (ground truth):
/** 
 * Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.
 * @param phoneNumber The phone number of the contact.
 * @param lazyLookup If this is true, the lookup query will not be performeduntil this view is clicked.
 */
public void assignContactFromPhone(String phoneNumber,boolean lazyLookup){
  mContactPhone=phoneNumber;
  if (!lazyLookup) {
    mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP,null,Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,mContactPhone),PHONE_LOOKUP_PROJECTION,null,null,null);
  }
 else {
    mContactUri=null;
  }
}
Program: 183197
Project: 183197
Buggy source:
public void onClick(View v){
  final Rect target=getTargetRect(v);
  if (mContactUri != null) {
    trigger(mContactUri,target);
  }
 else   if (mContactEmail != null) {
    mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER,target,Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,Uri.encode(mContactEmail)),EMAIL_LOOKUP_PROJECTION,null,null,null);
  }
 else   if (mContactPhone != null) {
    mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP_AND_TRIGGER,target,Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,mContactPhone),PHONE_LOOKUP_PROJECTION,null,null,null);
  }
 else {
    return;
  }
}

Fixed version (ground truth):
public void onClick(View v){
  if (mContactUri != null) {
    final ContentResolver resolver=getContext().getContentResolver();
    final Uri lookupUri=Contacts.getLookupUri(resolver,mContactUri);
    trigger(lookupUri);
  }
 else   if (mContactEmail != null) {
    mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER,mContactEmail,Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,Uri.encode(mContactEmail)),EMAIL_LOOKUP_PROJECTION,null,null,null);
  }
 else   if (mContactPhone != null) {
    mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP_AND_TRIGGER,mContactPhone,Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,mContactPhone),PHONE_LOOKUP_PROJECTION,null,null,null);
  }
 else {
    return;
  }
}
Program: 183198
Project: 183198
Buggy source:
/** 
 * Set the fasttrack window mode. Options are   {@link Intents.MODE_SMALL},  {@link Intents.MODE_MEDIUM},   {@link Intents.MODE_LARGE}.
 * @param size
 */
public void setMode(int size){
  mMode=size;
}

Fixed version (ground truth):
/** 
 * Set the fasttrack window mode. Options are   {@link FastTrack#MODE_SMALL},  {@link FastTrack#MODE_MEDIUM},   {@link FastTrack#MODE_LARGE}.
 * @param size
 */
public void setMode(int size){
  mMode=size;
}
Program: 183199
Project: 183199
Buggy source:
public FasttrackBadgeWidget(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  TypedArray a=context.obtainStyledAttributes(attrs,com.android.internal.R.styleable.FasttrackBadgeWidget,defStyle,0);
  mMode=a.getInt(com.android.internal.R.styleable.FasttrackBadgeWidget_fasttrackWindowSize,Intents.MODE_MEDIUM);
  a.recycle();
  init();
}

Fixed version (ground truth):
public FasttrackBadgeWidget(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  TypedArray a=context.obtainStyledAttributes(attrs,com.android.internal.R.styleable.FasttrackBadgeWidget,defStyle,0);
  mMode=a.getInt(com.android.internal.R.styleable.FasttrackBadgeWidget_fasttrackWindowSize,FastTrack.MODE_MEDIUM);
  a.recycle();
  init();
}
Program: 183200
Project: 183200
Buggy source:
/** 
 * Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.
 * @param emailAddress The email address of the contact.
 * @param lazyLookup If this is true, the lookup query will not be performeduntil this view is clicked.
 */
public void assignContactFromEmail(String emailAddress,boolean lazyLookup){
  mContactEmail=emailAddress;
  if (!lazyLookup) {
    mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP,null,Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,Uri.encode(mContactEmail)),EMAIL_LOOKUP_PROJECTION,null,null,null);
  }
}

Fixed version (ground truth):
/** 
 * Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.
 * @param emailAddress The email address of the contact.
 * @param lazyLookup If this is true, the lookup query will not be performeduntil this view is clicked.
 */
public void assignContactFromEmail(String emailAddress,boolean lazyLookup){
  mContactEmail=emailAddress;
  if (!lazyLookup) {
    mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP,null,Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,Uri.encode(mContactEmail)),EMAIL_LOOKUP_PROJECTION,null,null,null);
  }
 else {
    mContactUri=null;
  }
}
Program: 183201
Project: 183201
Buggy source:
private void trigger(Uri contactUri,Rect target){
  Intent intent=new Intent(Intents.SHOW_OR_CREATE_CONTACT,contactUri);
  intent.putExtra(Intents.EXTRA_TARGET_RECT,target);
  intent.putExtra(Intents.EXTRA_MODE,mMode);
  mContext.startActivity(intent);
}

Fixed version (ground truth):
private void trigger(Uri lookupUri){
  FastTrack.showFastTrack(getContext(),this,lookupUri,mMode,mExcludeMimes);
}
Program: 183202
Project: 183202
Buggy source:
@Override protected void onQueryComplete(int token,Object cookie,Cursor cursor){
  Uri contactUri=null;
  boolean trigger=false;
  try {
switch (token) {
case TOKEN_PHONE_LOOKUP_AND_TRIGGER:
      trigger=true;
case TOKEN_PHONE_LOOKUP:
{
      if (cursor != null && cursor.moveToFirst()) {
        long contactId=cursor.getLong(PHONE_ID_COLUMN_INDEX);
        String lookupKey=cursor.getString(PHONE_LOOKUP_STRING_COLUMN_INDEX);
        contactUri=Contacts.getLookupUri(contactId,lookupKey);
      }
      break;
    }
case TOKEN_EMAIL_LOOKUP_AND_TRIGGER:
  trigger=true;
case TOKEN_EMAIL_LOOKUP:
{
  if (cursor != null && cursor.moveToFirst()) {
    long contactId=cursor.getLong(EMAIL_ID_COLUMN_INDEX);
    String lookupKey=cursor.getString(EMAIL_LOOKUP_STRING_COLUMN_INDEX);
    contactUri=Contacts.getLookupUri(contactId,lookupKey);
  }
}
}
}
  finally {
if (cursor != null) {
cursor.close();
}
}
if (contactUri != null) {
mContactUri=contactUri;
if (trigger && cookie != null) {
trigger(contactUri,(Rect)cookie);
}
}
}

Fixed version (ground truth):
@Override protected void onQueryComplete(int token,Object cookie,Cursor cursor){
  Uri lookupUri=null;
  Uri createUri=null;
  boolean trigger=false;
  try {
switch (token) {
case TOKEN_PHONE_LOOKUP_AND_TRIGGER:
      trigger=true;
    createUri=Uri.fromParts("String_Node_Str",(String)cookie,null);
case TOKEN_PHONE_LOOKUP:
{
    if (cursor != null && cursor.moveToFirst()) {
      long contactId=cursor.getLong(PHONE_ID_COLUMN_INDEX);
      String lookupKey=cursor.getString(PHONE_LOOKUP_STRING_COLUMN_INDEX);
      lookupUri=Contacts.getLookupUri(contactId,lookupKey);
    }
    break;
  }
case TOKEN_EMAIL_LOOKUP_AND_TRIGGER:
trigger=true;
createUri=Uri.fromParts("String_Node_Str",(String)cookie,null);
case TOKEN_EMAIL_LOOKUP:
{
if (cursor != null && cursor.moveToFirst()) {
long contactId=cursor.getLong(EMAIL_ID_COLUMN_INDEX);
String lookupKey=cursor.getString(EMAIL_LOOKUP_STRING_COLUMN_INDEX);
lookupUri=Contacts.getLookupUri(contactId,lookupKey);
}
}
}
}
  finally {
if (cursor != null) {
cursor.close();
}
}
mContactUri=lookupUri;
if (trigger && lookupUri != null) {
trigger(lookupUri);
}
 else if (createUri != null) {
final Intent intent=new Intent(Intents.SHOW_OR_CREATE_CONTACT,createUri);
getContext().startActivity(intent);
}
}
Program: 183203
Project: 183203
Buggy source:
boolean isInProximity(double latitude,double longitude){
  Location loc=new Location("String_Node_Str");
  loc.setLatitude(latitude);
  loc.setLongitude(longitude);
  double radius=loc.distanceTo(mLocation);
  return radius <= mRadius;
}

Fixed version (ground truth):
boolean isInProximity(double latitude,double longitude,float accuracy){
  Location loc=new Location("String_Node_Str");
  loc.setLatitude(latitude);
  loc.setLongitude(longitude);
  double radius=loc.distanceTo(mLocation);
  return radius <= Math.max(mRadius,accuracy);
}
Program: 183211
Project: 183211
Buggy source:
protected void onLooperPrepared(){
  mDidSetup=true;
  mLooperTid=Process.myTid();
}

Fixed version (ground truth):
protected void onLooperPrepared(){
synchronized (HandlerThreadTest.this) {
    mDidSetup=true;
    mLooperTid=Process.myTid();
    HandlerThreadTest.this.notify();
  }
}
Program: 183212
Project: 183212
Buggy source:
@MediumTest public void testHandlerThread() throws Exception {
  HandlerThread th1=new HandlerThread("String_Node_Str"){
    protected void onLooperPrepared(){
      mDidSetup=true;
      mLooperTid=Process.myTid();
    }
  }
;
  assertFalse(th1.isAlive());
  assertNull(th1.getLooper());
  th1.start();
  assertTrue(th1.isAlive());
  assertNotNull(th1.getLooper());
  assertNotSame(Process.myTid(),mLooperTid);
  assertTrue(mDidSetup);
  final Handler h1=new Handler(th1.getLooper()){
    public void handleMessage(    Message msg){
      assertEquals(TEST_WHAT,msg.what);
      assertEquals(mLooperTid,Process.myTid());
      mGotMessageWhat=msg.what;
      mGotMessage=true;
synchronized (this) {
        notifyAll();
      }
    }
  }
;
  Message msg=h1.obtainMessage(TEST_WHAT);
synchronized (h1) {
    h1.sendMessage(msg);
    try {
      h1.wait();
    }
 catch (    InterruptedException e) {
    }
  }
  assertTrue(mGotMessage);
  assertEquals(TEST_WHAT,mGotMessageWhat);
}

Fixed version (ground truth):
@MediumTest public void testHandlerThread() throws Exception {
  HandlerThread th1=new HandlerThread("String_Node_Str"){
    protected void onLooperPrepared(){
synchronized (HandlerThreadTest.this) {
        mDidSetup=true;
        mLooperTid=Process.myTid();
        HandlerThreadTest.this.notify();
      }
    }
  }
;
  assertFalse(th1.isAlive());
  assertNull(th1.getLooper());
  th1.start();
  assertTrue(th1.isAlive());
  assertNotNull(th1.getLooper());
synchronized (this) {
    while (!mDidSetup) {
      try {
        wait();
      }
 catch (      InterruptedException e) {
      }
    }
  }
  assertNotSame(-1,mLooperTid);
  assertNotSame(Process.myTid(),mLooperTid);
  final Handler h1=new Handler(th1.getLooper()){
    public void handleMessage(    Message msg){
      assertEquals(TEST_WHAT,msg.what);
      assertEquals(mLooperTid,Process.myTid());
      mGotMessageWhat=msg.what;
      mGotMessage=true;
synchronized (this) {
        notifyAll();
      }
    }
  }
;
  Message msg=h1.obtainMessage(TEST_WHAT);
synchronized (h1) {
    h1.sendMessage(msg);
    try {
      h1.wait();
    }
 catch (    InterruptedException e) {
    }
  }
  assertTrue(mGotMessage);
  assertEquals(TEST_WHAT,mGotMessageWhat);
}
Program: 183213
Project: 183213
Buggy source:
public void onClick(View view){
  if (mContactUri == null) {
    return;
  }
switch (view.getId()) {
case R.id.star:
{
      final ContentValues values=new ContentValues(1);
      values.put(Contacts.STARRED,mStarredView.isChecked());
      mContentResolver.update(mContactUri,values,null,null);
      break;
    }
case R.id.photo:
{
    final Intent intent=new Intent(Intents.SHOW_OR_CREATE_CONTACT,mContactUri);
    final Rect target=getTargetRect(view);
    intent.putExtra(Intents.EXTRA_TARGET_RECT,target);
    intent.putExtra(Intents.EXTRA_MODE,Intents.MODE_SMALL);
    if (mExcludeMimes != null) {
      intent.putExtra(Intents.EXTRA_EXCLUDE_MIMES,mExcludeMimes);
    }
    mContext.startActivity(intent);
    break;
  }
}
}

Fixed version (ground truth):
public void onClick(View view){
  if (mContactUri == null) {
    return;
  }
  if (view.getId() == R.id.star) {
    final ContentValues values=new ContentValues(1);
    values.put(Contacts.STARRED,mStarredView.isChecked());
    mContentResolver.update(mContactUri,values,null,null);
  }
}
Program: 183214
Project: 183214
Buggy source:
/** 
 * Bind the contact details provided by the given   {@link Cursor}.
 */
protected void bindContactInfo(Cursor c){
  if (c == null || !c.moveToFirst())   return;
  final String displayName=c.getString(HEADER_DISPLAY_NAME_COLUMN_INDEX);
  final String phoneticName=null;
  this.setDisplayName(displayName,null);
  final boolean starred=c.getInt(HEADER_STARRED_COLUMN_INDEX) != 0;
  mStarredView.setChecked(starred);
  Bitmap photoBitmap=loadContactPhoto(c.getLong(HEADER_PHOTO_ID_COLUMN_INDEX),null);
  if (photoBitmap == null) {
    photoBitmap=loadPlaceholderPhoto(null);
  }
  mPhotoView.setImageBitmap(photoBitmap);
  int presence=c.getInt(HEADER_PRESENCE_STATUS_COLUMN_INDEX);
  mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
}

Fixed version (ground truth):
/** 
 * Bind the contact details provided by the given   {@link Cursor}.
 */
protected void bindContactInfo(Cursor c){
  if (c == null || !c.moveToFirst())   return;
  final String displayName=c.getString(HEADER_DISPLAY_NAME_COLUMN_INDEX);
  final long contactId=c.getLong(HEADER_CONTACT_ID_COLUMN_INDEX);
  final String lookupKey=c.getString(HEADER_LOOKUP_KEY_COLUMN_INDEX);
  final String phoneticName=null;
  this.setDisplayName(displayName,null);
  final boolean starred=c.getInt(HEADER_STARRED_COLUMN_INDEX) != 0;
  mStarredView.setChecked(starred);
  Bitmap photoBitmap=loadContactPhoto(c.getLong(HEADER_PHOTO_ID_COLUMN_INDEX),null);
  if (photoBitmap == null) {
    photoBitmap=loadPlaceholderPhoto(null);
  }
  mPhotoView.setImageBitmap(photoBitmap);
  mPhotoView.assignContactUri(Contacts.getLookupUri(contactId,lookupKey));
  int presence=c.getInt(HEADER_PRESENCE_STATUS_COLUMN_INDEX);
  mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
}
Program: 183215
Project: 183215
Buggy source:
/** 
 * Convenience method for binding all available data from an existing contact.
 * @param number The phone number used to do a reverse lookup inthe contacts database. If more than one contact contains this phone number, one of them will be chosen to bind to.
 */
public void bindFromPhoneNumber(String number){
  Cursor c=null;
  try {
    c=mContentResolver.query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.encode(number)),PHONE_LOOKUP_PROJECTION,null,null,null);
    if (c != null && c.moveToFirst()) {
      long contactId=c.getLong(PHONE_LOOKUP_CONTACT_ID_COLUMN_INDEX);
      bindFromContactId(contactId);
    }
 else {
      setDisplayName(number,null);
    }
  }
  finally {
    if (c != null) {
      c.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method for binding all available data from an existing contact.
 * @param number The phone number used to do a reverse lookup inthe contacts database. If more than one contact contains this phone number, one of them will be chosen to bind to.
 */
public void bindFromPhoneNumber(String number){
  mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP,number,Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,number),PHONE_LOOKUP_PROJECTION,null,null,null);
}
Program: 183216
Project: 183216
Buggy source:
/** 
 * Convenience method for binding all available data from an existing contact.
 * @param emailAddress The email address used to do a reverse lookup inthe contacts database. If more than one contact contains this email address, one of them will be chosen to bind to.
 */
public void bindFromEmail(String emailAddress){
  Cursor c=null;
  try {
    c=mContentResolver.query(Uri.withAppendedPath(Email.CONTENT_FILTER_EMAIL_URI,Uri.encode(emailAddress)),EMAIL_LOOKUP_PROJECTION,null,null,null);
    if (c != null && c.moveToFirst()) {
      long contactId=c.getLong(EMAIL_LOOKUP_CONTACT_ID_COLUMN_INDEX);
      bindFromContactId(contactId);
    }
 else {
      setDisplayName(emailAddress,null);
    }
  }
  finally {
    if (c != null) {
      c.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method for binding all available data from an existing contact.
 * @param emailAddress The email address used to do a reverse lookup inthe contacts database. If more than one contact contains this email address, one of them will be chosen to bind to.
 */
public void bindFromEmail(String emailAddress){
  mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP,emailAddress,Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,Uri.encode(emailAddress)),EMAIL_LOOKUP_PROJECTION,null,null,null);
}
Program: 183217
Project: 183217
Buggy source:
public ContactHeaderWidget(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  mContentResolver=mContext.getContentResolver();
  LayoutInflater inflater=(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.contact_header,this);
  mDisplayNameView=(TextView)findViewById(R.id.name);
  mDisplayNameView.setOnLongClickListener(this);
  mPhoneticNameView=(TextView)findViewById(R.id.phonetic_name);
  mStarredView=(CheckBox)findViewById(R.id.star);
  mStarredView.setOnClickListener(this);
  mPhotoView=(ImageView)findViewById(R.id.photo);
  mPhotoView.setOnClickListener(this);
  mPhotoView.setOnLongClickListener(this);
  mPresenceView=(ImageView)findViewById(R.id.presence);
  mStatusView=(TextView)findViewById(R.id.status);
  long now=SystemClock.elapsedRealtime();
  int num=(int)now & 0xf;
  if (num < 9) {
    mNoPhotoResource=R.drawable.ic_contact_picture;
  }
 else   if (num < 14) {
    mNoPhotoResource=R.drawable.ic_contact_picture_2;
  }
 else {
    mNoPhotoResource=R.drawable.ic_contact_picture_3;
  }
  mQueryHandler=new QueryHandler(mContentResolver);
}

Fixed version (ground truth):
public ContactHeaderWidget(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  mContentResolver=mContext.getContentResolver();
  LayoutInflater inflater=(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.contact_header,this);
  mDisplayNameView=(TextView)findViewById(R.id.name);
  mDisplayNameView.setOnLongClickListener(this);
  mPhoneticNameView=(TextView)findViewById(R.id.phonetic_name);
  mStarredView=(CheckBox)findViewById(R.id.star);
  mStarredView.setOnClickListener(this);
  mPhotoView=(FasttrackBadgeWidget)findViewById(R.id.photo);
  mPhotoView.setOnLongClickListener(this);
  mPresenceView=(ImageView)findViewById(R.id.presence);
  mStatusView=(TextView)findViewById(R.id.status);
  long now=SystemClock.elapsedRealtime();
  int num=(int)now & 0xf;
  if (num < 9) {
    mNoPhotoResource=R.drawable.ic_contact_picture;
  }
 else   if (num < 14) {
    mNoPhotoResource=R.drawable.ic_contact_picture_2;
  }
 else {
    mNoPhotoResource=R.drawable.ic_contact_picture_3;
  }
  mQueryHandler=new QueryHandler(mContentResolver);
}
Program: 183218
Project: 183218
Buggy source:
@Override protected void onQueryComplete(int token,Object cookie,Cursor cursor){
  try {
    if (token == TOKEN_CONTACT_INFO) {
      bindContactInfo(cursor);
      invalidate();
    }
 else     if (token == TOKEN_SOCIAL) {
      bindSocial(cursor);
      invalidate();
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
}

Fixed version (ground truth):
@Override protected void onQueryComplete(int token,Object cookie,Cursor cursor){
  try {
switch (token) {
case TOKEN_CONTACT_INFO:
{
        bindContactInfo(cursor);
        invalidate();
        break;
      }
case TOKEN_SOCIAL:
{
      bindSocial(cursor);
      invalidate();
      break;
    }
case TOKEN_PHONE_LOOKUP:
{
    if (cursor != null && cursor.moveToFirst()) {
      long contactId=cursor.getLong(PHONE_LOOKUP_CONTACT_ID_COLUMN_INDEX);
      String lookupKey=cursor.getString(PHONE_LOOKUP_CONTACT_LOOKUP_KEY_COLUMN_INDEX);
      bindFromContactUri(Contacts.getLookupUri(contactId,lookupKey));
    }
 else {
      setDisplayName((String)cookie,null);
    }
    break;
  }
case TOKEN_EMAIL_LOOKUP:
{
  if (cursor != null && cursor.moveToFirst()) {
    long contactId=cursor.getLong(EMAIL_LOOKUP_CONTACT_ID_COLUMN_INDEX);
    String lookupKey=cursor.getString(EMAIL_LOOKUP_CONTACT_LOOKUP_KEY_COLUMN_INDEX);
    bindFromContactUri(Contacts.getLookupUri(contactId,lookupKey));
  }
 else {
    setDisplayName((String)cookie,null);
  }
  break;
}
case TOKEN_LOOKUP_CONTACT_FOR_SOCIAL_QUERY:
{
if (cursor != null && cursor.moveToFirst()) {
  long contactId=cursor.getLong(CONTACT_LOOKUP_ID_COLUMN_INDEX);
  startSocialQuery(ContentUris.withAppendedId(Activities.CONTENT_CONTACT_STATUS_URI,contactId));
}
}
}
}
  finally {
if (cursor != null) {
cursor.close();
}
}
}
Program: 183220
Project: 183220
Buggy source:
/** 
 * Sets the setting for when the vibrate type should vibrate.
 * @param vibrateType The type of vibrate. One of{@link #VIBRATE_TYPE_NOTIFICATION} or{@link #VIBRATE_TYPE_RINGER}.
 * @param vibrateSetting The vibrate setting, one of{@link #VIBRATE_SETTING_ON},  {@link #VIBRATE_SETTING_OFF}, or  {@link #VIBRATE_SETTING_ONLY_SILENT}.
 * @see #getVibrateSetting(int)
 * @see #shouldVibrate(int)
 */
public void setVibrateSetting(int vibrateType,int vibrateSetting){
  IAudioService service=getService();
  try {
    service.setVibrateSetting(vibrateType,vibrateSetting);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sets the setting for when the vibrate type should vibrate. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param vibrateType The type of vibrate. One of{@link #VIBRATE_TYPE_NOTIFICATION} or{@link #VIBRATE_TYPE_RINGER}.
 * @param vibrateSetting The vibrate setting, one of{@link #VIBRATE_SETTING_ON},  {@link #VIBRATE_SETTING_OFF}, or  {@link #VIBRATE_SETTING_ONLY_SILENT}.
 * @see #getVibrateSetting(int)
 * @see #shouldVibrate(int)
 */
public void setVibrateSetting(int vibrateType,int vibrateSetting){
  IAudioService service=getService();
  try {
    service.setVibrateSetting(vibrateType,vibrateSetting);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183221
Project: 183221
Buggy source:
/** 
 * Adjusts the volume of a particular stream by one step in a direction.
 * @param streamType The stream type to adjust. One of {@link #STREAM_VOICE_CALL},  {@link #STREAM_SYSTEM},   {@link #STREAM_RING},   {@link #STREAM_MUSIC} or{@link #STREAM_ALARM}
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param flags One or more flags.
 * @see #adjustVolume(int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  IAudioService service=getService();
  try {
    service.adjustStreamVolume(streamType,direction,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Adjusts the volume of a particular stream by one step in a direction. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param streamType The stream type to adjust. One of {@link #STREAM_VOICE_CALL},  {@link #STREAM_SYSTEM},   {@link #STREAM_RING},   {@link #STREAM_MUSIC} or{@link #STREAM_ALARM}
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param flags One or more flags.
 * @see #adjustVolume(int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  IAudioService service=getService();
  try {
    service.adjustStreamVolume(streamType,direction,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183222
Project: 183222
Buggy source:
/** 
 * Mute or unmute an audio stream. <p> The mute command is protected against client process death: if a process with an active mute request on a stream dies, this stream will be unmuted automatically. <p> The mute requests for a given stream are cumulative: the AudioManager can receive several mute requests from one or more clients and the stream will be unmuted only when the same number of unmute requests are received. <p> For a better user experience, applications MUST unmute a muted stream in onPause() and mute is again in onResume() if appropriate.
 * @param streamType The stream to be muted/unmuted.
 * @param state The required mute state: true for mute ON, false for mute OFF
 */
public void setStreamMute(int streamType,boolean state){
  IAudioService service=getService();
  try {
    service.setStreamMute(streamType,state,mICallBack);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Mute or unmute an audio stream. <p> The mute command is protected against client process death: if a process with an active mute request on a stream dies, this stream will be unmuted automatically. <p> The mute requests for a given stream are cumulative: the AudioManager can receive several mute requests from one or more clients and the stream will be unmuted only when the same number of unmute requests are received. <p> For a better user experience, applications MUST unmute a muted stream in onPause() and mute is again in onResume() if appropriate. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param streamType The stream to be muted/unmuted.
 * @param state The required mute state: true for mute ON, false for mute OFF
 */
public void setStreamMute(int streamType,boolean state){
  IAudioService service=getService();
  try {
    service.setStreamMute(streamType,state,mICallBack);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183223
Project: 183223
Buggy source:
/** 
 * Adjusts the volume of the most relevant stream, or the given fallback stream.
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param suggestedStreamType The stream type that will be used if thereisn't a relevant stream.  {@link #USE_DEFAULT_STREAM_TYPE} is valid here.
 * @param flags One or more flags.
 * @see #adjustVolume(int,int)
 * @see #adjustStreamVolume(int,int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustSuggestedStreamVolume(int direction,int suggestedStreamType,int flags){
  IAudioService service=getService();
  try {
    service.adjustSuggestedStreamVolume(direction,suggestedStreamType,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Adjusts the volume of the most relevant stream, or the given fallback stream. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param suggestedStreamType The stream type that will be used if thereisn't a relevant stream.  {@link #USE_DEFAULT_STREAM_TYPE} is valid here.
 * @param flags One or more flags.
 * @see #adjustVolume(int,int)
 * @see #adjustStreamVolume(int,int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustSuggestedStreamVolume(int direction,int suggestedStreamType,int flags){
  IAudioService service=getService();
  try {
    service.adjustSuggestedStreamVolume(direction,suggestedStreamType,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183224
Project: 183224
Buggy source:
/** 
 * Adjusts the volume of the most relevant stream. For example, if a call is active, it will have the highest priority regardless of if the in-call screen is showing. Another example, if music is playing in the background and a call is not active, the music stream will be adjusted.
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param flags One or more flags.
 * @see #adjustSuggestedStreamVolume(int,int,int)
 * @see #adjustStreamVolume(int,int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustVolume(int direction,int flags){
  IAudioService service=getService();
  try {
    service.adjustVolume(direction,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Adjusts the volume of the most relevant stream. For example, if a call is active, it will have the highest priority regardless of if the in-call screen is showing. Another example, if music is playing in the background and a call is not active, the music stream will be adjusted. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param direction The direction to adjust the volume. One of{@link #ADJUST_LOWER},   {@link #ADJUST_RAISE}, or  {@link #ADJUST_SAME}.
 * @param flags One or more flags.
 * @see #adjustSuggestedStreamVolume(int,int,int)
 * @see #adjustStreamVolume(int,int,int)
 * @see #setStreamVolume(int,int,int)
 */
public void adjustVolume(int direction,int flags){
  IAudioService service=getService();
  try {
    service.adjustVolume(direction,flags);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183225
Project: 183225
Buggy source:
/** 
 * Request use of Bluetooth SCO headset for communications.
 * @param on set <var>true</var> to use bluetooth SCO for communications;<var>false</var> to not use bluetooth SCO for communications
 */
public void setBluetoothScoOn(boolean on){
  IAudioService service=getService();
  try {
    service.setBluetoothScoOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Request use of Bluetooth SCO headset for communications. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param on set <var>true</var> to use bluetooth SCO for communications;<var>false</var> to not use bluetooth SCO for communications
 */
public void setBluetoothScoOn(boolean on){
  IAudioService service=getService();
  try {
    service.setBluetoothScoOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183226
Project: 183226
Buggy source:
/** 
 * Sets the microphone mute on or off.
 * @param on set <var>true</var> to mute the microphone;<var>false</var> to turn mute off
 */
public void setMicrophoneMute(boolean on){
  AudioSystem.muteMicrophone(on);
}

Fixed version (ground truth):
/** 
 * Sets the microphone mute on or off. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param on set <var>true</var> to mute the microphone;<var>false</var> to turn mute off
 */
public void setMicrophoneMute(boolean on){
  AudioSystem.muteMicrophone(on);
}
Program: 183227
Project: 183227
Buggy source:
/** 
 * Sets the audio mode.
 * @param mode  the requested audio mode (NORMAL, RINGTONE, or IN_CALL).Informs the HAL about the current audio state so that it can route the audio appropriately.
 */
public void setMode(int mode){
  IAudioService service=getService();
  try {
    service.setMode(mode);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sets the audio mode. <p> The audio mode encompasses audio routing AND the behavior of the telephony layer. Therefore this method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application. In particular, the   {@link #MODE_IN_CALL} mode should only be used by the telephonyapplication when it places a phone call, as it will cause signals from the radio layer to feed the platform mixer.
 * @param mode  the requested audio mode (NORMAL, RINGTONE, or IN_CALL).Informs the HAL about the current audio state so that it can route the audio appropriately.
 */
public void setMode(int mode){
  IAudioService service=getService();
  try {
    service.setMode(mode);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183228
Project: 183228
Buggy source:
/** 
 * Sets the speakerphone on or off.
 * @param on set <var>true</var> to turn on speakerphone;<var>false</var> to turn it off
 */
public void setSpeakerphoneOn(boolean on){
  IAudioService service=getService();
  try {
    service.setSpeakerphoneOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sets the speakerphone on or off. <p> This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
 * @param on set <var>true</var> to turn on speakerphone;<var>false</var> to turn it off
 */
public void setSpeakerphoneOn(boolean on){
  IAudioService service=getService();
  try {
    service.setSpeakerphoneOn(on);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 183230
Project: 183230
Buggy source:
private void updatePhoneState(){
  Phone.State oldState=state;
  if (ringingCall.isRinging()) {
    state=Phone.State.RINGING;
  }
 else   if (pendingMO != null || !(foregroundCall.isIdle() && backgroundCall.isIdle())) {
    state=Phone.State.OFFHOOK;
  }
 else {
    state=Phone.State.IDLE;
  }
  if (state == Phone.State.IDLE && oldState != state) {
    voiceCallEndedRegistrants.notifyRegistrants(new AsyncResult(null,null,null));
  }
 else   if (oldState == Phone.State.IDLE && oldState != state) {
    voiceCallStartedRegistrants.notifyRegistrants(new AsyncResult(null,null,null));
  }
  if (state != oldState) {
    phone.notifyPhoneStateChanged();
  }
}

Fixed version (ground truth):
private void updatePhoneState(){
  Phone.State oldState=state;
  if (ringingCall.isRinging()) {
    state=Phone.State.RINGING;
  }
 else   if (pendingMO != null || !(foregroundCall.isIdle() && backgroundCall.isIdle())) {
    state=Phone.State.OFFHOOK;
  }
 else {
    state=Phone.State.IDLE;
  }
  if (state == Phone.State.IDLE && oldState != state) {
    voiceCallEndedRegistrants.notifyRegistrants(new AsyncResult(null,null,null));
  }
 else   if (oldState == Phone.State.IDLE && oldState != state) {
    voiceCallStartedRegistrants.notifyRegistrants(new AsyncResult(null,null,null));
  }
  if (Phone.DEBUG_PHONE) {
    log("String_Node_Str" + oldState + state);
  }
  if (state != oldState) {
    phone.notifyPhoneStateChanged();
  }
}
Program: 183241
Project: 183241
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (!mIsUserSeekable || !isEnabled()) {
    return false;
  }
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    setPressed(true);
  onStartTrackingTouch();
trackTouchEvent(event);
break;
case MotionEvent.ACTION_MOVE:
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
onStopTrackingTouch();
setPressed(false);
break;
}
return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (!mIsUserSeekable || !isEnabled()) {
    return false;
  }
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    setPressed(true);
  onStartTrackingTouch();
trackTouchEvent(event);
break;
case MotionEvent.ACTION_MOVE:
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
invalidate();
break;
case MotionEvent.ACTION_CANCEL:
onStopTrackingTouch();
setPressed(false);
invalidate();
break;
}
return true;
}
Program: 183244
Project: 183244
Buggy source:
/** 
 * @see AudioManager#setBluetoothScoOn() 
 */
public void setBluetoothScoOn(boolean on){
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_BT_SCO);
    AudioSystem.setForceUse(AudioSystem.FOR_RECORD,AudioSystem.FORCE_BT_SCO);
    mForcedUseForComm=AudioSystem.FORCE_BT_SCO;
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
    AudioSystem.setForceUse(AudioSystem.FOR_RECORD,AudioSystem.FORCE_NONE);
    mForcedUseForComm=AudioSystem.FORCE_NONE;
  }
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setBluetoothScoOn() 
 */
public void setBluetoothScoOn(boolean on){
  if (!checkAudioSettingsPermission("String_Node_Str")) {
    return;
  }
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_BT_SCO);
    AudioSystem.setForceUse(AudioSystem.FOR_RECORD,AudioSystem.FORCE_BT_SCO);
    mForcedUseForComm=AudioSystem.FORCE_BT_SCO;
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
    AudioSystem.setForceUse(AudioSystem.FOR_RECORD,AudioSystem.FORCE_NONE);
    mForcedUseForComm=AudioSystem.FORCE_NONE;
  }
}
Program: 183245
Project: 183245
Buggy source:
/** 
 * @see AudioManager#setSpeakerphoneOn() 
 */
public void setSpeakerphoneOn(boolean on){
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_SPEAKER);
    mForcedUseForComm=AudioSystem.FORCE_SPEAKER;
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
    mForcedUseForComm=AudioSystem.FORCE_NONE;
  }
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setSpeakerphoneOn() 
 */
public void setSpeakerphoneOn(boolean on){
  if (!checkAudioSettingsPermission("String_Node_Str")) {
    return;
  }
  if (on) {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_SPEAKER);
    mForcedUseForComm=AudioSystem.FORCE_SPEAKER;
  }
 else {
    AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION,AudioSystem.FORCE_NONE);
    mForcedUseForComm=AudioSystem.FORCE_NONE;
  }
}
Program: 183246
Project: 183246
Buggy source:
public void onTerminate(){
  if (mWriter != null) {
    try {
      mWriter.flush();
      if (mOutputStream != null && mOutputStream instanceof FileOutputStream) {
        ((FileOutputStream)mOutputStream).getFD().sync();
      }
    }
 catch (    IOException e) {
      Log.d(LOG_TAG,"String_Node_Str" + e.getMessage());
    }
 finally {
      try {
        mWriter.close();
      }
 catch (      IOException e) {
      }
    }
  }
}

Fixed version (ground truth):
public void onTerminate(){
  mOnTerminateIsCalled=true;
  if (mWriter != null) {
    try {
      mWriter.flush();
      if (mOutputStream != null && mOutputStream instanceof FileOutputStream) {
        ((FileOutputStream)mOutputStream).getFD().sync();
      }
    }
 catch (    IOException e) {
      Log.d(LOG_TAG,"String_Node_Str" + e.getMessage());
    }
 finally {
      try {
        mWriter.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 183248
Project: 183248
Buggy source:
private void appendVCardEmailLine(StringBuilder builder,int type,String label,String data){
  builder.append(VCARD_PROPERTY_EMAIL);
  builder.append(VCARD_ATTR_SEPARATOR);
switch (type) {
case Email.TYPE_CUSTOM:
    if (label.equals(android.provider.Contacts.ContactMethodsColumns.MOBILE_EMAIL_TYPE_NAME)) {
      builder.append(Constants.ATTR_TYPE_CELL);
    }
 else     if (mUsesAndroidProperty && VCardUtils.containsOnlyAlphaDigitHyphen(label)) {
      builder.append("String_Node_Str");
      builder.append(label);
    }
 else {
      builder.append(Constants.ATTR_TYPE_INTERNET);
    }
  break;
case Email.TYPE_HOME:
builder.append(Constants.ATTR_TYPE_HOME);
break;
case Email.TYPE_WORK:
builder.append(Constants.ATTR_TYPE_WORK);
break;
case Email.TYPE_OTHER:
builder.append(Constants.ATTR_TYPE_INTERNET);
break;
default :
Log.e(LOG_TAG,"String_Node_Str" + type);
builder.append(Constants.ATTR_TYPE_INTERNET);
break;
}
builder.append(VCARD_DATA_SEPARATOR);
builder.append(data);
builder.append(VCARD_COL_SEPARATOR);
}

Fixed version (ground truth):
private void appendVCardEmailLine(StringBuilder builder,int type,String label,String data){
  builder.append(VCARD_PROPERTY_EMAIL);
  builder.append(VCARD_ATTR_SEPARATOR);
switch (type) {
case Email.TYPE_CUSTOM:
    if (label.equals(android.provider.Contacts.ContactMethodsColumns.MOBILE_EMAIL_TYPE_NAME)) {
      builder.append(Constants.ATTR_TYPE_CELL);
    }
 else     if (mUsesAndroidProperty && VCardUtils.containsOnlyAlphaDigitHyphen(label)) {
      builder.append("String_Node_Str");
      builder.append(label);
    }
 else {
      builder.append(Constants.ATTR_TYPE_INTERNET);
    }
  break;
case Email.TYPE_HOME:
builder.append(Constants.ATTR_TYPE_HOME);
break;
case Email.TYPE_WORK:
builder.append(Constants.ATTR_TYPE_WORK);
break;
case Email.TYPE_OTHER:
builder.append(Constants.ATTR_TYPE_INTERNET);
break;
case Email.TYPE_MOBILE:
builder.append(Constants.ATTR_TYPE_CELL);
break;
default :
Log.e(LOG_TAG,"String_Node_Str" + type);
builder.append(Constants.ATTR_TYPE_INTERNET);
break;
}
builder.append(VCARD_DATA_SEPARATOR);
builder.append(data);
builder.append(VCARD_COL_SEPARATOR);
}
Program: 183249
Project: 183249
Buggy source:
@Override protected void handleAgent(String propertyValue) throws VCardException {
  throw new VCardException("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void handleAgent(String propertyValue){
  if (!mEmittedAgentWarning) {
    Log.w(LOG_TAG,"String_Node_Str");
    mEmittedAgentWarning=true;
  }
}
Program: 183250
Project: 183250
Buggy source:
void detach(){
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  if (mCreated) {
    try {
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.clear();
    mCreated=false;
  }
}

Fixed version (ground truth):
void detach(){
  mDestroyed=true;
  if (mVisible) {
    mVisible=false;
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + this);
    onVisibilityChanged(false);
  }
  if (mDestroyReportNeeded) {
    mDestroyReportNeeded=false;
    SurfaceHolder.Callback callbacks[];
synchronized (mSurfaceHolder.mCallbacks) {
      callbacks=new SurfaceHolder.Callback[mSurfaceHolder.mCallbacks.size()];
      mSurfaceHolder.mCallbacks.toArray(callbacks);
    }
    for (    SurfaceHolder.Callback c : callbacks) {
      c.surfaceDestroyed(mSurfaceHolder);
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mSurfaceHolder + "String_Node_Str"+ this);
    onSurfaceDestroyed(mSurfaceHolder);
  }
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + this);
  onDestroy();
  if (mCreated) {
    try {
      mSession.remove(mWindow);
    }
 catch (    RemoteException e) {
    }
    mSurfaceHolder.mSurface.release();
    mCreated=false;
  }
}
Program: 183252
Project: 183252
Buggy source:
private native void release();

Fixed version (ground truth):
/** 
 * Release the local reference to the server-side surface. @hide 
 */
public native void release();
Program: 183253
Project: 183253
Buggy source:
public void die(boolean immediate){
  checkThread();
  if (Config.LOGV)   Log.v("String_Node_Str","String_Node_Str" + this + "String_Node_Str"+ mSurface);
synchronized (this) {
    if (mAdded && !mFirst) {
      int viewVisibility=mView.getVisibility();
      boolean viewVisibilityChanged=mViewVisibility != viewVisibility;
      if (mWindowAttributesChanged || viewVisibilityChanged) {
        try {
          if ((relayoutWindow(mWindowAttributes,viewVisibility,false) & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
            sWindowSession.finishDrawing(mWindow);
          }
        }
 catch (        RemoteException e) {
        }
      }
      mSurface.clear();
    }
    if (mAdded) {
      mAdded=false;
      if (immediate) {
        dispatchDetachedFromWindow();
      }
 else       if (mView != null) {
        sendEmptyMessage(DIE);
      }
    }
  }
}

Fixed version (ground truth):
public void die(boolean immediate){
  checkThread();
  if (Config.LOGV)   Log.v("String_Node_Str","String_Node_Str" + this + "String_Node_Str"+ mSurface);
synchronized (this) {
    if (mAdded && !mFirst) {
      int viewVisibility=mView.getVisibility();
      boolean viewVisibilityChanged=mViewVisibility != viewVisibility;
      if (mWindowAttributesChanged || viewVisibilityChanged) {
        try {
          if ((relayoutWindow(mWindowAttributes,viewVisibility,false) & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
            sWindowSession.finishDrawing(mWindow);
          }
        }
 catch (        RemoteException e) {
        }
      }
      mSurface.release();
    }
    if (mAdded) {
      mAdded=false;
      if (immediate) {
        dispatchDetachedFromWindow();
      }
 else       if (mView != null) {
        sendEmptyMessage(DIE);
      }
    }
  }
}
Program: 183254
Project: 183254
Buggy source:
void dispatchDetachedFromWindow(){
  if (Config.LOGV)   Log.v("String_Node_Str","String_Node_Str" + this + "String_Node_Str"+ mSurface);
  if (mView != null) {
    mView.dispatchDetachedFromWindow();
  }
  mView=null;
  mAttachInfo.mRootView=null;
  mAttachInfo.mSurface=null;
  if (mUseGL) {
    destroyGL();
  }
  mSurface.clear();
  try {
    sWindowSession.remove(mWindow);
  }
 catch (  RemoteException e) {
  }
}

Fixed version (ground truth):
void dispatchDetachedFromWindow(){
  if (Config.LOGV)   Log.v("String_Node_Str","String_Node_Str" + this + "String_Node_Str"+ mSurface);
  if (mView != null) {
    mView.dispatchDetachedFromWindow();
  }
  mView=null;
  mAttachInfo.mRootView=null;
  mAttachInfo.mSurface=null;
  if (mUseGL) {
    destroyGL();
  }
  mSurface.release();
  try {
    sWindowSession.remove(mWindow);
  }
 catch (  RemoteException e) {
  }
}