Skip to main content

A simple python package to interface with adb

Project description

PY-ADB

This is a package to command android device with Python, it use ADB, so if you don't have it, plaese install it before.

REQUIREMENTS

# WINDOWS
choco install adb

# LINUX
sudo apt-get install android-tools-adb

# MAC
brew install android-platform-tools

BEFORE STARTING USING PY-ADB ENSURE YOU HAVE ENABLED DEVELOPER OPTIONS


Using PY-ADB is simple, just install adb-connector-python
pip install adb-connector-python
# create main.py file

EXAMPLES

# in main.py
from adb_connector_python.connector import Py_adb

adb_connector = Py_adb() 

print(adb_connector.ADB_VERSION) #  1.0.41
print(adb_connector.ADB_EXECUTABLE) # /usr/bin/adb

BASIC INFO

adb_connector.list_devices()
# [ { "id":"fh8swx9cs", "status":"device" }, { "id":"2439vjsacs", "status":"unauthorized" } ]

adb_connector.is_adb_running() # it runs on every action and raise exception if adb is not running
# True

adb_connector.get_first_avaiable_device()
# { "id":"fh8swx9cs", "status":"device" }

adb_connector.phone_data()
# {
#    "battery_data":{ "is_charging":True, "level":64 },
#    "device_data":{ "model":"AS3D24SS", "android_version":13,"brand":"Redmi" },
#    "status":{ "is_locked":True, "is_awake":False },
#    "packages":{ "count":130, "list":["com.android.google.youtube", ... ] }
# }

adb_connector.start_logcat() # start android log
adb_connector.start_logcat(term="Flutter") # only return log containing Flutter string
# This can be useful for debug, for example creating a custom error and ther looking for it

MANAGING APK

adb_connector.install_apk(path="path/to/apk")

adb_connector.uninstall_apk(
    package_name="com.android.google.youtube",
    device_id="2439vjsacs"
    )

SCREEN ACTIONS

# swipe on the screen from points x100 y100 to x300 y300
adb_connector.swipe(
    x_from=100,y_from=100,
    y_to=300,y_to=300
)

# tap on screen at cordinates x100 y100
adb_connector.tap(x=100,y=100)

adb_connector.home() # return to device home
adb_connector.back() # go back 
adb_connector.foreground_apps() # background app check

OPEN APPS

adb_connector.open_call_log()
adb_connector.open_calendar()
adb_connector.open_music()
adb_connector.open_calculator()
adb_connector.open_email()
adb_connector.open_browser()
adb_connector.open_camera()

# to see all supported app run
adb_connector.SUPPORTED_APPS

USER ACTIONS

# phone call
adb_connector.call(phone_number="xxxxxxxx")

# send sms
adb_connector.send_sms(phone_number="xxxxxxxx",message="hello world")

# unlock screen
adb_connector.unlock_screen(password="12345")

# lock screen
adb_connector.power_button() 

# take screenshot
adb_connector.screenshot()

# input text 
adb_connector.insert_text("important data")

# take a picture with frontal camera zoomming 5 times
adb_connector.take_picture(frontal_camera=True, zoom_in=5)

# video capture with external camera for 10 seconds, zoomming 3 times 
adb_connector.video_capture(zoom_out=3, duration=10 )

# activate voice assistant (ok google)
adb_connector.voice_assistant()

# toggle notification center
adb_connector.notification_center()

OTHER ACTIONS

# turn off device in 2 seconds
adb_connector.turn_off(countdown=2)

# reboot device in 10 seconds
adb_connector.reboot(countdown=10)

# raise / low volume
adb_connector.volume_up()
adb_connector.volume_down(times=7) # do it 7 times

# raise / low brightness
adb_connector.brightness_up(times=2) # do it 2 times
adb_connector.brightness_down()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adb-connector-python-1.0.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

adb_connector_python-1.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file adb-connector-python-1.0.1.tar.gz.

File metadata

  • Download URL: adb-connector-python-1.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for adb-connector-python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 caafdb51a6a6a0f0fc092b87dfb9345f2ef3eb980a423e0c6fcdb74a7de84a0f
MD5 73dda4d36b8f6e3fa93bf7e4a344f50d
BLAKE2b-256 0baf50bc3e5e65e9f00872e7a93e8e0e958fe734a00af6dfa0ddab9ae913c1f5

See more details on using hashes here.

File details

Details for the file adb_connector_python-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for adb_connector_python-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ea89aaa78d5de0bf2c7073fdd225fae1abb20ff7fed4f0eb39d314fa920b668
MD5 2ab8991f0d77619910d320ef697f849a
BLAKE2b-256 4f0d656655b4e2de31b073d6fb18d9c45c73e615413972451addd9e9e7fa70b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page