Loading include/input/InputDevice.h +2 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,8 @@ enum class InputDeviceSensorAccuracy : int32_t { ACCURACY_LOW = 1, ACCURACY_MEDIUM = 2, ACCURACY_HIGH = 3, ftl_last = ACCURACY_HIGH, }; enum class InputDeviceSensorReportingMode : int32_t { Loading libs/binder/ndk/ibinder.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -478,6 +478,21 @@ binder_status_t AIBinder_DeathRecipient::linkToDeath(const sp<IBinder>& binder, std::lock_guard<std::mutex> l(mDeathRecipientsMutex); if (mOnUnlinked && cookie && std::find_if(mDeathRecipients.begin(), mDeathRecipients.end(), [&cookie](android::sp<TransferDeathRecipient> recipient) { return recipient->getCookie() == cookie; }) != mDeathRecipients.end()) { ALOGE("Attempting to AIBinder_linkToDeath with the same cookie with an onUnlink callback. " "This will cause the onUnlinked callback to be called multiple times with the same " "cookie, which is usually not intended."); } if (!mOnUnlinked && cookie) { ALOGW("AIBinder_linkToDeath is being called with a non-null cookie and no onUnlink " "callback set. This might not be intended. AIBinder_DeathRecipient_setOnUnlinked " "should be called first."); } sp<TransferDeathRecipient> recipient = new TransferDeathRecipient(binder, cookie, this, mOnDied, mOnUnlinked); Loading libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp +50 −0 Original line number Diff line number Diff line Loading @@ -697,6 +697,56 @@ TEST(NdkBinder, DeathRecipientDropBinderOnDied) { } } void LambdaOnUnlinkMultiple(void* cookie) { auto funcs = static_cast<DeathRecipientCookie*>(cookie); (*funcs->onUnlink)(); }; TEST(NdkBinder, DeathRecipientMultipleLinks) { using namespace std::chrono_literals; ndk::SpAIBinder binder; sp<IFoo> foo = IFoo::getService(IFoo::kSomeInstanceName, binder.getR()); ASSERT_NE(nullptr, foo.get()); ASSERT_NE(nullptr, binder); std::function<void(void)> onDeath = [&] {}; std::mutex unlinkMutex; std::condition_variable unlinkCv; bool unlinkReceived = false; constexpr uint32_t kNumberOfLinksToDeath = 4; uint32_t countdown = kNumberOfLinksToDeath; std::function<void(void)> onUnlink = [&] { std::unique_lock<std::mutex> lockUnlink(unlinkMutex); countdown--; if (countdown == 0) { unlinkReceived = true; unlinkCv.notify_one(); } }; DeathRecipientCookie* cookie = new DeathRecipientCookie{&onDeath, &onUnlink}; ndk::ScopedAIBinder_DeathRecipient recipient(AIBinder_DeathRecipient_new(LambdaOnDeath)); AIBinder_DeathRecipient_setOnUnlinked(recipient.get(), LambdaOnUnlinkMultiple); for (int32_t i = 0; i < kNumberOfLinksToDeath; i++) { EXPECT_EQ(STATUS_OK, AIBinder_linkToDeath(binder.get(), recipient.get(), static_cast<void*>(cookie))); } foo = nullptr; binder = nullptr; std::unique_lock<std::mutex> lockUnlink(unlinkMutex); EXPECT_TRUE(unlinkCv.wait_for(lockUnlink, 5s, [&] { return unlinkReceived; })) << "countdown: " << countdown; EXPECT_TRUE(unlinkReceived); EXPECT_EQ(countdown, 0); } TEST(NdkBinder, RetrieveNonNdkService) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" Loading libs/input/InputTransport.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -387,9 +387,9 @@ status_t InputChannel::openInputChannelPair(const std::string& name, status_t InputChannel::sendMessage(const InputMessage* msg) { ATRACE_NAME_IF(ATRACE_ENABLED(), StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")", name.c_str(), msg->header.seq, msg->header.type)); StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", name.c_str(), msg->header.seq, ftl::enum_string(msg->header.type).c_str())); const size_t msgLength = msg->size(); InputMessage cleanMsg; msg->getSanitizedCopy(&cleanMsg); Loading Loading @@ -458,9 +458,10 @@ status_t InputChannel::receiveMessage(InputMessage* msg) { ftl::enum_string(msg->header.type).c_str()); if (ATRACE_ENABLED()) { // Add an additional trace point to include data about the received message. std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")", name.c_str(), msg->header.seq, msg->header.type); std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", name.c_str(), msg->header.seq, ftl::enum_string(msg->header.type).c_str()); ATRACE_NAME(message.c_str()); } return OK; Loading libs/input/input_flags.aconfig +6 −0 Original line number Diff line number Diff line Loading @@ -135,7 +135,13 @@ flag { description: "Enable prediction pruning based on jerk thresholds." bug: "266747654" is_fixed_read_only: true } flag { name: "device_associations" namespace: "input" description: "Binds InputDevice name and InputDevice description against display unique id." bug: "324075859" } flag { Loading Loading
include/input/InputDevice.h +2 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,8 @@ enum class InputDeviceSensorAccuracy : int32_t { ACCURACY_LOW = 1, ACCURACY_MEDIUM = 2, ACCURACY_HIGH = 3, ftl_last = ACCURACY_HIGH, }; enum class InputDeviceSensorReportingMode : int32_t { Loading
libs/binder/ndk/ibinder.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -478,6 +478,21 @@ binder_status_t AIBinder_DeathRecipient::linkToDeath(const sp<IBinder>& binder, std::lock_guard<std::mutex> l(mDeathRecipientsMutex); if (mOnUnlinked && cookie && std::find_if(mDeathRecipients.begin(), mDeathRecipients.end(), [&cookie](android::sp<TransferDeathRecipient> recipient) { return recipient->getCookie() == cookie; }) != mDeathRecipients.end()) { ALOGE("Attempting to AIBinder_linkToDeath with the same cookie with an onUnlink callback. " "This will cause the onUnlinked callback to be called multiple times with the same " "cookie, which is usually not intended."); } if (!mOnUnlinked && cookie) { ALOGW("AIBinder_linkToDeath is being called with a non-null cookie and no onUnlink " "callback set. This might not be intended. AIBinder_DeathRecipient_setOnUnlinked " "should be called first."); } sp<TransferDeathRecipient> recipient = new TransferDeathRecipient(binder, cookie, this, mOnDied, mOnUnlinked); Loading
libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp +50 −0 Original line number Diff line number Diff line Loading @@ -697,6 +697,56 @@ TEST(NdkBinder, DeathRecipientDropBinderOnDied) { } } void LambdaOnUnlinkMultiple(void* cookie) { auto funcs = static_cast<DeathRecipientCookie*>(cookie); (*funcs->onUnlink)(); }; TEST(NdkBinder, DeathRecipientMultipleLinks) { using namespace std::chrono_literals; ndk::SpAIBinder binder; sp<IFoo> foo = IFoo::getService(IFoo::kSomeInstanceName, binder.getR()); ASSERT_NE(nullptr, foo.get()); ASSERT_NE(nullptr, binder); std::function<void(void)> onDeath = [&] {}; std::mutex unlinkMutex; std::condition_variable unlinkCv; bool unlinkReceived = false; constexpr uint32_t kNumberOfLinksToDeath = 4; uint32_t countdown = kNumberOfLinksToDeath; std::function<void(void)> onUnlink = [&] { std::unique_lock<std::mutex> lockUnlink(unlinkMutex); countdown--; if (countdown == 0) { unlinkReceived = true; unlinkCv.notify_one(); } }; DeathRecipientCookie* cookie = new DeathRecipientCookie{&onDeath, &onUnlink}; ndk::ScopedAIBinder_DeathRecipient recipient(AIBinder_DeathRecipient_new(LambdaOnDeath)); AIBinder_DeathRecipient_setOnUnlinked(recipient.get(), LambdaOnUnlinkMultiple); for (int32_t i = 0; i < kNumberOfLinksToDeath; i++) { EXPECT_EQ(STATUS_OK, AIBinder_linkToDeath(binder.get(), recipient.get(), static_cast<void*>(cookie))); } foo = nullptr; binder = nullptr; std::unique_lock<std::mutex> lockUnlink(unlinkMutex); EXPECT_TRUE(unlinkCv.wait_for(lockUnlink, 5s, [&] { return unlinkReceived; })) << "countdown: " << countdown; EXPECT_TRUE(unlinkReceived); EXPECT_EQ(countdown, 0); } TEST(NdkBinder, RetrieveNonNdkService) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" Loading
libs/input/InputTransport.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -387,9 +387,9 @@ status_t InputChannel::openInputChannelPair(const std::string& name, status_t InputChannel::sendMessage(const InputMessage* msg) { ATRACE_NAME_IF(ATRACE_ENABLED(), StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")", name.c_str(), msg->header.seq, msg->header.type)); StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", name.c_str(), msg->header.seq, ftl::enum_string(msg->header.type).c_str())); const size_t msgLength = msg->size(); InputMessage cleanMsg; msg->getSanitizedCopy(&cleanMsg); Loading Loading @@ -458,9 +458,10 @@ status_t InputChannel::receiveMessage(InputMessage* msg) { ftl::enum_string(msg->header.type).c_str()); if (ATRACE_ENABLED()) { // Add an additional trace point to include data about the received message. std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")", name.c_str(), msg->header.seq, msg->header.type); std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", name.c_str(), msg->header.seq, ftl::enum_string(msg->header.type).c_str()); ATRACE_NAME(message.c_str()); } return OK; Loading
libs/input/input_flags.aconfig +6 −0 Original line number Diff line number Diff line Loading @@ -135,7 +135,13 @@ flag { description: "Enable prediction pruning based on jerk thresholds." bug: "266747654" is_fixed_read_only: true } flag { name: "device_associations" namespace: "input" description: "Binds InputDevice name and InputDevice description against display unique id." bug: "324075859" } flag { Loading