@Override publicintinterceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { ......
// Enable haptics if down and virtual key without multiple repetitions. If this is a hard // virtual key such as a navigation bar button, only vibrate if flag is enabled. finalbooleanisNavBarVirtKey= ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0); booleanuseHapticFeedback= down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 && (!isNavBarVirtKey || mNavBarVirtualKeyHapticFeedbackEnabled) && event.getRepeatCount() == 0;
// press and touch feedback of navigation keys begin Log.d(TAG, "keying vibration 1 = " + keyCode); if (keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_APP_SWITCH { if (down && event.getRepeatCount() == 0) { useHapticFeedback = true; Log.d(TAG, "keying vibration 2 = " + keyCode); } } // press and touch feedback of navigation keys end