Program: 162058
Project: 162058
Buggy source:
@Override public int onStartCommand(Intent intent,int flags,int startId){
  CV.logi("String_Node_Str");
  if (intent == null) {
    CV.logi("String_Node_Str");
    if (CV.getPrefAutoOnoff(this)) {
      if (CV.getPrefSleeping(this) && CV.isInSleepTime(this))       return START_NOT_STICKY;
      registerSensor();
    }
 else     if (CV.getPrefChargingOn(this) && CV.isPlugged(this)) {
      registerSensor();
    }
    return START_STICKY;
  }
  int action=intent.getIntExtra(CV.SERVICEACTION,-1);
switch (action) {
case CV.SERVICEACTION_SHOW_NOTIFICATION:
{
      if (CV.getPrefShowNotification(this))       showNotification();
 else       hideNotification();
      return START_NOT_STICKY;
    }
case CV.SERVICEACTION_SCREENOFF:
{
    CV.logi("String_Node_Str");
    if (!isActiveAdmin()) {
      Intent i=new Intent(this,MainActivity.class);
      i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      i.putExtra(CV.CLOSE_AFTER,true);
      this.startActivity(i);
    }
 else {
      deviceManager.lockNow();
    }
    return START_NOT_STICKY;
  }
case CV.SERVICEACTION_TOGGLE:
{
  CV.logi("String_Node_Str");
  String servicetype=intent.getStringExtra(CV.SERVICETYPE);
  if (servicetype != null && !servicetype.equals(CV.SERVICETYPE_SETTING)) {
    if (CV.isPlugged(this) && CV.getPrefChargingOn(this)) {
      SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(this);
      Editor editor=sp.edit();
      editor.putBoolean(CV.PREF_CHARGING_ON,false);
      editor.commit();
    }
 else {
      togglePreference();
    }
  }
  updateWidgetCharging(false);
  updateNotification();
  if (CV.getPrefAutoOnoff(this) == false) {
    unregisterSensor();
  }
 else {
    if (CV.getPrefSleeping(this) && CV.isInSleepTime(this))     return START_NOT_STICKY;
    registerSensor();
  }
  break;
}
case CV.SERVICEACTION_TURNON:
{
CV.logi("String_Node_Str");
if (!isRegistered()) {
  registerSensor();
  updateWidgetCharging(CV.isPlugged(this));
  updateNotification();
}
break;
}
case CV.SERVICEACTION_TURNOFF:
{
CV.logi("String_Node_Str");
if (isRegistered()) unregisterSensor();
if (!CV.getPrefAutoOnoff(this)) {
updateWidgetCharging(false);
updateNotification();
}
return START_NOT_STICKY;
}
case CV.SERVICEACTION_UPDATE_DISABLE_IN_LANDSCAPE:
{
if (mIsRegistered) {
if (CV.getPrefDisableInLandscape(this) == true) registerOrientationChange();
 else unregisterOrientationChange();
}
break;
}
case CV.SERVICEACTION_MODE_SLEEP:
{
if (CV.getPrefAutoOnoff(this) == false) return START_STICKY;
CV.logv("String_Node_Str");
boolean bSleepModeStart=intent.getBooleanExtra(CV.SLEEP_MODE_START,false);
CV.logv("String_Node_Str",bSleepModeStart);
if (bSleepModeStart) {
CV.logi("String_Node_Str");
unregisterSensor();
}
 else {
CV.logi("String_Node_Str");
registerSensor();
}
break;
}
case CV.SERVICEACTION_PARTIALLOCK_TOGGLE:
{
if (CV.getPrefNoPartialLock(this) && partialLock.isHeld()) {
partialLock.release();
}
 else if (!CV.getPrefNoPartialLock(this) && isRegistered()) {
partialLock.acquire();
}
break;
}
default :
CV.logi("String_Node_Str");
}
return START_STICKY;
}

Fixed version (ground truth):
@Override public int onStartCommand(Intent intent,int flags,int startId){
  CV.logi("String_Node_Str");
  if (intent == null) {
    CV.logi("String_Node_Str");
    if (CV.getPrefAutoOnoff(this)) {
      if (CV.getPrefSleeping(this) && CV.isInSleepTime(this))       return START_NOT_STICKY;
      registerSensor();
    }
 else     if (CV.getPrefChargingOn(this) && CV.isPlugged(this)) {
      registerSensor();
    }
    return START_STICKY;
  }
  int action=intent.getIntExtra(CV.SERVICEACTION,-1);
switch (action) {
case CV.SERVICEACTION_SHOW_NOTIFICATION:
{
      if (CV.getPrefShowNotification(this))       showNotification();
 else       hideNotification();
      return START_NOT_STICKY;
    }
case CV.SERVICEACTION_SCREENOFF:
{
    CV.logi("String_Node_Str");
    if (!isActiveAdmin()) {
      Intent i=new Intent(this,MainActivity.class);
      i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      i.putExtra(CV.CLOSE_AFTER,true);
      this.startActivity(i);
    }
 else {
      deviceManager.lockNow();
    }
    return START_NOT_STICKY;
  }
case CV.SERVICEACTION_TOGGLE:
{
  CV.logi("String_Node_Str");
  String servicetype=intent.getStringExtra(CV.SERVICETYPE);
  if (servicetype != null && !servicetype.equals(CV.SERVICETYPE_SETTING)) {
    if (CV.isPlugged(this) && CV.getPrefChargingOn(this)) {
      SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(this);
      Editor editor=sp.edit();
      editor.putBoolean(CV.PREF_CHARGING_ON,false);
      editor.commit();
    }
 else {
      togglePreference();
    }
  }
  updateWidgetCharging(false);
  updateNotification();
  if (CV.getPrefAutoOnoff(this) == false) {
    unregisterSensor();
  }
 else {
    if (CV.getPrefSleeping(this) && CV.isInSleepTime(this))     return START_NOT_STICKY;
    registerSensor();
  }
  break;
}
case CV.SERVICEACTION_TURNON:
{
CV.logi("String_Node_Str");
if (!isRegistered()) {
  registerSensor();
  updateWidgetCharging(CV.isPlugged(this));
  updateNotification();
}
break;
}
case CV.SERVICEACTION_TURNOFF:
{
CV.logi("String_Node_Str");
if (isRegistered()) unregisterSensor();
if (!CV.getPrefAutoOnoff(this)) {
updateWidgetCharging(false);
updateNotification();
}
return START_NOT_STICKY;
}
case CV.SERVICEACTION_UPDATE_DISABLE_IN_LANDSCAPE:
{
if (mIsRegistered) {
if (CV.getPrefDisableInLandscape(this) == true) registerOrientationChange();
 else unregisterOrientationChange();
}
break;
}
case CV.SERVICEACTION_MODE_SLEEP:
{
if (CV.getPrefAutoOnoff(this) == false) return START_STICKY;
CV.logv("String_Node_Str");
boolean bSleepModeStart=intent.getBooleanExtra(CV.SLEEP_MODE_START,false);
CV.logv("String_Node_Str",bSleepModeStart);
if (bSleepModeStart) {
CV.logi("String_Node_Str");
unregisterSensor();
}
 else {
CV.logi("String_Node_Str");
registerSensor();
}
break;
}
case CV.SERVICEACTION_PARTIALLOCK_TOGGLE:
{
if (CV.getPrefNoPartialLock(this) && partialLock.isHeld()) {
partialLock.release();
}
 else if (!CV.getPrefNoPartialLock(this) && isRegistered()) {
partialLock.acquire();
}
break;
}
case CV.SERVICEACTION_SET_SCHEDULE:
{
setSchedule();
break;
}
case CV.SERVICEACTION_CANCEL_SCHEDULE:
{
cancelSchedule();
break;
}
default :
CV.logi("String_Node_Str");
}
return START_STICKY;
}