Program: 183436
Project: 183436
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_MENU_LONG_PRESS:
{
      if (mPanelChordingKey == 0)       return;
      mKeycodeMenuTimeoutHandler.sendEmptyMessage(MSG_MENU_LONG_PRESS_COMPLETE);
      break;
    }
case MSG_CALL_LONG_PRESS:
{
    if (!mKeycodeCallTimeoutActive)     return;
    mKeycodeMenuTimeoutHandler.sendEmptyMessage(MSG_CALL_LONG_PRESS_COMPLETE);
    break;
  }
case MSG_CAMERA_LONG_PRESS:
{
  if (!mKeycodeCameraTimeoutActive)   return;
  Message newMessage=Message.obtain(msg);
  newMessage.what=MSG_CAMERA_LONG_PRESS_COMPLETE;
  mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
  break;
}
case MSG_SEARCH_LONG_PRESS:
{
if (!mSearchKeyDownReceived) return;
Message newMessage=Message.obtain(msg);
newMessage.what=MSG_SEARCH_LONG_PRESS_COMPLETE;
mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
break;
}
case MSG_MENU_LONG_PRESS_COMPLETE:
{
if (mPanelChordingKey == 0) return;
mPanelChordingKey=0;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
InputMethodManager imm=(InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
}
break;
case MSG_CALL_LONG_PRESS_COMPLETE:
{
if (!mKeycodeCallTimeoutActive) return;
mKeycodeCallTimeoutActive=false;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Intent intent=new Intent(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
getContext().startActivity(intent);
}
 catch (ActivityNotFoundException e) {
startCallActivity();
}
}
break;
case MSG_CAMERA_LONG_PRESS_COMPLETE:
{
if (!mKeycodeCameraTimeoutActive) return;
mKeycodeCameraTimeoutActive=false;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Intent intent=new Intent(Intent.ACTION_CAMERA_BUTTON,null);
intent.putExtra(Intent.EXTRA_KEY_EVENT,(KeyEvent)msg.obj);
getContext().sendOrderedBroadcast(intent,null);
sendCloseSystemWindows();
}
break;
case MSG_SEARCH_LONG_PRESS_COMPLETE:
{
if (getKeyguardManager().inKeyguardRestrictedInputMode() || !mSearchKeyDownReceived) {
mSearchKeyDownReceived=false;
return;
}
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Intent intent=new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
getContext().startActivity(intent);
mSearchKeyDownReceived=false;
}
 catch (ActivityNotFoundException e) {
}
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_MENU_LONG_PRESS:
{
      if (mPanelChordingKey == 0)       return;
      mKeycodeMenuTimeoutHandler.sendEmptyMessage(MSG_MENU_LONG_PRESS_COMPLETE);
      break;
    }
case MSG_CALL_LONG_PRESS:
{
    if (!mKeycodeCallTimeoutActive)     return;
    mKeycodeMenuTimeoutHandler.sendEmptyMessage(MSG_CALL_LONG_PRESS_COMPLETE);
    break;
  }
case MSG_CAMERA_LONG_PRESS:
{
  if (!mKeycodeCameraTimeoutActive)   return;
  Message newMessage=Message.obtain(msg);
  newMessage.what=MSG_CAMERA_LONG_PRESS_COMPLETE;
  mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
  break;
}
case MSG_SEARCH_LONG_PRESS:
{
if (!mSearchKeyDownReceived) return;
Message newMessage=Message.obtain(msg);
newMessage.what=MSG_SEARCH_LONG_PRESS_COMPLETE;
mKeycodeMenuTimeoutHandler.sendMessage(newMessage);
break;
}
case MSG_MENU_LONG_PRESS_COMPLETE:
{
if (mPanelChordingKey == 0) return;
mPanelChordingKey=0;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
InputMethodManager imm=(InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
}
break;
case MSG_CALL_LONG_PRESS_COMPLETE:
{
if (!mKeycodeCallTimeoutActive) return;
mKeycodeCallTimeoutActive=false;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Intent intent=new Intent(Intent.ACTION_VOICE_COMMAND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
getContext().startActivity(intent);
}
 catch (ActivityNotFoundException e) {
startCallActivity();
}
}
break;
case MSG_CAMERA_LONG_PRESS_COMPLETE:
{
if (!mKeycodeCameraTimeoutActive) return;
mKeycodeCameraTimeoutActive=false;
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
sendCloseSystemWindows();
Intent intent=new Intent(Intent.ACTION_CAMERA_BUTTON,null);
intent.putExtra(Intent.EXTRA_KEY_EVENT,(KeyEvent)msg.obj);
getContext().sendOrderedBroadcast(intent,null);
}
break;
case MSG_SEARCH_LONG_PRESS_COMPLETE:
{
if (getKeyguardManager().inKeyguardRestrictedInputMode() || !mSearchKeyDownReceived) {
mSearchKeyDownReceived=false;
return;
}
mDecor.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Intent intent=new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sendCloseSystemWindows();
getContext().startActivity(intent);
mSearchKeyDownReceived=false;
}
 catch (ActivityNotFoundException e) {
}
}
break;
}
}