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!
}


这里的震动值是从mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(),
com.android.internal.R.array.config_virtualKeyVibePattern);获得的。

对于震动时间是修改是在对应的xml中
frameworks/base/core/res/res/values/config.xml


0
10
20
30


这个mVibrator是Vibrator.java中的class.

你可能感兴趣的:(android基础)