use start update D-Bus interface for usb manager
Use the start update D-Bus interface for usb manager. This change is
based on -
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/65738
https://gerrit.openbmc.org/c/openbmc/docs/+/65739
Tested:
```
<6> StartUpdate succeeded, objectPath: /xyz/openbmc_project/software/ce236cf7
```
Change-Id: Ie8337836537d5ca5aca4bcaa0aa86cbd018752eb
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/usb/usb_manager_main.cpp b/usb/usb_manager_main.cpp
index 771b4cd..3f0e5f5 100644
--- a/usb/usb_manager_main.cpp
+++ b/usb/usb_manager_main.cpp
@@ -7,11 +7,6 @@
int main(int argc, char** argv)
{
namespace fs = std::filesystem;
- // Dbus constructs
- auto bus = sdbusplus::bus::new_default();
-
- // Get a default event loop
- auto event = sdeventplus::Event::get_default();
std::string deviceName{};
@@ -21,6 +16,7 @@
CLI11_PARSE(app, argc, argv);
+ // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
if (deviceName.empty())
{
lg2::error("The file name passed in is empty.");
@@ -29,11 +25,28 @@
fs::path devicePath = fs::path{"/dev"} / deviceName;
fs::path usbPath = fs::path{"/run/media/usb"} / deviceName;
+
+#ifdef START_UPDATE_DBUS_INTEFACE
+
+ sdbusplus::async::context ctx;
+ phosphor::usb::USBManager manager(ctx, devicePath, usbPath);
+ ctx.run();
+
+#else
+
+ // Dbus constructs
+ auto bus = sdbusplus::bus::new_default();
+
+ // Get a default event loop
+ auto event = sdeventplus::Event::get_default();
+
phosphor::usb::USBManager manager(bus, event, devicePath, usbPath);
// Attach the bus to sd_event to service user requests
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
event.loop();
+#endif // START_UPDATE_DBUS_INTEFACE
+
return 0;
}