对于2.2 我是在windowmanagerservice.java里处理的,处理压力值用压力值来判断
case RawInputEvent.EV_ABS: {
boolean screenIsOff = !mPowerManager.isScreenOn();
boolean screenIsDim = !mPowerManager.isScreenBright();
int brightness = mPowerManager.getBacklightBrightness();
if (screenIsOff) {
if (!mPolicy.isWakeAbsMovementTq(event.deviceId,
device.classes, event)) {
//Slog.i(TAG, "dropping because screenIsOff and !isWakeKey");
return false;
}
event.flags |= WindowManagerPolicy.FLAG_WOKE_HERE;
}
if (screenIsDim) {
event.flags |= WindowManagerPolicy.FLAG_BRIGHT_HERE;
}
if(brightness == 0){
mEventdownforBacklight = TOUCH_DOWN;
return !McuService.getMcuService().ResetBacklightStatus();
/* }else if (mEventdownforBacklight == TOUCH_DOWN){
if( (event.scancode == RawInputEvent.ABS_PRESSURE) &&
((event.value == 0) || (event.value > 1000)) ){
mEventdownforBacklight = TOUCH_UP;
mUpTime = SystemClock.elapsedRealtime();
}*/
}else if (mEventdownforBacklight == TOUCH_DOWN){
if( ((event.scancode == RawInputEvent.ABS_PRESSURE) &&
((event.value == 0) || (event.value > 1000))) ||
((event.scancode == RawInputEvent.ABS_MT_TOUCH_MAJOR) &&
(event.value == 0)) ){
mEventdownforBacklight = TOUCH_UP;
mUpTime = SystemClock.elapsedRealtime();
}
return false;
}else if (mEventdownforBacklight == TOUCH_UP){
if((SystemClock.elapsedRealtime() -mUpTime) < 200)
return false;
else{
mEventdownforBacklight = BACKLIGHT_ON;
return true;
}
}
return true;
}
对于2.3我是在frameworks/base/lib/ui/InputDispatcher.cpp的
void InputDispatcher::dispatchOnceInnerLocked(nsecs_t keyRepeatTimeout,
nsecs_t keyRepeatDelay, nsecs_t* nextWakeupTime) {
。。。。。。。。。。。。。。。。。。。。。。。。。。。
switch (mPendingEvent->type) {
case EventEntry::TYPE_CONFIGURATION_CHANGED: {
ConfigurationChangedEntry* typedEntry =
static_cast<ConfigurationChangedEntry*>(mPendingEvent);
done = dispatchConfigurationChangedLocked(currentTime, typedEntry);
dropReason = DROP_REASON_NOT_DROPPED; // configuration changes are never dropped
break;
}
case EventEntry::TYPE_KEY: {
KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
if (isAppSwitchDue) {
if (isAppSwitchKeyEventLocked(typedEntry)) {
resetPendingAppSwitchLocked(true);
isAppSwitchDue = false;
} else if (dropReason == DROP_REASON_NOT_DROPPED) {
dropReason = DROP_REASON_APP_SWITCH;
}
}
done = dispatchKeyLocked(currentTime, typedEntry, keyRepeatTimeout,
&dropReason, nextWakeupTime);
CheckAndOpenScreen();//处理物理按键的
break;
}
case EventEntry::TYPE_MOTION: {
MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
if (dropReason == DROP_REASON_NOT_DROPPED && isAppSwitchDue) {
dropReason = DROP_REASON_APP_SWITCH;
}
done = dispatchMotionLocked(currentTime, typedEntry,
&dropReason, nextWakeupTime);
CheckAndOpenScreen();//处理触摸屏的
break;
}
default:
assert(false);
break;
}
。。。。。。。。。。。。。。。。。
对于2.3input输入事件可以参考http://blog.csdn.net/andyhuabing/article/details/7006688整个帖子。