Merge "Fixing bug for APM ON if device in bad shape"
am: 8151539ba8
Change-Id: I5bea383b24f9acdc31cdebee59fc01d16014f637
diff --git a/acts/framework/acts/test_utils/tel/tel_test_utils.py b/acts/framework/acts/test_utils/tel/tel_test_utils.py
index 1a28418..9bc4cfd 100644
--- a/acts/framework/acts/test_utils/tel/tel_test_utils.py
+++ b/acts/framework/acts/test_utils/tel/tel_test_utils.py
@@ -4983,21 +4983,29 @@
ad.start_services(ad.skip_sl4a, skip_setup_wizard=skip_setup_wizard)
-def check_apm_mode_on_by_serial(serial_id):
- apm_check_cmd = "|".join(("adb -s %s shell dumpsys wifi" % serial_id,
- "grep -i airplanemodeon", "cut -f2 -d ' '"))
- output = exe_cmd(apm_check_cmd)
- if output.decode("utf-8").split("\n")[0] == "true":
+def check_apm_mode_on_by_serial(ad, serial_id):
+ try:
+ apm_check_cmd = "|".join(("adb -s %s shell dumpsys wifi" % serial_id,
+ "grep -i airplanemodeon", "cut -f2 -d ' '"))
+ output = exe_cmd(apm_check_cmd)
+ if output.decode("utf-8").split("\n")[0] == "true":
+ return True
+ else:
+ return False
+ except Exception as e:
+ ad.log.warning("Exception during check apm mode on %s", e)
return True
- else:
- return False
-def set_apm_mode_on_by_serial(serial_id):
- cmd1 = "adb -s %s shell settings put global airplane_mode_on 1" % serial_id
- cmd2 = "adb -s %s shell am broadcast -a android.intent.action.AIRPLANE_MODE" % serial_id
- exe_cmd(cmd1)
- exe_cmd(cmd2)
+def set_apm_mode_on_by_serial(ad, serial_id):
+ try:
+ cmd1 = "adb -s %s shell settings put global airplane_mode_on 1" % serial_id
+ cmd2 = "adb -s %s shell am broadcast -a android.intent.action.AIRPLANE_MODE" % serial_id
+ exe_cmd(cmd1)
+ exe_cmd(cmd2)
+ except Exception as e:
+ ad.log.warning("Exception during set apm mode on %s", e)
+ return True
def print_radio_info(ad, extra_msg=""):
diff --git a/acts/tests/google/tel/lab/TelLabEmergencyCallTest.py b/acts/tests/google/tel/lab/TelLabEmergencyCallTest.py
index 287d9f3..6129333 100644
--- a/acts/tests/google/tel/lab/TelLabEmergencyCallTest.py
+++ b/acts/tests/google/tel/lab/TelLabEmergencyCallTest.py
@@ -103,12 +103,13 @@
if len(list_of_devices) > 1:
for i in range(len(list_of_devices) - 1):
self.log.info("Serial %s", list_of_devices[i])
- if check_apm_mode_on_by_serial(list_of_devices[i]):
+ if check_apm_mode_on_by_serial(self.ad, list_of_devices[i]):
self.log.info("Device is already in APM ON")
else:
self.log.info("Device is not in APM, turning it ON")
- set_apm_mode_on_by_serial(list_of_devices[i])
- if check_apm_mode_on_by_serial(list_of_devices[i]):
+ set_apm_mode_on_by_serial(self.ad, list_of_devices[i])
+ if check_apm_mode_on_by_serial(self.ad,
+ list_of_devices[i]):
self.log.info("Device is now in APM ON")
def setup_class(self):