Program: 192333
Project: 192333
Buggy source:
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
case MSG_REPORT_IDLE_ON_LIGHT:
{
  EventLogTags.writeDeviceIdleOnStart();
  final boolean deepChanged;
  final boolean lightChanged;
  if (msg.what == MSG_REPORT_IDLE_ON) {
    deepChanged=mLocalPowerManager.setDeviceIdleMode(true);
    lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
  }
 else {
    deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
    lightChanged=mLocalPowerManager.setLightDeviceIdleMode(true);
  }
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(msg.what == MSG_REPORT_IDLE_ON ? BatteryStats.DEVICE_IDLE_MODE_DEEP : BatteryStats.DEVICE_IDLE_MODE_LIGHT,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  if (deepChanged) {
    getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
  }
  if (lightChanged) {
    getContext().sendBroadcastAsUser(mLightIdleIntent,UserHandle.ALL);
  }
  EventLogTags.writeDeviceIdleOnComplete();
}
break;
case MSG_REPORT_IDLE_OFF:
{
EventLogTags.writeDeviceIdleOffStart("String_Node_Str");
final boolean deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
final boolean lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(BatteryStats.DEVICE_IDLE_MODE_OFF,null,Process.myUid());
}
 catch (RemoteException e) {
}
if (deepChanged) {
incActiveIdleOps();
getContext().sendOrderedBroadcastAsUser(mIdleIntent,UserHandle.ALL,null,mIdleStartedDoneReceiver,null,0,null,null);
}
if (lightChanged) {
incActiveIdleOps();
getContext().sendOrderedBroadcastAsUser(mLightIdleIntent,UserHandle.ALL,null,mIdleStartedDoneReceiver,null,0,null,null);
}
decActiveIdleOps();
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
EventLogTags.writeDeviceIdleOffStart(activeReason != null ? activeReason : "String_Node_Str");
final boolean deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
final boolean lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(BatteryStats.DEVICE_IDLE_MODE_OFF,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (deepChanged) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
if (lightChanged) {
getContext().sendBroadcastAsUser(mLightIdleIntent,UserHandle.ALL);
}
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
case MSG_REPORT_MAINTENANCE_ACTIVITY:
{
boolean active=(msg.arg1 == 1);
final int size=mMaintenanceActivityListeners.beginBroadcast();
try {
for (int i=0; i < size; i++) {
try {
mMaintenanceActivityListeners.getBroadcastItem(i).onMaintenanceActivityChanged(active);
}
 catch (RemoteException ignored) {
}
}
}
  finally {
mMaintenanceActivityListeners.finishBroadcast();
}
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
case MSG_REPORT_IDLE_ON_LIGHT:
{
  EventLogTags.writeDeviceIdleOnStart();
  final boolean deepChanged;
  final boolean lightChanged;
  if (msg.what == MSG_REPORT_IDLE_ON) {
    deepChanged=mLocalPowerManager.setDeviceIdleMode(true);
    lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
  }
 else {
    deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
    lightChanged=mLocalPowerManager.setLightDeviceIdleMode(true);
  }
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(msg.what == MSG_REPORT_IDLE_ON ? BatteryStats.DEVICE_IDLE_MODE_DEEP : BatteryStats.DEVICE_IDLE_MODE_LIGHT,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  if (deepChanged) {
    getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
  }
  if (lightChanged) {
    getContext().sendBroadcastAsUser(mLightIdleIntent,UserHandle.ALL);
  }
  EventLogTags.writeDeviceIdleOnComplete();
}
break;
case MSG_REPORT_IDLE_OFF:
{
EventLogTags.writeDeviceIdleOffStart("String_Node_Str");
final boolean deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
final boolean lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(BatteryStats.DEVICE_IDLE_MODE_OFF,null,Process.myUid());
}
 catch (RemoteException e) {
}
if (deepChanged) {
incActiveIdleOps();
getContext().sendOrderedBroadcastAsUser(mIdleIntent,UserHandle.ALL,null,mIdleStartedDoneReceiver,null,0,null,null);
}
if (lightChanged) {
incActiveIdleOps();
getContext().sendOrderedBroadcastAsUser(mLightIdleIntent,UserHandle.ALL,null,mIdleStartedDoneReceiver,null,0,null,null);
}
decActiveIdleOps();
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
EventLogTags.writeDeviceIdleOffStart(activeReason != null ? activeReason : "String_Node_Str");
final boolean deepChanged=mLocalPowerManager.setDeviceIdleMode(false);
final boolean lightChanged=mLocalPowerManager.setLightDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(BatteryStats.DEVICE_IDLE_MODE_OFF,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (deepChanged) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
if (lightChanged) {
getContext().sendBroadcastAsUser(mLightIdleIntent,UserHandle.ALL);
}
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
case MSG_REPORT_MAINTENANCE_ACTIVITY:
{
boolean active=(msg.arg1 == 1);
final int size=mMaintenanceActivityListeners.beginBroadcast();
try {
for (int i=0; i < size; i++) {
try {
mMaintenanceActivityListeners.getBroadcastItem(i).onMaintenanceActivityChanged(active);
}
 catch (RemoteException ignored) {
}
}
}
  finally {
mMaintenanceActivityListeners.finishBroadcast();
}
}
break;
case MSG_FINISH_IDLE_OP:
{
decActiveIdleOps();
}
break;
}
}