Loading cmds/dumpstate/dumpstate.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -2296,8 +2296,7 @@ static void FinalizeFile() { std::string final_path = ds.path_; std::string final_path = ds.path_; if (ds.options_->OutputToCustomFile()) { if (ds.options_->OutputToCustomFile()) { std::string bugreport_dir = dirname(ds.options_->use_outfile.c_str()); final_path = ds.GetPath(ds.options_->out_dir, ".zip"); final_path = ds.GetPath(bugreport_dir, ".zip"); android::os::CopyFileToFile(ds.path_, final_path); android::os::CopyFileToFile(ds.path_, final_path); } } Loading Loading @@ -2418,7 +2417,7 @@ Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) // clang-format off // clang-format off case 'd': do_add_date = true; break; case 'd': do_add_date = true; break; case 'z': do_zip_file = true; break; case 'z': do_zip_file = true; break; case 'o': use_outfile = optarg; break; case 'o': out_dir = optarg; break; case 's': use_socket = true; break; case 's': use_socket = true; break; case 'S': use_control_socket = true; break; case 'S': use_control_socket = true; break; case 'v': show_header_only = true; break; case 'v': show_header_only = true; break; Loading cmds/dumpstate/dumpstate.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -386,12 +386,12 @@ class Dumpstate { // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; // File descriptor to output zip file. Takes precedence over use_outfile.. // File descriptor to output zip file. Takes precedence over out_dir. android::base::unique_fd bugreport_fd; android::base::unique_fd bugreport_fd; // File descriptor to screenshot file. // File descriptor to screenshot file. android::base::unique_fd screenshot_fd; android::base::unique_fd screenshot_fd; // Partial path to output file. // Custom output directory. std::string use_outfile; std::string out_dir; // Bugreport mode of the bugreport. // Bugreport mode of the bugreport. std::string bugreport_mode; std::string bugreport_mode; // Command-line arguments as string // Command-line arguments as string Loading Loading @@ -421,7 +421,7 @@ class Dumpstate { /* Returns if options specified require writing to custom file location */ /* Returns if options specified require writing to custom file location */ bool OutputToCustomFile() { bool OutputToCustomFile() { // Custom location is only honored in limited mode. // Custom location is only honored in limited mode. return limited_only && !use_outfile.empty() && bugreport_fd.get() == -1; return limited_only && !out_dir.empty() && bugreport_fd.get() == -1; } } }; }; Loading cmds/dumpstate/tests/dumpstate_test.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -172,7 +172,7 @@ TEST_F(DumpOptionsTest, InitializeNone) { EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_zip_file); EXPECT_FALSE(options_.do_zip_file); EXPECT_EQ("", options_.use_outfile); EXPECT_EQ("", options_.out_dir); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading Loading @@ -366,7 +366,7 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { EXPECT_TRUE(options_.use_control_socket); EXPECT_TRUE(options_.use_control_socket); EXPECT_FALSE(options_.do_vibrate); EXPECT_FALSE(options_.do_vibrate); EXPECT_TRUE(options_.limited_only); EXPECT_TRUE(options_.limited_only); EXPECT_EQ(" abc", std::string(options_.use_outfile)); EXPECT_EQ(" abc", std::string(options_.out_dir)); // Other options retain default values // Other options retain default values EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading include/input/Input.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -462,6 +462,8 @@ public: nsecs_t eventTime); nsecs_t eventTime); void initialize(const KeyEvent& from); void initialize(const KeyEvent& from); static const char* actionToString(int32_t action); protected: protected: int32_t mAction; int32_t mAction; int32_t mFlags; int32_t mFlags; Loading Loading @@ -725,6 +727,8 @@ public: static const char* getLabel(int32_t axis); static const char* getLabel(int32_t axis); static int32_t getAxisFromLabel(const char* label); static int32_t getAxisFromLabel(const char* label); static const char* actionToString(int32_t action); protected: protected: int32_t mAction; int32_t mAction; int32_t mActionButton; int32_t mActionButton; Loading libs/input/Input.cpp +31 −0 Original line number Original line Diff line number Diff line Loading @@ -169,6 +169,18 @@ void KeyEvent::initialize(const KeyEvent& from) { mEventTime = from.mEventTime; mEventTime = from.mEventTime; } } const char* KeyEvent::actionToString(int32_t action) { // Convert KeyEvent action to string switch (action) { case AKEY_EVENT_ACTION_DOWN: return "DOWN"; case AKEY_EVENT_ACTION_UP: return "UP"; case AKEY_EVENT_ACTION_MULTIPLE: return "MULTIPLE"; } return "UNKNOWN"; } // --- PointerCoords --- // --- PointerCoords --- Loading Loading @@ -678,6 +690,25 @@ int32_t MotionEvent::getAxisFromLabel(const char* label) { return getAxisByLabel(label); return getAxisByLabel(label); } } const char* MotionEvent::actionToString(int32_t action) { // Convert MotionEvent action to string switch (action & AMOTION_EVENT_ACTION_MASK) { case AMOTION_EVENT_ACTION_DOWN: return "DOWN"; case AMOTION_EVENT_ACTION_MOVE: return "MOVE"; case AMOTION_EVENT_ACTION_UP: return "UP"; case AMOTION_EVENT_ACTION_CANCEL: return "CANCEL"; case AMOTION_EVENT_ACTION_POINTER_DOWN: return "POINTER_DOWN"; case AMOTION_EVENT_ACTION_POINTER_UP: return "POINTER_UP"; } return "UNKNOWN"; } // --- FocusEvent --- // --- FocusEvent --- void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { Loading Loading
cmds/dumpstate/dumpstate.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -2296,8 +2296,7 @@ static void FinalizeFile() { std::string final_path = ds.path_; std::string final_path = ds.path_; if (ds.options_->OutputToCustomFile()) { if (ds.options_->OutputToCustomFile()) { std::string bugreport_dir = dirname(ds.options_->use_outfile.c_str()); final_path = ds.GetPath(ds.options_->out_dir, ".zip"); final_path = ds.GetPath(bugreport_dir, ".zip"); android::os::CopyFileToFile(ds.path_, final_path); android::os::CopyFileToFile(ds.path_, final_path); } } Loading Loading @@ -2418,7 +2417,7 @@ Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) // clang-format off // clang-format off case 'd': do_add_date = true; break; case 'd': do_add_date = true; break; case 'z': do_zip_file = true; break; case 'z': do_zip_file = true; break; case 'o': use_outfile = optarg; break; case 'o': out_dir = optarg; break; case 's': use_socket = true; break; case 's': use_socket = true; break; case 'S': use_control_socket = true; break; case 'S': use_control_socket = true; break; case 'v': show_header_only = true; break; case 'v': show_header_only = true; break; Loading
cmds/dumpstate/dumpstate.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -386,12 +386,12 @@ class Dumpstate { // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). // The HAL is actually an API surface that can be validated, while the AIDL is not (@hide). ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode dumpstate_hal_mode = ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; ::android::hardware::dumpstate::V1_1::DumpstateMode::DEFAULT; // File descriptor to output zip file. Takes precedence over use_outfile.. // File descriptor to output zip file. Takes precedence over out_dir. android::base::unique_fd bugreport_fd; android::base::unique_fd bugreport_fd; // File descriptor to screenshot file. // File descriptor to screenshot file. android::base::unique_fd screenshot_fd; android::base::unique_fd screenshot_fd; // Partial path to output file. // Custom output directory. std::string use_outfile; std::string out_dir; // Bugreport mode of the bugreport. // Bugreport mode of the bugreport. std::string bugreport_mode; std::string bugreport_mode; // Command-line arguments as string // Command-line arguments as string Loading Loading @@ -421,7 +421,7 @@ class Dumpstate { /* Returns if options specified require writing to custom file location */ /* Returns if options specified require writing to custom file location */ bool OutputToCustomFile() { bool OutputToCustomFile() { // Custom location is only honored in limited mode. // Custom location is only honored in limited mode. return limited_only && !use_outfile.empty() && bugreport_fd.get() == -1; return limited_only && !out_dir.empty() && bugreport_fd.get() == -1; } } }; }; Loading
cmds/dumpstate/tests/dumpstate_test.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -172,7 +172,7 @@ TEST_F(DumpOptionsTest, InitializeNone) { EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_add_date); EXPECT_FALSE(options_.do_zip_file); EXPECT_FALSE(options_.do_zip_file); EXPECT_EQ("", options_.use_outfile); EXPECT_EQ("", options_.out_dir); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.use_control_socket); EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading Loading @@ -366,7 +366,7 @@ TEST_F(DumpOptionsTest, InitializeLimitedOnlyBugreport) { EXPECT_TRUE(options_.use_control_socket); EXPECT_TRUE(options_.use_control_socket); EXPECT_FALSE(options_.do_vibrate); EXPECT_FALSE(options_.do_vibrate); EXPECT_TRUE(options_.limited_only); EXPECT_TRUE(options_.limited_only); EXPECT_EQ(" abc", std::string(options_.use_outfile)); EXPECT_EQ(" abc", std::string(options_.out_dir)); // Other options retain default values // Other options retain default values EXPECT_FALSE(options_.show_header_only); EXPECT_FALSE(options_.show_header_only); Loading
include/input/Input.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -462,6 +462,8 @@ public: nsecs_t eventTime); nsecs_t eventTime); void initialize(const KeyEvent& from); void initialize(const KeyEvent& from); static const char* actionToString(int32_t action); protected: protected: int32_t mAction; int32_t mAction; int32_t mFlags; int32_t mFlags; Loading Loading @@ -725,6 +727,8 @@ public: static const char* getLabel(int32_t axis); static const char* getLabel(int32_t axis); static int32_t getAxisFromLabel(const char* label); static int32_t getAxisFromLabel(const char* label); static const char* actionToString(int32_t action); protected: protected: int32_t mAction; int32_t mAction; int32_t mActionButton; int32_t mActionButton; Loading
libs/input/Input.cpp +31 −0 Original line number Original line Diff line number Diff line Loading @@ -169,6 +169,18 @@ void KeyEvent::initialize(const KeyEvent& from) { mEventTime = from.mEventTime; mEventTime = from.mEventTime; } } const char* KeyEvent::actionToString(int32_t action) { // Convert KeyEvent action to string switch (action) { case AKEY_EVENT_ACTION_DOWN: return "DOWN"; case AKEY_EVENT_ACTION_UP: return "UP"; case AKEY_EVENT_ACTION_MULTIPLE: return "MULTIPLE"; } return "UNKNOWN"; } // --- PointerCoords --- // --- PointerCoords --- Loading Loading @@ -678,6 +690,25 @@ int32_t MotionEvent::getAxisFromLabel(const char* label) { return getAxisByLabel(label); return getAxisByLabel(label); } } const char* MotionEvent::actionToString(int32_t action) { // Convert MotionEvent action to string switch (action & AMOTION_EVENT_ACTION_MASK) { case AMOTION_EVENT_ACTION_DOWN: return "DOWN"; case AMOTION_EVENT_ACTION_MOVE: return "MOVE"; case AMOTION_EVENT_ACTION_UP: return "UP"; case AMOTION_EVENT_ACTION_CANCEL: return "CANCEL"; case AMOTION_EVENT_ACTION_POINTER_DOWN: return "POINTER_DOWN"; case AMOTION_EVENT_ACTION_POINTER_UP: return "POINTER_UP"; } return "UNKNOWN"; } // --- FocusEvent --- // --- FocusEvent --- void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { Loading