diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp index 0a502c31ab..736ecaaf88 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp @@ -627,11 +627,7 @@ DumpResult FakeVehicleHardware::dump(const std::vector& options) { } else if (EqualsIgnoreCase(option, "--inject-event")) { result.buffer = dumpInjectEvent(options); } else if (EqualsIgnoreCase(option, kUserHalDumpOption)) { - if (options.size() == 1) { - result.buffer = mFakeUserHal->showDumpHelp(); - } else { - result.buffer = mFakeUserHal->dump(options[1]); - } + result.buffer = mFakeUserHal->dump(); } else if (EqualsIgnoreCase(option, "--genfakedata")) { result.buffer = genFakeDataCommand(options); } else { diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp index 3f97a4df70..0184462418 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp @@ -1520,26 +1520,16 @@ TEST_F(FakeVehicleHardwareTest, testDumpInvalidOptions) { ASSERT_THAT(result.buffer, ContainsRegex("Invalid option: --invalid")); } -TEST_F(FakeVehicleHardwareTest, testDumpFakeUserHalHelp) { - std::vector options; - options.push_back("--user-hal"); - - DumpResult result = getHardware()->dump(options); - ASSERT_FALSE(result.callerShouldDumpState); - ASSERT_NE(result.buffer, ""); - ASSERT_THAT(result.buffer, ContainsRegex("dumps state used for user management")); -} - TEST_F(FakeVehicleHardwareTest, testDumpFakeUserHal) { std::vector options; options.push_back("--user-hal"); - // Indent: " ". - options.push_back(" "); DumpResult result = getHardware()->dump(options); ASSERT_FALSE(result.callerShouldDumpState); ASSERT_NE(result.buffer, ""); - ASSERT_THAT(result.buffer, ContainsRegex(" No InitialUserInfo response\n")); + ASSERT_THAT(result.buffer, + ContainsRegex("No InitialUserInfo response\nNo SwitchUser response\nNo CreateUser " + "response\nNo SetUserIdentificationAssociation response\n")); } struct SetPropTestCase { diff --git a/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h b/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h index 4ae9c8c1cb..fcbe8fddea 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h +++ b/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h @@ -64,7 +64,7 @@ class FakeUserHal final { std::string showDumpHelp() const; // Dump its contents. - std::string dump(std::string indent) const; + std::string dump() const; private: const std::shared_ptr mValuePool; diff --git a/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp b/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp index 91318be8d7..878c2e7da0 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp @@ -339,33 +339,31 @@ std::string FakeUserHal::showDumpHelp() const { return fmt::format("{}: dumps state used for user management\n", kUserHalDumpOption); } -std::string FakeUserHal::dump(std::string indent) const { +std::string FakeUserHal::dump() const { std::scoped_lock lockGuard(mLock); std::string info; if (mInitialUserResponseFromCmd != nullptr) { - info += fmt::format("{}InitialUserInfo response: {}\n", indent, + info += fmt::format("InitialUserInfo response: {}\n", mInitialUserResponseFromCmd->toString()); } else { - info += fmt::format("{}No InitialUserInfo response\n", indent); + info += "No InitialUserInfo response\n"; } if (mSwitchUserResponseFromCmd != nullptr) { - info += fmt::format("{}SwitchUser response: {}\n", indent, - mSwitchUserResponseFromCmd->toString()); + info += fmt::format("SwitchUser response: {}\n", mSwitchUserResponseFromCmd->toString()); } else { - info += fmt::format("{}No SwitchUser response\n", indent); + info += "No SwitchUser response\n"; } if (mCreateUserResponseFromCmd != nullptr) { - info += fmt::format("{}CreateUser response: {}\n", indent, - mCreateUserResponseFromCmd->toString()); + info += fmt::format("CreateUser response: {}\n", mCreateUserResponseFromCmd->toString()); } else { - info += fmt::format("{}No CreateUser response\n", indent); + info += "No CreateUser response\n"; } if (mSetUserIdentificationAssociationResponseFromCmd != nullptr) { - info += fmt::format("{}SetUserIdentificationAssociation response: {}\n", indent, + info += fmt::format("SetUserIdentificationAssociation response: {}\n", mSetUserIdentificationAssociationResponseFromCmd->toString()); } else { - info += fmt::format("{}No SetUserIdentificationAssociation response\n", indent); + info += "No SetUserIdentificationAssociation response\n"; } return info; } diff --git a/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp b/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp index d447bf8cb9..62e9dc81f1 100644 --- a/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp +++ b/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp @@ -792,7 +792,7 @@ binder_status_t DefaultVehicleHal::dump(int fd, const char** args, uint32_t numA DumpResult result = mVehicleHardware->dump(options); dprintf(fd, "%s", (result.buffer + "\n").c_str()); if (!result.callerShouldDumpState) { - dprintf(fd, "Skip dumping Vehicle HAL State.\n"); + ALOGE("Skip dumping Vehicle HAL State."); return STATUS_OK; } dprintf(fd, "Vehicle HAL State: \n");