Skip to content

sergius-la/adb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADB Commands

Python package for executing adb commands.

List of adb commands

TODO: Add tests status

Install

Requirements:
Android SDK Tools - https://developer.android.com/studio/releases/sdk-tools
adb - PATH variable

Install with PIP
pip install git+https://github.com/sergius-la/adb.git


Cookbook


Commands

  • TODO: Add Dependencies into setup.py

  • TODO: Runner

  • ADB

    from py_adb.adb import ADB
    
    authorised_devices = ADB.get_connected_devices()
    all_connected_devices = ADB.get_connected_devices(False)
  • Device info

    from py_adb.device_info import DeviceInfo
    from py_adb.android_properties import Properties
    
    # Get current activity and package {activity, package}
    current_activity = DeviceInfo.get_current_activity("<Device ID>")
    
    # Device memory usage
    meminfo = DeviceInfo.get_meminfo("<Device ID>") 
    # Package memory information
    package_meminfo = DeviceInfo.get_meminfo("<Device ID>", "pid / package.name")
    # Save device memory usage
    DeviceInfo.save_meminfo("path_to_sane", "<Device ID>") 
    # Save package memory usage
    DeviceInfo.save_meminfo("path_to_sane", "<Device ID>", "pid / package.name") 
    
    # All Android Properties in dict
    all_properties = DeviceInfo.all_getprop("<Device ID>") 
    # Get specific Android Property
    specific_property = DeviceInfo.get_prop("<Device ID>", Properties.MODEL, Properties.ANDROID_VERSION)
    
    # Get package ID
    pid = DeviceInfo.get_pid("<Device ID>", "package.name") 
    
    # Get device display size {width, height} 
    display_size = DeviceInfo.get_display_size("<Device ID>")
  • Device manipulations:

    • set_screen_brightness(0 to 255)
    • screenshot(path_save_device)
    • save_screenshot(path_device, path_save, delete=False)
      • TODO: Name generator
      • TODO: Add Flag to delete file after save
    • open_notification_center(Device_ID)
      • TODO: Screen Caption
    • tap(x, y)
    • stipe(x1, y1, x2, y2)
    • send_text(text)
    • lock_device(Device ID)
    • unlock_device
      • UnlockType:
        • SWIPE
    • All Keyevent
      • BACK
      • POWER_BUTTON
      • TODO: Recent Apps
  • Files:

    • pull(path_from, path_to)
    • push(path_file, path_to)
    • delete(path_file)
    • clear_dir(path_dir)
  • Package info:

    from py_adb.package_info import PackageInfo
    
    PackageInfo.get_list_packages("<Device ID>") # List of installed apps
    PackageInfo.is_package_exist("<Device ID>", "package.name") # Check is package installed
    PackageInfo.get_package_version("<Device ID>", "package.name") # Get version of package
  • Package manipulations:

    • clear_package_cache(package)
    • install_app(path_package)
      • TODO: App ENUM Flags -d, -r
      • TODO: Test
      • TODO: Check path
    • start_package(package_name)
    • close_package(package_name)
      • TODO: Test
    • grant_permission(package_name, permissions)
    • revoke_permission(package_name, permissions)
  • Packages

  • Layout - UI Interacting

    • TODO: Search multiple elements
    • Element
    from py_adb.layout import Layout
    from py_adb.by import By
      
    element = Layout.get_element(By.ID, "<resource-id>")
    element.tap("<Device ID>")
    from py_adb.by import By
    
    # Search Element strategy  
    By.ID # Element id
    By.XPATH # xPath TODO: Implement

Unit Tests

Requirements:
Connect Android Device in the Developer Mode

  • Run Unit test (package root) - pytest --cov=py_adb tests/
  • To get report - coverage html

About

PyPackage - ADB commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages