Merge "Remove the input dispatcher throttle."
This commit is contained in:
@@ -39,9 +39,6 @@
|
|||||||
// Log debug messages about input event injection.
|
// Log debug messages about input event injection.
|
||||||
#define DEBUG_INJECTION 0
|
#define DEBUG_INJECTION 0
|
||||||
|
|
||||||
// Log debug messages about input event throttling.
|
|
||||||
#define DEBUG_THROTTLING 0
|
|
||||||
|
|
||||||
// Log debug messages about input focus tracking.
|
// Log debug messages about input focus tracking.
|
||||||
#define DEBUG_FOCUS 0
|
#define DEBUG_FOCUS 0
|
||||||
|
|
||||||
@@ -210,14 +207,6 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
|
|||||||
mKeyRepeatState.lastKeyEntry = NULL;
|
mKeyRepeatState.lastKeyEntry = NULL;
|
||||||
|
|
||||||
policy->getDispatcherConfiguration(&mConfig);
|
policy->getDispatcherConfiguration(&mConfig);
|
||||||
|
|
||||||
mThrottleState.minTimeBetweenEvents = 1000000000LL / mConfig.maxEventsPerSecond;
|
|
||||||
mThrottleState.lastDeviceId = -1;
|
|
||||||
|
|
||||||
#if DEBUG_THROTTLING
|
|
||||||
mThrottleState.originalSampleCount = 0;
|
|
||||||
ALOGD("Throttling - Max events per second = %d", mConfig.maxEventsPerSecond);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDispatcher::~InputDispatcher() {
|
InputDispatcher::~InputDispatcher() {
|
||||||
@@ -310,63 +299,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Inbound queue has at least one entry.
|
// Inbound queue has at least one entry.
|
||||||
EventEntry* entry = mInboundQueue.head;
|
EventEntry* entry = mInboundQueue.dequeueAtHead();
|
||||||
|
|
||||||
// Throttle the entry if it is a move event and there are no
|
|
||||||
// other events behind it in the queue. Due to movement batching, additional
|
|
||||||
// samples may be appended to this event by the time the throttling timeout
|
|
||||||
// expires.
|
|
||||||
// TODO Make this smarter and consider throttling per device independently.
|
|
||||||
if (entry->type == EventEntry::TYPE_MOTION
|
|
||||||
&& !isAppSwitchDue
|
|
||||||
&& mDispatchEnabled
|
|
||||||
&& (entry->policyFlags & POLICY_FLAG_PASS_TO_USER)
|
|
||||||
&& !entry->isInjected()) {
|
|
||||||
MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
|
|
||||||
int32_t deviceId = motionEntry->deviceId;
|
|
||||||
uint32_t source = motionEntry->source;
|
|
||||||
if (! isAppSwitchDue
|
|
||||||
&& !motionEntry->next // exactly one event, no successors
|
|
||||||
&& (motionEntry->action == AMOTION_EVENT_ACTION_MOVE
|
|
||||||
|| motionEntry->action == AMOTION_EVENT_ACTION_HOVER_MOVE)
|
|
||||||
&& deviceId == mThrottleState.lastDeviceId
|
|
||||||
&& source == mThrottleState.lastSource) {
|
|
||||||
nsecs_t nextTime = mThrottleState.lastEventTime
|
|
||||||
+ mThrottleState.minTimeBetweenEvents;
|
|
||||||
if (currentTime < nextTime) {
|
|
||||||
// Throttle it!
|
|
||||||
#if DEBUG_THROTTLING
|
|
||||||
ALOGD("Throttling - Delaying motion event for "
|
|
||||||
"device %d, source 0x%08x by up to %0.3fms.",
|
|
||||||
deviceId, source, (nextTime - currentTime) * 0.000001);
|
|
||||||
#endif
|
|
||||||
if (nextTime < *nextWakeupTime) {
|
|
||||||
*nextWakeupTime = nextTime;
|
|
||||||
}
|
|
||||||
if (mThrottleState.originalSampleCount == 0) {
|
|
||||||
mThrottleState.originalSampleCount =
|
|
||||||
motionEntry->countSamples();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG_THROTTLING
|
|
||||||
if (mThrottleState.originalSampleCount != 0) {
|
|
||||||
uint32_t count = motionEntry->countSamples();
|
|
||||||
ALOGD("Throttling - Motion event sample count grew by %d from %d to %d.",
|
|
||||||
count - mThrottleState.originalSampleCount,
|
|
||||||
mThrottleState.originalSampleCount, count);
|
|
||||||
mThrottleState.originalSampleCount = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mThrottleState.lastEventTime = currentTime;
|
|
||||||
mThrottleState.lastDeviceId = deviceId;
|
|
||||||
mThrottleState.lastSource = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
mInboundQueue.dequeue(entry);
|
|
||||||
mPendingEvent = entry;
|
mPendingEvent = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4080,7 +4013,6 @@ void InputDispatcher::dump(String8& dump) {
|
|||||||
dumpDispatchStateLocked(dump);
|
dumpDispatchStateLocked(dump);
|
||||||
|
|
||||||
dump.append(INDENT "Configuration:\n");
|
dump.append(INDENT "Configuration:\n");
|
||||||
dump.appendFormat(INDENT2 "MaxEventsPerSecond: %d\n", mConfig.maxEventsPerSecond);
|
|
||||||
dump.appendFormat(INDENT2 "KeyRepeatDelay: %0.1fms\n", mConfig.keyRepeatDelay * 0.000001f);
|
dump.appendFormat(INDENT2 "KeyRepeatDelay: %0.1fms\n", mConfig.keyRepeatDelay * 0.000001f);
|
||||||
dump.appendFormat(INDENT2 "KeyRepeatTimeout: %0.1fms\n", mConfig.keyRepeatTimeout * 0.000001f);
|
dump.appendFormat(INDENT2 "KeyRepeatTimeout: %0.1fms\n", mConfig.keyRepeatTimeout * 0.000001f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,15 +172,9 @@ struct InputDispatcherConfiguration {
|
|||||||
// The key repeat inter-key delay.
|
// The key repeat inter-key delay.
|
||||||
nsecs_t keyRepeatDelay;
|
nsecs_t keyRepeatDelay;
|
||||||
|
|
||||||
// The maximum suggested event delivery rate per second.
|
|
||||||
// This value is used to throttle motion event movement actions on a per-device
|
|
||||||
// basis. It is not intended to be a hard limit.
|
|
||||||
int32_t maxEventsPerSecond;
|
|
||||||
|
|
||||||
InputDispatcherConfiguration() :
|
InputDispatcherConfiguration() :
|
||||||
keyRepeatTimeout(500 * 1000000LL),
|
keyRepeatTimeout(500 * 1000000LL),
|
||||||
keyRepeatDelay(50 * 1000000LL),
|
keyRepeatDelay(50 * 1000000LL) { }
|
||||||
maxEventsPerSecond(60) { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -927,17 +921,6 @@ private:
|
|||||||
void incrementPendingForegroundDispatchesLocked(EventEntry* entry);
|
void incrementPendingForegroundDispatchesLocked(EventEntry* entry);
|
||||||
void decrementPendingForegroundDispatchesLocked(EventEntry* entry);
|
void decrementPendingForegroundDispatchesLocked(EventEntry* entry);
|
||||||
|
|
||||||
// Throttling state.
|
|
||||||
struct ThrottleState {
|
|
||||||
nsecs_t minTimeBetweenEvents;
|
|
||||||
|
|
||||||
nsecs_t lastEventTime;
|
|
||||||
int32_t lastDeviceId;
|
|
||||||
uint32_t lastSource;
|
|
||||||
|
|
||||||
uint32_t originalSampleCount; // only collected during debugging
|
|
||||||
} mThrottleState;
|
|
||||||
|
|
||||||
// Key repeat tracking.
|
// Key repeat tracking.
|
||||||
struct KeyRepeatState {
|
struct KeyRepeatState {
|
||||||
KeyEntry* lastKeyEntry; // or null if no repeat
|
KeyEntry* lastKeyEntry; // or null if no repeat
|
||||||
|
|||||||
@@ -667,25 +667,6 @@ public class InputManager implements Watchdog.Monitor {
|
|||||||
return ViewConfiguration.getLongPressTimeout();
|
return ViewConfiguration.getLongPressTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public int getMaxEventsPerSecond() {
|
|
||||||
int result = 0;
|
|
||||||
try {
|
|
||||||
result = Integer.parseInt(SystemProperties.get("windowsmgr.max_events_per_sec"));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
if (result < 1) {
|
|
||||||
// This number equates to the refresh rate * 1.5. The rate should be at least
|
|
||||||
// equal to the screen refresh rate. We increase the rate by 50% to compensate for
|
|
||||||
// the discontinuity between the actual rate that events come in at (they do
|
|
||||||
// not necessarily come in constantly and are not handled synchronously).
|
|
||||||
// Ideally, we would use Display.getRefreshRate(), but as this does not necessarily
|
|
||||||
// return a sensible result, we use '60' as our default assumed refresh rate.
|
|
||||||
result = 90;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public int getPointerLayer() {
|
public int getPointerLayer() {
|
||||||
return mWindowManagerService.mPolicy.windowTypeToLayerLw(
|
return mWindowManagerService.mPolicy.windowTypeToLayerLw(
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ static struct {
|
|||||||
jmethodID getExcludedDeviceNames;
|
jmethodID getExcludedDeviceNames;
|
||||||
jmethodID getKeyRepeatTimeout;
|
jmethodID getKeyRepeatTimeout;
|
||||||
jmethodID getKeyRepeatDelay;
|
jmethodID getKeyRepeatDelay;
|
||||||
jmethodID getMaxEventsPerSecond;
|
|
||||||
jmethodID getHoverTapTimeout;
|
jmethodID getHoverTapTimeout;
|
||||||
jmethodID getHoverTapSlop;
|
jmethodID getHoverTapSlop;
|
||||||
jmethodID getDoubleTapTimeout;
|
jmethodID getDoubleTapTimeout;
|
||||||
@@ -586,12 +585,6 @@ void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration
|
|||||||
if (!checkAndClearExceptionFromCallback(env, "getKeyRepeatDelay")) {
|
if (!checkAndClearExceptionFromCallback(env, "getKeyRepeatDelay")) {
|
||||||
outConfig->keyRepeatDelay = milliseconds_to_nanoseconds(keyRepeatDelay);
|
outConfig->keyRepeatDelay = milliseconds_to_nanoseconds(keyRepeatDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
jint maxEventsPerSecond = env->CallIntMethod(mCallbacksObj,
|
|
||||||
gCallbacksClassInfo.getMaxEventsPerSecond);
|
|
||||||
if (!checkAndClearExceptionFromCallback(env, "getMaxEventsPerSecond")) {
|
|
||||||
outConfig->maxEventsPerSecond = maxEventsPerSecond;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeInputManager::isKeyRepeatEnabled() {
|
bool NativeInputManager::isKeyRepeatEnabled() {
|
||||||
@@ -1480,9 +1473,6 @@ int register_android_server_InputManager(JNIEnv* env) {
|
|||||||
GET_METHOD_ID(gCallbacksClassInfo.getLongPressTimeout, clazz,
|
GET_METHOD_ID(gCallbacksClassInfo.getLongPressTimeout, clazz,
|
||||||
"getLongPressTimeout", "()I");
|
"getLongPressTimeout", "()I");
|
||||||
|
|
||||||
GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, clazz,
|
|
||||||
"getMaxEventsPerSecond", "()I");
|
|
||||||
|
|
||||||
GET_METHOD_ID(gCallbacksClassInfo.getPointerLayer, clazz,
|
GET_METHOD_ID(gCallbacksClassInfo.getPointerLayer, clazz,
|
||||||
"getPointerLayer", "()I");
|
"getPointerLayer", "()I");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user