Tell policy about responsive connections
If a connection is unresponsive, we tell the policy about it. Now, with
this patch, we will also tell the policy that a connection becomes
responsive again. This will allow the policy to cancel the ANR dialog if
it's currently shown, and to stop recurring ANR dialogs if the user was
previously waiting for the app longer.
Bug: 171218828
Test: atest inputflinger_tests
Test: manual test via unresponsive apps
Change-Id: Ifc00601b2c4e44b721a30d5f9ebf786780d1ffd7
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
index 463c5f1..1125257 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
@@ -45,11 +45,25 @@
/* Notifies the system that a configuration change has occurred. */
virtual void notifyConfigurationChanged(nsecs_t when) = 0;
- /* Notifies the system that an application is not responding.
- * Returns a new timeout to continue waiting, or 0 to abort dispatch. */
- virtual std::chrono::nanoseconds notifyAnr(
- const std::shared_ptr<InputApplicationHandle>& inputApplicationHandle,
- const sp<IBinder>& token, const std::string& reason) = 0;
+ /* Notifies the system that an application does not have a focused window.
+ */
+ virtual void notifyNoFocusedWindowAnr(
+ const std::shared_ptr<InputApplicationHandle>& inputApplicationHandle) = 0;
+
+ /* Notifies the system that a connection just became unresponsive. This indicates that ANR
+ * should be raised for this connection. The connection is identified via token.
+ * The string reason contains information about the input event that we haven't received
+ * a response for.
+ */
+ virtual void notifyConnectionUnresponsive(const sp<IBinder>& token,
+ const std::string& reason) = 0;
+
+ /* Notifies the system that a connection just became responsive. This is only called after the
+ * connection was first marked "unresponsive". This indicates that ANR dialog (if any) should
+ * no longer should be shown to the user. The connection is eligible to cause a new ANR in the
+ * future.
+ */
+ virtual void notifyConnectionResponsive(const sp<IBinder>& token) = 0;
/* Notifies the system that an input channel is unrecoverably broken. */
virtual void notifyInputChannelBroken(const sp<IBinder>& token) = 0;