Merge "Shift error log to info for rust data store" into main
diff --git a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
index 1210f71..39bb841 100644
--- a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
@@ -14,15 +14,18 @@
* limitations under the License.
*/
+#include <TestEventMatchers.h>
#include <android-base/logging.h>
#include <attestation/HmacKeyManager.h>
#include <ftl/enum.h>
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <input/BlockingQueue.h>
#include <input/InputConsumerNoResampling.h>
#include <input/InputTransport.h>
using android::base::Result;
+using ::testing::Matcher;
namespace android {
@@ -278,7 +281,7 @@
void SetUp() override {
std::unique_ptr<InputChannel> serverChannel;
status_t result =
- InputChannel::openInputChannelPair("channel name", serverChannel, mClientChannel);
+ InputChannel::openInputChannelPair("test channel", serverChannel, mClientChannel);
ASSERT_EQ(OK, result);
mPublisher = std::make_unique<InputPublisher>(std::move(serverChannel));
@@ -336,6 +339,8 @@
// accessed on the test thread.
BlockingQueue<bool> mProbablyHasInputResponses;
+ std::unique_ptr<MotionEvent> assertReceivedMotionEvent(const Matcher<MotionEvent>& matcher);
+
private:
sp<MessageHandler> mMessageHandler;
void handleMessage(const Message& message);
@@ -389,6 +394,20 @@
mLooper->sendMessage(mMessageHandler, msg);
}
+std::unique_ptr<MotionEvent> InputPublisherAndConsumerNoResamplingTest::assertReceivedMotionEvent(
+ const Matcher<MotionEvent>& matcher) {
+ std::optional<std::unique_ptr<MotionEvent>> event = mMotionEvents.popWithTimeout(TIMEOUT);
+ if (!event) {
+ ADD_FAILURE() << "No event was received, but expected motion " << matcher;
+ return nullptr;
+ }
+ if (*event == nullptr) {
+ LOG(FATAL) << "Event was received, but it was null";
+ }
+ EXPECT_THAT(**event, matcher);
+ return std::move(*event);
+}
+
void InputPublisherAndConsumerNoResamplingTest::handleMessage(const Message& message) {
switch (static_cast<LooperMessage>(message.what)) {
case LooperMessage::CALL_PROBABLY_HAS_INPUT: {
@@ -572,8 +591,7 @@
const nsecs_t publishTimeOfDown = systemTime(SYSTEM_TIME_MONOTONIC);
publishMotionEvent(*mPublisher, argsDown);
- // Consume the DOWN event.
- ASSERT_TRUE(mMotionEvents.popWithTimeout(TIMEOUT).has_value());
+ assertReceivedMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
verifyFinishedSignal(*mPublisher, mSeq, publishTimeOfDown);
@@ -622,10 +640,10 @@
// the motion as a batched event, or as a sequence of multiple single-sample MotionEvents (or a
// mix of those)
while (singleSampledMotionEvents.size() != nSamples) {
- const std::optional<std::unique_ptr<MotionEvent>> batchedMotionEvent =
- mMotionEvents.popWithTimeout(TIMEOUT);
+ const std::unique_ptr<MotionEvent> batchedMotionEvent =
+ assertReceivedMotionEvent(WithMotionAction(ACTION_MOVE));
// The events received by these calls are never null
- std::vector<MotionEvent> splitMotionEvents = splitBatchedMotionEvent(**batchedMotionEvent);
+ std::vector<MotionEvent> splitMotionEvents = splitBatchedMotionEvent(*batchedMotionEvent);
singleSampledMotionEvents.insert(singleSampledMotionEvents.end(), splitMotionEvents.begin(),
splitMotionEvents.end());
}
@@ -681,10 +699,7 @@
}
mNotifyLooperMayProceed.notify_all();
- std::optional<std::unique_ptr<MotionEvent>> optMotion = mMotionEvents.popWithTimeout(TIMEOUT);
- ASSERT_TRUE(optMotion.has_value());
- std::unique_ptr<MotionEvent> motion = std::move(*optMotion);
- ASSERT_EQ(ACTION_MOVE, motion->getAction());
+ assertReceivedMotionEvent(WithMotionAction(ACTION_MOVE));
verifyFinishedSignal(*mPublisher, seq, publishTime);
}
@@ -696,9 +711,7 @@
nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC);
publishMotionEvent(*mPublisher, args);
- std::optional<std::unique_ptr<MotionEvent>> optMotion = mMotionEvents.popWithTimeout(TIMEOUT);
- ASSERT_TRUE(optMotion.has_value());
- std::unique_ptr<MotionEvent> event = std::move(*optMotion);
+ std::unique_ptr<MotionEvent> event = assertReceivedMotionEvent(WithMotionAction(action));
verifyArgsEqualToEvent(args, *event);
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index 305feab..580cde3 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -362,6 +362,9 @@
/* Toggle Caps Lock */
virtual void toggleCapsLockState(int32_t deviceId) = 0;
+ /* Resets locked modifier state */
+ virtual void resetLockedModifierState() = 0;
+
/* Determine whether physical keys exist for the given framework-domain key codes. */
virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
const std::vector<int32_t>& keyCodes, uint8_t* outFlags) = 0;
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index ada6653..24919b6 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -590,6 +590,11 @@
}
}
+void InputReader::resetLockedModifierState() {
+ std::scoped_lock _l(mLock);
+ updateLedMetaStateLocked(0);
+}
+
bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask,
const std::vector<int32_t>& keyCodes, uint8_t* outFlags) {
std::scoped_lock _l(mLock);
diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h
index 7614a05..1403ca2 100644
--- a/services/inputflinger/reader/include/InputReader.h
+++ b/services/inputflinger/reader/include/InputReader.h
@@ -69,6 +69,8 @@
void toggleCapsLockState(int32_t deviceId) override;
+ void resetLockedModifierState() override;
+
bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
uint8_t* outFlags) override;
diff --git a/services/inputflinger/tests/KeyboardInputMapper_test.cpp b/services/inputflinger/tests/KeyboardInputMapper_test.cpp
index 39b583c..1dd32c4 100644
--- a/services/inputflinger/tests/KeyboardInputMapper_test.cpp
+++ b/services/inputflinger/tests/KeyboardInputMapper_test.cpp
@@ -926,6 +926,33 @@
ASSERT_EQ(AMETA_CAPS_LOCK_ON, mapper.getMetaState());
}
+TEST_F(KeyboardInputMapperTest, Process_ResetLockedModifierState) {
+ mFakeEventHub->addKey(EVENTHUB_ID, KEY_CAPSLOCK, 0, AKEYCODE_CAPS_LOCK, 0);
+ mFakeEventHub->addKey(EVENTHUB_ID, KEY_NUMLOCK, 0, AKEYCODE_NUM_LOCK, 0);
+ mFakeEventHub->addKey(EVENTHUB_ID, KEY_SCROLLLOCK, 0, AKEYCODE_SCROLL_LOCK, 0);
+
+ KeyboardInputMapper& mapper =
+ constructAndAddMapper<KeyboardInputMapper>(AINPUT_SOURCE_KEYBOARD);
+ // Initial metastate is AMETA_NONE.
+ ASSERT_EQ(AMETA_NONE, mapper.getMetaState());
+
+ // Toggle caps lock on.
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_CAPSLOCK, 1);
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_CAPSLOCK, 0);
+
+ // Toggle num lock on.
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_NUMLOCK, 1);
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_NUMLOCK, 0);
+
+ // Toggle scroll lock on.
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_SCROLLLOCK, 1);
+ process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_SCROLLLOCK, 0);
+ ASSERT_EQ(AMETA_CAPS_LOCK_ON | AMETA_NUM_LOCK_ON | AMETA_SCROLL_LOCK_ON, mapper.getMetaState());
+
+ mReader->resetLockedModifierState();
+ ASSERT_EQ(AMETA_NONE, mapper.getMetaState());
+}
+
TEST_F(KeyboardInputMapperTest, Process_LockedKeysShouldToggleInMultiDevices) {
// keyboard 1.
mFakeEventHub->addLed(EVENTHUB_ID, LED_CAPSL, true /*initially on*/);
diff --git a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
index 64f3c27..6be922d 100644
--- a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
@@ -75,6 +75,8 @@
void toggleCapsLockState(int32_t deviceId) { reader->toggleCapsLockState(deviceId); }
+ void resetLockedModifierState() { reader->resetLockedModifierState(); }
+
bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
uint8_t* outFlags) {
return reader->hasKeys(deviceId, sourceMask, keyCodes, outFlags);
@@ -226,6 +228,7 @@
fdp->ConsumeIntegral<int32_t>());
},
[&]() -> void { reader->toggleCapsLockState(fdp->ConsumeIntegral<int32_t>()); },
+ [&]() -> void { reader->resetLockedModifierState(); },
[&]() -> void {
size_t count = fdp->ConsumeIntegralInRange<size_t>(1, 1024);
std::vector<uint8_t> outFlags(count);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a66380b..37b35f2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2248,12 +2248,10 @@
return;
}
- if (FlagManager::getInstance().hotplug2()) {
- // TODO(b/311403559): use enum type instead of int
- const auto errorCode = static_cast<int32_t>(event);
- ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode, hwcDisplayId);
- mScheduler->dispatchHotplugError(errorCode);
- }
+ // TODO(b/311403559): use enum type instead of int
+ const auto errorCode = static_cast<int32_t>(event);
+ ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode, hwcDisplayId);
+ mScheduler->dispatchHotplugError(errorCode);
}
void SurfaceFlinger::onComposerHalVsyncPeriodTimingChanged(
@@ -3483,10 +3481,8 @@
processHotplugConnect(displayId, hwcDisplayId, std::move(*info),
displayString.c_str());
if (!activeModeIdOpt) {
- if (FlagManager::getInstance().hotplug2()) {
- mScheduler->dispatchHotplugError(
- static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN));
- }
+ mScheduler->dispatchHotplugError(
+ static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN));
getHwComposer().disconnectDisplay(displayId);
continue;
}
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index a99b57b..b56ee01 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -123,7 +123,6 @@
DUMP_READ_ONLY_FLAG(frame_rate_category_mrr);
DUMP_READ_ONLY_FLAG(misc1);
DUMP_READ_ONLY_FLAG(vrr_config);
- DUMP_READ_ONLY_FLAG(hotplug2);
DUMP_READ_ONLY_FLAG(hdcp_level_hal);
DUMP_READ_ONLY_FLAG(multithreaded_present);
DUMP_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace);
@@ -233,7 +232,6 @@
FLAG_MANAGER_READ_ONLY_FLAG(frame_rate_category_mrr, "debug.sf.frame_rate_category_mrr")
FLAG_MANAGER_READ_ONLY_FLAG(misc1, "")
FLAG_MANAGER_READ_ONLY_FLAG(vrr_config, "debug.sf.enable_vrr_config")
-FLAG_MANAGER_READ_ONLY_FLAG(hotplug2, "")
FLAG_MANAGER_READ_ONLY_FLAG(hdcp_level_hal, "")
FLAG_MANAGER_READ_ONLY_FLAG(multithreaded_present, "debug.sf.multithreaded_present")
FLAG_MANAGER_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace, "")
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index 480c9ac..9086537 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -61,7 +61,6 @@
bool stable_edid_ids() const;
bool misc1() const;
bool vrr_config() const;
- bool hotplug2() const;
bool hdcp_level_hal() const;
bool multithreaded_present() const;
bool add_sf_skipped_frames_to_trace() const;