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 my-adb-lib

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

git clone https://github.com/yourusername/my-adb-lib.git
cd my-adb-lib
pip install -e .

Cách sử dụng

Khởi tạo

from my_adb_lib 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 my_adb_lib.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 my_adb_lib.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 my_adb_lib.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.0.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.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oiadb-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 84dbc4d10270a07aafbfd58683f9601294b8e26920ed514c96de470a0cae59a2
MD5 37fd522d5270cc9e97afde2c23be6dd1
BLAKE2b-256 7cb959061f52692f2502531a522ad2f1929109b8032667d0dc1f146f5cd5bb9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oiadb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a383257ad23882d01ac92e658b1e3b96737e347cb655e1a317680a6d145110c0
MD5 415f7a84e18c6eb15d45c1f61efc05ee
BLAKE2b-256 eca16f392696b88edb8d87934b29da71c393a7db06ce3046ffa8b65e2f6a9675

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