android触屏震动以及震动强度修改
PhoneWindowManager.java:
在interceptKeyBeforeQueueing函数中
performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
这里把false改为true。
public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { final boolean hapticsDisabled = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0; if (!always && (hapticsDisabled || mKeyguardMediator.isShowingAndNotHidden())) { return false; } long[] pattern = null; switch (effectId) { case HapticFeedbackConstants.LONG_PRESS: pattern = mLongPressVibePattern; break; case HapticFeedbackConstants.VIRTUAL_KEY: pattern = mVirtualKeyVibePattern; break; case HapticFeedbackConstants.KEYBOARD_TAP: pattern = mKeyboardTapVibePattern; break; case HapticFeedbackConstants.SAFE_MODE_DISABLED: pattern = mSafeModeDisabledVibePattern; break; case HapticFeedbackConstants.SAFE_MODE_ENABLED: pattern = mSafeModeEnabledVibePattern; break; default: return false; } if (pattern.length == 1) { // One-shot vibration mVibrator.vibrate(pattern[0]); } else { // Pattern vibration mVibrator.vibrate(pattern, -1);//震动起来,OH! }