Add external_storage_path property to AndroidDevice.
Frequently referenced in instrumentation test utils.
Bug: None
Test: local
Change-Id: I7005d59d186557fe1ab88827efe86c8a7eefeea3
diff --git a/acts/framework/acts/controllers/android_device.py b/acts/framework/acts/controllers/android_device.py
index 1f8bbce..eb9efb2 100755
--- a/acts/framework/acts/controllers/android_device.py
+++ b/acts/framework/acts/controllers/android_device.py
@@ -986,6 +986,13 @@
self.log.debug("Find files in directory %s: %s", directory, files)
return files
+ @property
+ def external_storage_path(self):
+ """
+ The $EXTERNAL_STORAGE path on the device. Most commonly set to '/sdcard'
+ """
+ return self.adb.shell('echo $EXTERNAL_STORAGE')
+
def pull_files(self, device_paths, host_path=None):
"""Pull files from devices.
diff --git a/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py b/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py
index 6e676a4..bdff9b4 100644
--- a/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py
+++ b/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py
@@ -45,7 +45,7 @@
filename = os.path.basename(source_path)
else:
default_full_proto_dir = os.path.join(
- ad.adb.shell('echo $EXTERNAL_STORAGE'), DEFAULT_INST_LOG_DIR)
+ ad.external_storage_path, DEFAULT_INST_LOG_DIR)
filename = ad.adb.shell('ls %s -t | head -n1' % default_full_proto_dir)
if not filename:
raise ProtoParserError(
diff --git a/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py b/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py
index cb4068c..c276fc5 100644
--- a/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py
+++ b/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py
@@ -36,6 +36,7 @@
def setUp(self):
self.ad = mock.MagicMock()
+ self.ad.external_storage_path = ''
@mock.patch('os.path.exists', return_value=True)
def test_pull_proto_returns_correct_path_given_source(self, *_):
@@ -44,12 +45,12 @@
@mock.patch('os.path.exists', return_value=True)
def test_pull_proto_returns_correct_path_from_default_location(self, *_):
- self.ad.adb.shell.side_effect = ['', 'default']
+ self.ad.adb.shell.return_value = 'default'
self.assertEqual(parser.pull_proto(self.ad, DEST_DIR),
'dest/proto_dir/default')
def test_pull_proto_fails_if_no_default_proto_found(self, *_):
- self.ad.adb.shell.side_effect = ['', None]
+ self.ad.adb.shell.return_value = None
with self.assertRaisesRegex(
ProtoParserError, 'No instrumentation result'):
parser.pull_proto(self.ad, DEST_DIR)