Program: 199017
Project: 199017
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public long interceptKeyBeforeDispatching(WindowState win,KeyEvent event,int policyFlags){
  final boolean keyguardOn=keyguardOn();
  final int keyCode=event.getKeyCode();
  final int repeatCount=event.getRepeatCount();
  final int metaState=event.getMetaState();
  final int flags=event.getFlags();
  final boolean down=event.getAction() == KeyEvent.ACTION_DOWN;
  final boolean canceled=event.isCanceled();
  if (DEBUG_INPUT) {
    Log.d(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ down+ "String_Node_Str"+ repeatCount+ "String_Node_Str"+ keyguardOn+ "String_Node_Str"+ mHomePressed+ "String_Node_Str"+ canceled);
  }
  if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) {
    if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) {
      final long now=SystemClock.uptimeMillis();
      final long timeoutTime=mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS;
      if (now < timeoutTime) {
        return timeoutTime - now;
      }
    }
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeDownKeyConsumedByScreenshotChord) {
      if (!down) {
        mVolumeDownKeyConsumedByScreenshotChord=false;
      }
      return -1;
    }
  }
  if (mPendingMetaAction && keyCode != KeyEvent.KEYCODE_META_LEFT) {
    mPendingMetaAction=false;
  }
  if (keyCode == KeyEvent.KEYCODE_HOME) {
    if (!down) {
      cancelPreloadRecentApps();
      mHomePressed=false;
      if (mHomeConsumed) {
        mHomeConsumed=false;
        return -1;
      }
      if (canceled) {
        Log.i(TAG,"String_Node_Str");
        return -1;
      }
      TelecommManager telecommManager=getTelecommService();
      if (telecommManager != null && telecommManager.isRinging()) {
        Log.i(TAG,"String_Node_Str");
        return -1;
      }
      if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
        mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
        mHomeDoubleTapPending=true;
        mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,ViewConfiguration.getDoubleTapTimeout());
        return -1;
      }
      launchHomeFromHotKey();
      return -1;
    }
    WindowManager.LayoutParams attrs=win != null ? win.getAttrs() : null;
    if (attrs != null) {
      final int type=attrs.type;
      if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
        return 0;
      }
      final int typeCount=WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length;
      for (int i=0; i < typeCount; i++) {
        if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) {
          return -1;
        }
      }
    }
    if (repeatCount == 0) {
      mHomePressed=true;
      if (mHomeDoubleTapPending) {
        mHomeDoubleTapPending=false;
        mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
        handleDoubleTapOnHome();
      }
 else       if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
        preloadRecentApps();
      }
    }
 else     if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
      if (!keyguardOn) {
        handleLongPressOnHome();
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_MENU) {
    final int chordBug=KeyEvent.META_SHIFT_ON;
    if (down && repeatCount == 0) {
      if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) {
        Intent intent=new Intent(Intent.ACTION_BUG_REPORT);
        mContext.sendOrderedBroadcastAsUser(intent,UserHandle.CURRENT,null,null,null,0,null,null);
        return -1;
      }
 else       if (SHOW_PROCESSES_ON_ALT_MENU && (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) {
        Intent service=new Intent();
        service.setClassName(mContext,"String_Node_Str");
        ContentResolver res=mContext.getContentResolver();
        boolean shown=Settings.Global.getInt(res,Settings.Global.SHOW_PROCESSES,0) != 0;
        if (!shown) {
          mContext.startService(service);
        }
 else {
          mContext.stopService(service);
        }
        Settings.Global.putInt(res,Settings.Global.SHOW_PROCESSES,shown ? 0 : 1);
        return -1;
      }
    }
  }
 else   if (keyCode == KeyEvent.KEYCODE_SEARCH) {
    if (down) {
      if (repeatCount == 0) {
        mSearchKeyShortcutPending=true;
        mConsumeSearchKeyUp=false;
      }
    }
 else {
      mSearchKeyShortcutPending=false;
      if (mConsumeSearchKeyUp) {
        mConsumeSearchKeyUp=false;
        return -1;
      }
    }
    return 0;
  }
 else   if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
    if (!keyguardOn) {
      if (down && repeatCount == 0) {
        preloadRecentApps();
      }
 else       if (!down) {
        toggleRecentApps();
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_ASSIST) {
    if (down) {
      if (repeatCount == 0) {
        mAssistKeyLongPressed=false;
      }
 else       if (repeatCount == 1) {
        mAssistKeyLongPressed=true;
        if (!keyguardOn) {
          launchAssistLongPressAction();
        }
      }
    }
 else {
      if (mAssistKeyLongPressed) {
        mAssistKeyLongPressed=false;
      }
 else {
        if (!keyguardOn) {
          launchAssistAction();
        }
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_SYSRQ) {
    if (down && repeatCount == 0) {
      mHandler.post(mScreenshotRunnable);
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) {
    if (down) {
      int direction=keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1;
      int auto=Settings.System.getIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS_MODE,Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL,UserHandle.USER_CURRENT_OR_SELF);
      if (auto != 0) {
        Settings.System.putIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS_MODE,Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL,UserHandle.USER_CURRENT_OR_SELF);
      }
      int min=mPowerManager.getMinimumScreenBrightnessSetting();
      int max=mPowerManager.getMaximumScreenBrightnessSetting();
      int step=(max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction;
      int brightness=Settings.System.getIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS,mPowerManager.getDefaultScreenBrightnessSetting(),UserHandle.USER_CURRENT_OR_SELF);
      brightness+=step;
      brightness=Math.min(max,brightness);
      brightness=Math.max(min,brightness);
      Settings.System.putIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS,brightness,UserHandle.USER_CURRENT_OR_SELF);
      Intent intent=new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG);
      mContext.sendBroadcastAsUser(intent,UserHandle.CURRENT_OR_SELF);
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_META_LEFT) {
    if (down) {
      mPendingMetaAction=true;
    }
 else     if (mPendingMetaAction) {
      mPendingMetaAction=false;
      launchAssistAction();
    }
    return -1;
  }
  if (mSearchKeyShortcutPending) {
    final KeyCharacterMap kcm=event.getKeyCharacterMap();
    if (kcm.isPrintingKey(keyCode)) {
      mConsumeSearchKeyUp=true;
      mSearchKeyShortcutPending=false;
      if (down && repeatCount == 0 && !keyguardOn) {
        Intent shortcutIntent=mShortcutManager.getIntent(kcm,keyCode,metaState);
        if (shortcutIntent != null) {
          shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          try {
            mContext.startActivityAsUser(shortcutIntent,UserHandle.CURRENT);
          }
 catch (          ActivityNotFoundException ex) {
            Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ KeyEvent.keyCodeToString(keyCode),ex);
          }
        }
 else {
          Slog.i(TAG,"String_Node_Str" + "String_Node_Str" + KeyEvent.keyCodeToString(keyCode));
        }
      }
      return -1;
    }
  }
  if (down && repeatCount == 0 && !keyguardOn && (metaState & KeyEvent.META_META_ON) != 0) {
    final KeyCharacterMap kcm=event.getKeyCharacterMap();
    if (kcm.isPrintingKey(keyCode)) {
      Intent shortcutIntent=mShortcutManager.getIntent(kcm,keyCode,metaState & ~(KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON));
      if (shortcutIntent != null) {
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
          mContext.startActivityAsUser(shortcutIntent,UserHandle.CURRENT);
        }
 catch (        ActivityNotFoundException ex) {
          Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ KeyEvent.keyCodeToString(keyCode),ex);
        }
        return -1;
      }
    }
  }
  if (down && repeatCount == 0 && !keyguardOn) {
    String category=sApplicationLaunchKeyCategories.get(keyCode);
    if (category != null) {
      Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,category);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      try {
        mContext.startActivityAsUser(intent,UserHandle.CURRENT);
      }
 catch (      ActivityNotFoundException ex) {
        Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + keyCode + "String_Node_Str"+ category,ex);
      }
      return -1;
    }
  }
  if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) {
    if (mRecentAppsHeldModifiers == 0 && !keyguardOn) {
      final int shiftlessModifiers=event.getModifiers() & ~KeyEvent.META_SHIFT_MASK;
      if (KeyEvent.metaStateHasModifiers(shiftlessModifiers,KeyEvent.META_ALT_ON) || KeyEvent.metaStateHasModifiers(shiftlessModifiers,KeyEvent.META_META_ON)) {
        mRecentAppsHeldModifiers=shiftlessModifiers;
        showRecentApps(true);
        return -1;
      }
    }
  }
 else   if (!down && mRecentAppsHeldModifiers != 0 && (metaState & mRecentAppsHeldModifiers) == 0) {
    mRecentAppsHeldModifiers=0;
    hideRecentApps(true);
  }
  if (down && repeatCount == 0 && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH || (keyCode == KeyEvent.KEYCODE_SPACE && (metaState & KeyEvent.META_CTRL_MASK) != 0))) {
    int direction=(metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1;
    mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(),direction);
    return -1;
  }
  if (mLanguageSwitchKeyPressed && !down && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH || keyCode == KeyEvent.KEYCODE_SPACE)) {
    mLanguageSwitchKeyPressed=false;
    return -1;
  }
  if (mGlobalKeyManager.handleGlobalKey(mContext,keyCode,event)) {
    return -1;
  }
  if ((metaState & KeyEvent.META_META_LEFT_ON) != 0) {
    return -1;
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public long interceptKeyBeforeDispatching(WindowState win,KeyEvent event,int policyFlags){
  final boolean keyguardOn=keyguardOn();
  final int keyCode=event.getKeyCode();
  final int repeatCount=event.getRepeatCount();
  final int metaState=event.getMetaState();
  final int flags=event.getFlags();
  final boolean down=event.getAction() == KeyEvent.ACTION_DOWN;
  final boolean canceled=event.isCanceled();
  if (DEBUG_INPUT) {
    Log.d(TAG,"String_Node_Str" + keyCode + "String_Node_Str"+ down+ "String_Node_Str"+ repeatCount+ "String_Node_Str"+ keyguardOn+ "String_Node_Str"+ mHomePressed+ "String_Node_Str"+ canceled);
  }
  if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) {
    if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) {
      final long now=SystemClock.uptimeMillis();
      final long timeoutTime=mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS;
      if (now < timeoutTime) {
        return timeoutTime - now;
      }
    }
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeDownKeyConsumedByScreenshotChord) {
      if (!down) {
        mVolumeDownKeyConsumedByScreenshotChord=false;
      }
      return -1;
    }
  }
  if (mPendingMetaAction && keyCode != KeyEvent.KEYCODE_META_LEFT) {
    mPendingMetaAction=false;
  }
  if (keyCode == KeyEvent.KEYCODE_HOME) {
    if (!down) {
      cancelPreloadRecentApps();
      mHomePressed=false;
      if (mHomeConsumed) {
        mHomeConsumed=false;
        return -1;
      }
      if (canceled) {
        Log.i(TAG,"String_Node_Str");
        return -1;
      }
      TelecommManager telecommManager=getTelecommService();
      if (telecommManager != null && telecommManager.isRinging()) {
        Log.i(TAG,"String_Node_Str");
        return -1;
      }
      if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
        mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
        mHomeDoubleTapPending=true;
        mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,ViewConfiguration.getDoubleTapTimeout());
        return -1;
      }
      launchHomeFromHotKey();
      return -1;
    }
    WindowManager.LayoutParams attrs=win != null ? win.getAttrs() : null;
    if (attrs != null) {
      final int type=attrs.type;
      if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
        return 0;
      }
      final int typeCount=WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length;
      for (int i=0; i < typeCount; i++) {
        if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) {
          return -1;
        }
      }
    }
    if (repeatCount == 0) {
      mHomePressed=true;
      if (mHomeDoubleTapPending) {
        mHomeDoubleTapPending=false;
        mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
        handleDoubleTapOnHome();
      }
 else       if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
        preloadRecentApps();
      }
    }
 else     if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
      if (!keyguardOn) {
        handleLongPressOnHome();
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_MENU) {
    final int chordBug=KeyEvent.META_SHIFT_ON;
    if (down && repeatCount == 0) {
      if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) {
        Intent intent=new Intent(Intent.ACTION_BUG_REPORT);
        mContext.sendOrderedBroadcastAsUser(intent,UserHandle.CURRENT,null,null,null,0,null,null);
        return -1;
      }
 else       if (SHOW_PROCESSES_ON_ALT_MENU && (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) {
        Intent service=new Intent();
        service.setClassName(mContext,"String_Node_Str");
        ContentResolver res=mContext.getContentResolver();
        boolean shown=Settings.Global.getInt(res,Settings.Global.SHOW_PROCESSES,0) != 0;
        if (!shown) {
          mContext.startService(service);
        }
 else {
          mContext.stopService(service);
        }
        Settings.Global.putInt(res,Settings.Global.SHOW_PROCESSES,shown ? 0 : 1);
        return -1;
      }
    }
  }
 else   if (keyCode == KeyEvent.KEYCODE_SEARCH) {
    if (down) {
      if (repeatCount == 0) {
        mSearchKeyShortcutPending=true;
        mConsumeSearchKeyUp=false;
      }
    }
 else {
      mSearchKeyShortcutPending=false;
      if (mConsumeSearchKeyUp) {
        mConsumeSearchKeyUp=false;
        return -1;
      }
    }
    return 0;
  }
 else   if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
    if (!keyguardOn) {
      if (down && repeatCount == 0) {
        preloadRecentApps();
      }
 else       if (!down) {
        toggleRecentApps();
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_ASSIST) {
    if (down) {
      if (repeatCount == 0) {
        mAssistKeyLongPressed=false;
      }
 else       if (repeatCount == 1) {
        mAssistKeyLongPressed=true;
        if (!keyguardOn) {
          launchAssistLongPressAction();
        }
      }
    }
 else {
      if (mAssistKeyLongPressed) {
        mAssistKeyLongPressed=false;
      }
 else {
        if (!keyguardOn) {
          launchAssistAction();
        }
      }
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_SYSRQ) {
    if (down && repeatCount == 0) {
      mHandler.post(mScreenshotRunnable);
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) {
    if (down) {
      int direction=keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1;
      int auto=Settings.System.getIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS_MODE,Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL,UserHandle.USER_CURRENT_OR_SELF);
      if (auto != 0) {
        Settings.System.putIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS_MODE,Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL,UserHandle.USER_CURRENT_OR_SELF);
      }
      int min=mPowerManager.getMinimumScreenBrightnessSetting();
      int max=mPowerManager.getMaximumScreenBrightnessSetting();
      int step=(max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction;
      int brightness=Settings.System.getIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS,mPowerManager.getDefaultScreenBrightnessSetting(),UserHandle.USER_CURRENT_OR_SELF);
      brightness+=step;
      brightness=Math.min(max,brightness);
      brightness=Math.max(min,brightness);
      Settings.System.putIntForUser(mContext.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS,brightness,UserHandle.USER_CURRENT_OR_SELF);
      Intent intent=new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG);
      mContext.sendBroadcastAsUser(intent,UserHandle.CURRENT_OR_SELF);
    }
    return -1;
  }
 else   if (keyCode == KeyEvent.KEYCODE_META_LEFT) {
    if (down) {
      mPendingMetaAction=true;
    }
 else     if (mPendingMetaAction) {
      mPendingMetaAction=false;
      launchAssistAction();
    }
    return -1;
  }
  if (mSearchKeyShortcutPending) {
    final KeyCharacterMap kcm=event.getKeyCharacterMap();
    if (kcm.isPrintingKey(keyCode)) {
      mConsumeSearchKeyUp=true;
      mSearchKeyShortcutPending=false;
      if (down && repeatCount == 0 && !keyguardOn) {
        Intent shortcutIntent=mShortcutManager.getIntent(kcm,keyCode,metaState);
        if (shortcutIntent != null) {
          shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          try {
            mContext.startActivityAsUser(shortcutIntent,UserHandle.CURRENT);
          }
 catch (          ActivityNotFoundException ex) {
            Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ KeyEvent.keyCodeToString(keyCode),ex);
          }
        }
 else {
          Slog.i(TAG,"String_Node_Str" + "String_Node_Str" + KeyEvent.keyCodeToString(keyCode));
        }
      }
      return -1;
    }
  }
  if (down && repeatCount == 0 && !keyguardOn && (metaState & KeyEvent.META_META_ON) != 0) {
    final KeyCharacterMap kcm=event.getKeyCharacterMap();
    if (kcm.isPrintingKey(keyCode)) {
      Intent shortcutIntent=mShortcutManager.getIntent(kcm,keyCode,metaState & ~(KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON));
      if (shortcutIntent != null) {
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
          mContext.startActivityAsUser(shortcutIntent,UserHandle.CURRENT);
        }
 catch (        ActivityNotFoundException ex) {
          Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ KeyEvent.keyCodeToString(keyCode),ex);
        }
        return -1;
      }
    }
  }
  if (down && repeatCount == 0 && !keyguardOn) {
    String category=sApplicationLaunchKeyCategories.get(keyCode);
    if (category != null) {
      Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,category);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      try {
        mContext.startActivityAsUser(intent,UserHandle.CURRENT);
      }
 catch (      ActivityNotFoundException ex) {
        Slog.w(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + keyCode + "String_Node_Str"+ category,ex);
      }
      return -1;
    }
  }
  if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) {
    if (mRecentAppsHeldModifiers == 0 && !keyguardOn) {
      final int shiftlessModifiers=event.getModifiers() & ~KeyEvent.META_SHIFT_MASK;
      if (KeyEvent.metaStateHasModifiers(shiftlessModifiers,KeyEvent.META_ALT_ON)) {
        mRecentAppsHeldModifiers=shiftlessModifiers;
        showRecentApps(true);
        return -1;
      }
    }
  }
 else   if (!down && mRecentAppsHeldModifiers != 0 && (metaState & mRecentAppsHeldModifiers) == 0) {
    mRecentAppsHeldModifiers=0;
    hideRecentApps(true);
  }
  if (down && repeatCount == 0 && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH || (keyCode == KeyEvent.KEYCODE_SPACE && (metaState & KeyEvent.META_CTRL_MASK) != 0))) {
    int direction=(metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1;
    mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(),direction);
    return -1;
  }
  if (mLanguageSwitchKeyPressed && !down && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH || keyCode == KeyEvent.KEYCODE_SPACE)) {
    mLanguageSwitchKeyPressed=false;
    return -1;
  }
  if (mGlobalKeyManager.handleGlobalKey(mContext,keyCode,event)) {
    return -1;
  }
  if ((metaState & KeyEvent.META_META_LEFT_ON) != 0) {
    return -1;
  }
  return 0;
}