Split monitor and window ANR notification paths
Currently, both monitors and windows share the same ANR notification
paths. This means that InputManagerService must be the one to determine
whether the ANR event belongs to a monitor or to a window.
We previously kept track of this by recording the pid inside
InputManagerService. However, there seems to be a path where the gesture
monitor process dies that does not lead to a notification of the java
layer. This resulted in having multiple registered processes.
Now, we will rely on the native layer to manage the pid and to notify
the java layer appropriately.
Bug: 175593831
Test: atest inputflinger_tests
Change-Id: Ie1f7e976dcadcf07a83f78b3ca856b5c43096e2f
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
index d9ec020..b976129 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
@@ -50,20 +50,31 @@
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.
+ /* Notifies the system that a window just became unresponsive. This indicates that ANR
+ * should be raised for this window. The window 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;
+ virtual void notifyWindowUnresponsive(const sp<IBinder>& token, const std::string& reason) = 0;
+ /* Notifies the system that a monitor just became unresponsive. This indicates that ANR
+ * should be raised for this monitor. The monitor is identified via its pid.
+ * The string reason contains information about the input event that we haven't received
+ * a response for.
+ */
+ virtual void notifyMonitorUnresponsive(int32_t pid, 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
+ /* Notifies the system that a window just became responsive. This is only called after the
+ * window was first marked "unresponsive". This indicates that ANR dialog (if any) should
+ * no longer should be shown to the user. The window is eligible to cause a new ANR in the
* future.
*/
- virtual void notifyConnectionResponsive(const sp<IBinder>& token) = 0;
+ virtual void notifyWindowResponsive(const sp<IBinder>& token) = 0;
+ /* Notifies the system that a monitor just became responsive. This is only called after the
+ * monitor was first marked "unresponsive". This indicates that ANR dialog (if any) should
+ * no longer should be shown to the user. The monitor is eligible to cause a new ANR in the
+ * future.
+ */
+ virtual void notifyMonitorResponsive(int32_t pid) = 0;
/* Notifies the system that an input channel is unrecoverably broken. */
virtual void notifyInputChannelBroken(const sp<IBinder>& token) = 0;