Loading core/java/android/view/InputEventReceiver.java +12 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public abstract class InputEventReceiver { InputChannel inputChannel, MessageQueue messageQueue); private static native void nativeDispose(long receiverPtr); private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled); private static native boolean nativeProbablyHasInput(long receiverPtr); private static native void nativeReportTimeline(long receiverPtr, int inputEventId, long gpuCompletedTime, long presentTime); private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr, Loading Loading @@ -91,6 +92,17 @@ public abstract class InputEventReceiver { } } /** * Checks the receiver for input availability. * May return false negatives. */ public boolean probablyHasInput() { if (mReceiverPtr == 0) { return false; } return nativeProbablyHasInput(mReceiverPtr); } /** * Disposes the receiver. * Must be called on the same Looper thread to which the receiver is attached. Loading core/java/android/view/View.java +30 −0 Original line number Diff line number Diff line Loading @@ -22855,6 +22855,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * Determines whether an unprocessed input event is available on the window. * * This is only a performance hint (a.k.a. the Input Hint) and may return false negative * results. Callers should not rely on availability of the input event based on the return * value of this method. * * The Input Hint functionality is experimental, and can be removed in the future OS releases. * * This method only returns nontrivial results on a View that is attached to a Window. Such View * can be acquired using `Activity.getWindow().getDecorView()`, and only after the view * hierarchy is attached (via {@link android.app.Activity#setContentView(android.view.View)}). * * In multi-window mode the View can provide the Input Hint only for the window it is attached * to. Therefore, checking input availability for the whole application would require asking * for the hint from more than one View. * * The initial implementation does not return false positives, but callers should not rely on * it: false positives may occur in future OS releases. * * @hide */ public boolean probablyHasInput() { ViewRootImpl viewRootImpl = getViewRootImpl(); if (viewRootImpl == null) { return false; } return viewRootImpl.probablyHasInput(); } /** * Destroys all hardware rendering resources. This method is invoked * when the system needs to reclaim resources. Upon execution of this core/java/android/view/ViewRootImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -10553,6 +10553,18 @@ public final class ViewRootImpl implements ViewParent, return false; } /** * Checks the input event receiver for input availability. * May return false negatives. * @hide */ public boolean probablyHasInput() { if (mInputEventReceiver == null) { return false; } return mInputEventReceiver.probablyHasInput(); } /** * Adds a scroll capture callback to this window. * Loading core/jni/android_view_InputEventReceiver.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ public: status_t initialize(); void dispose(); status_t finishInputEvent(uint32_t seq, bool handled); bool probablyHasInput(); status_t reportTimeline(int32_t inputEventId, nsecs_t gpuCompletedTime, nsecs_t presentTime); status_t consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch); Loading Loading @@ -165,6 +166,10 @@ status_t NativeInputEventReceiver::finishInputEvent(uint32_t seq, bool handled) return processOutboundEvents(); } bool NativeInputEventReceiver::probablyHasInput() { return mInputConsumer.probablyHasInput(); } status_t NativeInputEventReceiver::reportTimeline(int32_t inputEventId, nsecs_t gpuCompletedTime, nsecs_t presentTime) { if (kDebugDispatchCycle) { Loading Loading @@ -547,6 +552,12 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jlong receiverPtr, } } static bool nativeProbablyHasInput(JNIEnv* env, jclass clazz, jlong receiverPtr) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); return receiver->probablyHasInput(); } static void nativeReportTimeline(JNIEnv* env, jclass clazz, jlong receiverPtr, jint inputEventId, jlong gpuCompletedTime, jlong presentTime) { if (IdGenerator::getSource(inputEventId) != IdGenerator::Source::INPUT_READER) { Loading Loading @@ -597,6 +608,7 @@ static const JNINativeMethod gMethods[] = { (void*)nativeInit}, {"nativeDispose", "(J)V", (void*)nativeDispose}, {"nativeFinishInputEvent", "(JIZ)V", (void*)nativeFinishInputEvent}, {"nativeProbablyHasInput", "(J)Z", (void*)nativeProbablyHasInput}, {"nativeReportTimeline", "(JIJJ)V", (void*)nativeReportTimeline}, {"nativeConsumeBatchedInputEvents", "(JJ)Z", (void*)nativeConsumeBatchedInputEvents}, {"nativeDump", "(JLjava/lang/String;)Ljava/lang/String;", (void*)nativeDump}, Loading Loading
core/java/android/view/InputEventReceiver.java +12 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public abstract class InputEventReceiver { InputChannel inputChannel, MessageQueue messageQueue); private static native void nativeDispose(long receiverPtr); private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled); private static native boolean nativeProbablyHasInput(long receiverPtr); private static native void nativeReportTimeline(long receiverPtr, int inputEventId, long gpuCompletedTime, long presentTime); private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr, Loading Loading @@ -91,6 +92,17 @@ public abstract class InputEventReceiver { } } /** * Checks the receiver for input availability. * May return false negatives. */ public boolean probablyHasInput() { if (mReceiverPtr == 0) { return false; } return nativeProbablyHasInput(mReceiverPtr); } /** * Disposes the receiver. * Must be called on the same Looper thread to which the receiver is attached. Loading
core/java/android/view/View.java +30 −0 Original line number Diff line number Diff line Loading @@ -22855,6 +22855,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * Determines whether an unprocessed input event is available on the window. * * This is only a performance hint (a.k.a. the Input Hint) and may return false negative * results. Callers should not rely on availability of the input event based on the return * value of this method. * * The Input Hint functionality is experimental, and can be removed in the future OS releases. * * This method only returns nontrivial results on a View that is attached to a Window. Such View * can be acquired using `Activity.getWindow().getDecorView()`, and only after the view * hierarchy is attached (via {@link android.app.Activity#setContentView(android.view.View)}). * * In multi-window mode the View can provide the Input Hint only for the window it is attached * to. Therefore, checking input availability for the whole application would require asking * for the hint from more than one View. * * The initial implementation does not return false positives, but callers should not rely on * it: false positives may occur in future OS releases. * * @hide */ public boolean probablyHasInput() { ViewRootImpl viewRootImpl = getViewRootImpl(); if (viewRootImpl == null) { return false; } return viewRootImpl.probablyHasInput(); } /** * Destroys all hardware rendering resources. This method is invoked * when the system needs to reclaim resources. Upon execution of this
core/java/android/view/ViewRootImpl.java +12 −0 Original line number Diff line number Diff line Loading @@ -10553,6 +10553,18 @@ public final class ViewRootImpl implements ViewParent, return false; } /** * Checks the input event receiver for input availability. * May return false negatives. * @hide */ public boolean probablyHasInput() { if (mInputEventReceiver == null) { return false; } return mInputEventReceiver.probablyHasInput(); } /** * Adds a scroll capture callback to this window. * Loading
core/jni/android_view_InputEventReceiver.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ public: status_t initialize(); void dispose(); status_t finishInputEvent(uint32_t seq, bool handled); bool probablyHasInput(); status_t reportTimeline(int32_t inputEventId, nsecs_t gpuCompletedTime, nsecs_t presentTime); status_t consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch); Loading Loading @@ -165,6 +166,10 @@ status_t NativeInputEventReceiver::finishInputEvent(uint32_t seq, bool handled) return processOutboundEvents(); } bool NativeInputEventReceiver::probablyHasInput() { return mInputConsumer.probablyHasInput(); } status_t NativeInputEventReceiver::reportTimeline(int32_t inputEventId, nsecs_t gpuCompletedTime, nsecs_t presentTime) { if (kDebugDispatchCycle) { Loading Loading @@ -547,6 +552,12 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jlong receiverPtr, } } static bool nativeProbablyHasInput(JNIEnv* env, jclass clazz, jlong receiverPtr) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); return receiver->probablyHasInput(); } static void nativeReportTimeline(JNIEnv* env, jclass clazz, jlong receiverPtr, jint inputEventId, jlong gpuCompletedTime, jlong presentTime) { if (IdGenerator::getSource(inputEventId) != IdGenerator::Source::INPUT_READER) { Loading Loading @@ -597,6 +608,7 @@ static const JNINativeMethod gMethods[] = { (void*)nativeInit}, {"nativeDispose", "(J)V", (void*)nativeDispose}, {"nativeFinishInputEvent", "(JIZ)V", (void*)nativeFinishInputEvent}, {"nativeProbablyHasInput", "(J)Z", (void*)nativeProbablyHasInput}, {"nativeReportTimeline", "(JIJJ)V", (void*)nativeReportTimeline}, {"nativeConsumeBatchedInputEvents", "(JJ)Z", (void*)nativeConsumeBatchedInputEvents}, {"nativeDump", "(JLjava/lang/String;)Ljava/lang/String;", (void*)nativeDump}, Loading