Merge "Pass source to dispatchBatchedInputEventPending (1/2)" into rvc-dev am: aec6f5f6fa am: eb95d1deee
Change-Id: I75ddf5fd1a77ba171c5b72a0d578d3bad58fd028
This commit is contained in:
@@ -35,7 +35,7 @@ public class BatchedInputEventReceiver extends InputEventReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBatchedInputEventPending() {
|
public void onBatchedInputEventPending(int source) {
|
||||||
scheduleBatchedInput();
|
scheduleBatchedInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,8 +147,9 @@ public abstract class InputEventReceiver {
|
|||||||
* samples until the recipient calls {@link #consumeBatchedInputEvents} or
|
* samples until the recipient calls {@link #consumeBatchedInputEvents} or
|
||||||
* an event is received that ends the batch and causes it to be consumed
|
* an event is received that ends the batch and causes it to be consumed
|
||||||
* immediately (such as a pointer up event).
|
* immediately (such as a pointer up event).
|
||||||
|
* @param source The source of the batched event.
|
||||||
*/
|
*/
|
||||||
public void onBatchedInputEventPending() {
|
public void onBatchedInputEventPending(int source) {
|
||||||
consumeBatchedInputEvents(-1);
|
consumeBatchedInputEvents(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,13 +220,6 @@ public abstract class InputEventReceiver {
|
|||||||
onInputEvent(event);
|
onInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from native code.
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
private void dispatchBatchedInputEventPending() {
|
|
||||||
onBatchedInputEventPending();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for InputEventReceiver
|
* Factory for InputEventReceiver
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -504,7 +504,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
int mPendingInputEventCount;
|
int mPendingInputEventCount;
|
||||||
boolean mProcessInputEventsScheduled;
|
boolean mProcessInputEventsScheduled;
|
||||||
boolean mUnbufferedInputDispatch;
|
boolean mUnbufferedInputDispatch;
|
||||||
boolean mUnbufferedInputDispatchBySource;
|
|
||||||
@InputSourceClass
|
@InputSourceClass
|
||||||
int mUnbufferedInputSource = SOURCE_CLASS_NONE;
|
int mUnbufferedInputSource = SOURCE_CLASS_NONE;
|
||||||
|
|
||||||
@@ -1872,9 +1871,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
mTraversalBarrier = mHandler.getLooper().getQueue().postSyncBarrier();
|
mTraversalBarrier = mHandler.getLooper().getQueue().postSyncBarrier();
|
||||||
mChoreographer.postCallback(
|
mChoreographer.postCallback(
|
||||||
Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
|
Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
|
||||||
if (!mUnbufferedInputDispatch && !mUnbufferedInputDispatchBySource) {
|
|
||||||
scheduleConsumeBatchedInput();
|
|
||||||
}
|
|
||||||
notifyRendererOfFramePending();
|
notifyRendererOfFramePending();
|
||||||
pokeDrawLockIfNeeded();
|
pokeDrawLockIfNeeded();
|
||||||
}
|
}
|
||||||
@@ -8156,7 +8152,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
@Override
|
@Override
|
||||||
public void onInputEvent(InputEvent event) {
|
public void onInputEvent(InputEvent event) {
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "processInputEventForCompatibility");
|
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "processInputEventForCompatibility");
|
||||||
processUnbufferedRequest(event);
|
|
||||||
List<InputEvent> processedEvents;
|
List<InputEvent> processedEvents;
|
||||||
try {
|
try {
|
||||||
processedEvents =
|
processedEvents =
|
||||||
@@ -8181,12 +8176,18 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBatchedInputEventPending() {
|
public void onBatchedInputEventPending(int source) {
|
||||||
if (mUnbufferedInputDispatch || mUnbufferedInputDispatchBySource) {
|
final boolean unbuffered = mUnbufferedInputDispatch
|
||||||
super.onBatchedInputEventPending();
|
|| (source & mUnbufferedInputSource) != SOURCE_CLASS_NONE;
|
||||||
} else {
|
if (unbuffered) {
|
||||||
scheduleConsumeBatchedInput();
|
if (mConsumeBatchedInputScheduled) {
|
||||||
|
unscheduleConsumeBatchedInput();
|
||||||
|
}
|
||||||
|
// Consume event immediately if unbuffered input dispatch has been requested.
|
||||||
|
consumeBatchedInputEvents(-1);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
scheduleConsumeBatchedInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -8199,17 +8200,6 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
unscheduleConsumeBatchedInput();
|
unscheduleConsumeBatchedInput();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processUnbufferedRequest(InputEvent event) {
|
|
||||||
if (!(event instanceof MotionEvent)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mUnbufferedInputDispatchBySource =
|
|
||||||
(event.getSource() & mUnbufferedInputSource) != SOURCE_CLASS_NONE;
|
|
||||||
if (mUnbufferedInputDispatchBySource && mConsumeBatchedInputScheduled) {
|
|
||||||
scheduleConsumeBatchedInputImmediately();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
WindowInputEventReceiver mInputEventReceiver;
|
WindowInputEventReceiver mInputEventReceiver;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static struct {
|
|||||||
|
|
||||||
jmethodID dispatchInputEvent;
|
jmethodID dispatchInputEvent;
|
||||||
jmethodID onFocusEvent;
|
jmethodID onFocusEvent;
|
||||||
jmethodID dispatchBatchedInputEventPending;
|
jmethodID onBatchedInputEventPending;
|
||||||
} gInputEventReceiverClassInfo;
|
} gInputEventReceiverClassInfo;
|
||||||
|
|
||||||
|
|
||||||
@@ -242,37 +242,40 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
|
|
||||||
status_t status = mInputConsumer.consume(&mInputEventFactory,
|
status_t status = mInputConsumer.consume(&mInputEventFactory,
|
||||||
consumeBatches, frameTime, &seq, &inputEvent);
|
consumeBatches, frameTime, &seq, &inputEvent);
|
||||||
if (status) {
|
if (status != OK && status != WOULD_BLOCK) {
|
||||||
if (status == WOULD_BLOCK) {
|
ALOGE("channel '%s' ~ Failed to consume input event. status=%d",
|
||||||
if (!skipCallbacks && !mBatchedInputEventPending
|
getInputChannelName().c_str(), status);
|
||||||
&& mInputConsumer.hasPendingBatch()) {
|
return status;
|
||||||
// There is a pending batch. Come back later.
|
}
|
||||||
if (!receiverObj.get()) {
|
|
||||||
receiverObj.reset(jniGetReferent(env, mReceiverWeakGlobal));
|
|
||||||
if (!receiverObj.get()) {
|
|
||||||
ALOGW("channel '%s' ~ Receiver object was finalized "
|
|
||||||
"without being disposed.", getInputChannelName().c_str());
|
|
||||||
return DEAD_OBJECT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mBatchedInputEventPending = true;
|
if (status == WOULD_BLOCK) {
|
||||||
if (kDebugDispatchCycle) {
|
if (!skipCallbacks && !mBatchedInputEventPending && mInputConsumer.hasPendingBatch()) {
|
||||||
ALOGD("channel '%s' ~ Dispatching batched input event pending notification.",
|
// There is a pending batch. Come back later.
|
||||||
getInputChannelName().c_str());
|
if (!receiverObj.get()) {
|
||||||
}
|
receiverObj.reset(jniGetReferent(env, mReceiverWeakGlobal));
|
||||||
env->CallVoidMethod(receiverObj.get(),
|
if (!receiverObj.get()) {
|
||||||
gInputEventReceiverClassInfo.dispatchBatchedInputEventPending);
|
ALOGW("channel '%s' ~ Receiver object was finalized "
|
||||||
if (env->ExceptionCheck()) {
|
"without being disposed.",
|
||||||
ALOGE("Exception dispatching batched input events.");
|
getInputChannelName().c_str());
|
||||||
mBatchedInputEventPending = false; // try again later
|
return DEAD_OBJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OK;
|
|
||||||
|
mBatchedInputEventPending = true;
|
||||||
|
if (kDebugDispatchCycle) {
|
||||||
|
ALOGD("channel '%s' ~ Dispatching batched input event pending notification.",
|
||||||
|
getInputChannelName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
env->CallVoidMethod(receiverObj.get(),
|
||||||
|
gInputEventReceiverClassInfo.onBatchedInputEventPending,
|
||||||
|
mInputConsumer.getPendingBatchSource());
|
||||||
|
if (env->ExceptionCheck()) {
|
||||||
|
ALOGE("Exception dispatching batched input events.");
|
||||||
|
mBatchedInputEventPending = false; // try again later
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ALOGE("channel '%s' ~ Failed to consume input event. status=%d",
|
return OK;
|
||||||
getInputChannelName().c_str(), status);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
assert(inputEvent);
|
assert(inputEvent);
|
||||||
|
|
||||||
@@ -441,8 +444,9 @@ int register_android_view_InputEventReceiver(JNIEnv* env) {
|
|||||||
"dispatchInputEvent", "(ILandroid/view/InputEvent;)V");
|
"dispatchInputEvent", "(ILandroid/view/InputEvent;)V");
|
||||||
gInputEventReceiverClassInfo.onFocusEvent =
|
gInputEventReceiverClassInfo.onFocusEvent =
|
||||||
GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onFocusEvent", "(ZZ)V");
|
GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onFocusEvent", "(ZZ)V");
|
||||||
gInputEventReceiverClassInfo.dispatchBatchedInputEventPending = GetMethodIDOrDie(env,
|
gInputEventReceiverClassInfo.onBatchedInputEventPending =
|
||||||
gInputEventReceiverClassInfo.clazz, "dispatchBatchedInputEventPending", "()V");
|
GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onBatchedInputEventPending",
|
||||||
|
"(I)V");
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user