noccylabs/androidtk2

$ git tag


$ git branch
* master

AndroidToolkit

Installing

The easiest way to install ATK is globally using composer:

$ composer global require noccylabs/android:@dev noccylabs/androidtk2:@dev

If you haven't already, make sure composers global bin dir is on the path. If it is not, add it to your ~/.bashrc:

export PATH="~/.composer/vendor/bin:$PATH"

Once you have re-opened the shell if needed (or just used source ~/.bashrc) you can use the atk and ajs commands.

Manual install

You can also clone the git repository manually and create symlinks as needed.

Automatic install

Once you have cloned the repository, you can use the makefile in the phar directory to build and install a standalone version. Plugins are expected to be in /usr/share/androidtk/plugins.

$ cd phar 
$ sudo make install

Usage

All namespaces and commands can be shortened to their shortest unique length. For example, screen:record can be written as s:r or s:rec etc.

Device status

Use the status command to get some geeky status information about the device:

$ atk device:status 

Properties

Use the device:props command to review the build properties.

$ atk device:props

For scripting purposes, you can also export props as json:

$ atk device:props --json > props.json

Backups

You can perform backup of most (if not all) devices including unrooted stock devices as long as they are running Android 4.0 or later.

$ atk backup:create

The process is interactive if not enough arguments are provided on the command line:

$ atk2 backup:create
Do you want to backup all applications? [Y/n]: n
To search the package list, prefix your query with '?'
Select package []: ?tapet
com.sharpregion.tapet
Select package []: *.tapet
Selecting com.sharpregion.tapet
Select package []: 
Include .apks [Y/n]: 
Include apk expansion files (.obb files) [Y/n]: 
Include shared storage/sdcard contents [y/N]: 
Include system applications [y/N]: 
Backup filename [161020_1712_custom_apk_obb.ab]: 161020_1712_app_tapet.ab
Start backing up? [Y/n]: 
You need to confirm the backup on your device before it can begin.
No progress information will be displayed during the operation.
Depending on your options this could take a while, so go make a pizza or something.

Please note that this will not back up contacts, messages, calendar events or
accounts etc. Only applications and their data is included in the backup.

Backup completed.
$ ll *tapet.ab
-rw-r----- 1 noccy noccy 21338843 okt 20 17:12 161020_1712_app_tapet.ab

Scripting

Note: If you can't see the script command, that means the plugin failed to locate V8Js on your system. Install V8Js using PECL or suitable method. See below!

The bundled plugin atk.core.scripting bridges JavaScript with ATK.

// Get the device list
var devices = android.getDeviceList();

// Iterate over the devices
devices.each(function (device) {
    io.printf("%s: %s\n", device.getSerial(), device.getModel());
});

Save as devices.ajs and execute with:

$ atk script devices.ajs

Or:

$ ajs devices.ajs

Install V8JS on Ubuntu with PHP 7

First, you need to upgrade libv8:

$ sudo apt-add-repository ppa:pinepain/libv8-5.2

Next, install the extension via pecl:

$ sudo pecl install v8js

And once it completes, enable it:

$ echo "extension=v8js.so" | sudo tee /etc/php/7.0/mods-available/v8js.ini
$ sudo phpenmod v8js

Screenshots and capture

You can save up to 3 minutes of captured video using the record command, provided by the bundled plugin adb.screenrecord:

$ atk screen:record -d 180 -o video.mp4

You can also take screenshots in png format:

$ atk screen:capture -o image.png

Plugins

When running standalone, plugins should be in ../plugins with respect to the bin folder. For installed .phar version, /usr/share/androidtk/plugins is used instead.

Bundled plugins