Loading cmds/dumpstate/dumpstate.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -816,6 +816,8 @@ void Dumpstate::PrintHeader() const { printf("Kernel: "); DumpFileToFd(STDOUT_FILENO, "", "/proc/version"); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Bootconfig: "); DumpFileToFd(STDOUT_FILENO, "", "/proc/bootconfig"); printf("Uptime: "); RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"}, CommandOptions::WithTimeout(1).Always().Build()); Loading libs/binderthreadstate/include/binderthreadstate/CallerUtils.h +6 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,12 @@ enum class BinderCallType { // Based on where we are in recursion of nested binder/hwbinder calls, determine // which one we are closer to. inline static BinderCallType getCurrentServingCall() { const void* hwbinderSp = android::hardware::IPCThreadState::self()->getServingStackPointer(); const void* binderSp = android::IPCThreadState::self()->getServingStackPointer(); auto* hwState = android::hardware::IPCThreadState::selfOrNull(); auto* state = android::IPCThreadState::selfOrNull(); // getServingStackPointer can also return nullptr const void* hwbinderSp = hwState ? hwState->getServingStackPointer() : nullptr; const void* binderSp = state ? state->getServingStackPointer() : nullptr; if (hwbinderSp == nullptr && binderSp == nullptr) return BinderCallType::NONE; if (hwbinderSp == nullptr) return BinderCallType::BINDER; Loading libs/binderthreadstate/test.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,16 @@ #include <BnAidlStuff.h> #include <android-base/logging.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binderthreadstate/CallerUtils.h> #include <binderthreadstateutilstest/1.0/IHidlStuff.h> #include <gtest/gtest.h> #include <hidl/HidlTransportSupport.h> #include <hwbinder/IPCThreadState.h> #include <thread> #include <linux/prctl.h> #include <sys/prctl.h> Loading Loading @@ -154,6 +159,20 @@ TEST(BinderThreadState, LocalAidlCall) { EXPECT_TRUE(server->callLocal().isOk()); } TEST(BinderThreadState, DoesntInitializeBinderDriver) { // this is on another thread, because it's testing thread-specific // state and we expect it not to be initialized. std::thread([&] { EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull()); EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull()); (void)getCurrentServingCall(); EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull()); EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull()); }).join(); } TEST(BindThreadState, RemoteHidlCall) { auto stuff = IHidlStuff::getService(id2name(kP1Id)); ASSERT_NE(nullptr, stuff); Loading services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "gestures/HardwareStateConverter.h" #include <chrono> Loading Loading @@ -80,14 +83,9 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t schs.fingers.clear(); for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) { MultiTouchMotionAccumulator::Slot slot = mMotionAccumulator.getSlot(i); if (!slot.isInUse()) { continue; } // Some touchpads continue to report contacts even after they've identified them as palms. // We want to exclude these contacts from the HardwareStates, but still need to report a // tracking ID of -1 if a finger turns into a palm. const bool isPalm = slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM; if (isPalm && mFingerSlots.find(i) == mFingerSlots.end()) { // We want to exclude these contacts from the HardwareStates. if (!slot.isInUse() || slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM) { continue; } Loading @@ -101,12 +99,7 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t fingerState.orientation = slot.getOrientation(); fingerState.position_x = slot.getX(); fingerState.position_y = slot.getY(); fingerState.tracking_id = isPalm ? -1 : slot.getTrackingId(); if (fingerState.tracking_id == -1) { mFingerSlots.erase(i); } else { mFingerSlots.insert(i); } fingerState.tracking_id = slot.getTrackingId(); } schs.state.fingers = schs.fingers.data(); schs.state.finger_cnt = schs.fingers.size(); Loading @@ -117,7 +110,6 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t void HardwareStateConverter::reset() { mCursorButtonAccumulator.reset(mDeviceContext); mTouchButtonAccumulator.reset(); mFingerSlots.clear(); mMscTimestamp = 0; } Loading services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ private: MultiTouchMotionAccumulator mMotionAccumulator; TouchButtonAccumulator mTouchButtonAccumulator; int32_t mMscTimestamp = 0; std::set<size_t> mFingerSlots; }; } // namespace android Loading
cmds/dumpstate/dumpstate.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -816,6 +816,8 @@ void Dumpstate::PrintHeader() const { printf("Kernel: "); DumpFileToFd(STDOUT_FILENO, "", "/proc/version"); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Bootconfig: "); DumpFileToFd(STDOUT_FILENO, "", "/proc/bootconfig"); printf("Uptime: "); RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"}, CommandOptions::WithTimeout(1).Always().Build()); Loading
libs/binderthreadstate/include/binderthreadstate/CallerUtils.h +6 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,12 @@ enum class BinderCallType { // Based on where we are in recursion of nested binder/hwbinder calls, determine // which one we are closer to. inline static BinderCallType getCurrentServingCall() { const void* hwbinderSp = android::hardware::IPCThreadState::self()->getServingStackPointer(); const void* binderSp = android::IPCThreadState::self()->getServingStackPointer(); auto* hwState = android::hardware::IPCThreadState::selfOrNull(); auto* state = android::IPCThreadState::selfOrNull(); // getServingStackPointer can also return nullptr const void* hwbinderSp = hwState ? hwState->getServingStackPointer() : nullptr; const void* binderSp = state ? state->getServingStackPointer() : nullptr; if (hwbinderSp == nullptr && binderSp == nullptr) return BinderCallType::NONE; if (hwbinderSp == nullptr) return BinderCallType::BINDER; Loading
libs/binderthreadstate/test.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,16 @@ #include <BnAidlStuff.h> #include <android-base/logging.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binderthreadstate/CallerUtils.h> #include <binderthreadstateutilstest/1.0/IHidlStuff.h> #include <gtest/gtest.h> #include <hidl/HidlTransportSupport.h> #include <hwbinder/IPCThreadState.h> #include <thread> #include <linux/prctl.h> #include <sys/prctl.h> Loading Loading @@ -154,6 +159,20 @@ TEST(BinderThreadState, LocalAidlCall) { EXPECT_TRUE(server->callLocal().isOk()); } TEST(BinderThreadState, DoesntInitializeBinderDriver) { // this is on another thread, because it's testing thread-specific // state and we expect it not to be initialized. std::thread([&] { EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull()); EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull()); (void)getCurrentServingCall(); EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull()); EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull()); }).join(); } TEST(BindThreadState, RemoteHidlCall) { auto stuff = IHidlStuff::getService(id2name(kP1Id)); ASSERT_NE(nullptr, stuff); Loading
services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "gestures/HardwareStateConverter.h" #include <chrono> Loading Loading @@ -80,14 +83,9 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t schs.fingers.clear(); for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) { MultiTouchMotionAccumulator::Slot slot = mMotionAccumulator.getSlot(i); if (!slot.isInUse()) { continue; } // Some touchpads continue to report contacts even after they've identified them as palms. // We want to exclude these contacts from the HardwareStates, but still need to report a // tracking ID of -1 if a finger turns into a palm. const bool isPalm = slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM; if (isPalm && mFingerSlots.find(i) == mFingerSlots.end()) { // We want to exclude these contacts from the HardwareStates. if (!slot.isInUse() || slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM) { continue; } Loading @@ -101,12 +99,7 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t fingerState.orientation = slot.getOrientation(); fingerState.position_x = slot.getX(); fingerState.position_y = slot.getY(); fingerState.tracking_id = isPalm ? -1 : slot.getTrackingId(); if (fingerState.tracking_id == -1) { mFingerSlots.erase(i); } else { mFingerSlots.insert(i); } fingerState.tracking_id = slot.getTrackingId(); } schs.state.fingers = schs.fingers.data(); schs.state.finger_cnt = schs.fingers.size(); Loading @@ -117,7 +110,6 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t void HardwareStateConverter::reset() { mCursorButtonAccumulator.reset(mDeviceContext); mTouchButtonAccumulator.reset(); mFingerSlots.clear(); mMscTimestamp = 0; } Loading
services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ private: MultiTouchMotionAccumulator mMotionAccumulator; TouchButtonAccumulator mTouchButtonAccumulator; int32_t mMscTimestamp = 0; std::set<size_t> mFingerSlots; }; } // namespace android