GithubHelp home page GithubHelp logo

italankin / adbc Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 38 KB

Device selection facade for ADB

License: MIT License

C 97.79% Makefile 2.21%
adb android c utility adb-shell adb-android adb-commands

adbc's Introduction

adbc GitHub release (latest by date)

adbc is an ADB facade which shows a device selection dialog, if multiple Android devices are connected.

To find a path to adb executable adbc uses ANDROID_HOME or ANDROID_SDK_ROOT environment variables. If none of the above is defined, adbc will assume adb is available via PATH.

Usage

Running a command

$ adbc <adb command>

For example:

$ adbc shell dumpsys activity | grep mResumed

If there are multiple connected Android devices, the select dialog will be shown:

select a device:
  1: emulator-5554      device
  2: emulator-5556      device
  ... other devices ...
  q: quit

Running with no arguments

With no arguments adbc will print selected device id. It can be used by scripts to prompt user to select a device, and then execute commands on the selected device.

For example, if we need to execute multiple commands on one device:

$ SELECTED_DEVICE=`adbc`
$ adb -s $SELECTED_DEVICE shell input text login
$ adb -s $SELECTED_DEVICE shell input keyevent TAB
$ adb -s $SELECTED_DEVICE shell input text password
$ adb -s $SELECTED_DEVICE shell input keyevent ENTER

You can also use ANDROID_SERIAL variable:

$ export ANDROID_SERIAL=`adbc`
$ adb shell  # will be executed on the selected device

Print version

Run adbc with --adbc-version option:

$ adbc --adbc-version
adbc version: 1.0.1
Using adb path: /home/user/android-sdk/platform-tools/adb
Android Debug Bridge version 1.0.41
Version 29.0.5-5949299
Installed as /home/user/android-sdk/platform-tools/adb

Downloads

MacOS (unsigned) and Linux binaries are available. See releases.

Building

Requirements

  • gcc
  • ncurses

Building executable

An executable can be built with this command:

$ make adbc

The executable will be created at ./build/adbc.

adbc's People

Contributors

italankin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

adbc's Issues

Invalid escaping of spaces

Arguments with escaped spaces are treated incorrectly:

$ adbc install app\ \(1\).apk
Performing Streamed Install
adb: failed to stat (1).apk: No such file or directory

ADB commands not escaped

Command

$ adbc shell echo \\\)

fails with error:

/system/bin/sh: syntax error: unexpected ')'

Should successfully print )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.