Merge "Notify dispatcher when its configuration needs to be updated" into udc-dev am: 8db57bf911
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/22761147
Change-Id: If92291fe5cd5504a889d80e9042b284618fae360
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 97b57b4..67a5280 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -676,7 +676,6 @@
SurfaceComposerClient::getDefault()->addWindowInfosListener(mWindowInfoListener);
#endif
mKeyRepeatState.lastKeyEntry = nullptr;
- policy->getDispatcherConfiguration(&mConfig);
}
InputDispatcher::~InputDispatcher() {
@@ -6606,6 +6605,14 @@
mLooper->wake();
}
+void InputDispatcher::requestRefreshConfiguration() {
+ InputDispatcherConfiguration config;
+ mPolicy->getDispatcherConfiguration(&config);
+
+ std::scoped_lock _l(mLock);
+ mConfig = config;
+}
+
void InputDispatcher::setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout) {
std::scoped_lock _l(mLock);
mMonitorDispatchingTimeout = timeout;
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 7aa1a2d..dd7f7fe 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -149,6 +149,8 @@
void cancelCurrentTouch() override;
+ void requestRefreshConfiguration() override;
+
// Public to allow tests to verify that a Monitor can get ANR.
void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout);
@@ -166,7 +168,7 @@
std::unique_ptr<InputThread> mThread;
sp<InputDispatcherPolicyInterface> mPolicy;
- android::InputDispatcherConfiguration mConfig;
+ android::InputDispatcherConfiguration mConfig GUARDED_BY(mLock);
std::mutex mLock;
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
index 76dce63..c752ddd 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
@@ -225,6 +225,12 @@
* Abort the current touch stream.
*/
virtual void cancelCurrentTouch() = 0;
+
+ /**
+ * Request that the InputDispatcher's configuration, which can be obtained through the policy,
+ * be updated.
+ */
+ virtual void requestRefreshConfiguration() = 0;
};
} // namespace android
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 3bfc7bf..b3c5095 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -5284,6 +5284,7 @@
mFakePolicy = sp<FakeInputDispatcherPolicy>::make();
mFakePolicy->setKeyRepeatConfiguration(KEY_REPEAT_TIMEOUT, KEY_REPEAT_DELAY);
mDispatcher = std::make_unique<InputDispatcher>(mFakePolicy);
+ mDispatcher->requestRefreshConfiguration();
mDispatcher->setInputDispatchMode(/*enabled*/ true, /*frozen*/ false);
ASSERT_EQ(OK, mDispatcher->start());