Program: 23370
Project: 23370
Buggy source:
/** 
 * {@inheritDoc} 
 */
public int interceptKeyTq(RawInputEvent event,boolean screenIsOn){
  int result=ACTION_PASS_TO_USER;
  final boolean isWakeKey=isWakeKeyTq(event);
  final boolean keyguardShowing=keyguardIsShowingTq();
  if (false) {
    Log.d(TAG,"String_Node_Str" + event + "String_Node_Str"+ event.keycode+ "String_Node_Str"+ screenIsOn+ "String_Node_Str"+ keyguardShowing);
  }
  if (keyguardShowing) {
    if (screenIsOn) {
      result|=ACTION_PASS_TO_USER;
    }
 else {
      result&=~ACTION_PASS_TO_USER;
      final boolean isKeyDown=(event.type == RawInputEvent.EV_KEY) && (event.value != 0);
      if (isWakeKey && isKeyDown) {
        if (!mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(event.keycode) && (event.keycode == KeyEvent.KEYCODE_VOLUME_DOWN || event.keycode == KeyEvent.KEYCODE_VOLUME_UP)) {
          if (isInCall()) {
            mKeyguardMediator.pokeWakelock();
          }
 else           if (isMusicActive()) {
            handleVolumeKey(AudioManager.STREAM_MUSIC,event.keycode);
          }
        }
      }
    }
  }
 else   if (!screenIsOn) {
    if (isInCall() && event.type == RawInputEvent.EV_KEY && (event.keycode == KeyEvent.KEYCODE_VOLUME_DOWN || event.keycode == KeyEvent.KEYCODE_VOLUME_UP)) {
      result&=~ACTION_PASS_TO_USER;
      handleVolumeKey(AudioManager.STREAM_VOICE_CALL,event.keycode);
    }
    if (isWakeKey) {
      result|=ACTION_POKE_USER_ACTIVITY;
      result&=~ACTION_PASS_TO_USER;
    }
  }
  int type=event.type;
  int code=event.keycode;
  boolean down=event.value != 0;
  if (type == RawInputEvent.EV_KEY) {
    if (code == KeyEvent.KEYCODE_ENDCALL || code == KeyEvent.KEYCODE_POWER) {
      if (down) {
        boolean handled=false;
        ITelephony phoneServ=getPhoneInterface();
        if (phoneServ != null) {
          try {
            if (code == KeyEvent.KEYCODE_ENDCALL) {
              handled=phoneServ.endCall();
            }
 else             if (code == KeyEvent.KEYCODE_POWER && phoneServ.isRinging()) {
              phoneServ.silenceRinger();
              handled=true;
            }
          }
 catch (          RemoteException ex) {
            Log.w(TAG,"String_Node_Str" + ex);
          }
        }
 else {
          Log.w(TAG,"String_Node_Str");
        }
        if ((handled && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) {
          mShouldTurnOffOnKeyUp=false;
        }
 else {
          mShouldTurnOffOnKeyUp=true;
          mHandler.postDelayed(mPowerLongPress,ViewConfiguration.getGlobalActionKeyTimeout());
          result&=~ACTION_PASS_TO_USER;
        }
      }
 else {
        mHandler.removeCallbacks(mPowerLongPress);
        if (mShouldTurnOffOnKeyUp) {
          mShouldTurnOffOnKeyUp=false;
          boolean gohome=(mEndcallBehavior & ENDCALL_HOME) != 0;
          boolean sleeps=(mEndcallBehavior & ENDCALL_SLEEPS) != 0;
          if (keyguardShowing || (sleeps && !gohome) || (gohome && !goHome() && sleeps)) {
            Log.d(TAG,"String_Node_Str" + Integer.toHexString(mEndcallBehavior));
            result&=~ACTION_POKE_USER_ACTIVITY;
            result|=ACTION_GO_TO_SLEEP;
          }
          result&=~ACTION_PASS_TO_USER;
        }
      }
    }
 else     if (isMediaKey(code)) {
      if ((result & ACTION_PASS_TO_USER) == 0) {
        KeyEvent keyEvent=new KeyEvent(event.when,event.when,down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP,code,0);
        mBroadcastWakeLock.acquire();
        mHandler.post(new PassHeadsetKey(keyEvent));
      }
    }
 else     if (code == KeyEvent.KEYCODE_CALL) {
      if (down) {
        try {
          ITelephony phoneServ=getPhoneInterface();
          if (phoneServ != null) {
            if (phoneServ.isRinging()) {
              Log.i(TAG,"String_Node_Str" + "String_Node_Str");
              phoneServ.answerRingingCall();
              result&=~ACTION_PASS_TO_USER;
            }
          }
 else {
            Log.w(TAG,"String_Node_Str");
          }
        }
 catch (        RemoteException ex) {
          Log.w(TAG,"String_Node_Str",ex);
        }
      }
    }
 else     if ((code == KeyEvent.KEYCODE_VOLUME_UP) || (code == KeyEvent.KEYCODE_VOLUME_DOWN)) {
      if (down) {
        try {
          ITelephony phoneServ=getPhoneInterface();
          if (phoneServ != null) {
            if (phoneServ.isRinging()) {
              Log.i(TAG,"String_Node_Str" + "String_Node_Str");
              phoneServ.silenceRinger();
              result&=~ACTION_PASS_TO_USER;
            }
          }
 else {
            Log.w(TAG,"String_Node_Str");
          }
        }
 catch (        RemoteException ex) {
          Log.w(TAG,"String_Node_Str",ex);
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public int interceptKeyTq(RawInputEvent event,boolean screenIsOn){
  int result=ACTION_PASS_TO_USER;
  final boolean isWakeKey=isWakeKeyTq(event);
  final boolean keyguardActive=(screenIsOn ? mKeyguardMediator.isShowingAndNotHidden() : mKeyguardMediator.isShowing());
  if (false) {
    Log.d(TAG,"String_Node_Str" + event + "String_Node_Str"+ event.keycode+ "String_Node_Str"+ screenIsOn+ "String_Node_Str"+ keyguardActive);
  }
  if (keyguardActive) {
    if (screenIsOn) {
      result|=ACTION_PASS_TO_USER;
    }
 else {
      result&=~ACTION_PASS_TO_USER;
      final boolean isKeyDown=(event.type == RawInputEvent.EV_KEY) && (event.value != 0);
      if (isWakeKey && isKeyDown) {
        if (!mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(event.keycode) && (event.keycode == KeyEvent.KEYCODE_VOLUME_DOWN || event.keycode == KeyEvent.KEYCODE_VOLUME_UP)) {
          if (isInCall()) {
            mKeyguardMediator.pokeWakelock();
          }
 else           if (isMusicActive()) {
            handleVolumeKey(AudioManager.STREAM_MUSIC,event.keycode);
          }
        }
      }
    }
  }
 else   if (!screenIsOn) {
    if (isInCall() && event.type == RawInputEvent.EV_KEY && (event.keycode == KeyEvent.KEYCODE_VOLUME_DOWN || event.keycode == KeyEvent.KEYCODE_VOLUME_UP)) {
      result&=~ACTION_PASS_TO_USER;
      handleVolumeKey(AudioManager.STREAM_VOICE_CALL,event.keycode);
    }
    if (isWakeKey) {
      result|=ACTION_POKE_USER_ACTIVITY;
      result&=~ACTION_PASS_TO_USER;
    }
  }
  int type=event.type;
  int code=event.keycode;
  boolean down=event.value != 0;
  if (type == RawInputEvent.EV_KEY) {
    if (code == KeyEvent.KEYCODE_ENDCALL || code == KeyEvent.KEYCODE_POWER) {
      if (down) {
        boolean handled=false;
        ITelephony phoneServ=getPhoneInterface();
        if (phoneServ != null) {
          try {
            if (code == KeyEvent.KEYCODE_ENDCALL) {
              handled=phoneServ.endCall();
            }
 else             if (code == KeyEvent.KEYCODE_POWER && phoneServ.isRinging()) {
              phoneServ.silenceRinger();
              handled=true;
            }
          }
 catch (          RemoteException ex) {
            Log.w(TAG,"String_Node_Str" + ex);
          }
        }
 else {
          Log.w(TAG,"String_Node_Str");
        }
        if ((handled && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) {
          mShouldTurnOffOnKeyUp=false;
        }
 else {
          mShouldTurnOffOnKeyUp=true;
          mHandler.postDelayed(mPowerLongPress,ViewConfiguration.getGlobalActionKeyTimeout());
          result&=~ACTION_PASS_TO_USER;
        }
      }
 else {
        mHandler.removeCallbacks(mPowerLongPress);
        if (mShouldTurnOffOnKeyUp) {
          mShouldTurnOffOnKeyUp=false;
          boolean gohome=(mEndcallBehavior & ENDCALL_HOME) != 0;
          boolean sleeps=(mEndcallBehavior & ENDCALL_SLEEPS) != 0;
          if (keyguardActive || (sleeps && !gohome) || (gohome && !goHome() && sleeps)) {
            Log.d(TAG,"String_Node_Str" + Integer.toHexString(mEndcallBehavior));
            result&=~ACTION_POKE_USER_ACTIVITY;
            result|=ACTION_GO_TO_SLEEP;
          }
          result&=~ACTION_PASS_TO_USER;
        }
      }
    }
 else     if (isMediaKey(code)) {
      if ((result & ACTION_PASS_TO_USER) == 0) {
        KeyEvent keyEvent=new KeyEvent(event.when,event.when,down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP,code,0);
        mBroadcastWakeLock.acquire();
        mHandler.post(new PassHeadsetKey(keyEvent));
      }
    }
 else     if (code == KeyEvent.KEYCODE_CALL) {
      if (down) {
        try {
          ITelephony phoneServ=getPhoneInterface();
          if (phoneServ != null) {
            if (phoneServ.isRinging()) {
              Log.i(TAG,"String_Node_Str" + "String_Node_Str");
              phoneServ.answerRingingCall();
              result&=~ACTION_PASS_TO_USER;
            }
          }
 else {
            Log.w(TAG,"String_Node_Str");
          }
        }
 catch (        RemoteException ex) {
          Log.w(TAG,"String_Node_Str",ex);
        }
      }
    }
 else     if ((code == KeyEvent.KEYCODE_VOLUME_UP) || (code == KeyEvent.KEYCODE_VOLUME_DOWN)) {
      if (down) {
        try {
          ITelephony phoneServ=getPhoneInterface();
          if (phoneServ != null) {
            if (phoneServ.isRinging()) {
              Log.i(TAG,"String_Node_Str" + "String_Node_Str");
              phoneServ.silenceRinger();
              result&=~ACTION_PASS_TO_USER;
            }
          }
 else {
            Log.w(TAG,"String_Node_Str");
          }
        }
 catch (        RemoteException ex) {
          Log.w(TAG,"String_Node_Str",ex);
        }
      }
    }
  }
  return result;
}