Beispiel #1
0
    def test_push_dir(self):
        self.assertTrue(self.device.connect())

        mtime = 100
        filedata = b'Ohayou sekai.\nGood morning world!'

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(FileSyncMessage(constants.OKAY))),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(FileSyncMessage(constants.OKAY))),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        # Expected `bulk_write` values
        #TODO

        with patch('adb_shell.adb_device.open',
                   mock_open(read_data=filedata)), patch(
                       'os.path.isdir', lambda x: x == 'TEST_DIR/'), patch(
                           'os.listdir',
                           return_value=['TEST_FILE1', 'TEST_FILE2']):
            self.device.push('TEST_DIR/', '/data', mtime=mtime)
Beispiel #2
0
    def test_shell_no_return(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(self.device.shell('TEST'), '')
Beispiel #3
0
    def test_shell_multibytes_sequence_exceeds_max(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'0'*(constants.MAX_ADB_DATA-1) + b'\xe3\x81\x82'),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(u'0'*(constants.MAX_ADB_DATA-1) + u'\u3042', self.device.shell('TEST'))
Beispiel #4
0
    def test_shell_error_timeout_multiple_clse(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b''),
                                                       AdbMessage(command=constants.CLSE, arg0=2, arg1=1, data=b''))

        with self.assertRaises(exceptions.InvalidCommandError):
            self.device.shell('TEST', total_timeout_s=-1)
Beispiel #5
0
    def test_shell_error_remote_id2(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=2, arg1=1, data=b'PASS'))

        with self.assertRaises(exceptions.InvalidResponseError):
            self.device.shell('TEST')
    def test_shell_error_timeout(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'')
        self.device._handle._bulk_read = msg1.pack()

        with self.assertRaises(exceptions.InvalidCommandError):
            self.device.shell('TEST', total_timeout_s=-1)
    def test_shell_error_local_id2(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                          AdbMessage(command=constants.WRTE, arg0=1, arg1=2, data=b'PASS'))

        with self.assertRaises(exceptions.InterleavedDataError):
            self.device.shell('TEST')
            self.device.shell('TEST')
Beispiel #8
0
    def test_shell_data_length_exceeds_max(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'0'*(constants.MAX_ADB_DATA+1)),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.device.shell('TEST')
        self.assertTrue(True)
    def test_shell_return_pass(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                          AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'PA'),
                                                          AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'SS'),
                                                          AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(self.device.shell('TEST'), 'PASS')
Beispiel #10
0
    def test_shell_dont_decode(self):
        self.assertTrue(self.device.connect())
        
        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'PA'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'SS'),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(self.device.shell('TEST', decode=False), b'PASS')
Beispiel #11
0
    def test_shell_with_multibytes_sequence_over_two_messages(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'\xe3'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'\x81\x82'),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(u'\u3042', self.device.shell('TEST'))
Beispiel #12
0
    def test_shell_multiple_clse(self):
        # https://github.com/JeffLIrion/adb_shell/issues/15#issuecomment-536795938
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'')
        msg2 = AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'PASS')
        msg3 = AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b'')
        self.device._handle._bulk_read = b''.join([
            b'OKAY\xd9R\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xb4\xbe\xa6',
            b'WRTE\xd9R\x00\x00\x01\x00\x00\x00\x01\x00\x00\x002\x00\x00\x00\xa8\xad\xab\xba',
            b'2',
            b'WRTE\xd9R\x00\x00\x01\x00\x00\x00\x0c\x02\x00\x00\xc0\x92\x00\x00\xa8\xad\xab\xba',
            b'Wake Locks: size=2\ncom.google.android.tvlauncher\n\n- STREAM_MUSIC:\n   Muted: true\n   Min: 0\n   Max: 15\n   Current: 2 (speaker): 15, 4 (headset): 10, 8 (headphone): 10, 80 (bt_a2dp): 10, 1000 (digital_dock): 10, 4000000 (usb_headset): 3, 40000000 (default): 15\n   Devices: speaker\n- STREAM_ALARM:\n   Muted: true\n   Min: 1\n   Max: 7\n   Current: 2 (speaker): 7, 4 (headset): 5, 8 (headphone): 5, 80 (bt_a2dp): 5, 1000 (digital_dock): 5, 4000000 (usb_headset): 1, 40000000 (default): 7\n   Devices: speaker\n- STREAM_NOTIFICATION:\n',
            b'CLSE\xd9R\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\xb3\xac\xba',
            msg1.pack(),
            b'CLSE\xdaR\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbc\xb3\xac\xba',
            msg2.pack(), msg2.data,
            msg3.pack()
        ])

        self.device.shell(
            "dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\\c' && dumpsys audio | grep paused | grep -qv 'Buffer Queue' && echo -e '1\\c' || (dumpsys audio | grep started | grep -qv 'Buffer Queue' && echo '2\\c' || echo '0\\c') && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP && (dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {' || echo) && dumpsys audio | grep '\\- STREAM_MUSIC:' -A 12"
        )
        self.assertEqual(self.device.shell('TEST'), 'PASS')
Beispiel #13
0
    def test_filesync_read_invalid_response_error(self):
        self.assertTrue(self.device.connect())
        self.device._handle._bulk_write = b''

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=join_messages(FileSyncStatMessage(constants.DENT, 1, 2, 3),
                                                                                                                             FileSyncStatMessage(constants.DONE, 0, 0, 0))))

        with self.assertRaises(exceptions.InvalidResponseError):
            self.device.stat('/data')
Beispiel #14
0
    def test_shell_error_local_id(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.OKAY,
                          arg0=1,
                          arg1=1234,
                          data=b'\x00')
        self.device._handle._bulk_read = b''.join([msg1.pack(), msg1.data])

        with self.assertRaises(exceptions.InvalidResponseError):
            self.device.shell('TEST')
Beispiel #15
0
    def test_filesync_read_adb_command_failure_exceptions(self):
        self.assertTrue(self.device.connect())
        self.device._handle._bulk_write = b''

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=join_messages(FileSyncStatMessage(constants.FAIL, 1, 2, 3),
                                                                                                                             FileSyncStatMessage(constants.DONE, 0, 0, 0))))

        with self.assertRaises(exceptions.AdbCommandFailureException):
            self.device.stat('/data')
Beispiel #16
0
    def test_streaming_shell_dont_decode(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'ABC'),
            AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'123'),
        )

        generator = self.device.streaming_shell('TEST', decode=False)
        self.assertEqual(b'ABC', next(generator))
        self.assertEqual(b'123', next(generator))
    async def test_streaming_shell_dont_decode(self):
        self.assertTrue(await self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'ABC'),
            AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'123'),
        )

        async_generator = self.device.streaming_shell('TEST', decode=False)
        self.assertEqual(await async_generator.__anext__(), b'ABC')
        self.assertEqual(await async_generator.__anext__(), b'123')
Beispiel #18
0
    def test_push_fail(self):
        self.assertTrue(self.device.connect())
        self.device._handle._bulk_write = b''

        mtime = 100
        filedata = b'Ohayou sekai.\nGood morning world!'

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b''),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=join_messages(FileSyncMessage(constants.FAIL, data=b''))))

        with self.assertRaises(exceptions.PushFailedError), patch('adb_shell.adb_device.open', mock_open(read_data=filedata)):
            self.device.push('TEST_FILE', '/data', mtime=mtime)
Beispiel #19
0
    def _test_push(self, mtime):
        self.assertTrue(self.device.connect())
        self.device._handle._bulk_write = b''

        filedata = b'Ohayou sekai.\nGood morning world!'

        # Provide the `bulk_read` return values
        self.device._handle._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                       AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b''),
                                                       AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=join_messages(FileSyncMessage(constants.OKAY, data=b''))),
                                                       AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        # Expected `bulk_write` values
        expected_bulk_write = join_messages(AdbMessage(command=constants.OPEN, arg0=1, arg1=0, data=b'sync:\x00'),
                                            AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=join_messages(FileSyncMessage(command=constants.SEND, data=b'/data,33272'),
                                                                                                                  FileSyncMessage(command=constants.DATA, data=filedata),
                                                                                                                  FileSyncMessage(command=constants.DONE, arg0=mtime))),
                                            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b''),
                                            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        with patch('time.time', return_value=mtime):
            self.device.push(BytesIO(filedata), '/data', mtime=mtime)
            self.assertEqual(expected_bulk_write, self.device._handle._bulk_write)

        return True
Beispiel #20
0
    def test_stat(self):
        self.assertTrue(self.device.connect())
        self.device._handle._bulk_write = b''

        # Provide the `bulk_read` return values

        self.device._handle._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(
                           FileSyncStatMessage(constants.STAT, 1, 2, 3),
                           FileSyncStatMessage(constants.DONE, 0, 0, 0))),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        # Expected `bulk_write` values
        expected_bulk_write = join_messages(
            AdbMessage(command=constants.OPEN,
                       arg0=1,
                       arg1=0,
                       data=b'sync:\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(
                           FileSyncMessage(command=constants.STAT,
                                           data=b'/data'))),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b''),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual((1, 2, 3), self.device.stat('/data'))
        self.assertEqual(expected_bulk_write, self.device._handle._bulk_write)
    async def test_shell_data_length_exceeds_max(self):
        self.assertTrue(await self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=b'0' * (self.device.max_chunk_size + 1)),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        await self.device.shell('TEST')
        self.assertTrue(True)
    async def test_shell_multibytes_sequence_exceeds_max(self):
        self.assertTrue(await self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=b'0' * (self.device.max_chunk_size - 1) +
                       b'\xe3\x81\x82'),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        self.assertEqual(await self.device.shell('TEST'),
                         u'0' * (self.device.max_chunk_size - 1) + u'\u3042')
Beispiel #23
0
    def test_shell_error_local_id(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1234, data=b'\x00'))

        with self.assertRaises(exceptions.InvalidResponseError):
            self.device.shell('TEST')
Beispiel #24
0
    def test_shell_error_transport_timeout(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b''))

        with self.assertRaises(exceptions.InvalidCommandError):
            self.device.shell('TEST', read_timeout_s=-1)
Beispiel #25
0
    def test_shell_error_timeout(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
                                                          AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'PA'),
                                                          AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'SS'),
                                                          AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        def fake_read_until(*args, **kwargs):
            time.sleep(0.2)
            return b'WRTE', b'PA'

        with patch('adb_shell.adb_device.AdbDevice._read_until', fake_read_until):
            with self.assertRaises(exceptions.AdbTimeoutError):
                self.device.shell('TEST', timeout_s=0.5)

        # Clear the `_bulk_read` buffer so that `self.tearDown()` passes
        self.device._transport._bulk_read = b''
Beispiel #26
0
    def test_shell_data_length_exceeds_max(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00')
        msg2 = AdbMessage(command=constants.WRTE,
                          arg0=1,
                          arg1=1,
                          data=b'0' * (constants.MAX_ADB_DATA + 1))
        msg3 = AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b'')
        self.device._handle._bulk_read = b''.join(
            [msg1.pack(), msg1.data,
             msg2.pack(), msg2.data,
             msg3.pack()])

        self.device.shell('TEST')
        self.assertTrue(True)
Beispiel #27
0
    def test_shell_multibytes_sequence_exceeds_max(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00')
        msg2 = AdbMessage(command=constants.WRTE,
                          arg0=1,
                          arg1=1,
                          data=b'0' * (constants.MAX_ADB_DATA - 1) +
                          b'\xe3\x81\x82')
        msg3 = AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b'')
        self.device._handle._bulk_read = b''.join(
            [msg1.pack(), msg1.data,
             msg2.pack(), msg2.data,
             msg3.pack()])

        res = self.device.shell('TEST')
        self.assertEqual(u'0' * (constants.MAX_ADB_DATA - 1) + u'\u3042', res)
    async def test_list(self):
        self.assertTrue(await self.device.connect())
        self.device._transport._bulk_write = b''

        # Provide the `bulk_read` return values
        self.device._transport._bulk_read = join_messages(
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00'),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(
                           FileSyncListMessage(constants.DENT,
                                               1,
                                               2,
                                               3,
                                               data=b'file1'),
                           FileSyncListMessage(constants.DENT,
                                               4,
                                               5,
                                               6,
                                               data=b'file2'),
                           FileSyncListMessage(constants.DONE, 0, 0, 0))),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        # Expected `bulk_write` values
        expected_bulk_write = join_messages(
            AdbMessage(command=constants.OPEN,
                       arg0=1,
                       arg1=0,
                       data=b'sync:\x00'),
            AdbMessage(command=constants.WRTE,
                       arg0=1,
                       arg1=1,
                       data=join_messages(
                           FileSyncMessage(command=constants.LIST,
                                           data=b'/dir'))),
            AdbMessage(command=constants.OKAY, arg0=1, arg1=1),
            AdbMessage(command=constants.CLSE, arg0=1, arg1=1, data=b''))

        expected_result = [
            DeviceFile(filename=bytearray(b'file1'), mode=1, size=2, mtime=3),
            DeviceFile(filename=bytearray(b'file2'), mode=4, size=5, mtime=6)
        ]

        self.assertEqual(await self.device.list('/dir'), expected_result)
        self.assertEqual(self.device._transport._bulk_write,
                         expected_bulk_write)
Beispiel #29
0
        def writer():
            while True:
                try:
                    cmd = input()
                    cmd += '\r'  # Required. Send a carriage return right after the cmd
                    cmd = cmd.encode('utf8')

                    # Send the cmd raw
                    msg = AdbMessage(constants.WRTE, adb_info.local_id,
                                     adb_info.remote_id, cmd)
                    device._send(msg, adb_info)
                except EOFError:
                    device.close()
                    break
Beispiel #30
0
    def test_shell_error_checksum(self):
        self.assertTrue(self.device.connect())

        # Provide the `bulk_read` return values
        msg1 = AdbMessage(command=constants.OKAY, arg0=1, arg1=1, data=b'\x00')
        msg2 = AdbMessage(command=constants.WRTE, arg0=1, arg1=1, data=b'PASS')
        self.device._handle._bulk_read = b''.join([msg1.pack(), msg1.data, msg2.pack(), msg2.data[:-1] + b'0'])

        with self.assertRaises(exceptions.InvalidChecksumError):
            self.device.shell('TEST')