Skip to main content

ADB Python wrapper library with enhanced functionality

Project description

My ADB Lib

Thư viện Python wrapper cho Android Debug Bridge (ADB) không yêu cầu phụ thuộc bên ngoài.

Giới thiệu

My ADB Lib là một thư viện Python giúp tương tác với thiết bị Android thông qua ADB (Android Debug Bridge). Thư viện này được thiết kế để đơn giản hóa việc sử dụng các lệnh ADB trong các ứng dụng Python, tự động hóa kiểm thử, và quản lý thiết bị Android.

Yêu cầu

  • Python 3.6 trở lên
  • ADB đã được cài đặt và có trong PATH

Cài đặt

pip install oiadb

Hoặc cài đặt từ mã nguồn:

git clone https://github.com/tiendung102k3/oiadb
cd oiadb
pip install -e .

Cách sử dụng

Khởi tạo

from oiadb import MyADB

# Khởi tạo với thiết bị mặc định
adb = MyADB()

# Hoặc chỉ định thiết bị cụ thể
adb = MyADB(device_id="emulator-5554")

Các thao tác cơ bản

# Liệt kê các thiết bị đã kết nối
devices = adb.get_devices()
print(devices)

# Cài đặt ứng dụng
adb.install_app("/path/to/app.apk")

# Gỡ cài đặt ứng dụng
adb.uninstall_app("com.example.app")

# Khởi động lại thiết bị
adb.reboot_device()

Tương tác với thiết bị

from oiadb.commands import interaction

# Nhấn vào tọa độ màn hình
interaction.tap(500, 500)

# Vuốt màn hình
interaction.swipe(100, 500, 600, 500)

# Nhập văn bản
interaction.text_input("Hello World")

# Nhấn phím Home
interaction.home()

Quản lý file

from oiadb.commands import file_ops

# Đẩy file từ máy tính lên thiết bị
file_ops.push("/path/on/computer", "/path/on/device")

# Lấy file từ thiết bị về máy tính
file_ops.pull("/path/on/device", "/path/on/computer")

Xem log

from oiadb.commands import logs

# Xem logcat
logcat_output = logs.logcat()
print(logcat_output)

# Tạo báo cáo lỗi
bugreport = logs.bugreport()

Tài liệu API

Lớp MyADB

Lớp chính để tương tác với ADB.

  • __init__(device_id=None): Khởi tạo đối tượng ADB với ID thiết bị tùy chọn
  • run(command): Chạy lệnh ADB tùy chỉnh
  • get_devices(): Liệt kê các thiết bị đã kết nối
  • reboot_device(): Khởi động lại thiết bị
  • install_app(apk_path): Cài đặt ứng dụng từ file APK
  • uninstall_app(package_name): Gỡ cài đặt ứng dụng
  • push_file(local_path, remote_path): Đẩy file lên thiết bị
  • pull_file(remote_path, local_path): Lấy file từ thiết bị
  • get_device_info(): Lấy thông tin thiết bị

Module commands

Các module lệnh chuyên biệt:

  • app_info: Lấy thông tin ứng dụng
  • apps: Quản lý ứng dụng
  • basic: Các lệnh ADB cơ bản
  • connect: Kết nối thiết bị qua mạng
  • device_actions: Các hành động thiết bị
  • device_info: Thông tin thiết bị
  • file_ops: Thao tác file
  • interaction: Tương tác với thiết bị
  • logs: Xem log thiết bị
  • permissions: Quản lý quyền

Đóng góp

Đóng góp luôn được chào đón! Vui lòng tạo issue hoặc pull request trên GitHub.

Giấy phép

MIT License

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

oiadb-0.2.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oiadb-0.2.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file oiadb-0.2.1.tar.gz.

File metadata

  • Download URL: oiadb-0.2.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for oiadb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 48e49441192841ed5ed1290294d47e88367e30611c44e675ed449ef2c52f7911
MD5 4bcfba833231147056b325e8bf62f2d7
BLAKE2b-256 bdc256c916744ab7505cf924b3b5f4bb88ba3659886d1c7a1f3986150ea4b9cf

See more details on using hashes here.

File details

Details for the file oiadb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: oiadb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for oiadb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a9add24b3cba8b805d21a95b433fe8cab59e63a883fb83a2442f34ed61772836
MD5 17432ed70bcf7604c3f5c32b49feb77c
BLAKE2b-256 1024710c28efcbfd7006cca2a095a5107390ce606f7f35374feab456bb461423

See more details on using hashes here.

Supported by

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