Allow DeviceState to accept base_cmd as a formattable string

Bug: 130375017
Test: unit tests
Change-Id: Ifeaab18541c1b45e7b04672843a0fd43a4c54c87
diff --git a/acts/framework/acts/test_utils/instrumentation/adb_command_types.py b/acts/framework/acts/test_utils/instrumentation/adb_command_types.py
index fe1b7ce..5c55734 100644
--- a/acts/framework/acts/test_utils/instrumentation/adb_command_types.py
+++ b/acts/framework/acts/test_utils/instrumentation/adb_command_types.py
@@ -37,9 +37,11 @@
         Args:
             values: The value(s) to run the command with
         """
-
-        return str.strip(' '.join(
-            [self._base_cmd] + [str(value) for value in values]))
+        try:
+            return self._base_cmd % values
+        except TypeError:
+            return str.strip(' '.join(
+                [self._base_cmd] + [str(value) for value in values]))
 
     def toggle(self, enabled):
         """Returns the command corresponding to the desired state.
diff --git a/acts/framework/tests/test_utils/instrumentation/adb_command_types_test.py b/acts/framework/tests/test_utils/instrumentation/adb_command_types_test.py
index f5b6cb9..d934cc0 100755
--- a/acts/framework/tests/test_utils/instrumentation/adb_command_types_test.py
+++ b/acts/framework/tests/test_utils/instrumentation/adb_command_types_test.py
@@ -36,6 +36,15 @@
         self.assertEqual(device_state.set_value(val1, val2),
                          'run command with vals 15 24')
 
+    def test_device_state_with_base_cmd_as_format_string(self):
+        """Tests that DeviceState returns the correct ADB command if the base
+        command is given as a format string.
+        """
+        base_cmd = 'echo %s > /test/data'
+        val = 23
+        device_state = DeviceState(base_cmd)
+        self.assertEqual(device_state.set_value(val), 'echo 23 > /test/data')
+
     def test_device_binary_state(self):
         """Tests that DeviceState returns the correct ADB commands with toggle.
         """