diff --git a/python-packages/adb/device.py b/python-packages/adb/device.py index 8694ab4b3..392fafea8 100644 --- a/python-packages/adb/device.py +++ b/python-packages/adb/device.py @@ -198,7 +198,7 @@ class AndroidDevice(object): _RETURN_CODE_SEARCH_LENGTH = len('{0}255\r\n'.format(_RETURN_CODE_DELIMITER)) # Feature name strings. - SHELL_PROTOCOL_FEATURE = 'shell_2' + SHELL_PROTOCOL_FEATURE = 'shell_v2' def __init__(self, serial, product=None): self.serial = serial diff --git a/python-packages/adb/test_device.py b/python-packages/adb/test_device.py index bef748831..a1e659fd9 100644 --- a/python-packages/adb/test_device.py +++ b/python-packages/adb/test_device.py @@ -215,12 +215,24 @@ class ShellTest(DeviceTest): if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features: raise unittest.SkipTest('shell protocol unsupported on this device') + # Shell protocol should be used by default. result = self.device.shell_nocheck( shlex.split('echo foo; echo bar >&2; exit 17')) self.assertEqual(17, result[0]) self.assertEqual('foo' + self.device.linesep, result[1]) self.assertEqual('bar' + self.device.linesep, result[2]) + self.assertEqual(17, self._interactive_shell([], 'exit 17')) + + # -x flag should disable shell protocol. + result = self.device.shell_nocheck( + shlex.split('-x echo foo; echo bar >&2; exit 17')) + self.assertEqual(0, result[0]) + self.assertEqual('foo{0}bar{0}'.format(self.device.linesep), result[1]) + self.assertEqual('', result[2]) + + self.assertEqual(0, self._interactive_shell(['-x'], 'exit 17')) + def test_non_interactive_sigint(self): """Tests that SIGINT in a non-interactive shell kills the process.