Program: 41307
Project: 41307
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case SHOW_ERROR_MSG:
{
      HashMap data=(HashMap)msg.obj;
synchronized (ActivityManagerService.this) {
        ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
        if (proc != null && proc.crashDialog != null) {
          Slog.e(TAG,"String_Node_Str" + proc);
          return;
        }
        AppErrorResult res=(AppErrorResult)data.get("String_Node_Str");
        if (!mSleeping && !mShuttingDown) {
          Dialog d=new AppErrorDialog(mContext,res,proc);
          d.show();
          proc.crashDialog=d;
        }
 else {
          res.set(0);
        }
      }
      ensureBootCompleted();
    }
  break;
case SHOW_NOT_RESPONDING_MSG:
{
synchronized (ActivityManagerService.this) {
    HashMap data=(HashMap)msg.obj;
    ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
    if (proc != null && proc.anrDialog != null) {
      Slog.e(TAG,"String_Node_Str" + proc);
      return;
    }
    Intent intent=new Intent("String_Node_Str");
    if (!mProcessesReady) {
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    }
    broadcastIntentLocked(null,null,intent,null,null,0,null,null,null,false,false,MY_PID,Process.SYSTEM_UID);
    Dialog d=new AppNotRespondingDialog(ActivityManagerService.this,mContext,proc,(ActivityRecord)data.get("String_Node_Str"));
    d.show();
    proc.anrDialog=d;
  }
  ensureBootCompleted();
}
break;
case SHOW_STRICT_MODE_VIOLATION_MSG:
{
HashMap<String,Object> data=(HashMap<String,Object>)msg.obj;
synchronized (ActivityManagerService.this) {
ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
if (proc == null) {
  Slog.e(TAG,"String_Node_Str");
  break;
}
if (proc.crashDialog != null) {
  Slog.e(TAG,"String_Node_Str" + proc);
  return;
}
AppErrorResult res=(AppErrorResult)data.get("String_Node_Str");
if (!mSleeping && !mShuttingDown) {
  Dialog d=new StrictModeViolationDialog(mContext,res,proc);
  d.show();
  proc.crashDialog=d;
}
 else {
  res.set(0);
}
}
ensureBootCompleted();
}
break;
case SHOW_FACTORY_ERROR_MSG:
{
Dialog d=new FactoryErrorDialog(mContext,msg.getData().getCharSequence("String_Node_Str"));
d.show();
ensureBootCompleted();
}
break;
case UPDATE_CONFIGURATION_MSG:
{
final ContentResolver resolver=mContext.getContentResolver();
Settings.System.putConfiguration(resolver,(Configuration)msg.obj);
}
break;
case GC_BACKGROUND_PROCESSES_MSG:
{
synchronized (ActivityManagerService.this) {
performAppGcsIfAppropriateLocked();
}
}
break;
case WAIT_FOR_DEBUGGER_MSG:
{
synchronized (ActivityManagerService.this) {
ProcessRecord app=(ProcessRecord)msg.obj;
if (msg.arg1 != 0) {
if (!app.waitedForDebugger) {
Dialog d=new AppWaitingForDebuggerDialog(ActivityManagerService.this,mContext,app);
app.waitDialog=d;
app.waitedForDebugger=true;
d.show();
}
}
 else {
if (app.waitDialog != null) {
app.waitDialog.dismiss();
app.waitDialog=null;
}
}
}
}
break;
case BROADCAST_INTENT_MSG:
{
if (DEBUG_BROADCAST) Slog.v(TAG,"String_Node_Str");
processNextBroadcast(true);
}
break;
case BROADCAST_TIMEOUT_MSG:
{
if (mDidDexOpt) {
mDidDexOpt=false;
Message nmsg=mHandler.obtainMessage(BROADCAST_TIMEOUT_MSG);
mHandler.sendMessageDelayed(nmsg,BROADCAST_TIMEOUT);
return;
}
if (mProcessesReady) {
broadcastTimeout();
}
}
break;
case SERVICE_TIMEOUT_MSG:
{
if (mDidDexOpt) {
mDidDexOpt=false;
Message nmsg=mHandler.obtainMessage(SERVICE_TIMEOUT_MSG);
nmsg.obj=msg.obj;
mHandler.sendMessageDelayed(nmsg,SERVICE_TIMEOUT);
return;
}
serviceTimeout((ProcessRecord)msg.obj);
}
break;
case UPDATE_TIME_ZONE:
{
synchronized (ActivityManagerService.this) {
for (int i=mLruProcesses.size() - 1; i >= 0; i--) {
ProcessRecord r=mLruProcesses.get(i);
if (r.thread != null) {
try {
r.thread.updateTimeZone();
}
 catch (RemoteException ex) {
Slog.w(TAG,"String_Node_Str" + r.info.processName);
}
}
}
}
}
break;
case SHOW_UID_ERROR_MSG:
{
AlertDialog d=new BaseErrorDialog(mContext);
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
d.setCancelable(false);
d.setTitle("String_Node_Str");
d.setMessage("String_Node_Str");
d.setButton("String_Node_Str",mHandler.obtainMessage(IM_FEELING_LUCKY_MSG));
mUidAlert=d;
d.show();
}
break;
case IM_FEELING_LUCKY_MSG:
{
if (mUidAlert != null) {
mUidAlert.dismiss();
mUidAlert=null;
}
}
break;
case PROC_START_TIMEOUT_MSG:
{
if (mDidDexOpt) {
mDidDexOpt=false;
Message nmsg=mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
nmsg.obj=msg.obj;
mHandler.sendMessageDelayed(nmsg,PROC_START_TIMEOUT);
return;
}
ProcessRecord app=(ProcessRecord)msg.obj;
synchronized (ActivityManagerService.this) {
processStartTimedOutLocked(app);
}
}
break;
case DO_PENDING_ACTIVITY_LAUNCHES_MSG:
{
synchronized (ActivityManagerService.this) {
doPendingActivityLaunchesLocked(true);
}
}
break;
case KILL_APPLICATION_MSG:
{
synchronized (ActivityManagerService.this) {
int uid=msg.arg1;
boolean restart=(msg.arg2 == 1);
String pkg=(String)msg.obj;
forceStopPackageLocked(pkg,uid,restart,false,true);
}
}
break;
case FINALIZE_PENDING_INTENT_MSG:
{
((PendingIntentRecord)msg.obj).completeFinalize();
}
break;
case POST_HEAVY_NOTIFICATION_MSG:
{
INotificationManager inm=NotificationManager.getService();
if (inm == null) {
return;
}
ActivityRecord root=(ActivityRecord)msg.obj;
ProcessRecord process=root.app;
if (process == null) {
return;
}
try {
Context context=mContext.createPackageContext(process.info.packageName,0);
String text=mContext.getString(R.string.heavy_weight_notification,context.getApplicationInfo().loadLabel(context.getPackageManager()));
Notification notification=new Notification();
notification.icon=com.android.internal.R.drawable.stat_sys_adb;
notification.when=0;
notification.flags=Notification.FLAG_ONGOING_EVENT;
notification.tickerText=text;
notification.defaults=0;
notification.sound=null;
notification.vibrate=null;
notification.setLatestEventInfo(context,text,mContext.getText(R.string.heavy_weight_notification_detail),PendingIntent.getActivity(mContext,0,root.intent,PendingIntent.FLAG_CANCEL_CURRENT));
try {
int[] outId=new int[1];
inm.enqueueNotification("String_Node_Str",R.string.heavy_weight_notification,notification,outId);
}
 catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,"String_Node_Str",e);
}
catch (RemoteException e) {
}
}
 catch (NameNotFoundException e) {
Slog.w(TAG,"String_Node_Str",e);
}
}
break;
case CANCEL_HEAVY_NOTIFICATION_MSG:
{
INotificationManager inm=NotificationManager.getService();
if (inm == null) {
return;
}
try {
inm.cancelNotification("String_Node_Str",R.string.heavy_weight_notification);
}
 catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,"String_Node_Str",e);
}
catch (RemoteException e) {
}
}
break;
case CHECK_EXCESSIVE_WAKE_LOCKS_MSG:
{
synchronized (ActivityManagerService.this) {
checkExcessivePowerUsageLocked(true);
removeMessages(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
Message nmsg=obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
sendMessageDelayed(nmsg,POWER_CHECK_DELAY);
}
}
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
switch (msg.what) {
case SHOW_ERROR_MSG:
{
      HashMap data=(HashMap)msg.obj;
synchronized (ActivityManagerService.this) {
        ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
        if (proc != null && proc.crashDialog != null) {
          Slog.e(TAG,"String_Node_Str" + proc);
          return;
        }
        AppErrorResult res=(AppErrorResult)data.get("String_Node_Str");
        if (!mSleeping && !mShuttingDown) {
          Dialog d=new AppErrorDialog(mContext,res,proc);
          d.show();
          proc.crashDialog=d;
        }
 else {
          res.set(0);
        }
      }
      ensureBootCompleted();
    }
  break;
case SHOW_NOT_RESPONDING_MSG:
{
synchronized (ActivityManagerService.this) {
    HashMap data=(HashMap)msg.obj;
    ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
    if (proc != null && proc.anrDialog != null) {
      Slog.e(TAG,"String_Node_Str" + proc);
      return;
    }
    Intent intent=new Intent("String_Node_Str");
    if (!mProcessesReady) {
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    }
    broadcastIntentLocked(null,null,intent,null,null,0,null,null,null,false,false,MY_PID,Process.SYSTEM_UID);
    Dialog d=new AppNotRespondingDialog(ActivityManagerService.this,mContext,proc,(ActivityRecord)data.get("String_Node_Str"));
    d.show();
    proc.anrDialog=d;
  }
  ensureBootCompleted();
}
break;
case SHOW_STRICT_MODE_VIOLATION_MSG:
{
HashMap<String,Object> data=(HashMap<String,Object>)msg.obj;
synchronized (ActivityManagerService.this) {
ProcessRecord proc=(ProcessRecord)data.get("String_Node_Str");
if (proc == null) {
  Slog.e(TAG,"String_Node_Str");
  break;
}
if (proc.crashDialog != null) {
  Slog.e(TAG,"String_Node_Str" + proc);
  return;
}
AppErrorResult res=(AppErrorResult)data.get("String_Node_Str");
if (!mSleeping && !mShuttingDown) {
  Dialog d=new StrictModeViolationDialog(mContext,res,proc);
  d.show();
  proc.crashDialog=d;
}
 else {
  res.set(0);
}
}
ensureBootCompleted();
}
break;
case SHOW_FACTORY_ERROR_MSG:
{
Dialog d=new FactoryErrorDialog(mContext,msg.getData().getCharSequence("String_Node_Str"));
d.show();
ensureBootCompleted();
}
break;
case UPDATE_CONFIGURATION_MSG:
{
final ContentResolver resolver=mContext.getContentResolver();
Settings.System.putConfiguration(resolver,(Configuration)msg.obj);
}
break;
case GC_BACKGROUND_PROCESSES_MSG:
{
synchronized (ActivityManagerService.this) {
performAppGcsIfAppropriateLocked();
}
}
break;
case WAIT_FOR_DEBUGGER_MSG:
{
synchronized (ActivityManagerService.this) {
ProcessRecord app=(ProcessRecord)msg.obj;
if (msg.arg1 != 0) {
if (!app.waitedForDebugger) {
Dialog d=new AppWaitingForDebuggerDialog(ActivityManagerService.this,mContext,app);
app.waitDialog=d;
app.waitedForDebugger=true;
d.show();
}
}
 else {
if (app.waitDialog != null) {
app.waitDialog.dismiss();
app.waitDialog=null;
}
}
}
}
break;
case BROADCAST_INTENT_MSG:
{
if (DEBUG_BROADCAST) Slog.v(TAG,"String_Node_Str");
processNextBroadcast(true);
}
break;
case BROADCAST_TIMEOUT_MSG:
{
synchronized (ActivityManagerService.this) {
broadcastTimeoutLocked(true);
}
}
break;
case SERVICE_TIMEOUT_MSG:
{
if (mDidDexOpt) {
mDidDexOpt=false;
Message nmsg=mHandler.obtainMessage(SERVICE_TIMEOUT_MSG);
nmsg.obj=msg.obj;
mHandler.sendMessageDelayed(nmsg,SERVICE_TIMEOUT);
return;
}
serviceTimeout((ProcessRecord)msg.obj);
}
break;
case UPDATE_TIME_ZONE:
{
synchronized (ActivityManagerService.this) {
for (int i=mLruProcesses.size() - 1; i >= 0; i--) {
ProcessRecord r=mLruProcesses.get(i);
if (r.thread != null) {
try {
r.thread.updateTimeZone();
}
 catch (RemoteException ex) {
Slog.w(TAG,"String_Node_Str" + r.info.processName);
}
}
}
}
}
break;
case SHOW_UID_ERROR_MSG:
{
AlertDialog d=new BaseErrorDialog(mContext);
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
d.setCancelable(false);
d.setTitle("String_Node_Str");
d.setMessage("String_Node_Str");
d.setButton("String_Node_Str",mHandler.obtainMessage(IM_FEELING_LUCKY_MSG));
mUidAlert=d;
d.show();
}
break;
case IM_FEELING_LUCKY_MSG:
{
if (mUidAlert != null) {
mUidAlert.dismiss();
mUidAlert=null;
}
}
break;
case PROC_START_TIMEOUT_MSG:
{
if (mDidDexOpt) {
mDidDexOpt=false;
Message nmsg=mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
nmsg.obj=msg.obj;
mHandler.sendMessageDelayed(nmsg,PROC_START_TIMEOUT);
return;
}
ProcessRecord app=(ProcessRecord)msg.obj;
synchronized (ActivityManagerService.this) {
processStartTimedOutLocked(app);
}
}
break;
case DO_PENDING_ACTIVITY_LAUNCHES_MSG:
{
synchronized (ActivityManagerService.this) {
doPendingActivityLaunchesLocked(true);
}
}
break;
case KILL_APPLICATION_MSG:
{
synchronized (ActivityManagerService.this) {
int uid=msg.arg1;
boolean restart=(msg.arg2 == 1);
String pkg=(String)msg.obj;
forceStopPackageLocked(pkg,uid,restart,false,true);
}
}
break;
case FINALIZE_PENDING_INTENT_MSG:
{
((PendingIntentRecord)msg.obj).completeFinalize();
}
break;
case POST_HEAVY_NOTIFICATION_MSG:
{
INotificationManager inm=NotificationManager.getService();
if (inm == null) {
return;
}
ActivityRecord root=(ActivityRecord)msg.obj;
ProcessRecord process=root.app;
if (process == null) {
return;
}
try {
Context context=mContext.createPackageContext(process.info.packageName,0);
String text=mContext.getString(R.string.heavy_weight_notification,context.getApplicationInfo().loadLabel(context.getPackageManager()));
Notification notification=new Notification();
notification.icon=com.android.internal.R.drawable.stat_sys_adb;
notification.when=0;
notification.flags=Notification.FLAG_ONGOING_EVENT;
notification.tickerText=text;
notification.defaults=0;
notification.sound=null;
notification.vibrate=null;
notification.setLatestEventInfo(context,text,mContext.getText(R.string.heavy_weight_notification_detail),PendingIntent.getActivity(mContext,0,root.intent,PendingIntent.FLAG_CANCEL_CURRENT));
try {
int[] outId=new int[1];
inm.enqueueNotification("String_Node_Str",R.string.heavy_weight_notification,notification,outId);
}
 catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,"String_Node_Str",e);
}
catch (RemoteException e) {
}
}
 catch (NameNotFoundException e) {
Slog.w(TAG,"String_Node_Str",e);
}
}
break;
case CANCEL_HEAVY_NOTIFICATION_MSG:
{
INotificationManager inm=NotificationManager.getService();
if (inm == null) {
return;
}
try {
inm.cancelNotification("String_Node_Str",R.string.heavy_weight_notification);
}
 catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,"String_Node_Str",e);
}
catch (RemoteException e) {
}
}
break;
case CHECK_EXCESSIVE_WAKE_LOCKS_MSG:
{
synchronized (ActivityManagerService.this) {
checkExcessivePowerUsageLocked(true);
removeMessages(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
Message nmsg=obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
sendMessageDelayed(nmsg,POWER_CHECK_DELAY);
}
}
break;
}
}