用于android测试和开发的瑞士军刀

adb-enhanced的Python项目详细描述


亚行增强版DownloadsPyPI versionBuild StatusCircleCI

Logo

ADB Enhanced是一款用于Android测试和开发的瑞士军刀。一个命令行界面,用于触发各种场景,如屏幕旋转、电池节省模式、数据节省模式、打瞌睡模式、权限授予/撤销。

发布公告

Release announcement

安装

sudo pip3 install adb-enhanced

  1. sudo pip install adb-enhanced对于基于python2的安装也可以,但是,我建议转到python3,因为我将在2018年12月31日之后的任何时候都不支持python2。
  2. 如果您没有sudo访问权限或安装时没有sudo,则可能无法在路径中正确配置adbe
  3. 要设置bash/z-sh自动完成,请在安装adb enhanced之后执行sudo pip3 install infi.docopt-completion && docopt-completion $(which adbe)

示例

设备配置

  • 打开“打瞌睡”模式

    adbe doze on

  • 关闭移动数据

    adbe mobile-data off

  • 打开节电模式

    adbe battery saver on

  • 不要在后台保留活动

    adbe dont-keep-activities on

  • 截图 adbe screenshot ~/Downloads/screenshot1.png

  • 拍一段视频 adbe screenrecord video.mp4 # Press ^C when finished

权限

  • 授予与存储相关的运行时权限

    adbe permissions grant com.example storage

  • 撤消与存储相关的运行时权限

    adbe permissions revoke com.example storage

与应用程序交互

  • 启动应用程序

    adbe start com.example

  • 关闭应用程序

    adbe force-stop com.example

  • 清除应用程序数据-相当于卸载和重新安装

    adbe clear-data com.example

  • ls/cat/rm任何文件,无需担心添加“run-as”或“su-root”

    adbe ls /data/data/com.example/databases只要com.example是可调试的包或shell具有根权限或目录已被公开访问,就可以工作{/p>

设备信息

  • 详细的设备信息,包括型号名称、Android API版本等、设备序列号

    $ adbe devices
    Unlock Device "dcc54112" and give USB debugging access to this PC/Laptop by unlocking and reconnecting the device. More info about this device: "unauthorized usb:339869696X transport_id:17"
    
    Serial ID: dcc54111
    Manufacturer: OnePlus
    Model: ONEPLUS A5000 (OnePlus 5T)
    Release: 8.1.0
    SDK version: 27
    CPU: arm64-v8a
    
    Serial ID: emulator-5554
    Manufacturer: unknown
    Model: Android SDK built for x86
    Release: 4.4.2
    SDK version: 19
    CPU: x86
    

应用程序信息

  • 有关应用程序版本、目标sdk版本、权限(请求、授予、拒绝)、安装程序包名称等的详细信息。

    $ adbe app info com.google.android.youtube
    App name: com.google.android.youtube
    Version: 12.17.41
    Version Code: 121741370
    Is debuggable: False
    Min SDK version: 21
    Target SDK version: 26
    
    Permissions:
    
    Install time granted permissions:
    com.google.android.c2dm.permission.RECEIVE
    android.permission.USE_CREDENTIALS
    com.google.android.providers.gsf.permission.READ_GSERVICES
    com.google.android.youtube.permission.C2D_MESSAGE
    android.permission.MANAGE_ACCOUNTS
    android.permission.SYSTEM_ALERT_WINDOW
    android.permission.NFC
    android.permission.CHANGE_NETWORK_STATE
    android.permission.RECEIVE_BOOT_COMPLETED
    com.google.android.gms.permission.AD_ID_NOTIFICATION
    android.permission.INTERNET
    android.permission.GET_PACKAGE_SIZE
    android.permission.ACCESS_NETWORK_STATE
    android.permission.VIBRATE
    android.permission.ACCESS_WIFI_STATE
    android.permission.WAKE_LOCK
    
    Runtime Permissions not granted and not yet requested:
    android.permission.WRITE_EXTERNAL_STORAGE
    android.permission.MANAGE_DOCUMENTS
    android.permission.GET_ACCOUNTS
    android.permission.CAMERA
    android.permission.RECORD_AUDIO
    android.permission.READ_CONTACTS
    android.permission.ACCESS_FINE_LOCATION
    android.permission.ACCESS_COARSE_LOCATION
    android.permission.READ_PHONE_STATE
    android.permission.SEND_SMS
    android.permission.RECEIVE_SMS
    com.sec.android.provider.badge.permission.READ
    com.sec.android.provider.badge.permission.WRITE
    com.htc.launcher.permission.READ_SETTINGS
    com.htc.launcher.permission.UPDATE_SHORTCUT
    com.sonyericsson.home.permission.BROADCAST_BADGE
    com.sonymobile.home.permission.PROVIDER_INSERT_BADGE
    android.permission.READ_EXTERNAL_STORAGE
    
    Installer package name: None
    
  • 应用程序备份到tar文件,与android特有的.ab格式不同

    $ adbe app backup com.google.android.youtube backup.tar
    

使用量

adbe [options] rotate (landscape | portrait | left | right)
adbe [options] gfx (on | off | lines)
adbe [options] overdraw (on | off | deut)
adbe [options] layout (on | off)
adbe [options] airplane (on | off)
adbe [options] battery level <percentage>
adbe [options] battery saver (on | off)
adbe [options] battery reset
adbe [options] doze (on | off)
adbe [options] jank <app_name>
adbe [options] devices
adbe [options] top-activity
adbe [options] dump-ui <xml_file>
adbe [options] mobile-data (on | off)
adbe [options] mobile-data saver (on | off)
adbe [options] rtl (on | off)
adbe [options] screenshot <filename.png>
adbe [options] screenrecord <filename.mp4>
adbe [options] dont-keep-activities (on | off)
adbe [options] animations (on | off)
adbe [options] show-taps (on | off)
adbe [options] stay-awake-while-charging (on | off)
adbe [options] input-text <text>
adbe [options] press back
adbe [options] open-url <url>
adbe [options] permission-groups list all
adbe [options] permissions list (all | dangerous)
adbe [options] permissions (grant | revoke) <app_name> (calendar | camera | contacts | location | microphone | phone | sensors | sms | storage)
adbe [options] apps list (all | system | third-party | debug | backup-enabled)
adbe [options] standby-bucket get <app_name>
adbe [options] standby-bucket set <app_name> (active | working_set | frequent | rare)
adbe [options] restrict-background (true | false) <app_name>
adbe [options] ls [-a] [-l] [-R|-r] <file_path>
adbe [options] rm [-f] [-R|-r] <file_path>
adbe [options] mv [-f] <src_path> <dest_path>
adbe [options] pull [-a] <file_path_on_android>
adbe [options] pull [-a] <file_path_on_android> <file_path_on_machine>
adbe [options] push <file_path_on_machine> <file_path_on_android>
adbe [options] cat <file_path>
adbe [options] start <app_name>
adbe [options] stop <app_name>
adbe [options] restart <app_name>
adbe [options] force-stop <app_name>
adbe [options] clear-data <app_name>
adbe [options] app info <app_name>
adbe [options] app path <app_name>
adbe [options] app signature <app_name>
adbe [options] app backup <app_name> [<backup_tar_file_path>]
adbe [options] install <file_path>
adbe [options] uninstall <app_name>

选项

-e, --emulator          directs the command to the only running emulator
-d, --device            directs the command to the only connected "USB" device
-s, --serial SERIAL     directs the command to the device or emulator with the given serial number or qualifier.
                        Overrides ANDROID_SERIAL environment variable.
-l                      For long list format, only valid for "ls" command
-R                      For recursive directory listing, only valid for "ls" and "rm" command
-r                      For delete file, only valid for "ls" and "rm" command
-f                      For forced deletion of a file, only valid for "rm" command
-v, --verbose           Verbose mode
--no-python2-warn       Don't warn about Python 2 deprecation

python3迁移时间线

  • 2017年11月27日-代码与python3兼容
  • 2018年1月18日-pip(python包管理器)更新了与python3兼容的版本
  • 2018年11月15日-不鼓励基于python2的安装。建议使用Python3。
  • 2018年12月31日—2018年12月31日之后,python2将不再获得官方支持。

测试

python -m pytest -v tests/adbe_tests.py  # Python2 tests
python3 -m pytest -v tests/adbe_tests.py  # Python3 tests

发布新版本

可以使用^{}脚本发布新的生成。测试版本可以使用release.py test release进行,生产版本可以使用release.py production release

更新文档以读取文档

pandoc --from=markdown --to=rst --output=docs/README.rst README.md && cd docs && make html 如果您丢失了pandoc,就必须执行brew install pandoc

注:本项目灵感来源于android-scripts

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用servlet的正确方法是什么?   java Android ListView选中所有复选框(自定义ResourceCursorAdapter)   java如何在一个活动中正确处理多个片段交互侦听器?   java jUnit和忽略继承的测试   具有多个权限的java ActivityResultLauncher   Java:我可以通过应用程序将客户端重定向到loadbalancer后面的同一个会话/节点吗?   java如何使用Hibernate保存具有一对一关系的两个类?   java JEditorPane字体大小设置不准确   java为什么JUnit4导入不被识别,即使JUnit4在我的有效pom中。xml?   多次使用流后的java空映射   JavaSwing中AccessibleContext的用途是什么?   java指定使用T的类   java查找twitter4j转发速率限制   枚举的Java数组(类)   java通过Maven build排除了一些类