diff options
| author | 2021-03-09 04:35:46 +0000 | |
|---|---|---|
| committer | 2021-03-09 04:35:46 +0000 | |
| commit | 11e34081ef8227755c655c53953f7e2aad0bb090 (patch) | |
| tree | 96e6add30f8f13bf7e8b94fd30554f9dbdcbf814 | |
| parent | cf69b996705e8cf02fe0880ce4f0ebf562fc2cff (diff) | |
| parent | b04b9b8a04851db813e913fc2e3db3b91e1fe196 (diff) | |
Merge "Add support for a hw_timeout_multiplier system property." into sc-dev
| -rw-r--r-- | libs/input/android/os/IInputConstants.aidl | 5 | ||||
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 7 | ||||
| -rw-r--r-- | services/inputflinger/docs/anr.md | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/libs/input/android/os/IInputConstants.aidl b/libs/input/android/os/IInputConstants.aidl index bce0ec8367..4b90844490 100644 --- a/libs/input/android/os/IInputConstants.aidl +++ b/libs/input/android/os/IInputConstants.aidl @@ -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. /** diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 465e8be24b..19f8694a5e 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -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 diff --git a/services/inputflinger/docs/anr.md b/services/inputflinger/docs/anr.md index ce64fe9224..5b931d678f 100644 --- a/services/inputflinger/docs/anr.md +++ b/services/inputflinger/docs/anr.md @@ -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. |