Program: 190944
Project: 190944
Buggy source:
int onShellCommand(Shell shell,String cmd){
  PrintWriter pw=shell.getOutPrintWriter();
  if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      String arg=shell.getNextArg();
      try {
        if (arg == null || "String_Node_Str".equals(arg)) {
          stepIdleStateLocked("String_Node_Str");
          pw.print("String_Node_Str");
          pw.println(stateToString(mState));
        }
 else         if ("String_Node_Str".equals(arg)) {
          stepLightIdleStateLocked("String_Node_Str");
          pw.print("String_Node_Str");
          pw.println(lightStateToString(mLightState));
        }
 else {
          pw.println("String_Node_Str" + arg);
        }
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      String arg=shell.getNextArg();
      try {
        if (arg == null || "String_Node_Str".equals(arg)) {
          if (!mDeepEnabled) {
            pw.println("String_Node_Str");
            return -1;
          }
          mForceIdle=true;
          becomeInactiveIfAppropriateLocked();
          int curState=mState;
          while (curState != STATE_IDLE) {
            stepIdleStateLocked("String_Node_Str");
            if (curState == mState) {
              pw.print("String_Node_Str");
              pw.println(stateToString(mState));
              exitForceIdleLocked();
              return -1;
            }
            curState=mState;
          }
          pw.println("String_Node_Str");
        }
 else         if ("String_Node_Str".equals(arg)) {
          mForceIdle=true;
          becomeInactiveIfAppropriateLocked();
          int curLightState=mLightState;
          while (curLightState != LIGHT_STATE_IDLE) {
            stepIdleStateLocked("String_Node_Str");
            if (curLightState == mLightState) {
              pw.print("String_Node_Str");
              pw.println(lightStateToString(mLightState));
              exitForceIdleLocked();
              return -1;
            }
            curLightState=mLightState;
          }
          pw.println("String_Node_Str");
        }
 else {
          pw.println("String_Node_Str" + arg);
        }
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      try {
        mForceIdle=true;
        becomeInactiveIfAppropriateLocked();
        pw.print("String_Node_Str");
        pw.print(lightStateToString(mLightState));
        pw.print("String_Node_Str");
        pw.println(stateToString(mState));
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      try {
        exitForceIdleLocked();
        pw.print("String_Node_Str");
        pw.print(lightStateToString(mLightState));
        pw.print("String_Node_Str");
        pw.println(stateToString(mState));
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      String arg=shell.getNextArg();
      if (arg != null) {
        long token=Binder.clearCallingIdentity();
        try {
switch (arg) {
case "String_Node_Str":
            pw.println(lightStateToString(mLightState));
          break;
case "String_Node_Str":
        pw.println(stateToString(mState));
      break;
case "String_Node_Str":
    pw.println(mForceIdle);
  break;
case "String_Node_Str":
pw.println(mScreenOn);
break;
case "String_Node_Str":
pw.println(mCharging);
break;
case "String_Node_Str":
pw.println(mNetworkConnected);
break;
default :
pw.println("String_Node_Str" + arg);
break;
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
 else {
pw.println("String_Node_Str");
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
long token=Binder.clearCallingIdentity();
String arg=shell.getNextArg();
try {
boolean becomeActive=false;
boolean valid=false;
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (mDeepEnabled) {
mDeepEnabled=false;
becomeActive=true;
pw.println("String_Node_Str");
}
}
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (mLightEnabled) {
mLightEnabled=false;
becomeActive=true;
pw.println("String_Node_Str");
}
}
if (becomeActive) {
becomeActiveLocked((arg == null ? "String_Node_Str" : arg) + "String_Node_Str",Process.myUid());
}
if (!valid) {
pw.println("String_Node_Str" + arg);
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
long token=Binder.clearCallingIdentity();
String arg=shell.getNextArg();
try {
boolean becomeInactive=false;
boolean valid=false;
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (!mDeepEnabled) {
mDeepEnabled=true;
becomeInactive=true;
pw.println("String_Node_Str");
}
}
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (!mLightEnabled) {
mLightEnabled=true;
becomeInactive=true;
pw.println("String_Node_Str");
}
}
if (becomeInactive) {
becomeInactiveIfAppropriateLocked();
}
if (!valid) {
pw.println("String_Node_Str" + arg);
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
synchronized (this) {
String arg=shell.getNextArg();
if (arg == null || "String_Node_Str".equals(arg)) {
pw.println(mDeepEnabled && mLightEnabled ? "String_Node_Str" : 0);
}
 else if ("String_Node_Str".equals(arg)) {
pw.println(mDeepEnabled ? "String_Node_Str" : 0);
}
 else if ("String_Node_Str".equals(arg)) {
pw.println(mLightEnabled ? "String_Node_Str" : 0);
}
 else {
pw.println("String_Node_Str" + arg);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
long token=Binder.clearCallingIdentity();
try {
String arg=shell.getNextArg();
if (arg != null) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
do {
if (arg.length() < 1 || (arg.charAt(0) != '-' && arg.charAt(0) != '+' && arg.charAt(0) != '=')) {
pw.println("String_Node_Str" + arg);
return -1;
}
char op=arg.charAt(0);
String pkg=arg.substring(1);
if (op == '+') {
if (addPowerSaveWhitelistAppInternal(pkg)) {
pw.println("String_Node_Str" + pkg);
}
 else {
pw.println("String_Node_Str" + pkg);
}
}
 else if (op == '-') {
if (removePowerSaveWhitelistAppInternal(pkg)) {
pw.println("String_Node_Str" + pkg);
}
}
 else {
pw.println(getPowerSaveWhitelistAppInternal(pkg));
}
}
 while ((arg=shell.getNextArg()) != null);
}
 else {
synchronized (this) {
for (int j=0; j < mPowerSaveWhitelistAppsExceptIdle.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistAppsExceptIdle.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistAppsExceptIdle.valueAt(j));
}
for (int j=0; j < mPowerSaveWhitelistApps.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistApps.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistApps.valueAt(j));
}
for (int j=0; j < mPowerSaveWhitelistUserApps.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistUserApps.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistUserApps.valueAt(j));
}
}
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
 else if ("String_Node_Str".equals(cmd)) {
String opt;
while ((opt=shell.getNextOption()) != null) {
if ("String_Node_Str".equals(opt)) {
opt=shell.getNextArg();
if (opt == null) {
pw.println("String_Node_Str");
return -1;
}
shell.userId=Integer.parseInt(opt);
}
}
String arg=shell.getNextArg();
if (arg != null) {
try {
addPowerSaveTempWhitelistAppChecked(arg,10000L,shell.userId,"String_Node_Str");
}
 catch (RemoteException re) {
pw.println("String_Node_Str" + re);
}
}
 else {
dumpTempWhitelistSchedule(pw,false);
}
}
 else {
return shell.handleDefaultCommands(cmd);
}
return 0;
}

Fixed version (ground truth):
int onShellCommand(Shell shell,String cmd){
  PrintWriter pw=shell.getOutPrintWriter();
  if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      String arg=shell.getNextArg();
      try {
        if (arg == null || "String_Node_Str".equals(arg)) {
          stepIdleStateLocked("String_Node_Str");
          pw.print("String_Node_Str");
          pw.println(stateToString(mState));
        }
 else         if ("String_Node_Str".equals(arg)) {
          stepLightIdleStateLocked("String_Node_Str");
          pw.print("String_Node_Str");
          pw.println(lightStateToString(mLightState));
        }
 else {
          pw.println("String_Node_Str" + arg);
        }
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      String arg=shell.getNextArg();
      try {
        if (arg == null || "String_Node_Str".equals(arg)) {
          if (!mDeepEnabled) {
            pw.println("String_Node_Str");
            return -1;
          }
          mForceIdle=true;
          becomeInactiveIfAppropriateLocked();
          int curState=mState;
          while (curState != STATE_IDLE) {
            stepIdleStateLocked("String_Node_Str");
            if (curState == mState) {
              pw.print("String_Node_Str");
              pw.println(stateToString(mState));
              exitForceIdleLocked();
              return -1;
            }
            curState=mState;
          }
          pw.println("String_Node_Str");
        }
 else         if ("String_Node_Str".equals(arg)) {
          mForceIdle=true;
          becomeInactiveIfAppropriateLocked();
          int curLightState=mLightState;
          while (curLightState != LIGHT_STATE_IDLE) {
            stepIdleStateLocked("String_Node_Str");
            if (curLightState == mLightState) {
              pw.print("String_Node_Str");
              pw.println(lightStateToString(mLightState));
              exitForceIdleLocked();
              return -1;
            }
            curLightState=mLightState;
          }
          pw.println("String_Node_Str");
        }
 else {
          pw.println("String_Node_Str" + arg);
        }
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      try {
        mForceIdle=true;
        becomeInactiveIfAppropriateLocked();
        pw.print("String_Node_Str");
        pw.print(lightStateToString(mLightState));
        pw.print("String_Node_Str");
        pw.println(stateToString(mState));
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      long token=Binder.clearCallingIdentity();
      try {
        exitForceIdleLocked();
        pw.print("String_Node_Str");
        pw.print(lightStateToString(mLightState));
        pw.print("String_Node_Str");
        pw.println(stateToString(mState));
      }
  finally {
        Binder.restoreCallingIdentity(token);
      }
    }
  }
 else   if ("String_Node_Str".equals(cmd)) {
    getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
      String arg=shell.getNextArg();
      if (arg != null) {
        long token=Binder.clearCallingIdentity();
        try {
switch (arg) {
case "String_Node_Str":
            pw.println(lightStateToString(mLightState));
          break;
case "String_Node_Str":
        pw.println(stateToString(mState));
      break;
case "String_Node_Str":
    pw.println(mForceIdle);
  break;
case "String_Node_Str":
pw.println(mScreenOn);
break;
case "String_Node_Str":
pw.println(mCharging);
break;
case "String_Node_Str":
pw.println(mNetworkConnected);
break;
default :
pw.println("String_Node_Str" + arg);
break;
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
 else {
pw.println("String_Node_Str");
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
long token=Binder.clearCallingIdentity();
String arg=shell.getNextArg();
try {
boolean becomeActive=false;
boolean valid=false;
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (mDeepEnabled) {
mDeepEnabled=false;
becomeActive=true;
pw.println("String_Node_Str");
}
}
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (mLightEnabled) {
mLightEnabled=false;
becomeActive=true;
pw.println("String_Node_Str");
}
}
if (becomeActive) {
becomeActiveLocked((arg == null ? "String_Node_Str" : arg) + "String_Node_Str",Process.myUid());
}
if (!valid) {
pw.println("String_Node_Str" + arg);
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
synchronized (this) {
long token=Binder.clearCallingIdentity();
String arg=shell.getNextArg();
try {
boolean becomeInactive=false;
boolean valid=false;
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (!mDeepEnabled) {
mDeepEnabled=true;
becomeInactive=true;
pw.println("String_Node_Str");
}
}
if (arg == null || "String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
valid=true;
if (!mLightEnabled) {
mLightEnabled=true;
becomeInactive=true;
pw.println("String_Node_Str");
}
}
if (becomeInactive) {
becomeInactiveIfAppropriateLocked();
}
if (!valid) {
pw.println("String_Node_Str" + arg);
}
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
synchronized (this) {
String arg=shell.getNextArg();
if (arg == null || "String_Node_Str".equals(arg)) {
pw.println(mDeepEnabled && mLightEnabled ? "String_Node_Str" : 0);
}
 else if ("String_Node_Str".equals(arg)) {
pw.println(mDeepEnabled ? "String_Node_Str" : 0);
}
 else if ("String_Node_Str".equals(arg)) {
pw.println(mLightEnabled ? "String_Node_Str" : 0);
}
 else {
pw.println("String_Node_Str" + arg);
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
String arg=shell.getNextArg();
if (arg != null) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,null);
long token=Binder.clearCallingIdentity();
try {
do {
if (arg.length() < 1 || (arg.charAt(0) != '-' && arg.charAt(0) != '+' && arg.charAt(0) != '=')) {
pw.println("String_Node_Str" + arg);
return -1;
}
char op=arg.charAt(0);
String pkg=arg.substring(1);
if (op == '+') {
if (addPowerSaveWhitelistAppInternal(pkg)) {
pw.println("String_Node_Str" + pkg);
}
 else {
pw.println("String_Node_Str" + pkg);
}
}
 else if (op == '-') {
if (removePowerSaveWhitelistAppInternal(pkg)) {
pw.println("String_Node_Str" + pkg);
}
}
 else {
pw.println(getPowerSaveWhitelistAppInternal(pkg));
}
}
 while ((arg=shell.getNextArg()) != null);
}
  finally {
Binder.restoreCallingIdentity(token);
}
}
 else {
synchronized (this) {
for (int j=0; j < mPowerSaveWhitelistAppsExceptIdle.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistAppsExceptIdle.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistAppsExceptIdle.valueAt(j));
}
for (int j=0; j < mPowerSaveWhitelistApps.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistApps.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistApps.valueAt(j));
}
for (int j=0; j < mPowerSaveWhitelistUserApps.size(); j++) {
pw.print("String_Node_Str");
pw.print(mPowerSaveWhitelistUserApps.keyAt(j));
pw.print("String_Node_Str");
pw.println(mPowerSaveWhitelistUserApps.valueAt(j));
}
}
}
}
 else if ("String_Node_Str".equals(cmd)) {
String opt;
while ((opt=shell.getNextOption()) != null) {
if ("String_Node_Str".equals(opt)) {
opt=shell.getNextArg();
if (opt == null) {
pw.println("String_Node_Str");
return -1;
}
shell.userId=Integer.parseInt(opt);
}
}
String arg=shell.getNextArg();
if (arg != null) {
try {
addPowerSaveTempWhitelistAppChecked(arg,10000L,shell.userId,"String_Node_Str");
}
 catch (RemoteException re) {
pw.println("String_Node_Str" + re);
}
}
 else {
dumpTempWhitelistSchedule(pw,false);
}
}
 else {
return shell.handleDefaultCommands(cmd);
}
return 0;
}