nus-yam/ex-repair huggingface dataset:
Program: 198228
Project: 198228
Buggy source:
private int totalBytes(AdvertiseData data){
  if (data == null) {
    return 0;
  }
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}

Fixed version (ground truth):
private int totalBytes(AdvertiseData data){
  if (data == null)   return 0;
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}
Program: 198229
Project: 198229
Buggy source:
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,false,callback));
}

Fixed version (ground truth):
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,true,callback));
}
Program: 198230
Project: 198230
Buggy source:
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,false,callback));
}

Fixed version (ground truth):
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,true,callback));
}
Program: 198231
Project: 198231
Buggy source:
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,false,callback));
}

Fixed version (ground truth):
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,true,callback));
}
Program: 198232
Project: 198232
Buggy source:
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,false,callback));
}

Fixed version (ground truth):
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,true,callback));
}
Program: 198233
Project: 198233
Buggy source:
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,false,callback));
}

Fixed version (ground truth):
@ServiceThreadOnly void doManualPortSwitching(int portId,IHdmiControlCallback callback){
  assertRunOnServiceThread();
  if (!mService.isValidPortId(portId)) {
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  if (portId == getActivePortId()) {
    invokeCallback(callback,HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  mActiveSource.invalidate();
  if (!mService.isControlEnabled()) {
    setActivePortId(portId);
    invokeCallback(callback,HdmiControlManager.RESULT_INCORRECT_MODE);
    return;
  }
  int oldPath=getActivePortId() != Constants.INVALID_PORT_ID ? mService.portIdToPath(getActivePortId()) : getDeviceInfo().getPhysicalAddress();
  int newPath=mService.portIdToPath(portId);
  HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(mAddress,oldPath,newPath);
  mService.sendCecCommand(routingChange);
  removeAction(RoutingControlAction.class);
  addAndStartAction(new RoutingControlAction(this,newPath,true,callback));
}
Program: 198234
Project: 198234
Buggy source:
@Override public void run(){
  callback.onStartFailure(error);
}

Fixed version (ground truth):
@Override public void run(){
  callback.onStartSuccess(settings);
}
Program: 198236
Project: 198236
Buggy source:
/** 
 * Stop Bluetooth LE advertising. The   {@code callback} must be the same one use in{@link BluetoothLeAdvertiser#startAdvertising}. <p> Requires   {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
 * @param callback {@link AdvertiseCallback} identifies the advertising instance to stop.
 */
public void stopAdvertising(final AdvertiseCallback callback){
  checkAdapterState();
  if (callback == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  AdvertiseCallbackWrapper wrapper=mLeAdvertisers.get(callback);
  if (wrapper == null)   return;
  try {
    IBluetoothGatt gatt=mBluetoothManager.getBluetoothGatt();
    if (gatt != null)     gatt.stopMultiAdvertising(wrapper.mClientIf);
    if (wrapper.advertiseStopped()) {
      mLeAdvertisers.remove(callback);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void stopAdvertising(){
synchronized (this) {
    try {
      mBluetoothGatt.stopMultiAdvertising(mClientIf);
      wait(LE_CALLBACK_TIMEOUT_MILLIS);
    }
 catch (    InterruptedException|RemoteException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
    if (mLeAdvertisers.containsKey(mAdvertiseCallback)) {
      mLeAdvertisers.remove(mAdvertiseCallback);
    }
  }
}
Program: 198237
Project: 198237
Buggy source:
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        mClientIf=-1;
        notifyAll();
      }
    }
 else {
      mClientIf=-1;
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
        return;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    mClientIf=-1;
    notifyAll();
  }
}
Program: 198238
Project: 198238
Buggy source:
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mAdvertiseCallback.onStartSuccess(settings);
        mIsAdvertising=true;
      }
 else {
        mAdvertiseCallback.onStartFailure(status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}

Fixed version (ground truth):
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mIsAdvertising=true;
        postStartSuccess(mAdvertiseCallback,settings);
      }
 else {
        postStartFailure(mAdvertiseCallback,status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
        mLeAdvertisers.remove(mAdvertiseCallback);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}
Program: 198239
Project: 198239
Buggy source:
private int totalBytes(AdvertiseData data){
  if (data == null) {
    return 0;
  }
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}

Fixed version (ground truth):
private int totalBytes(AdvertiseData data){
  if (data == null)   return 0;
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}
Program: 198240
Project: 198240
Buggy source:
@Override public void run(){
  callback.onStartFailure(error);
}

Fixed version (ground truth):
@Override public void run(){
  callback.onStartSuccess(settings);
}
Program: 198242
Project: 198242
Buggy source:
/** 
 * Stop Bluetooth LE advertising. The   {@code callback} must be the same one use in{@link BluetoothLeAdvertiser#startAdvertising}. <p> Requires   {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
 * @param callback {@link AdvertiseCallback} identifies the advertising instance to stop.
 */
public void stopAdvertising(final AdvertiseCallback callback){
  checkAdapterState();
  if (callback == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  AdvertiseCallbackWrapper wrapper=mLeAdvertisers.get(callback);
  if (wrapper == null)   return;
  try {
    IBluetoothGatt gatt=mBluetoothManager.getBluetoothGatt();
    if (gatt != null)     gatt.stopMultiAdvertising(wrapper.mClientIf);
    if (wrapper.advertiseStopped()) {
      mLeAdvertisers.remove(callback);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void stopAdvertising(){
synchronized (this) {
    try {
      mBluetoothGatt.stopMultiAdvertising(mClientIf);
      wait(LE_CALLBACK_TIMEOUT_MILLIS);
    }
 catch (    InterruptedException|RemoteException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
    if (mLeAdvertisers.containsKey(mAdvertiseCallback)) {
      mLeAdvertisers.remove(mAdvertiseCallback);
    }
  }
}
Program: 198243
Project: 198243
Buggy source:
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        mClientIf=-1;
        notifyAll();
      }
    }
 else {
      mClientIf=-1;
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
        return;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    mClientIf=-1;
    notifyAll();
  }
}
Program: 198244
Project: 198244
Buggy source:
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mAdvertiseCallback.onStartSuccess(settings);
        mIsAdvertising=true;
      }
 else {
        mAdvertiseCallback.onStartFailure(status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}

Fixed version (ground truth):
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mIsAdvertising=true;
        postStartSuccess(mAdvertiseCallback,settings);
      }
 else {
        postStartFailure(mAdvertiseCallback,status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
        mLeAdvertisers.remove(mAdvertiseCallback);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}
Program: 198245
Project: 198245
Buggy source:
private int totalBytes(AdvertiseData data){
  if (data == null) {
    return 0;
  }
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}

Fixed version (ground truth):
private int totalBytes(AdvertiseData data){
  if (data == null)   return 0;
  int size=FLAGS_FIELD_BYTES;
  if (data.getServiceUuids() != null) {
    int num16BitUuids=0;
    int num32BitUuids=0;
    int num128BitUuids=0;
    for (    ParcelUuid uuid : data.getServiceUuids()) {
      if (BluetoothUuid.is16BitUuid(uuid)) {
        ++num16BitUuids;
      }
 else       if (BluetoothUuid.is32BitUuid(uuid)) {
        ++num32BitUuids;
      }
 else {
        ++num128BitUuids;
      }
    }
    if (num16BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num16BitUuids * BluetoothUuid.UUID_BYTES_16_BIT;
    }
    if (num32BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num32BitUuids * BluetoothUuid.UUID_BYTES_32_BIT;
    }
    if (num128BitUuids != 0) {
      size+=OVERHEAD_BYTES_PER_FIELD + num128BitUuids * BluetoothUuid.UUID_BYTES_128_BIT;
    }
  }
  for (  ParcelUuid uuid : data.getServiceData().keySet()) {
    size+=OVERHEAD_BYTES_PER_FIELD + SERVICE_DATA_UUID_LENGTH + byteLength(data.getServiceData().get(uuid));
  }
  for (int i=0; i < data.getManufacturerSpecificData().size(); ++i) {
    size+=OVERHEAD_BYTES_PER_FIELD + MANUFACTURER_SPECIFIC_DATA_LENGTH + byteLength(data.getManufacturerSpecificData().valueAt(i));
  }
  if (data.getIncludeTxPowerLevel()) {
    size+=OVERHEAD_BYTES_PER_FIELD + 1;
  }
  if (data.getIncludeDeviceName() && mBluetoothAdapter.getName() != null) {
    size+=OVERHEAD_BYTES_PER_FIELD + mBluetoothAdapter.getName().length();
  }
  return size;
}
Program: 198246
Project: 198246
Buggy source:
private static String createImageFilename(ActivityRecord r,int taskId){
  return String.valueOf(taskId) + ACTIVITY_ICON_SUFFIX + r.createTime+ TaskPersister.IMAGE_EXTENSION;
}

Fixed version (ground truth):
private static String createImageFilename(long createTime,int taskId){
  return String.valueOf(taskId) + ACTIVITY_ICON_SUFFIX + createTime+ TaskPersister.IMAGE_EXTENSION;
}
Program: 198247
Project: 198247
Buggy source:
void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException {
  out.attribute(null,ATTR_ID,String.valueOf(createTime));
  out.attribute(null,ATTR_LAUNCHEDFROMUID,String.valueOf(launchedFromUid));
  if (launchedFromPackage != null) {
    out.attribute(null,ATTR_LAUNCHEDFROMPACKAGE,launchedFromPackage);
  }
  if (resolvedType != null) {
    out.attribute(null,ATTR_RESOLVEDTYPE,resolvedType);
  }
  out.attribute(null,ATTR_COMPONENTSPECIFIED,String.valueOf(componentSpecified));
  out.attribute(null,ATTR_USERID,String.valueOf(userId));
  if (taskDescription != null) {
    task.saveTaskDescription(taskDescription,createImageFilename(this,task.taskId),out);
  }
  out.startTag(null,TAG_INTENT);
  intent.saveToXml(out);
  out.endTag(null,TAG_INTENT);
  if (isPersistable() && persistentState != null) {
    out.startTag(null,TAG_PERSISTABLEBUNDLE);
    persistentState.saveToXml(out);
    out.endTag(null,TAG_PERSISTABLEBUNDLE);
  }
}

Fixed version (ground truth):
void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException {
  out.attribute(null,ATTR_ID,String.valueOf(createTime));
  out.attribute(null,ATTR_LAUNCHEDFROMUID,String.valueOf(launchedFromUid));
  if (launchedFromPackage != null) {
    out.attribute(null,ATTR_LAUNCHEDFROMPACKAGE,launchedFromPackage);
  }
  if (resolvedType != null) {
    out.attribute(null,ATTR_RESOLVEDTYPE,resolvedType);
  }
  out.attribute(null,ATTR_COMPONENTSPECIFIED,String.valueOf(componentSpecified));
  out.attribute(null,ATTR_USERID,String.valueOf(userId));
  if (taskDescription != null) {
    task.saveTaskDescription(taskDescription,createImageFilename(createTime,task.taskId),out);
  }
  out.startTag(null,TAG_INTENT);
  intent.saveToXml(out);
  out.endTag(null,TAG_INTENT);
  if (isPersistable() && persistentState != null) {
    out.startTag(null,TAG_PERSISTABLEBUNDLE);
    persistentState.saveToXml(out);
    out.endTag(null,TAG_PERSISTABLEBUNDLE);
  }
}
Program: 198251
Project: 198251
Buggy source:
void makeFinishing(){
  if (!finishing) {
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}

Fixed version (ground truth):
void makeFinishing(){
  if (!finishing) {
    if (this == task.stack.getVisibleBehindActivity()) {
      mStackSupervisor.requestVisibleBehindLocked(this,false);
    }
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}
Program: 198252
Project: 198252
Buggy source:
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if (top.fullscreen || top.state != ActivityState.RESUMED || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}

Fixed version (ground truth):
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if ((visible && (top.fullscreen || top.state != ActivityState.RESUMED)) || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
 else   if (!visible && stack.getVisibleBehindActivity() != r) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + visible + "String_Node_Str"+ stack.getVisibleBehindActivity()+ "String_Node_Str"+ r);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}
Program: 198253
Project: 198253
Buggy source:
void makeFinishing(){
  if (!finishing) {
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}

Fixed version (ground truth):
void makeFinishing(){
  if (!finishing) {
    if (this == task.stack.getVisibleBehindActivity()) {
      mStackSupervisor.requestVisibleBehindLocked(this,false);
    }
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}
Program: 198254
Project: 198254
Buggy source:
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if (top.fullscreen || top.state != ActivityState.RESUMED || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}

Fixed version (ground truth):
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if ((visible && (top.fullscreen || top.state != ActivityState.RESUMED)) || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
 else   if (!visible && stack.getVisibleBehindActivity() != r) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + visible + "String_Node_Str"+ stack.getVisibleBehindActivity()+ "String_Node_Str"+ r);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}
Program: 198255
Project: 198255
Buggy source:
void makeFinishing(){
  if (!finishing) {
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}

Fixed version (ground truth):
void makeFinishing(){
  if (!finishing) {
    if (this == task.stack.getVisibleBehindActivity()) {
      mStackSupervisor.requestVisibleBehindLocked(this,false);
    }
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}
Program: 198256
Project: 198256
Buggy source:
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if (top.fullscreen || top.state != ActivityState.RESUMED || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}

Fixed version (ground truth):
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if ((visible && (top.fullscreen || top.state != ActivityState.RESUMED)) || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
 else   if (!visible && stack.getVisibleBehindActivity() != r) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + visible + "String_Node_Str"+ stack.getVisibleBehindActivity()+ "String_Node_Str"+ r);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}
Program: 198257
Project: 198257
Buggy source:
void makeFinishing(){
  if (!finishing) {
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}

Fixed version (ground truth):
void makeFinishing(){
  if (!finishing) {
    if (this == task.stack.getVisibleBehindActivity()) {
      mStackSupervisor.requestVisibleBehindLocked(this,false);
    }
    finishing=true;
    if (stopped) {
      clearOptionsLocked();
    }
  }
}
Program: 198258
Project: 198258
Buggy source:
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if (top.fullscreen || top.state != ActivityState.RESUMED || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}

Fixed version (ground truth):
boolean requestVisibleBehindLocked(ActivityRecord r,boolean visible){
  final ActivityStack stack=r.task.stack;
  if (stack == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str");
    return false;
  }
  final boolean isVisible=stack.hasVisibleBehindActivity();
  if (DEBUG_VISIBLE_BEHIND)   Slog.d(TAG,"String_Node_Str" + r + "String_Node_Str"+ visible+ "String_Node_Str"+ isVisible);
  final ActivityRecord top=topRunningActivityLocked();
  if (top == null || top == r || (visible == isVisible)) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str");
    stack.setVisibleBehindActivity(visible ? r : null);
    return true;
  }
  if ((visible && (top.fullscreen || top.state != ActivityState.RESUMED)) || top.app == null || top.app.thread == null) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + top.fullscreen + "String_Node_Str"+ top.state+ "String_Node_Str"+ top.app+ "String_Node_Str"+ top.app.thread);
    return false;
  }
 else   if (!visible && stack.getVisibleBehindActivity() != r) {
    if (DEBUG_VISIBLE_BEHIND)     Slog.d(TAG,"String_Node_Str" + visible + "String_Node_Str"+ stack.getVisibleBehindActivity()+ "String_Node_Str"+ r);
    return false;
  }
  stack.setVisibleBehindActivity(visible ? r : null);
  if (!visible) {
    final ActivityRecord next=stack.findNextTranslucentActivity(r);
    if (next != null) {
      mService.convertFromTranslucent(next.appToken);
    }
  }
  try {
    top.app.thread.scheduleBackgroundVisibleBehindChanged(top.appToken,visible);
  }
 catch (  RemoteException e) {
  }
  return true;
}
Program: 198259
Project: 198259
Buggy source:
@Override public void run(){
  callback.onStartFailure(error);
}

Fixed version (ground truth):
@Override public void run(){
  callback.onStartSuccess(settings);
}
Program: 198261
Project: 198261
Buggy source:
/** 
 * Stop Bluetooth LE advertising. The   {@code callback} must be the same one use in{@link BluetoothLeAdvertiser#startAdvertising}. <p> Requires   {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
 * @param callback {@link AdvertiseCallback} identifies the advertising instance to stop.
 */
public void stopAdvertising(final AdvertiseCallback callback){
  checkAdapterState();
  if (callback == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  AdvertiseCallbackWrapper wrapper=mLeAdvertisers.get(callback);
  if (wrapper == null)   return;
  try {
    IBluetoothGatt gatt=mBluetoothManager.getBluetoothGatt();
    if (gatt != null)     gatt.stopMultiAdvertising(wrapper.mClientIf);
    if (wrapper.advertiseStopped()) {
      mLeAdvertisers.remove(callback);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void stopAdvertising(){
synchronized (this) {
    try {
      mBluetoothGatt.stopMultiAdvertising(mClientIf);
      wait(LE_CALLBACK_TIMEOUT_MILLIS);
    }
 catch (    InterruptedException|RemoteException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
    if (mLeAdvertisers.containsKey(mAdvertiseCallback)) {
      mLeAdvertisers.remove(mAdvertiseCallback);
    }
  }
}
Program: 198262
Project: 198262
Buggy source:
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        mClientIf=-1;
        notifyAll();
      }
    }
 else {
      mClientIf=-1;
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Application interface registered - app is ready to go
 */
@Override public void onClientRegistered(int status,int clientIf){
  Log.d(TAG,"String_Node_Str" + status + "String_Node_Str"+ clientIf);
synchronized (this) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
      mClientIf=clientIf;
      try {
        mBluetoothGatt.startMultiAdvertising(mClientIf,mAdvertisement,mScanResponse,mSettings);
        return;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    mClientIf=-1;
    notifyAll();
  }
}
Program: 198263
Project: 198263
Buggy source:
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mAdvertiseCallback.onStartSuccess(settings);
        mIsAdvertising=true;
      }
 else {
        mAdvertiseCallback.onStartFailure(status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}

Fixed version (ground truth):
@Override public void onMultiAdvertiseCallback(int status,boolean isStart,AdvertiseSettings settings){
synchronized (this) {
    if (isStart) {
      if (status == AdvertiseCallback.ADVERTISE_SUCCESS) {
        mIsAdvertising=true;
        postStartSuccess(mAdvertiseCallback,settings);
      }
 else {
        postStartFailure(mAdvertiseCallback,status);
      }
    }
 else {
      try {
        mBluetoothGatt.unregisterClient(mClientIf);
        mClientIf=-1;
        mIsAdvertising=false;
        mLeAdvertisers.remove(mAdvertiseCallback);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
    notifyAll();
  }
}