nus-yam/ex-repair huggingface dataset:
Program: 198016
Project: 198016
Buggy source:
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) {
    Slog.w(TAG,"String_Node_Str" + keyCode);
    return;
  }
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}
Program: 198019
Project: 198019
Buggy source:
public boolean handleApplicationWtf(IBinder app,String tag,ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeStrongBinder(app);
  data.writeString(tag);
  crashInfo.writeToParcel(data,0);
  mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}

Fixed version (ground truth):
public boolean handleApplicationWtf(IBinder app,String tag,boolean system,ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeStrongBinder(app);
  data.writeString(tag);
  data.writeInt(system ? 1 : 0);
  crashInfo.writeToParcel(data,0);
  mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}
Program: 198020
Project: 198020
Buggy source:
public boolean handleApplicationWtf(IBinder app,String tag,ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException ;

Fixed version (ground truth):
public boolean handleApplicationWtf(IBinder app,String tag,boolean system,ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException ;
Program: 198021
Project: 198021
Buggy source:
static int wtf(int logId,String tag,String msg,Throwable tr,boolean localStack){
  TerribleFailure what=new TerribleFailure(msg,tr);
  int bytes=println_native(logId,ASSERT,tag,msg + '\n' + getStackTraceString(localStack ? what : tr));
  sWtfHandler.onTerribleFailure(tag,what);
  return bytes;
}

Fixed version (ground truth):
static int wtf(int logId,String tag,String msg,Throwable tr,boolean localStack,boolean system){
  TerribleFailure what=new TerribleFailure(msg,tr);
  int bytes=println_native(logId,ASSERT,tag,msg + '\n' + getStackTraceString(localStack ? what : tr));
  sWtfHandler.onTerribleFailure(tag,what,system);
  return bytes;
}
Program: 198022
Project: 198022
Buggy source:
/** 
 * Like   {@link #wtf(String,String)}, but also writes to the log the full call stack.
 * @hide
 */
public static int wtfStack(String tag,String msg){
  return wtf(LOG_ID_MAIN,tag,msg,null,true);
}

Fixed version (ground truth):
/** 
 * Like   {@link #wtf(String,String)}, but also writes to the log the full call stack.
 * @hide
 */
public static int wtfStack(String tag,String msg){
  return wtf(LOG_ID_MAIN,tag,msg,null,true,false);
}
Program: 198023
Project: 198023
Buggy source:
public void onTerribleFailure(String tag,TerribleFailure what){
  RuntimeInit.wtf(tag,what);
}

Fixed version (ground truth):
public void onTerribleFailure(String tag,TerribleFailure what,boolean system){
  RuntimeInit.wtf(tag,what,system);
}
Program: 198024
Project: 198024
Buggy source:
public static int wtf(String tag,String msg,Throwable tr){
  return Log.wtf(Log.LOG_ID_SYSTEM,tag,msg,tr,false);
}

Fixed version (ground truth):
public static int wtf(String tag,String msg,Throwable tr){
  return Log.wtf(Log.LOG_ID_SYSTEM,tag,msg,tr,false,true);
}
Program: 198025
Project: 198025
Buggy source:
public static int wtfStack(String tag,String msg){
  return Log.wtf(Log.LOG_ID_SYSTEM,tag,msg,null,true);
}

Fixed version (ground truth):
public static int wtfStack(String tag,String msg){
  return Log.wtf(Log.LOG_ID_SYSTEM,tag,msg,null,true,true);
}
Program: 198026
Project: 198026
Buggy source:
/** 
 * Report a serious error in the current process.  May or may not cause the process to terminate (depends on system settings).
 * @param tag to record with the error
 * @param t exception describing the error site and conditions
 */
public static void wtf(String tag,Throwable t){
  try {
    if (ActivityManagerNative.getDefault().handleApplicationWtf(mApplicationObject,tag,new ApplicationErrorReport.CrashInfo(t))) {
      Process.killProcess(Process.myPid());
      System.exit(10);
    }
  }
 catch (  Throwable t2) {
    Slog.e(TAG,"String_Node_Str",t2);
    Slog.e(TAG,"String_Node_Str",t);
  }
}

Fixed version (ground truth):
/** 
 * Report a serious error in the current process.  May or may not cause the process to terminate (depends on system settings).
 * @param tag to record with the error
 * @param t exception describing the error site and conditions
 */
public static void wtf(String tag,Throwable t,boolean system){
  try {
    if (ActivityManagerNative.getDefault().handleApplicationWtf(mApplicationObject,tag,system,new ApplicationErrorReport.CrashInfo(t))) {
      Process.killProcess(Process.myPid());
      System.exit(10);
    }
  }
 catch (  Throwable t2) {
    Slog.e(TAG,"String_Node_Str",t2);
    Slog.e(TAG,"String_Node_Str",t);
  }
}
Program: 198028
Project: 198028
Buggy source:
/** 
 * Used by   {@link Log} via {@link com.android.internal.os.RuntimeInit} to report serious errors.
 * @param app object of the crashing app, null for the system server
 * @param tag reported by the caller
 * @param crashInfo describing the context of the error
 * @return true if the process should exit immediately (WTF is fatal)
 */
public boolean handleApplicationWtf(IBinder app,String tag,ApplicationErrorReport.CrashInfo crashInfo){
  ProcessRecord r=findAppProcess(app,"String_Node_Str");
  final String processName=app == null ? "String_Node_Str" : (r == null ? "String_Node_Str" : r.processName);
  EventLog.writeEvent(EventLogTags.AM_WTF,UserHandle.getUserId(Binder.getCallingUid()),Binder.getCallingPid(),processName,r == null ? -1 : r.info.flags,tag,crashInfo.exceptionMessage);
  addErrorToDropBox("String_Node_Str",r,processName,null,null,tag,null,null,crashInfo);
  if (r != null && r.pid != Process.myPid() && Settings.Global.getInt(mContext.getContentResolver(),Settings.Global.WTF_IS_FATAL,0) != 0) {
    crashApplication(r,crashInfo);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Used by   {@link Log} via {@link com.android.internal.os.RuntimeInit} to report serious errors.
 * @param app object of the crashing app, null for the system server
 * @param tag reported by the caller
 * @param system whether this wtf is coming from the system
 * @param crashInfo describing the context of the error
 * @return true if the process should exit immediately (WTF is fatal)
 */
public boolean handleApplicationWtf(IBinder app,final String tag,boolean system,final ApplicationErrorReport.CrashInfo crashInfo){
  final ProcessRecord r=findAppProcess(app,"String_Node_Str");
  final String processName=app == null ? "String_Node_Str" : (r == null ? "String_Node_Str" : r.processName);
  EventLog.writeEvent(EventLogTags.AM_WTF,UserHandle.getUserId(Binder.getCallingUid()),Binder.getCallingPid(),processName,r == null ? -1 : r.info.flags,tag,crashInfo.exceptionMessage);
  if (system) {
    mHandler.post(new Runnable(){
      @Override public void run(){
        addErrorToDropBox("String_Node_Str",r,processName,null,null,tag,null,null,crashInfo);
      }
    }
);
    return false;
  }
  addErrorToDropBox("String_Node_Str",r,processName,null,null,tag,null,null,crashInfo);
  if (r != null && r.pid != Process.myPid() && Settings.Global.getInt(mContext.getContentResolver(),Settings.Global.WTF_IS_FATAL,0) != 0) {
    crashApplication(r,crashInfo);
    return true;
  }
 else {
    return false;
  }
}
Program: 198029
Project: 198029
Buggy source:
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) {
    Slog.w(TAG,"String_Node_Str" + keyCode);
    return;
  }
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}
Program: 198032
Project: 198032
Buggy source:
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) {
    Slog.w(TAG,"String_Node_Str" + keyCode);
    return;
  }
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}
Program: 198033
Project: 198033
Buggy source:
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sends key to a target CEC device.
 * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
 * @param isPressed true if this is key press event
 */
@Override @ServiceThreadOnly protected void sendKeyEvent(int keyCode,boolean isPressed){
  assertRunOnServiceThread();
  if (!HdmiCecKeycode.isSupportedKeycode(keyCode)) {
    Slog.w(TAG,"String_Node_Str" + keyCode);
    return;
  }
  List<SendKeyAction> action=getActions(SendKeyAction.class);
  if (!action.isEmpty()) {
    action.get(0).processKeyEvent(keyCode,isPressed);
  }
 else {
    if (isPressed && getActiveSource().isValid()) {
      int logicalAddress=getActiveSource().logicalAddress;
      addAndStartAction(new SendKeyAction(this,logicalAddress,keyCode));
    }
 else {
      Slog.w(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ isPressed);
    }
  }
}
Program: 198034
Project: 198034
Buggy source:
@Override @ServiceThreadOnly protected boolean handleInitiateArc(HdmiCecMessage message){
  assertRunOnServiceThread();
  removeAction(RequestArcInitiationAction.class);
  SetArcTransmissionStateAction action=new SetArcTransmissionStateAction(this,message.getSource(),true);
  addAndStartAction(action);
  return true;
}

Fixed version (ground truth):
@Override @ServiceThreadOnly protected boolean handleInitiateArc(HdmiCecMessage message){
  assertRunOnServiceThread();
  if (!canStartArcUpdateAction(message.getSource(),true)) {
    mService.maySendFeatureAbortCommand(message,Constants.ABORT_REFUSED);
    if (!isConnectedToArcPort(message.getSource())) {
      displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
    }
    return true;
  }
  removeAction(RequestArcInitiationAction.class);
  SetArcTransmissionStateAction action=new SetArcTransmissionStateAction(this,message.getSource(),true);
  addAndStartAction(action);
  return true;
}
Program: 198035
Project: 198035
Buggy source:
@ServiceThreadOnly private void startArcAction(boolean enabled){
  assertRunOnServiceThread();
  HdmiDeviceInfo info=getAvrDeviceInfo();
  if (info == null) {
    return;
  }
  if (!isConnectedToArcPort(info.getPhysicalAddress())) {
    return;
  }
  if (enabled) {
    removeAction(RequestArcTerminationAction.class);
    if (!hasAction(RequestArcInitiationAction.class)) {
      addAndStartAction(new RequestArcInitiationAction(this,info.getLogicalAddress()));
    }
  }
 else {
    removeAction(RequestArcInitiationAction.class);
    if (!hasAction(RequestArcTerminationAction.class)) {
      addAndStartAction(new RequestArcTerminationAction(this,info.getLogicalAddress()));
    }
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void startArcAction(boolean enabled){
  assertRunOnServiceThread();
  HdmiDeviceInfo info=getAvrDeviceInfo();
  if (info == null) {
    Slog.w(TAG,"String_Node_Str");
    return;
  }
  if (!canStartArcUpdateAction(info.getLogicalAddress(),enabled)) {
    Slog.w(TAG,"String_Node_Str");
    if (enabled && !isConnectedToArcPort(info.getPhysicalAddress())) {
      displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
    }
    return;
  }
  if (enabled) {
    removeAction(RequestArcTerminationAction.class);
    if (!hasAction(RequestArcInitiationAction.class)) {
      addAndStartAction(new RequestArcInitiationAction(this,info.getLogicalAddress()));
    }
  }
 else {
    removeAction(RequestArcInitiationAction.class);
    if (!hasAction(RequestArcTerminationAction.class)) {
      addAndStartAction(new RequestArcTerminationAction(this,info.getLogicalAddress()));
    }
  }
}
Program: 198036
Project: 198036
Buggy source:
/** 
 * Return a   {@link HdmiDeviceInfo} corresponding to the given {@code logicalAddress}. This is not thread-safe. For thread safety, call   {@link #getSafeCecDeviceInfo(int)}.
 * @param address logical address of the device to be retrieved
 * @return {@link HdmiDeviceInfo} matched with the given {@code logicalAddress}. Returns null if no logical address matched
 */
@ServiceThreadOnly HdmiDeviceInfo getCecDeviceInfo(int logicalAddress){
  assertRunOnServiceThread();
  return mDeviceInfos.get(HdmiDeviceInfo.idForCecDevice(logicalAddress));
}

Fixed version (ground truth):
/** 
 * Return a   {@link HdmiDeviceInfo} corresponding to the given {@code logicalAddress}. This is not thread-safe. For thread safety, call   {@link #getSafeCecDeviceInfo(int)}.
 * @param logicalAddress logical address of the device to be retrieved
 * @return {@link HdmiDeviceInfo} matched with the given {@code logicalAddress}. Returns null if no logical address matched
 */
@ServiceThreadOnly HdmiDeviceInfo getCecDeviceInfo(int logicalAddress){
  assertRunOnServiceThread();
  return mDeviceInfos.get(HdmiDeviceInfo.idForCecDevice(logicalAddress));
}
Program: 198037
Project: 198037
Buggy source:
void displayOsd(int messageId){
  Intent intent=new Intent(HdmiControlManager.ACTION_OSD_MESSAGE);
  intent.putExtra(HdmiControlManager.EXTRA_MESSAGE_ID,messageId);
  mService.getContext().sendBroadcastAsUser(intent,UserHandle.ALL,HdmiControlService.PERMISSION);
}

Fixed version (ground truth):
@ServiceThreadOnly void displayOsd(int messageId){
  assertRunOnServiceThread();
  mService.displayOsd(messageId);
}
Program: 198038
Project: 198038
Buggy source:
/** 
 * Return a list of all   {@link HdmiDeviceInfo}. <p>Declared as package-private. accessed by   {@link HdmiControlService} only.This is not thread-safe. For thread safety, call  {@link #getSafeExternalInputs} whichdoes not include local device.
 */
@ServiceThreadOnly List<HdmiDeviceInfo> getDeviceInfoList(boolean includelLocalDevice){
  assertRunOnServiceThread();
  if (includelLocalDevice) {
    return HdmiUtils.sparseArrayToList(mDeviceInfos);
  }
 else {
    ArrayList<HdmiDeviceInfo> infoList=new ArrayList<>();
    for (int i=0; i < mDeviceInfos.size(); ++i) {
      HdmiDeviceInfo info=mDeviceInfos.valueAt(i);
      if (!isLocalDeviceAddress(info.getLogicalAddress())) {
        infoList.add(info);
      }
    }
    return infoList;
  }
}

Fixed version (ground truth):
/** 
 * Return a list of all   {@link HdmiDeviceInfo}. <p>Declared as package-private. accessed by   {@link HdmiControlService} only.This is not thread-safe. For thread safety, call  {@link #getSafeExternalInputsLocked} whichdoes not include local device.
 */
@ServiceThreadOnly List<HdmiDeviceInfo> getDeviceInfoList(boolean includelLocalDevice){
  assertRunOnServiceThread();
  if (includelLocalDevice) {
    return HdmiUtils.sparseArrayToList(mDeviceInfos);
  }
 else {
    ArrayList<HdmiDeviceInfo> infoList=new ArrayList<>();
    for (int i=0; i < mDeviceInfos.size(); ++i) {
      HdmiDeviceInfo info=mDeviceInfos.valueAt(i);
      if (!isLocalDeviceAddress(info.getLogicalAddress())) {
        infoList.add(info);
      }
    }
    return infoList;
  }
}
Program: 198039
Project: 198039
Buggy source:
@Override public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos){
  for (  HdmiDeviceInfo info : deviceInfos) {
    addCecDevice(info);
  }
  for (  HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
    addCecDevice(device.getDeviceInfo());
  }
  addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
  addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
  if (mSystemAudioActivated && getAvrDeviceInfo() != null) {
    addAndStartAction(new SystemAudioAutoInitiationAction(HdmiCecLocalDeviceTv.this,getAvrDeviceInfo().getLogicalAddress()));
    if (mArcEstablished) {
      startArcAction(true);
    }
  }
}

Fixed version (ground truth):
@Override public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos){
  for (  HdmiDeviceInfo info : deviceInfos) {
    addCecDevice(info);
  }
  for (  HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
    addCecDevice(device.getDeviceInfo());
  }
  addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
  addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
  HdmiDeviceInfo avr=getAvrDeviceInfo();
  if (avr != null) {
    onNewAvrAdded(avr);
  }
}
Program: 198040
Project: 198040
Buggy source:
@ServiceThreadOnly private void launchDeviceDiscovery(){
  assertRunOnServiceThread();
  clearDeviceInfoList();
  DeviceDiscoveryAction action=new DeviceDiscoveryAction(this,new DeviceDiscoveryCallback(){
    @Override public void onDeviceDiscoveryDone(    List<HdmiDeviceInfo> deviceInfos){
      for (      HdmiDeviceInfo info : deviceInfos) {
        addCecDevice(info);
      }
      for (      HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
        addCecDevice(device.getDeviceInfo());
      }
      addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
      addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
      if (mSystemAudioActivated && getAvrDeviceInfo() != null) {
        addAndStartAction(new SystemAudioAutoInitiationAction(HdmiCecLocalDeviceTv.this,getAvrDeviceInfo().getLogicalAddress()));
        if (mArcEstablished) {
          startArcAction(true);
        }
      }
    }
  }
);
  addAndStartAction(action);
}

Fixed version (ground truth):
@ServiceThreadOnly private void launchDeviceDiscovery(){
  assertRunOnServiceThread();
  clearDeviceInfoList();
  DeviceDiscoveryAction action=new DeviceDiscoveryAction(this,new DeviceDiscoveryCallback(){
    @Override public void onDeviceDiscoveryDone(    List<HdmiDeviceInfo> deviceInfos){
      for (      HdmiDeviceInfo info : deviceInfos) {
        addCecDevice(info);
      }
      for (      HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
        addCecDevice(device.getDeviceInfo());
      }
      addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
      addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
      HdmiDeviceInfo avr=getAvrDeviceInfo();
      if (avr != null) {
        onNewAvrAdded(avr);
      }
    }
  }
);
  addAndStartAction(action);
}
Program: 198041
Project: 198041
Buggy source:
@ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled){
  assertRunOnServiceThread();
  if (mArcFeatureEnabled != enabled) {
    if (enabled) {
      if (!mArcEstablished) {
        startArcAction(true);
      }
    }
 else {
      if (mArcEstablished) {
        startArcAction(false);
      }
    }
    mArcFeatureEnabled=enabled;
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled){
  assertRunOnServiceThread();
  if (mArcFeatureEnabled != enabled) {
    mArcFeatureEnabled=enabled;
    if (enabled) {
      if (!mArcEstablished) {
        startArcAction(true);
      }
    }
 else {
      if (mArcEstablished) {
        startArcAction(false);
      }
    }
  }
}
Program: 198042
Project: 198042
Buggy source:
/** 
 * Build &lt;Report Physical Address&gt; command. It has two bytes physical address and one byte device type as parameter. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param address physical address of device
 * @param deviceType type of device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPhysicalAddressCommand(int src,int address,int deviceType){
  byte[] params=new byte[]{(byte)((address >> 8) & 0xFF),(byte)(address & 0xFF),(byte)deviceType};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Report Physical Address&gt; command. It has two bytes physical address and one byte device type as parameter. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param address physical address of device
 * @param deviceType type of device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPhysicalAddressCommand(int src,int address,int deviceType){
  byte[] params=new byte[]{(byte)((address >> 8) & 0xFF),(byte)(address & 0xFF),(byte)(deviceType & 0xFF)};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS,params);
}
Program: 198043
Project: 198043
Buggy source:
/** 
 * Build &lt;Report Power Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param powerStatus power status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPowerStatus(int src,int dest,int powerStatus){
  byte[] param=new byte[]{(byte)(powerStatus)};
  return buildCommand(src,dest,Constants.MESSAGE_REPORT_POWER_STATUS,param);
}

Fixed version (ground truth):
/** 
 * Build &lt;Report Power Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param powerStatus power status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPowerStatus(int src,int dest,int powerStatus){
  byte[] param=new byte[]{(byte)(powerStatus & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_REPORT_POWER_STATUS,param);
}
Program: 198044
Project: 198044
Buggy source:
/** 
 * Build &lt;Feature Abort&gt; command. &lt;Feature Abort&gt; consists of 1 byte original opcode and 1 byte reason fields with basic fields.
 * @param src source address of command
 * @param dest destination address of command
 * @param originalOpcode original opcode causing feature abort
 * @param reason reason of feature abort
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildFeatureAbortCommand(int src,int dest,int originalOpcode,int reason){
  byte[] params=new byte[]{(byte)originalOpcode,(byte)reason};
  return buildCommand(src,dest,Constants.MESSAGE_FEATURE_ABORT,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Feature Abort&gt; command. &lt;Feature Abort&gt; consists of 1 byte original opcode and 1 byte reason fields with basic fields.
 * @param src source address of command
 * @param dest destination address of command
 * @param originalOpcode original opcode causing feature abort
 * @param reason reason of feature abort
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildFeatureAbortCommand(int src,int dest,int originalOpcode,int reason){
  byte[] params=new byte[]{(byte)(originalOpcode & 0xFF),(byte)(reason & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_FEATURE_ABORT,params);
}
Program: 198045
Project: 198045
Buggy source:
private static byte[] physicalAddressToParam(int physicalAddress){
  return new byte[]{(byte)(physicalAddress >> 8),(byte)(physicalAddress & 0xFF)};
}

Fixed version (ground truth):
private static byte[] physicalAddressToParam(int physicalAddress){
  return new byte[]{(byte)((physicalAddress >> 8) & 0xFF),(byte)(physicalAddress & 0xFF)};
}
Program: 198046
Project: 198046
Buggy source:
/** 
 * Build &lt;Set Menu Language &gt; command. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param language 3-letter ISO639-2 based language code
 * @return newly created {@link HdmiCecMessage} if language is valid.Otherwise, return null
 */
static HdmiCecMessage buildSetMenuLanguageCommand(int src,String language){
  if (language.length() != 3) {
    return null;
  }
  String normalized=language.toLowerCase();
  byte[] params=new byte[]{(byte)normalized.charAt(0),(byte)normalized.charAt(1),(byte)normalized.charAt(2)};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_SET_MENU_LANGUAGE,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Set Menu Language &gt; command. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param language 3-letter ISO639-2 based language code
 * @return newly created {@link HdmiCecMessage} if language is valid.Otherwise, return null
 */
static HdmiCecMessage buildSetMenuLanguageCommand(int src,String language){
  if (language.length() != 3) {
    return null;
  }
  String normalized=language.toLowerCase();
  byte[] params=new byte[]{(byte)(normalized.charAt(0) & 0xFF),(byte)(normalized.charAt(1) & 0xFF),(byte)(normalized.charAt(2) & 0xFF)};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_SET_MENU_LANGUAGE,params);
}
Program: 198047
Project: 198047
Buggy source:
/** 
 * Build &lt;Report Menu Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param menuStatus menu status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportMenuStatus(int src,int dest,int menuStatus){
  byte[] param=new byte[]{(byte)(menuStatus)};
  return buildCommand(src,dest,Constants.MESSAGE_MENU_STATUS,param);
}

Fixed version (ground truth):
/** 
 * Build &lt;Report Menu Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param menuStatus menu status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportMenuStatus(int src,int dest,int menuStatus){
  byte[] param=new byte[]{(byte)(menuStatus & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_MENU_STATUS,param);
}
Program: 198048
Project: 198048
Buggy source:
/** 
 * Build &lt;Device Vendor Id&gt; command. It has one byte cec version as parameter.
 * @param src source address of command
 * @param dest destination address of command
 * @param version version of cec. Use 0x04 for "Version 1.3a" and 0x05 for"Version 1.4 or 1.4a or 1.4b
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildCecVersion(int src,int dest,int version){
  byte[] params=new byte[]{(byte)version};
  return buildCommand(src,dest,Constants.MESSAGE_CEC_VERSION,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Device Vendor Id&gt; command. It has one byte cec version as parameter.
 * @param src source address of command
 * @param dest destination address of command
 * @param version version of cec. Use 0x04 for "Version 1.3a" and 0x05 for"Version 1.4 or 1.4a or 1.4b
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildCecVersion(int src,int dest,int version){
  byte[] params=new byte[]{(byte)(version & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_CEC_VERSION,params);
}
Program: 198049
Project: 198049
Buggy source:
/** 
 * Whether a device of the specified physical address is connected to ARC enabled port.
 */
boolean isConnectedToArcPort(int physicalAddress){
  int portId=mPortIdMap.get(physicalAddress);
  if (portId != Constants.INVALID_PORT_ID) {
    return mPortInfoMap.get(portId).isArcSupported();
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Whether a device of the specified physical address is connected to ARC enabled port.
 */
boolean isConnectedToArcPort(int physicalAddress){
  int portId=pathToPortId(physicalAddress);
  if (portId != Constants.INVALID_PORT_ID) {
    return mPortInfoMap.get(portId).isArcSupported();
  }
  return false;
}
Program: 198050
Project: 198050
Buggy source:
private String buildMessage(String message,Pair<Long,Integer> timing,long curTime){
  return new StringBuilder().append("String_Node_Str").append(timing == null ? curTime : timing.second).append("String_Node_Str").append(message).toString();
}

Fixed version (ground truth):
private String buildMessage(String message,@Nullable Pair<Long,Integer> timing){
  return new StringBuilder().append("String_Node_Str").append(timing == null ? 1 : timing.second).append("String_Node_Str").append(message).toString();
}
Program: 198051
Project: 198051
Buggy source:
void warning(String logMessage){
  long curTime=SystemClock.uptimeMillis();
  Pair<Long,Integer> timing=mWarningTimingCache.get(logMessage);
  if (shouldLogNow(timing,curTime)) {
    Slog.w(mTag,buildMessage(logMessage,timing,curTime));
    mWarningTimingCache.put(logMessage,new Pair<>(curTime,1));
  }
 else {
    increaseLogCount(mWarningTimingCache,logMessage);
  }
}

Fixed version (ground truth):
void warning(String logMessage){
  long curTime=SystemClock.uptimeMillis();
  Pair<Long,Integer> timing=mWarningTimingCache.get(logMessage);
  if (shouldLogNow(timing,curTime)) {
    Slog.w(mTag,buildMessage(logMessage,timing));
    mWarningTimingCache.put(logMessage,new Pair<>(curTime,1));
  }
 else {
    increaseLogCount(mWarningTimingCache,logMessage);
  }
}
Program: 198052
Project: 198052
Buggy source:
private boolean shouldLogNow(Pair<Long,Integer> timing,long curTime){
  return timing == null || curTime - timing.first > ERROR_LOG_DURATTION_MILLIS;
}

Fixed version (ground truth):
private boolean shouldLogNow(@Nullable Pair<Long,Integer> timing,long curTime){
  return timing == null || curTime - timing.first > ERROR_LOG_DURATTION_MILLIS;
}
Program: 198053
Project: 198053
Buggy source:
void error(String logMessage){
  long curTime=SystemClock.uptimeMillis();
  Pair<Long,Integer> timing=mErrorTimingCache.get(logMessage);
  if (shouldLogNow(timing,curTime)) {
    Slog.e(mTag,buildMessage(logMessage,timing,curTime));
    mErrorTimingCache.put(logMessage,new Pair<>(curTime,1));
  }
 else {
    increaseLogCount(mErrorTimingCache,logMessage);
  }
}

Fixed version (ground truth):
void error(String logMessage){
  long curTime=SystemClock.uptimeMillis();
  Pair<Long,Integer> timing=mErrorTimingCache.get(logMessage);
  if (shouldLogNow(timing,curTime)) {
    Slog.e(mTag,buildMessage(logMessage,timing));
    mErrorTimingCache.put(logMessage,new Pair<>(curTime,1));
  }
 else {
    increaseLogCount(mErrorTimingCache,logMessage);
  }
}
Program: 198054
Project: 198054
Buggy source:
@Override @ServiceThreadOnly protected boolean handleInitiateArc(HdmiCecMessage message){
  assertRunOnServiceThread();
  removeAction(RequestArcInitiationAction.class);
  SetArcTransmissionStateAction action=new SetArcTransmissionStateAction(this,message.getSource(),true);
  addAndStartAction(action);
  return true;
}

Fixed version (ground truth):
@Override @ServiceThreadOnly protected boolean handleInitiateArc(HdmiCecMessage message){
  assertRunOnServiceThread();
  if (!canStartArcUpdateAction(message.getSource(),true)) {
    mService.maySendFeatureAbortCommand(message,Constants.ABORT_REFUSED);
    if (!isConnectedToArcPort(message.getSource())) {
      displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
    }
    return true;
  }
  removeAction(RequestArcInitiationAction.class);
  SetArcTransmissionStateAction action=new SetArcTransmissionStateAction(this,message.getSource(),true);
  addAndStartAction(action);
  return true;
}
Program: 198055
Project: 198055
Buggy source:
@ServiceThreadOnly private void startArcAction(boolean enabled){
  assertRunOnServiceThread();
  HdmiDeviceInfo info=getAvrDeviceInfo();
  if (info == null) {
    return;
  }
  if (!isConnectedToArcPort(info.getPhysicalAddress())) {
    return;
  }
  if (enabled) {
    removeAction(RequestArcTerminationAction.class);
    if (!hasAction(RequestArcInitiationAction.class)) {
      addAndStartAction(new RequestArcInitiationAction(this,info.getLogicalAddress()));
    }
  }
 else {
    removeAction(RequestArcInitiationAction.class);
    if (!hasAction(RequestArcTerminationAction.class)) {
      addAndStartAction(new RequestArcTerminationAction(this,info.getLogicalAddress()));
    }
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void startArcAction(boolean enabled){
  assertRunOnServiceThread();
  HdmiDeviceInfo info=getAvrDeviceInfo();
  if (info == null) {
    Slog.w(TAG,"String_Node_Str");
    return;
  }
  if (!canStartArcUpdateAction(info.getLogicalAddress(),enabled)) {
    Slog.w(TAG,"String_Node_Str");
    if (enabled && !isConnectedToArcPort(info.getPhysicalAddress())) {
      displayOsd(OSD_MESSAGE_ARC_CONNECTED_INVALID_PORT);
    }
    return;
  }
  if (enabled) {
    removeAction(RequestArcTerminationAction.class);
    if (!hasAction(RequestArcInitiationAction.class)) {
      addAndStartAction(new RequestArcInitiationAction(this,info.getLogicalAddress()));
    }
  }
 else {
    removeAction(RequestArcInitiationAction.class);
    if (!hasAction(RequestArcTerminationAction.class)) {
      addAndStartAction(new RequestArcTerminationAction(this,info.getLogicalAddress()));
    }
  }
}
Program: 198056
Project: 198056
Buggy source:
/** 
 * Return a   {@link HdmiDeviceInfo} corresponding to the given {@code logicalAddress}. This is not thread-safe. For thread safety, call   {@link #getSafeCecDeviceInfo(int)}.
 * @param address logical address of the device to be retrieved
 * @return {@link HdmiDeviceInfo} matched with the given {@code logicalAddress}. Returns null if no logical address matched
 */
@ServiceThreadOnly HdmiDeviceInfo getCecDeviceInfo(int logicalAddress){
  assertRunOnServiceThread();
  return mDeviceInfos.get(HdmiDeviceInfo.idForCecDevice(logicalAddress));
}

Fixed version (ground truth):
/** 
 * Return a   {@link HdmiDeviceInfo} corresponding to the given {@code logicalAddress}. This is not thread-safe. For thread safety, call   {@link #getSafeCecDeviceInfo(int)}.
 * @param logicalAddress logical address of the device to be retrieved
 * @return {@link HdmiDeviceInfo} matched with the given {@code logicalAddress}. Returns null if no logical address matched
 */
@ServiceThreadOnly HdmiDeviceInfo getCecDeviceInfo(int logicalAddress){
  assertRunOnServiceThread();
  return mDeviceInfos.get(HdmiDeviceInfo.idForCecDevice(logicalAddress));
}
Program: 198057
Project: 198057
Buggy source:
void displayOsd(int messageId){
  Intent intent=new Intent(HdmiControlManager.ACTION_OSD_MESSAGE);
  intent.putExtra(HdmiControlManager.EXTRA_MESSAGE_ID,messageId);
  mService.getContext().sendBroadcastAsUser(intent,UserHandle.ALL,HdmiControlService.PERMISSION);
}

Fixed version (ground truth):
@ServiceThreadOnly void displayOsd(int messageId){
  assertRunOnServiceThread();
  mService.displayOsd(messageId);
}
Program: 198058
Project: 198058
Buggy source:
/** 
 * Return a list of all   {@link HdmiDeviceInfo}. <p>Declared as package-private. accessed by   {@link HdmiControlService} only.This is not thread-safe. For thread safety, call  {@link #getSafeExternalInputs} whichdoes not include local device.
 */
@ServiceThreadOnly List<HdmiDeviceInfo> getDeviceInfoList(boolean includelLocalDevice){
  assertRunOnServiceThread();
  if (includelLocalDevice) {
    return HdmiUtils.sparseArrayToList(mDeviceInfos);
  }
 else {
    ArrayList<HdmiDeviceInfo> infoList=new ArrayList<>();
    for (int i=0; i < mDeviceInfos.size(); ++i) {
      HdmiDeviceInfo info=mDeviceInfos.valueAt(i);
      if (!isLocalDeviceAddress(info.getLogicalAddress())) {
        infoList.add(info);
      }
    }
    return infoList;
  }
}

Fixed version (ground truth):
/** 
 * Return a list of all   {@link HdmiDeviceInfo}. <p>Declared as package-private. accessed by   {@link HdmiControlService} only.This is not thread-safe. For thread safety, call  {@link #getSafeExternalInputsLocked} whichdoes not include local device.
 */
@ServiceThreadOnly List<HdmiDeviceInfo> getDeviceInfoList(boolean includelLocalDevice){
  assertRunOnServiceThread();
  if (includelLocalDevice) {
    return HdmiUtils.sparseArrayToList(mDeviceInfos);
  }
 else {
    ArrayList<HdmiDeviceInfo> infoList=new ArrayList<>();
    for (int i=0; i < mDeviceInfos.size(); ++i) {
      HdmiDeviceInfo info=mDeviceInfos.valueAt(i);
      if (!isLocalDeviceAddress(info.getLogicalAddress())) {
        infoList.add(info);
      }
    }
    return infoList;
  }
}
Program: 198059
Project: 198059
Buggy source:
@Override public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos){
  for (  HdmiDeviceInfo info : deviceInfos) {
    addCecDevice(info);
  }
  for (  HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
    addCecDevice(device.getDeviceInfo());
  }
  addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
  addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
  if (mSystemAudioActivated && getAvrDeviceInfo() != null) {
    addAndStartAction(new SystemAudioAutoInitiationAction(HdmiCecLocalDeviceTv.this,getAvrDeviceInfo().getLogicalAddress()));
    if (mArcEstablished) {
      startArcAction(true);
    }
  }
}

Fixed version (ground truth):
@Override public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos){
  for (  HdmiDeviceInfo info : deviceInfos) {
    addCecDevice(info);
  }
  for (  HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
    addCecDevice(device.getDeviceInfo());
  }
  addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
  addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
  HdmiDeviceInfo avr=getAvrDeviceInfo();
  if (avr != null) {
    onNewAvrAdded(avr);
  }
}
Program: 198060
Project: 198060
Buggy source:
@ServiceThreadOnly private void launchDeviceDiscovery(){
  assertRunOnServiceThread();
  clearDeviceInfoList();
  DeviceDiscoveryAction action=new DeviceDiscoveryAction(this,new DeviceDiscoveryCallback(){
    @Override public void onDeviceDiscoveryDone(    List<HdmiDeviceInfo> deviceInfos){
      for (      HdmiDeviceInfo info : deviceInfos) {
        addCecDevice(info);
      }
      for (      HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
        addCecDevice(device.getDeviceInfo());
      }
      addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
      addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
      if (mSystemAudioActivated && getAvrDeviceInfo() != null) {
        addAndStartAction(new SystemAudioAutoInitiationAction(HdmiCecLocalDeviceTv.this,getAvrDeviceInfo().getLogicalAddress()));
        if (mArcEstablished) {
          startArcAction(true);
        }
      }
    }
  }
);
  addAndStartAction(action);
}

Fixed version (ground truth):
@ServiceThreadOnly private void launchDeviceDiscovery(){
  assertRunOnServiceThread();
  clearDeviceInfoList();
  DeviceDiscoveryAction action=new DeviceDiscoveryAction(this,new DeviceDiscoveryCallback(){
    @Override public void onDeviceDiscoveryDone(    List<HdmiDeviceInfo> deviceInfos){
      for (      HdmiDeviceInfo info : deviceInfos) {
        addCecDevice(info);
      }
      for (      HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
        addCecDevice(device.getDeviceInfo());
      }
      addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
      addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
      HdmiDeviceInfo avr=getAvrDeviceInfo();
      if (avr != null) {
        onNewAvrAdded(avr);
      }
    }
  }
);
  addAndStartAction(action);
}
Program: 198061
Project: 198061
Buggy source:
@ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled){
  assertRunOnServiceThread();
  if (mArcFeatureEnabled != enabled) {
    if (enabled) {
      if (!mArcEstablished) {
        startArcAction(true);
      }
    }
 else {
      if (mArcEstablished) {
        startArcAction(false);
      }
    }
    mArcFeatureEnabled=enabled;
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled){
  assertRunOnServiceThread();
  if (mArcFeatureEnabled != enabled) {
    mArcFeatureEnabled=enabled;
    if (enabled) {
      if (!mArcEstablished) {
        startArcAction(true);
      }
    }
 else {
      if (mArcEstablished) {
        startArcAction(false);
      }
    }
  }
}
Program: 198062
Project: 198062
Buggy source:
/** 
 * Build &lt;Report Physical Address&gt; command. It has two bytes physical address and one byte device type as parameter. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param address physical address of device
 * @param deviceType type of device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPhysicalAddressCommand(int src,int address,int deviceType){
  byte[] params=new byte[]{(byte)((address >> 8) & 0xFF),(byte)(address & 0xFF),(byte)deviceType};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Report Physical Address&gt; command. It has two bytes physical address and one byte device type as parameter. <p>This is a broadcast message sent to all devices on the bus.
 * @param src source address of command
 * @param address physical address of device
 * @param deviceType type of device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPhysicalAddressCommand(int src,int address,int deviceType){
  byte[] params=new byte[]{(byte)((address >> 8) & 0xFF),(byte)(address & 0xFF),(byte)(deviceType & 0xFF)};
  return buildCommand(src,Constants.ADDR_BROADCAST,Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS,params);
}
Program: 198063
Project: 198063
Buggy source:
/** 
 * Build &lt;Report Power Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param powerStatus power status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPowerStatus(int src,int dest,int powerStatus){
  byte[] param=new byte[]{(byte)(powerStatus)};
  return buildCommand(src,dest,Constants.MESSAGE_REPORT_POWER_STATUS,param);
}

Fixed version (ground truth):
/** 
 * Build &lt;Report Power Status&gt; command.
 * @param src source address of command
 * @param dest destination address of command
 * @param powerStatus power status of the device
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildReportPowerStatus(int src,int dest,int powerStatus){
  byte[] param=new byte[]{(byte)(powerStatus & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_REPORT_POWER_STATUS,param);
}
Program: 198064
Project: 198064
Buggy source:
/** 
 * Build &lt;Feature Abort&gt; command. &lt;Feature Abort&gt; consists of 1 byte original opcode and 1 byte reason fields with basic fields.
 * @param src source address of command
 * @param dest destination address of command
 * @param originalOpcode original opcode causing feature abort
 * @param reason reason of feature abort
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildFeatureAbortCommand(int src,int dest,int originalOpcode,int reason){
  byte[] params=new byte[]{(byte)originalOpcode,(byte)reason};
  return buildCommand(src,dest,Constants.MESSAGE_FEATURE_ABORT,params);
}

Fixed version (ground truth):
/** 
 * Build &lt;Feature Abort&gt; command. &lt;Feature Abort&gt; consists of 1 byte original opcode and 1 byte reason fields with basic fields.
 * @param src source address of command
 * @param dest destination address of command
 * @param originalOpcode original opcode causing feature abort
 * @param reason reason of feature abort
 * @return newly created {@link HdmiCecMessage}
 */
static HdmiCecMessage buildFeatureAbortCommand(int src,int dest,int originalOpcode,int reason){
  byte[] params=new byte[]{(byte)(originalOpcode & 0xFF),(byte)(reason & 0xFF)};
  return buildCommand(src,dest,Constants.MESSAGE_FEATURE_ABORT,params);
}
Program: 198065
Project: 198065
Buggy source:
private static byte[] physicalAddressToParam(int physicalAddress){
  return new byte[]{(byte)(physicalAddress >> 8),(byte)(physicalAddress & 0xFF)};
}

Fixed version (ground truth):
private static byte[] physicalAddressToParam(int physicalAddress){
  return new byte[]{(byte)((physicalAddress >> 8) & 0xFF),(byte)(physicalAddress & 0xFF)};
}