nus-yam/ex-repair huggingface dataset:
Program: 38924
Project: 38924
Buggy source:
@Override public void export(Network network,Properties parameters,DataSource dataSource){
  if (network == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  XMLExportOptions options=new XMLExportOptions();
  if (parameters != null) {
    options.setIndent(!"String_Node_Str".equals(parameters.getProperty(INDENT_PROPERTY))).setWithBranchSV("String_Node_Str".equals(parameters.getProperty(WITH_BRANCH_STATE_VARIABLES_PROPERTY))).setForceBusBranchTopo("String_Node_Str".equals(parameters.getProperty(FORCE_BUS_BRANCH_TOPO_PROPERTY,"String_Node_Str"))).setOnlyMainCc("String_Node_Str".equals(parameters.getProperty(ONLY_MAIN_CC_PROPERTIES))).setAnonymized("String_Node_Str".equals(parameters.getProperty(ANONYMISED_PROPERTIES))).setSkipExtensions("String_Node_Str".equals(parameters.getProperty(SKIP_EXTENSIONS_PROPERTIES)));
  }
  try {
    long startTime=System.currentTimeMillis();
    try (OutputStream os=dataSource.newOutputStream(null,"String_Node_Str",false);BufferedOutputStream bos=new BufferedOutputStream(os)){
      Anonymizer anonymizer=NetworkXml.write(network,options,bos);
      if (anonymizer != null) {
        try (BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(dataSource.newOutputStream("String_Node_Str","String_Node_Str",false)))){
          anonymizer.write(writer);
        }
       }
    }
     LOGGER.debug("String_Node_Str",(System.currentTimeMillis() - startTime));
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public void export(Network network,Properties parameters,DataSource dataSource){
  if (network == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  XMLExportOptions options=new XMLExportOptions();
  if (parameters != null) {
    options.setIndent(!"String_Node_Str".equals(parameters.getProperty(INDENT_PROPERTY))).setWithBranchSV("String_Node_Str".equals(parameters.getProperty(WITH_BRANCH_STATE_VARIABLES_PROPERTY))).setForceBusBranchTopo("String_Node_Str".equals(parameters.getProperty(FORCE_BUS_BRANCH_TOPO_PROPERTY,"String_Node_Str"))).setOnlyMainCc("String_Node_Str".equals(parameters.getProperty(ONLY_MAIN_CC_PROPERTIES))).setAnonymized("String_Node_Str".equals(parameters.getProperty(ANONYMISED_PROPERTIES))).setSkipExtensions("String_Node_Str".equals(parameters.getProperty(SKIP_EXTENSIONS_PROPERTIES)));
  }
  try {
    long startTime=System.currentTimeMillis();
    try (OutputStream os=dataSource.newOutputStream(null,"String_Node_Str",false);BufferedOutputStream bos=new BufferedOutputStream(os)){
      Anonymizer anonymizer=NetworkXml.write(network,options,bos);
      if (anonymizer != null) {
        try (BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(dataSource.newOutputStream("String_Node_Str","String_Node_Str",false),StandardCharsets.UTF_8))){
          anonymizer.write(writer);
        }
       }
    }
     LOGGER.debug("String_Node_Str",(System.currentTimeMillis() - startTime));
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 38925
Project: 38925
Buggy source:
@Override public Network import_(ReadOnlyDataSource dataSource,Properties parameters){
  Objects.requireNonNull(dataSource);
  Network network;
  long startTime=System.currentTimeMillis();
  try {
    String ext=findExtension(dataSource);
    if (ext == null) {
      throw new RuntimeException("String_Node_Str" + dataSource.getBaseName() + "String_Node_Str"+ Joiner.on("String_Node_Str").join(EXTENSIONS)+ "String_Node_Str");
    }
    boolean throwExceptionIfExtensionNotFound=(Boolean)Importers.readParameter(getFormat(),parameters,THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND,defaultValueConfig);
    Anonymizer anonymizer=null;
    if (dataSource.exists("String_Node_Str","String_Node_Str")) {
      anonymizer=new SimpleAnonymizer();
      try (BufferedReader reader=new BufferedReader(new InputStreamReader(dataSource.newInputStream("String_Node_Str","String_Node_Str")))){
        anonymizer.read(reader);
      }
     }
    try (InputStream is=dataSource.newInputStream(null,ext)){
      network=NetworkXml.read(is,new XmlImportConfig(throwExceptionIfExtensionNotFound),anonymizer);
    }
     LOGGER.debug("String_Node_Str",(System.currentTimeMillis() - startTime));
  }
 catch (  IOException e) {
    throw new ITeslaException(e);
  }
  return network;
}

Fixed version (ground truth):
@Override public Network import_(ReadOnlyDataSource dataSource,Properties parameters){
  Objects.requireNonNull(dataSource);
  Network network;
  long startTime=System.currentTimeMillis();
  try {
    String ext=findExtension(dataSource);
    if (ext == null) {
      throw new RuntimeException("String_Node_Str" + dataSource.getBaseName() + "String_Node_Str"+ Joiner.on("String_Node_Str").join(EXTENSIONS)+ "String_Node_Str");
    }
    boolean throwExceptionIfExtensionNotFound=(Boolean)Importers.readParameter(getFormat(),parameters,THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND,defaultValueConfig);
    Anonymizer anonymizer=null;
    if (dataSource.exists("String_Node_Str","String_Node_Str")) {
      anonymizer=new SimpleAnonymizer();
      try (BufferedReader reader=new BufferedReader(new InputStreamReader(dataSource.newInputStream("String_Node_Str","String_Node_Str"),StandardCharsets.UTF_8))){
        anonymizer.read(reader);
      }
     }
    try (InputStream is=dataSource.newInputStream(null,ext)){
      network=NetworkXml.read(is,new XmlImportConfig(throwExceptionIfExtensionNotFound),anonymizer);
    }
     LOGGER.debug("String_Node_Str",(System.currentTimeMillis() - startTime));
  }
 catch (  IOException e) {
    throw new ITeslaException(e);
  }
  return network;
}
Program: 38926
Project: 38926
Buggy source:
public static int readOptionalIntegerAttribute(XMLStreamReader reader,String attributeName,int defaultValue){
  String attributeValue=reader.getAttributeValue(null,attributeName);
  return attributeValue != null ? Integer.valueOf(attributeValue) : defaultValue;
}

Fixed version (ground truth):
public static int readOptionalIntegerAttribute(XMLStreamReader reader,String attributeName,int defaultValue){
  String attributeValue=reader.getAttributeValue(null,attributeName);
  return attributeValue != null ? Integer.parseInt(attributeValue) : defaultValue;
}
Program: 38927
Project: 38927
Buggy source:
public static int readIntAttribute(XMLStreamReader reader,String attributeName){
  return Integer.valueOf(reader.getAttributeValue(null,attributeName));
}

Fixed version (ground truth):
public static int readIntAttribute(XMLStreamReader reader,String attributeName){
  return Integer.parseInt(reader.getAttributeValue(null,attributeName));
}
Program: 38928
Project: 38928
Buggy source:
@Before public void setUp() throws Exception {
  fileSystem=Jimfs.newFileSystem(Configuration.unix());
  configDir=Files.createDirectory(fileSystem.getPath("String_Node_Str"));
  platformConfig=new InMemoryPlatformConfig(fileSystem);
  moduleConfig=platformConfig.createModuleConfig("String_Node_Str");
  moduleConfig.setStringListProperty("String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str"));
  moduleConfig.setStringProperty("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  fileSystem=Jimfs.newFileSystem(Configuration.unix());
  platformConfig=new InMemoryPlatformConfig(fileSystem);
  moduleConfig=platformConfig.createModuleConfig("String_Node_Str");
  moduleConfig.setStringListProperty("String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str"));
  moduleConfig.setStringProperty("String_Node_Str","String_Node_Str");
}
Program: 38929
Project: 38929
Buggy source:
@Deprecated default void run(CommandLine line) throws Exception {
  run(line,new ToolRunningContext());
}

Fixed version (ground truth):
@Deprecated default void run(CommandLine line) throws Exception {
}
Program: 38931
Project: 38931
Buggy source:
public static Network read(InputStream is) throws XMLStreamException {
  XMLStreamReader reader=XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is);
  reader.next();
  String id=reader.getAttributeValue(null,"String_Node_Str");
  DateTime date=ISODateTimeFormat.dateTime().parseDateTime(reader.getAttributeValue(null,"String_Node_Str"));
  String sourceFormat=reader.getAttributeValue(null,"String_Node_Str");
  Network network=NetworkFactory.create(id,sourceFormat);
  network.setDate(date);
  List<Runnable> endTasks=new ArrayList<>();
  XmlUtil.readUntilEndElement(NETWORK_ROOT_ELEMENT_NAME,reader,() -> {
switch (reader.getLocalName()) {
case SubstationXml.ROOT_ELEMENT_NAME:
      SubstationXml.INSTANCE.read(reader,network,endTasks);
    break;
case LineXml.ROOT_ELEMENT_NAME:
  LineXml.INSTANCE.read(reader,network,endTasks);
break;
case TieLineXml.ROOT_ELEMENT_NAME:
TieLineXml.INSTANCE.read(reader,network,endTasks);
break;
default :
throw new AssertionError();
}
}
);
endTasks.forEach(Runnable::run);
return network;
}

Fixed version (ground truth):
public static Network read(InputStream is) throws XMLStreamException {
  XMLStreamReader reader=XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is);
  reader.next();
  String id=reader.getAttributeValue(null,"String_Node_Str");
  DateTime date=DateTime.parse(reader.getAttributeValue(null,"String_Node_Str"));
  String sourceFormat=reader.getAttributeValue(null,"String_Node_Str");
  Network network=NetworkFactory.create(id,sourceFormat);
  network.setDate(date);
  List<Runnable> endTasks=new ArrayList<>();
  XmlUtil.readUntilEndElement(NETWORK_ROOT_ELEMENT_NAME,reader,() -> {
switch (reader.getLocalName()) {
case SubstationXml.ROOT_ELEMENT_NAME:
      SubstationXml.INSTANCE.read(reader,network,endTasks);
    break;
case LineXml.ROOT_ELEMENT_NAME:
  LineXml.INSTANCE.read(reader,network,endTasks);
break;
case TieLineXml.ROOT_ELEMENT_NAME:
TieLineXml.INSTANCE.read(reader,network,endTasks);
break;
default :
throw new AssertionError();
}
}
);
endTasks.forEach(Runnable::run);
return network;
}
Program: 38932
Project: 38932
Buggy source:
public static void write(Network n,XMLExportOptions options,OutputStream os) throws XMLStreamException {
  XMLStreamWriter writer=XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os,StandardCharsets.UTF_8.toString());
  if (options.isIndent()) {
    IndentingXMLStreamWriter indentingWriter=new IndentingXMLStreamWriter(writer);
    indentingWriter.setIndent(INDENT);
    writer=indentingWriter;
  }
  writer.writeStartDocument(StandardCharsets.UTF_8.toString(),"String_Node_Str");
  writer.setPrefix(IIDM_PREFIX,IIDM_URI);
  writer.writeStartElement(IIDM_URI,NETWORK_ROOT_ELEMENT_NAME);
  writer.writeNamespace(IIDM_PREFIX,IIDM_URI);
  writer.writeAttribute("String_Node_Str",n.getId());
  writer.writeAttribute("String_Node_Str",n.getDate().toString(ISODateTimeFormat.dateTime()));
  writer.writeAttribute("String_Node_Str",n.getSourceFormat());
  BusFilter filter=BusFilter.create(n,options);
  XmlWriterContext context=new XmlWriterContext(writer,options,filter);
  for (  Substation s : n.getSubstations()) {
    SubstationXml.INSTANCE.write(s,null,context);
  }
  for (  Line l : n.getLines()) {
    if (!filter.test(l)) {
      continue;
    }
    if (l.isTieLine()) {
      TieLineXml.INSTANCE.write((TieLine)l,n,context);
    }
 else {
      LineXml.INSTANCE.write(l,n,context);
    }
  }
  writer.writeEndElement();
  writer.writeEndDocument();
}

Fixed version (ground truth):
public static void write(Network n,XMLExportOptions options,OutputStream os) throws XMLStreamException {
  XMLStreamWriter writer=XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os,StandardCharsets.UTF_8.toString());
  if (options.isIndent()) {
    IndentingXMLStreamWriter indentingWriter=new IndentingXMLStreamWriter(writer);
    indentingWriter.setIndent(INDENT);
    writer=indentingWriter;
  }
  writer.writeStartDocument(StandardCharsets.UTF_8.toString(),"String_Node_Str");
  writer.setPrefix(IIDM_PREFIX,IIDM_URI);
  writer.writeStartElement(IIDM_URI,NETWORK_ROOT_ELEMENT_NAME);
  writer.writeNamespace(IIDM_PREFIX,IIDM_URI);
  writer.writeAttribute("String_Node_Str",n.getId());
  writer.writeAttribute("String_Node_Str",n.getDate().toString());
  writer.writeAttribute("String_Node_Str",n.getSourceFormat());
  BusFilter filter=BusFilter.create(n,options);
  XmlWriterContext context=new XmlWriterContext(writer,options,filter);
  for (  Substation s : n.getSubstations()) {
    SubstationXml.INSTANCE.write(s,null,context);
  }
  for (  Line l : n.getLines()) {
    if (!filter.test(l)) {
      continue;
    }
    if (l.isTieLine()) {
      TieLineXml.INSTANCE.write((TieLine)l,n,context);
    }
 else {
      LineXml.INSTANCE.write(l,n,context);
    }
  }
  writer.writeEndElement();
  writer.writeEndDocument();
}
Program: 38933
Project: 38933
Buggy source:
@Override protected void writeRootElementAttributes(VoltageLevel vl,Substation s,XmlWriterContext context) throws XMLStreamException {
  context.getWriter().writeAttribute("String_Node_Str",vl.getDate().toString(ISODateTimeFormat.dateTime()));
  context.getWriter().writeAttribute("String_Node_Str",vl.getHorizon().name());
  context.getWriter().writeAttribute("String_Node_Str",Integer.toString(vl.getForecastDistance()));
  writeFloat("String_Node_Str",vl.getNominalV(),context.getWriter());
  writeFloat("String_Node_Str",vl.getLowVoltageLimit(),context.getWriter());
  writeFloat("String_Node_Str",vl.getHighVoltageLimit(),context.getWriter());
  context.getWriter().writeAttribute("String_Node_Str",vl.getTopologyKind().name());
}

Fixed version (ground truth):
@Override protected void writeRootElementAttributes(VoltageLevel vl,Substation s,XmlWriterContext context) throws XMLStreamException {
  context.getWriter().writeAttribute("String_Node_Str",vl.getDate().toString());
  context.getWriter().writeAttribute("String_Node_Str",vl.getHorizon().name());
  context.getWriter().writeAttribute("String_Node_Str",Integer.toString(vl.getForecastDistance()));
  writeFloat("String_Node_Str",vl.getNominalV(),context.getWriter());
  writeFloat("String_Node_Str",vl.getLowVoltageLimit(),context.getWriter());
  writeFloat("String_Node_Str",vl.getHighVoltageLimit(),context.getWriter());
  context.getWriter().writeAttribute("String_Node_Str",vl.getTopologyKind().name());
}
Program: 38934
Project: 38934
Buggy source:
@Override protected VoltageLevel readRootElementAttributes(VoltageLevelAdder adder,XMLStreamReader reader,List<Runnable> endTasks){
  DateTime date=ISODateTimeFormat.dateTime().parseDateTime(reader.getAttributeValue(null,"String_Node_Str"));
  Horizon horizon=Horizon.valueOf(reader.getAttributeValue(null,"String_Node_Str"));
  int forecastDistance=readIntAttribute(reader,"String_Node_Str");
  float nominalV=readFloatAttribute(reader,"String_Node_Str");
  float lowVoltageLimit=readOptionalFloatAttribute(reader,"String_Node_Str");
  float highVoltageLimit=readOptionalFloatAttribute(reader,"String_Node_Str");
  TopologyKind topologyKind=TopologyKind.valueOf(reader.getAttributeValue(null,"String_Node_Str"));
  return adder.setDate(date).setHorizon(horizon).setForecastDistance(forecastDistance).setNominalV(nominalV).setLowVoltageLimit(lowVoltageLimit).setHighVoltageLimit(highVoltageLimit).setTopologyKind(topologyKind).add();
}

Fixed version (ground truth):
@Override protected VoltageLevel readRootElementAttributes(VoltageLevelAdder adder,XMLStreamReader reader,List<Runnable> endTasks){
  DateTime date=DateTime.parse(reader.getAttributeValue(null,"String_Node_Str"));
  Horizon horizon=Horizon.valueOf(reader.getAttributeValue(null,"String_Node_Str"));
  int forecastDistance=readIntAttribute(reader,"String_Node_Str");
  float nominalV=readFloatAttribute(reader,"String_Node_Str");
  float lowVoltageLimit=readOptionalFloatAttribute(reader,"String_Node_Str");
  float highVoltageLimit=readOptionalFloatAttribute(reader,"String_Node_Str");
  TopologyKind topologyKind=TopologyKind.valueOf(reader.getAttributeValue(null,"String_Node_Str"));
  return adder.setDate(date).setHorizon(horizon).setForecastDistance(forecastDistance).setNominalV(nominalV).setLowVoltageLimit(lowVoltageLimit).setHighVoltageLimit(highVoltageLimit).setTopologyKind(topologyKind).add();
}
Program: 38935
Project: 38935
Buggy source:
@Override public void onDetached(){
  super.onDetached();
  RemotePreferenceManager.get(mContext).detach(getKey());
}

Fixed version (ground truth):
@Override public void onDetached(){
  super.onDetached();
  RemotePreferenceManager.get(mContext).detach(getKey(),this);
}
Program: 38936
Project: 38936
Buggy source:
public synchronized static RemotePreferenceManager get(Context context){
  if (sInstance == null) {
    sInstance=new RemotePreferenceManager(context);
  }
  return sInstance;
}

Fixed version (ground truth):
public synchronized static RemotePreferenceManager get(Context context){
  if (sInstance == null) {
    sInstance=new RemotePreferenceManager(context.getApplicationContext());
  }
  return sInstance;
}
Program: 38937
Project: 38937
Buggy source:
public void detach(String key){
synchronized (mCallbacks) {
    if (mCallbacks.remove(key) != null && mCallbacks.size() == 0) {
      mContext.unregisterReceiver(mListener);
      if (mThread != null) {
        mThread.quit();
      }
    }
  }
}

Fixed version (ground truth):
public void detach(String key,OnRemoteUpdateListener pref){
synchronized (mCallbacks) {
    Set<OnRemoteUpdateListener> cbs=mCallbacks.get(key);
    if (cbs != null && cbs.remove(pref) && cbs.isEmpty() && mCallbacks.remove(key) != null && mCallbacks.isEmpty()) {
      mContext.unregisterReceiver(mListener);
      if (mThread != null) {
        mThread.quit();
        mThread=null;
      }
      mHandler=null;
    }
  }
}
Program: 38938
Project: 38938
Buggy source:
@Override public void run(){
synchronized (mCallbacks) {
    if (mCallbacks.containsKey(key)) {
      mCallbacks.get(key).onRemoteUpdated(bundle);
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
synchronized (mCallbacks) {
    if (mCallbacks.containsKey(key)) {
      Set<OnRemoteUpdateListener> cbs=mCallbacks.get(key);
      if (cbs != null) {
        for (        OnRemoteUpdateListener cb : cbs) {
          cb.onRemoteUpdated(bundle);
        }
      }
    }
  }
}
Program: 38939
Project: 38939
Buggy source:
public void attach(String key,OnRemoteUpdateListener pref){
  Intent i;
synchronized (mCache) {
    i=mCache.get(key);
    if (i == null && !mCache.containsKey(key)) {
      i=pref.getReceiverIntent();
      mCache.put(key,i);
    }
  }
synchronized (mCallbacks) {
    if (i != null) {
      mCallbacks.put(key,pref);
      if (mCallbacks.size() == 1) {
        mThread=new HandlerThread("String_Node_Str");
        mThread.start();
        mHandler=new Handler(mThread.getLooper());
        mContext.registerReceiver(mListener,new IntentFilter(ACTION_REFRESH_PREFERENCE),Manifest.permission.MANAGE_REMOTE_PREFERENCES,mHandler);
      }
      requestUpdate(key);
    }
  }
}

Fixed version (ground truth):
public void attach(String key,OnRemoteUpdateListener pref){
  Intent i;
synchronized (mCache) {
    i=mCache.get(key);
    if (i == null && !mCache.containsKey(key)) {
      i=pref.getReceiverIntent();
      mCache.put(key,i);
    }
  }
synchronized (mCallbacks) {
    if (i != null) {
      Set<OnRemoteUpdateListener> cbs=mCallbacks.get(key);
      if (cbs == null) {
        cbs=new HashSet<>();
        mCallbacks.put(key,cbs);
        if (mCallbacks.size() == 1) {
          mThread=new HandlerThread("String_Node_Str");
          mThread.start();
          mHandler=new Handler(mThread.getLooper());
          mContext.registerReceiver(mListener,new IntentFilter(ACTION_REFRESH_PREFERENCE),Manifest.permission.MANAGE_REMOTE_PREFERENCES,mHandler);
        }
      }
      cbs.add(pref);
      requestUpdate(key);
    }
  }
}
Program: 38940
Project: 38940
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Objects.toString(intent));
  if (ACTION_REFRESH_PREFERENCE.equals(intent.getAction())) {
    final String key=intent.getStringExtra(EXTRA_KEY);
synchronized (mCallbacks) {
      if (key != null && mCallbacks.containsKey(key)) {
        requestUpdate(key);
      }
    }
  }
 else   if (ACTION_UPDATE_PREFERENCE.equals(intent.getAction())) {
    if (getAbortBroadcast()) {
      Log.e(TAG,"String_Node_Str" + getResultCode());
      return;
    }
    final Bundle bundle=getResultExtras(true);
    final String key=bundle.getString(EXTRA_KEY);
synchronized (mCallbacks) {
      if (key != null && mCallbacks.containsKey(key)) {
        mMainHandler.post(new Runnable(){
          @Override public void run(){
synchronized (mCallbacks) {
              if (mCallbacks.containsKey(key)) {
                mCallbacks.get(key).onRemoteUpdated(bundle);
              }
            }
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Objects.toString(intent));
  if (ACTION_REFRESH_PREFERENCE.equals(intent.getAction())) {
    final String key=intent.getStringExtra(EXTRA_KEY);
synchronized (mCallbacks) {
      if (key != null && mCallbacks.containsKey(key)) {
        requestUpdate(key);
      }
    }
  }
 else   if (ACTION_UPDATE_PREFERENCE.equals(intent.getAction())) {
    if (getAbortBroadcast()) {
      Log.e(TAG,"String_Node_Str" + getResultCode());
      return;
    }
    final Bundle bundle=getResultExtras(true);
    final String key=bundle.getString(EXTRA_KEY);
synchronized (mCallbacks) {
      if (key != null && mCallbacks.containsKey(key)) {
        mMainHandler.post(new Runnable(){
          @Override public void run(){
synchronized (mCallbacks) {
              if (mCallbacks.containsKey(key)) {
                Set<OnRemoteUpdateListener> cbs=mCallbacks.get(key);
                if (cbs != null) {
                  for (                  OnRemoteUpdateListener cb : cbs) {
                    cb.onRemoteUpdated(bundle);
                  }
                }
              }
            }
          }
        }
);
      }
    }
  }
}
Program: 38941
Project: 38941
Buggy source:
@Override protected void onTwilightUpdated(){
  mHandler.post(mTransitionRunnable);
}

Fixed version (ground truth):
@Override protected void onTwilightUpdated(){
  updateColorTemperature();
}
Program: 38942
Project: 38942
Buggy source:
@Override protected void onScreenStateChanged(){
  if (isTransitioning()) {
    if (isScreenOn()) {
      mHandler.post(mTransitionRunnable);
    }
 else {
      mHandler.removeCallbacks(mTransitionRunnable);
    }
  }
}

Fixed version (ground truth):
@Override protected void onScreenStateChanged(){
  updateColorTemperature();
}
Program: 38943
Project: 38943
Buggy source:
private void enableLightSensor(boolean enable){
  if (enable && !mLightSensorEnabled) {
    mAmbientLux=0.0f;
    mState=LOW;
    mLightSensorEnabled=true;
    mRingBuffer.clear();
    mSensorManager.registerListener(mListener,mLightSensor,mLightSensorRate * 1000,mLuxHandler);
  }
 else   if (!enable && mLightSensorEnabled) {
    mLightSensorEnabled=false;
    mSensorManager.unregisterListener(mListener);
    mLuxHandler.clear();
  }
}

Fixed version (ground truth):
private void enableLightSensor(boolean enable){
  if (enable && !mLightSensorEnabled) {
    mLightSensorEnabled=true;
    mSensorManager.registerListener(mListener,mLightSensor,mLightSensorRate * 1000,mLuxHandler);
  }
 else   if (!enable && mLightSensorEnabled) {
    mSensorManager.unregisterListener(mListener);
    mLuxHandler.clear();
    mAmbientLux=0.0f;
    mState=LOW;
    mLightSensorEnabled=false;
    mRingBuffer.clear();
  }
}
Program: 38944
Project: 38944
Buggy source:
@Override public void onTwilightUpdated(TwilightState twilight){
  super.onTwilightUpdated(twilight);
  mHandler.post(mTransitionRunnable);
}

Fixed version (ground truth):
@Override protected void onTwilightUpdated(){
  mHandler.post(mTransitionRunnable);
}
Program: 38945
Project: 38945
Buggy source:
/** 
 * Where is the sun anyway? This calculation determines day or night, and scales the value around sunset/sunrise for a smooth transition.
 * @param now
 * @param sunset
 * @param sunrise
 * @return float between 0 and 1
 */
private static float adj(long now,long sunset,long sunrise){
  if (sunset < 0 || sunrise < 0 || now < sunset || now > sunrise) {
    return 1.0f;
  }
  if (now < sunset + TWILIGHT_ADJUSTMENT_TIME) {
    return MathUtils.lerp(1.0f,0.0f,(float)(now - sunset) / TWILIGHT_ADJUSTMENT_TIME);
  }
  if (now > sunrise - TWILIGHT_ADJUSTMENT_TIME) {
    return MathUtils.lerp(1.0f,0.0f,(float)(sunrise - now) / TWILIGHT_ADJUSTMENT_TIME);
  }
  return 0.0f;
}

Fixed version (ground truth):
/** 
 * Where is the sun anyway? This calculation determines day or night, and scales the value around sunset/sunrise for a smooth transition.
 * @param now
 * @param sunset
 * @param sunrise
 * @return float between 0 and 1
 */
private static float adj(long now,long sunset,long sunrise){
  if (sunset < 0 || sunrise < 0 || now < sunset || now > (sunrise + TWILIGHT_ADJUSTMENT_TIME)) {
    return 1.0f;
  }
  if (now <= (sunset + TWILIGHT_ADJUSTMENT_TIME)) {
    return MathUtils.lerp(1.0f,0.0f,(float)(now - sunset) / TWILIGHT_ADJUSTMENT_TIME);
  }
  if (now >= sunrise) {
    return MathUtils.lerp(1.0f,0.0f,(float)((sunrise + TWILIGHT_ADJUSTMENT_TIME) - now) / TWILIGHT_ADJUSTMENT_TIME);
  }
  return 0.0f;
}
Program: 38946
Project: 38946
Buggy source:
private void updateColorTemperature(){
  mHandler.removeCallbacks(mTransitionRunnable);
  int temperature=mDayTemperature;
  int mode=getMode();
  if (mode == MODE_OFF || isLowPowerMode()) {
    temperature=OFF_TEMPERATURE;
  }
 else   if (mode == MODE_NIGHT) {
    temperature=mNightTemperature;
  }
 else   if (mode == MODE_AUTO) {
    temperature=getTwilightK();
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + mode + "String_Node_Str"+ temperature+ "String_Node_Str"+ mColorTemperature);
  }
  if (mAnimator != null) {
    mAnimator.cancel();
    mAnimator.removeAllUpdateListeners();
  }
  mAnimator=ValueAnimator.ofInt(mColorTemperature,temperature);
  mAnimator.setDuration(Math.abs(mColorTemperature - temperature) / 2);
  mAnimator.addUpdateListener(new AnimatorUpdateListener(){
    @Override public void onAnimationUpdate(    final ValueAnimator animation){
      mHandler.post(new Runnable(){
        @Override public void run(){
          setDisplayTemperature((Integer)animation.getAnimatedValue());
        }
      }
);
    }
  }
);
  mAnimator.start();
}

Fixed version (ground truth):
private synchronized void updateColorTemperature(){
  if (!mUseTemperatureAdjustment || !isScreenOn()) {
    return;
  }
  int temperature=mDayTemperature;
  int mode=getMode();
  if (mode == MODE_OFF || isLowPowerMode()) {
    temperature=mDefaultDayTemperature;
  }
 else   if (mode == MODE_NIGHT) {
    temperature=mNightTemperature;
  }
 else   if (mode == MODE_AUTO) {
    temperature=getTwilightK();
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + mode + "String_Node_Str"+ temperature+ "String_Node_Str"+ mColorTemperature);
  }
  setDisplayTemperature(temperature);
}
Program: 38947
Project: 38947
Buggy source:
@Override public void run(){
  setDisplayTemperature((Integer)animation.getAnimatedValue());
}

Fixed version (ground truth):
@Override public void run(){
synchronized (ColorTemperatureController.this) {
    updateColorTemperature();
    mTransitioning=getMode() == MODE_AUTO && mColorTemperature != mDayTemperature && mColorTemperature != mNightTemperature;
    if (mTransitioning) {
      mHandler.postDelayed(mTransitionRunnable,DateUtils.MINUTE_IN_MILLIS);
    }
  }
}
Program: 38948
Project: 38948
Buggy source:
void getCapabilities(final BitSet caps){
  if (mUseTemperatureAdjustment) {
    caps.set(MODE_AUTO);
    caps.set(MODE_DAY);
    caps.set(MODE_NIGHT);
  }
}

Fixed version (ground truth):
@Override public boolean getCapabilities(final BitSet caps){
  if (mUseTemperatureAdjustment) {
    caps.set(MODE_AUTO);
    caps.set(MODE_DAY);
    caps.set(MODE_NIGHT);
  }
  return mUseTemperatureAdjustment;
}
Program: 38949
Project: 38949
Buggy source:
private synchronized void setDisplayTemperature(int temperature){
  mColorTemperature=temperature;
  final float[] rgb=ColorUtils.temperatureToRGB(temperature);
  mDisplayHardware.setAdditionalAdjustment(rgb);
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + temperature + "String_Node_Str");
  }
}

Fixed version (ground truth):
private synchronized void setDisplayTemperature(int temperature){
  mColorTemperature=temperature;
  final float[] rgb=ColorUtils.temperatureToRGB(temperature);
  if (mDisplayHardware.setAdditionalAdjustment(rgb)) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + temperature + "String_Node_Str");
    }
  }
}
Program: 38950
Project: 38950
Buggy source:
@Override public boolean onStart(){
  if (!mDisplayHardware.hasColorAdjustment()) {
    return false;
  }
  mUseTemperatureAdjustment=true;
  mDefaultDayTemperature=mContext.getResources().getInteger(org.cyanogenmod.platform.internal.R.integer.config_dayColorTemperature);
  mDefaultNightTemperature=mContext.getResources().getInteger(org.cyanogenmod.platform.internal.R.integer.config_nightColorTemperature);
  registerSettings(CMSettings.System.getUriFor(CMSettings.System.DISPLAY_TEMPERATURE_DAY),CMSettings.System.getUriFor(CMSettings.System.DISPLAY_TEMPERATURE_NIGHT));
  return true;
}

Fixed version (ground truth):
@Override public void onStart(){
  if (!mUseTemperatureAdjustment) {
    return;
  }
  mDayTemperature=getDayColorTemperature();
  mNightTemperature=getNightColorTemperature();
  registerSettings(DISPLAY_TEMPERATURE_DAY,DISPLAY_TEMPERATURE_NIGHT);
}
Program: 38951
Project: 38951
Buggy source:
@Override public synchronized void onSettingsChanged(Uri uri){
  mDayTemperature=getDayColorTemperature();
  mNightTemperature=getNightColorTemperature();
  updateColorTemperature();
}

Fixed version (ground truth):
@Override protected synchronized void onSettingsChanged(Uri uri){
  if (uri == null || uri.equals(DISPLAY_TEMPERATURE_DAY)) {
    mDayTemperature=getDayColorTemperature();
  }
  if (uri == null || uri.equals(DISPLAY_TEMPERATURE_NIGHT)) {
    mNightTemperature=getNightColorTemperature();
  }
  updateColorTemperature();
}
Program: 38952
Project: 38952
Buggy source:
public ColorTemperatureController(Context context,Handler handler,DisplayHardwareController displayHardware){
  super(context,handler);
  mDisplayHardware=displayHardware;
}

Fixed version (ground truth):
public ColorTemperatureController(Context context,Handler handler,DisplayHardwareController displayHardware){
  super(context,handler);
  mDisplayHardware=displayHardware;
  mUseTemperatureAdjustment=mDisplayHardware.hasColorAdjustment();
  mDefaultDayTemperature=mContext.getResources().getInteger(org.cyanogenmod.platform.internal.R.integer.config_dayColorTemperature);
  mDefaultNightTemperature=mContext.getResources().getInteger(org.cyanogenmod.platform.internal.R.integer.config_nightColorTemperature);
}
Program: 38953
Project: 38953
Buggy source:
@Override public void dump(PrintWriter pw){
  pw.println();
  pw.println("String_Node_Str");
  pw.println("String_Node_Str" + mDayTemperature);
  pw.println("String_Node_Str" + mNightTemperature);
  pw.println();
  pw.println("String_Node_Str");
  pw.println("String_Node_Str" + mColorTemperature);
  if (getTwilight() != null) {
    pw.println("String_Node_Str" + getTwilight().toString());
  }
  pw.println("String_Node_Str" + mHandler.hasCallbacks(mTransitionRunnable));
}

Fixed version (ground truth):
@Override public void dump(PrintWriter pw){
  pw.println();
  pw.println("String_Node_Str");
  pw.println("String_Node_Str" + mDayTemperature);
  pw.println("String_Node_Str" + mNightTemperature);
  pw.println();
  pw.println("String_Node_Str");
  pw.println("String_Node_Str" + mColorTemperature);
  pw.println("String_Node_Str" + mTransitioning);
}
Program: 38954
Project: 38954
Buggy source:
/** 
 * @hide to prevent subclassing from outside of the framework
 */
private LiveDisplayManager(Context context){
  Context appContext=context.getApplicationContext();
  if (appContext != null) {
    mContext=appContext;
  }
 else {
    mContext=context;
  }
  sService=getService();
  if (context.getPackageManager().hasSystemFeature(CMContextConstants.Features.LIVEDISPLAY) && !checkService()) {
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  try {
    mConfig=sService.getConfig();
  }
 catch (  RemoteException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * @hide to prevent subclassing from outside of the framework
 */
private LiveDisplayManager(Context context){
  Context appContext=context.getApplicationContext();
  if (appContext != null) {
    mContext=appContext;
  }
 else {
    mContext=context;
  }
  sService=getService();
  if (!context.getPackageManager().hasSystemFeature(CMContextConstants.Features.LIVEDISPLAY) || !checkService()) {
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  try {
    mConfig=sService.getConfig();
    if (mConfig == null) {
      throw new RuntimeException("String_Node_Str");
    }
  }
 catch (  RemoteException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}
Program: 38955
Project: 38955
Buggy source:
private synchronized void updateColorAdjustment(){
  if (!mUseColorAdjustment) {
    return;
  }
  final float[] rgb=getDefaultAdjustment();
  if (!isLowPowerMode()) {
    System.arraycopy(mAdditionalAdjustment,0,rgb,0,3);
    rgb[0]*=mColorAdjustment[0];
    rgb[1]*=mColorAdjustment[1];
    rgb[2]*=mColorAdjustment[2];
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(rgb));
  }
  if (validateColors(rgb)) {
    animateDisplayColor(rgb);
  }
}

Fixed version (ground truth):
private synchronized void updateColorAdjustment(){
  if (!mUseColorAdjustment) {
    return;
  }
  final float[] rgb=getDefaultAdjustment();
  if (!isLowPowerMode()) {
    copyColors(mColorAdjustment,rgb);
    rgb[0]*=mAdditionalAdjustment[0];
    rgb[1]*=mAdditionalAdjustment[1];
    rgb[2]*=mAdditionalAdjustment[2];
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(rgb));
  }
  if (validateColors(rgb)) {
    animateDisplayColor(rgb);
  }
}
Program: 38956
Project: 38956
Buggy source:
@Override public synchronized void onSettingsChanged(Uri uri){
  if (uri == null || uri.equals(DISPLAY_CABC)) {
    updateCABCMode();
  }
  if (uri == null || uri.equals(DISPLAY_AUTO_CONTRAST)) {
    updateAutoContrast();
  }
  if (uri == null || uri.equals(DISPLAY_COLOR_ENHANCE)) {
    updateColorEnhancement();
  }
  if (uri == null || uri.equals(DISPLAY_COLOR_ADJUSTMENT) && parseColorAdjustment(getString(CMSettings.System.DISPLAY_COLOR_ADJUSTMENT),mColorAdjustment)) {
    updateColorAdjustment();
  }
}

Fixed version (ground truth):
@Override public synchronized void onSettingsChanged(Uri uri){
  if (uri == null || uri.equals(DISPLAY_CABC)) {
    updateCABCMode();
  }
  if (uri == null || uri.equals(DISPLAY_AUTO_CONTRAST)) {
    updateAutoContrast();
  }
  if (uri == null || uri.equals(DISPLAY_COLOR_ENHANCE)) {
    updateColorEnhancement();
  }
  if (uri == null || uri.equals(DISPLAY_COLOR_ADJUSTMENT)) {
    copyColors(getColorAdjustment(),mColorAdjustment);
    updateColorAdjustment();
  }
}
Program: 38957
Project: 38957
Buggy source:
/** 
 * Ensure all values are within range
 * @param colors
 * @return true if valid
 */
private boolean validateColors(float[] colors){
  if (colors != null && colors.length == 3 && !(colors[0] <= 0.0f && colors[1] <= 0.0f && colors[2] <= 0.0f)) {
    for (int i=0; i < 3; i++) {
      if (colors[i] > 1.0f) {
        colors[i]=1.0f;
      }
    }
    return true;
  }
  colors[0]=1.0f;
  colors[1]=1.0f;
  colors[2]=1.0f;
  return false;
}

Fixed version (ground truth):
/** 
 * Ensure all values are within range
 * @param colors
 * @return true if valid
 */
private boolean validateColors(float[] colors){
  if (colors == null || colors.length != 3) {
    return false;
  }
  for (int i=0; i < 3; i++) {
    colors[i]=MathUtils.constrain(colors[i],0.0f,1.0f);
  }
  return true;
}
Program: 38958
Project: 38958
Buggy source:
/** 
 * Additional adjustments provided by night mode
 * @param adj
 */
synchronized boolean setAdditionalAdjustment(float[] adj){
  if (!mUseColorAdjustment) {
    return false;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(adj));
  }
  if (validateColors(adj)) {
    System.arraycopy(adj,0,mAdditionalAdjustment,0,3);
    updateColorAdjustment();
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Additional adjustments provided by night mode
 * @param adj
 */
synchronized boolean setAdditionalAdjustment(float[] adj){
  if (!mUseColorAdjustment) {
    return false;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + Arrays.toString(adj));
  }
  if (validateColors(adj)) {
    copyColors(adj,mAdditionalAdjustment);
    updateColorAdjustment();
    return true;
  }
  return false;
}
Program: 38960
Project: 38960
Buggy source:
@Override public void onAnimationUpdate(final ValueAnimator animation){
synchronized (DisplayHardwareController.this) {
    float[] value=(float[])animation.getAnimatedValue();
    mHardware.setDisplayColorCalibration(new int[]{(int)(value[0] * mMaxColor),(int)(value[1] * mMaxColor),(int)(value[2] * mMaxColor)});
    screenRefresh();
  }
}

Fixed version (ground truth):
@Override public void onAnimationUpdate(final ValueAnimator animation){
synchronized (DisplayHardwareController.this) {
    if (isScreenOn()) {
      float[] value=(float[])animation.getAnimatedValue();
      mHardware.setDisplayColorCalibration(new int[]{(int)(value[0] * mMaxColor),(int)(value[1] * mMaxColor),(int)(value[2] * mMaxColor)});
      screenRefresh();
    }
  }
}
Program: 38961
Project: 38961
Buggy source:
public DisplayHardwareController(Context context,Handler handler){
  super(context,handler);
  mHardware=CMHardwareManager.getInstance(mContext);
  mUseCABC=mHardware.isSupported(CMHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT);
  mDefaultCABC=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultCABC);
  mUseColorEnhancement=mHardware.isSupported(CMHardwareManager.FEATURE_COLOR_ENHANCEMENT);
  mDefaultColorEnhancement=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultColorEnhancement);
  mUseAutoContrast=mHardware.isSupported(CMHardwareManager.FEATURE_AUTO_CONTRAST);
  mDefaultAutoContrast=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultAutoContrast);
  mUseColorAdjustment=mHardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION);
  mMaxColor=mHardware.getDisplayColorCalibrationMax();
}

Fixed version (ground truth):
public DisplayHardwareController(Context context,Handler handler){
  super(context,handler);
  mHardware=CMHardwareManager.getInstance(mContext);
  mUseCABC=mHardware.isSupported(CMHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT);
  mDefaultCABC=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultCABC);
  mUseColorEnhancement=mHardware.isSupported(CMHardwareManager.FEATURE_COLOR_ENHANCEMENT);
  mDefaultColorEnhancement=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultColorEnhancement);
  mUseAutoContrast=mHardware.isSupported(CMHardwareManager.FEATURE_AUTO_CONTRAST);
  mDefaultAutoContrast=mContext.getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_defaultAutoContrast);
  mUseColorAdjustment=mHardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION);
  if (mUseColorAdjustment) {
    mMaxColor=mHardware.getDisplayColorCalibrationMax();
    copyColors(getColorAdjustment(),mColorAdjustment);
  }
 else {
    mMaxColor=0;
  }
}
Program: 38962
Project: 38962
Buggy source:
@Override protected synchronized void onScreenStateChanged(){
  if (mUseColorAdjustment) {
    if (mAnimator != null && mAnimator.isRunning() && !isScreenOn()) {
      mAnimator.cancel();
      mDirty=true;
    }
 else     if (mDirty && isScreenOn()) {
      updateColorAdjustment();
      mDirty=false;
    }
  }
}

Fixed version (ground truth):
@Override protected synchronized void onScreenStateChanged(){
  if (mUseColorAdjustment) {
    if (mAnimator != null && mAnimator.isRunning() && !isScreenOn()) {
      mAnimator.cancel();
    }
 else     if (isScreenOn()) {
      updateColorAdjustment();
    }
  }
}
Program: 38963
Project: 38963
Buggy source:
private synchronized boolean setPowerProfileInternal(int profile,boolean fromUser){
  if (profile == mCurrentProfile) {
    return false;
  }
  if (profile < 0 || profile > mNumProfiles) {
    Slog.e(TAG,"String_Node_Str" + profile);
    return false;
  }
  mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
  long token=Binder.clearCallingIdentity();
  if (fromUser) {
    CMSettings.Secure.putInt(mContext.getContentResolver(),CMSettings.Secure.PERFORMANCE_PROFILE,profile);
  }
  mCurrentProfile=profile;
  mHandler.removeMessages(MSG_CPU_BOOST);
  mHandler.removeMessages(MSG_LAUNCH_BOOST);
  mHandler.sendMessage(Message.obtain(mHandler,MSG_SET_PROFILE,profile,(fromUser ? 1 : 0)));
  Binder.restoreCallingIdentity(token);
  return true;
}

Fixed version (ground truth):
/** 
 * Apply a power profile and persist if fromUser = true
 * @param profile  power profile
 * @param fromUser true to persist the profile
 * @return          true if the active profile changed
 */
private synchronized boolean setPowerProfileInternal(int profile,boolean fromUser){
  if (DEBUG) {
    Slog.v(TAG,String.format("String_Node_Str",profile,fromUser));
  }
  if (profile < 0 || profile > mNumProfiles) {
    Slog.e(TAG,"String_Node_Str" + profile);
    return false;
  }
  if (fromUser) {
    CMSettings.Secure.putInt(mContext.getContentResolver(),CMSettings.Secure.PERFORMANCE_PROFILE,profile);
  }
  if (profile == mCurrentProfile) {
    return false;
  }
  mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
  long token=Binder.clearCallingIdentity();
  mCurrentProfile=profile;
  mHandler.removeMessages(MSG_CPU_BOOST);
  mHandler.removeMessages(MSG_LAUNCH_BOOST);
  mHandler.sendMessage(Message.obtain(mHandler,MSG_SET_PROFILE,profile,(fromUser ? 1 : 0)));
  Binder.restoreCallingIdentity(token);
  return true;
}
Program: 38964
Project: 38964
Buggy source:
@Override public void activityResumed(Intent intent){
  if (!hasAppProfiles() || intent == null || mProfileSetByUser) {
    return;
  }
  final ComponentName cn=intent.getComponent();
  if (cn == null) {
    return;
  }
  int forApp=getProfileForActivity(cn.flattenToString());
  if (forApp == mCurrentProfile) {
    return;
  }
  setPowerProfileInternal(forApp,false);
}

Fixed version (ground truth):
@Override public void activityResumed(Intent intent){
  String activityName=null;
  if (intent != null) {
    final ComponentName cn=intent.getComponent();
    if (cn != null) {
      activityName=cn.flattenToString();
    }
  }
  mCurrentActivityName=activityName;
  applyProfile();
}
Program: 38965
Project: 38965
Buggy source:
@Override public void onBootPhase(int phase){
  if (phase == PHASE_SYSTEM_SERVICES_READY) {
synchronized (this) {
      mPm=getLocalService(PowerManagerInternal.class);
      mNumProfiles=mPm.getFeature(POWER_FEATURE_SUPPORTED_PROFILES);
      Slog.d(TAG,"String_Node_Str" + mNumProfiles);
      if (mNumProfiles > 0) {
        int profile=CMSettings.Secure.getInt(mContext.getContentResolver(),CMSettings.Secure.PERFORMANCE_PROFILE,PerformanceManager.PROFILE_BALANCED);
        if (profile == PerformanceManager.PROFILE_HIGH_PERFORMANCE) {
          profile=PerformanceManager.PROFILE_BALANCED;
        }
        setPowerProfileInternal(profile,true);
        mPm.registerLowPowerModeObserver(mLowPowerModeListener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onBootPhase(int phase){
  if (phase == PHASE_SYSTEM_SERVICES_READY) {
synchronized (this) {
      mPm=getLocalService(PowerManagerInternal.class);
      mNumProfiles=mPm.getFeature(POWER_FEATURE_SUPPORTED_PROFILES);
      if (mNumProfiles > 0) {
        int profile=getUserProfile();
        if (profile == PerformanceManager.PROFILE_HIGH_PERFORMANCE) {
          Slog.i(TAG,String.format("String_Node_Str",profile,PerformanceManager.PROFILE_BALANCED));
          setPowerProfileInternal(PerformanceManager.PROFILE_BALANCED,true);
        }
 else {
          setPowerProfileInternal(profile,false);
        }
        mPm.registerLowPowerModeObserver(mLowPowerModeListener);
      }
    }
  }
}
Program: 38966
Project: 38966
Buggy source:
@Override public int getPowerProfile(){
  return CMSettings.Secure.getInt(mContext.getContentResolver(),CMSettings.Secure.PERFORMANCE_PROFILE,PerformanceManager.PROFILE_BALANCED);
}

Fixed version (ground truth):
@Override public int getPowerProfile(){
  return getUserProfile();
}
Program: 38967
Project: 38967
Buggy source:
@Override public void onLowPowerModeChanged(boolean enabled){
  if (mNumProfiles < 1) {
    return;
  }
  if (enabled == mLowPowerModeEnabled) {
    return;
  }
  if (enabled && mCurrentProfile != PerformanceManager.PROFILE_POWER_SAVE) {
    setPowerProfileInternal(PerformanceManager.PROFILE_POWER_SAVE,true);
  }
 else   if (!enabled && mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE) {
    setPowerProfileInternal(PerformanceManager.PROFILE_BALANCED,true);
  }
}

Fixed version (ground truth):
@Override public void onLowPowerModeChanged(boolean enabled){
  if (enabled == mLowPowerModeEnabled) {
    return;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + enabled);
  }
  mLowPowerModeEnabled=enabled;
  applyProfile();
}
Program: 38968
Project: 38968
Buggy source:
public PerformanceManagerService(Context context){
  super(context);
  mContext=context;
  String[] activities=context.getResources().getStringArray(R.array.config_auto_perf_activities);
  if (activities != null && activities.length > 0) {
    mPatterns=new Pattern[activities.length];
    mProfiles=new int[activities.length];
    for (int i=0; i < activities.length; i++) {
      String[] info=activities[i].split("String_Node_Str");
      if (info.length == 2) {
        mPatterns[i]=Pattern.compile(info[0]);
        mProfiles[i]=Integer.valueOf(info[1]);
      }
    }
  }
  mHandlerThread=new ServiceThread(TAG,Process.THREAD_PRIORITY_URGENT_DISPLAY + 1,false);
  mHandlerThread.start();
  mHandler=new PerformanceManagerHandler(mHandlerThread.getLooper());
}

Fixed version (ground truth):
public PerformanceManagerService(Context context){
  super(context);
  mContext=context;
  String[] activities=context.getResources().getStringArray(R.array.config_auto_perf_activities);
  if (activities != null && activities.length > 0) {
    mPatterns=new Pattern[activities.length];
    mProfiles=new int[activities.length];
    for (int i=0; i < activities.length; i++) {
      String[] info=activities[i].split("String_Node_Str");
      if (info.length == 2) {
        mPatterns[i]=Pattern.compile(info[0]);
        mProfiles[i]=Integer.valueOf(info[1]);
        if (DEBUG) {
          Slog.d(TAG,String.format("String_Node_Str",i,info[0],info[1]));
        }
      }
    }
  }
  mHandlerThread=new ServiceThread(TAG,Process.THREAD_PRIORITY_URGENT_DISPLAY + 1,false);
  mHandlerThread.start();
  mHandler=new PerformanceManagerHandler(mHandlerThread.getLooper());
}
Program: 38969
Project: 38969
Buggy source:
private void testMigrateSettingsForUser(int userId){
  Bundle arg=new Bundle();
  arg.putInt(CMSettings.CALL_METHOD_USER_KEY,userId);
  IContentProvider contentProvider=mContentResolver.acquireProvider(CMSettings.AUTHORITY);
  try {
    contentProvider.call(mContentResolver.getPackageName(),CMSettings.CALL_METHOD_MIGRATE_SETTINGS_FOR_USER,null,arg);
  }
 catch (  RemoteException ex) {
    fail("String_Node_Str");
  }
  final String actualPullDownValue=CMSettings.System.getStringForUser(mContentResolver,CMSettings.System.QS_QUICK_PULLDOWN,userId);
  assertEquals(expectedPullDownValue,actualPullDownValue);
  final int actualKeyboardBrightness=CMSettings.Secure.getIntForUser(mContentResolver,CMSettings.Secure.KEYBOARD_BRIGHTNESS,-1,userId);
  assertEquals(expectedKeyboardBrightness,actualKeyboardBrightness);
}

Fixed version (ground truth):
private void testMigrateSettingsForUser(int userId){
}