Skip to content

A Python implementation of ADB with shell and FileSync functionality.

License

Notifications You must be signed in to change notification settings

JeffLIrion/adb_shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

149ffbc · Oct 29, 2024
Oct 29, 2024
Apr 8, 2024
Oct 26, 2023
Oct 20, 2023
Oct 18, 2023
Sep 16, 2019
Sep 16, 2019
Sep 16, 2019
Oct 29, 2024
Oct 26, 2023
Nov 4, 2020
Nov 7, 2019
Mar 29, 2020
Oct 19, 2023
Nov 20, 2022
Oct 20, 2023
Oct 29, 2024

Repository files navigation

adb_shell

https://travis-ci.com/JeffLIrion/adb_shell.svg?branch=master https://coveralls.io/repos/github/JeffLIrion/adb_shell/badge.svg?branch=master https://pepy.tech/badge/adb-shell

Documentation for this package can be found at https://adb-shell.readthedocs.io/.

Prebuilt wheel can be downloaded from nightly.link.

This Python package implements ADB shell and FileSync functionality. It originated from python-adb.

Installation

pip install adb-shell

Async

To utilize the async version of this code, you must install into a Python 3.7+ environment via:

pip install adb-shell[async]

USB Support (Experimental)

To connect to a device via USB, install this package via:

pip install adb-shell[usb]

Example Usage

(Based on androidtv/adb_manager.py)

from adb_shell.adb_device import AdbDeviceTcp, AdbDeviceUsb
from adb_shell.auth.sign_pythonrsa import PythonRSASigner

# Load the public and private keys
adbkey = 'path/to/adbkey'
with open(adbkey) as f:
    priv = f.read()
with open(adbkey + '.pub') as f:
     pub = f.read()
signer = PythonRSASigner(pub, priv)

# Connect
device1 = AdbDeviceTcp('192.168.0.222', 5555, default_transport_timeout_s=9.)
device1.connect(rsa_keys=[signer], auth_timeout_s=0.1)

# Connect via USB (package must be installed via `pip install adb-shell[usb])`
device2 = AdbDeviceUsb()
device2.connect(rsa_keys=[signer], auth_timeout_s=0.1)

# Send a shell command
response1 = device1.shell('echo TEST1')
response2 = device2.shell('echo TEST2')

Generate ADB Key Files

If you need to generate a key, you can do so as follows.

from adb_shell.auth.keygen import keygen

keygen('path/to/adbkey')

About

A Python implementation of ADB with shell and FileSync functionality.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published