[autotest]: Add wait for modem before inhibit

Waiting for modem on modemmanager object needed to prevent
modem not found failure that can happen when tried to inhibit
while chromium switching slots

BUG=None
TEST=on test esim profiles: test_that -b trogdor localhost:2226 --fast
cellular_Hermes_MultiProfile.testci

Change-Id: I2591bb968ccba2c3ee14ad196140cf68c4cc581d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3100308
Reviewed-by: Srikanth Oruganti <srikanthkumar@google.com>
Reviewed-by: Pavan Holla <pholla@google.com>
Tested-by: Srikanth Oruganti <srikanthkumar@google.com>
Commit-Queue: Srikanth Oruganti <srikanthkumar@google.com>
diff --git a/client/cros/cellular/hermes_utils.py b/client/cros/cellular/hermes_utils.py
index b2acdfc..48c6402 100644
--- a/client/cros/cellular/hermes_utils.py
+++ b/client/cros/cellular/hermes_utils.py
@@ -8,6 +8,7 @@
 
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.cros.cellular import hermes_constants
+from autotest_lib.client.cros.cellular import mm1_constants
 from autotest_lib.client.cros.networking import hermes_proxy
 from autotest_lib.client.cros.networking import mm1_proxy
 
@@ -61,6 +62,10 @@
     """
     try:
         logging.info('Modem Manager Inhibit/UnInhibit start')
+        # This wait prevents inhibit call in middle of slot switches
+        # triggered by chromium. They can happen on new build at first boot
+        result = mm_proxy.wait_for_modem(mm1_constants.MM_MODEM_POLL_TIME)
+
         mm_proxy.inhibit_device(dbus.Boolean(is_inhibit))
     except dbus.exceptions.DBusException as error:
         raise error.TestFail('mm_inhibit failed. error:', error)