Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request install package analog to adb install #214

Open
wimmatthijs opened this issue Feb 17, 2023 · 4 comments
Open

Feature request install package analog to adb install #214

wimmatthijs opened this issue Feb 17, 2023 · 4 comments

Comments

@wimmatthijs
Copy link

wimmatthijs commented Feb 17, 2023

I'm using this library for testing purposes.
Installing the apk to test through adb would be very nice feature to have.
cfr adb install <package.apk>

@JeffLIrion
Copy link
Owner

Does this work?

dev._service(b'install', b'<package.apk>')

@jmcerrejon
Copy link

jmcerrejon commented May 8, 2023

Hello. I'm trying the next on a Quest 2 using macOS:

    result = device._service(
        b"install",
        b"/Users/ulysess/Documents/test/test.apk",
    )

I get the next issue (running with both sudo or not):

Traceback (most recent call last):
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/transport/usb_transport.py", line 283, in bulk_read
    return bytes(self._transport.bulkRead(self._read_endpoint, numbytes, timeout=self._timeout_ms(transport_timeout_s)))
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/usb1/__init__.py", line 1412, in bulkRead
    transferred = self._bulkTransfer(endpoint, data, length, timeout)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/usb1/__init__.py", line 1358, in _bulkTransfer
    mayRaiseUSBError(libusb1.libusb_bulk_transfer(
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/usb1/__init__.py", line 127, in mayRaiseUSBError
    __raiseUSBError(value)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/usb1/__init__.py", line 119, in raiseUSBError
    raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
usb1.USBErrorTimeout: LIBUSB_ERROR_TIMEOUT [-7]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ulysess/Documents/sc/test_adb/main.py", line 235, in <module>
    main()
  File "/Users/ulysess/Documents/sc/test_adb/main.py", line 203, in main
    install_apk(args.install, destination_full_path)
  File "/Users/ulysess/Documents/sc/test_adb/main.py", line 164, in install_apk
    result = device._service(
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 710, in _service
    return b''.join(self._streaming_command(service, command, transport_timeout_s, read_timeout_s, timeout_s)).decode('utf8', _DECODE_ERRORS)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 1288, in _streaming_command
    adb_info = self._open(b'%s:%s' % (service, command), transport_timeout_s, read_timeout_s, timeout_s)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 1186, in _open
    _, adb_info.remote_id, _, _ = self._io_manager.read([constants.OKAY], adb_info)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 339, in read
    cmd, arg0, arg1, data = self._read_packet_from_device(adb_info)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 486, in _read_packet_from_device
    msg = self._read_bytes_from_device(constants.MESSAGE_SIZE, adb_info)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/adb_device.py", line 442, in _read_bytes_from_device
    temp = self._transport.bulk_read(length, adb_info.transport_timeout_s)
  File "/Users/ulysess/Documents/sc/test_adb/.venv/lib/python3.9/site-packages/adb_shell/transport/usb_transport.py", line 285, in bulk_read
    raise exceptions.UsbReadFailedError('Could not receive data from %s (timeout %sms)' % (self.usb_info, self._timeout_ms(transport_timeout_s)), e)
adb_shell.exceptions.UsbReadFailedError: Could not receive data from first 1WMHH812AS9999 (timeout 10000ms): LIBUSB_ERROR_TIMEOUT [-7]

The log I get: messages.log

@wimmatthijs
Copy link
Author

@jmcerrejon @JeffLIrion I worked around the issue by pushing the apk myself and doing a shell pm install command.....
So for now my workaround works, i just thought it would be a nice feature to have in this otherwise very nice and useful package.

@jmcerrejon
Copy link

Yeah, that's the way to proceed now, but It's a great feature to take into account. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants