Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11e34081 authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Android (Google) Code Review
Browse files

Merge "Add support for a hw_timeout_multiplier system property." into sc-dev

parents cf69b996 b04b9b8a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ package android.os;
/** @hide */
interface IInputConstants
{
    const int DEFAULT_DISPATCHING_TIMEOUT_MILLIS = 5000; // 5 seconds
    // This should be multiplied by the value of the system property ro.hw_timeout_multiplier before
    // use. A pre-multiplied constant is available in Java in
    // android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS.
    const int UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS = 5000; // 5 seconds

    // Compatibility changes.
    /**
+5 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ static constexpr bool DEBUG_TOUCH_OCCLUSION = true;
#define DEBUG_HOVER 0

#include <android-base/chrono_utils.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android/os/IInputConstants.h>
#include <binder/Binder.h>
@@ -78,6 +79,7 @@ static constexpr bool DEBUG_TOUCH_OCCLUSION = true;
#define INDENT3 "      "
#define INDENT4 "        "

using android::base::HwTimeoutMultiplier;
using android::base::StringPrintf;
using android::os::BlockUntrustedTouchesMode;
using android::os::IInputConstants;
@@ -89,8 +91,9 @@ namespace android::inputdispatcher {

// Default input dispatching timeout if there is no focused application or paused window
// from which to determine an appropriate dispatching timeout.
constexpr std::chrono::duration DEFAULT_INPUT_DISPATCHING_TIMEOUT =
        std::chrono::milliseconds(android::os::IInputConstants::DEFAULT_DISPATCHING_TIMEOUT_MILLIS);
const std::chrono::duration DEFAULT_INPUT_DISPATCHING_TIMEOUT = std::chrono::milliseconds(
        android::os::IInputConstants::UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS *
        HwTimeoutMultiplier());

// Amount of time to allow for all pending events to be processed when an app switch
// key is on the way.  This is used to preempt input dispatch and drop input events
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ Every dispatch cycle, InputDispatcher will check all connections to see if any a

When a dispatch entry is sent to the app, its `deliveryTime` and `timeoutTime` fields are populated. The `deliveryTime` is the time that the event is delivered to the app. This is simply the current time inside `publishMotionEvent`. The `timeoutTime` is the time when this entry would be considered overdue. At that time, the ANR process would start for this connection.

Most connections are associated with a window, and each window may have a custom timeout time. To calculate the timeout time of a specific event, simply add the `window.dispatchingTimeout` to the current time. In case where there is no associated window, such as gesture monitors, use the default dispatching timeout which is defined in `IInputConstants::DEFAULT_DISPATCHING_TIMEOUT_MILLIS`.
Most connections are associated with a window, and each window may have a custom timeout time. To calculate the timeout time of a specific event, simply add the `window.dispatchingTimeout` to the current time. In case where there is no associated window, such as gesture monitors, use the default dispatching timeout which is defined in `android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS`.

The `timeoutTime` field of the `DispatchEntry` is needed because the window associated with a specific connection may change its timeout time. Therefore, entries sent prior to the timeout change would need to follow the previous timeout value. If a window timeout changes, it only affects new events being dispatched, and does not alter the timeout times of events already sent to the app.