Code Monkey home page Code Monkey logo

simpleadb's Introduction

SimpleADB

This is a module to execute simple commands with ADB

Build Status

Basic Usage

var SimpleADB = require('simple-adb').SimpleADB;

var sadb = new SimpleADB();

sadb.connect('192.168.1.5')
    .then(function () {
       console.log('connected');
    })
    .catch(function (err) {
       console.log(err);
    });

Here is an example on how to reboot your android device via ADB

var SimpleADB = require('simple-adb').SimpleADB;

var sadb = new SimpleADB();

sadb.connect('192.168.1.5')
     .then(function () {
        sadb.reboot()
            .then(function () {
                console.log('rebooted');
            });
     })
     .catch(function (err) {
        console.log(err);
     });

The SimpleADB Class

var SimpleADB = require('simple-adb').SimpleADB;

var sadb = new SimpleADB({
        logger: null, // optional - if populated, should be a Bunyan instance.
        logLevel: 'error' | 'warn' | 'info', //optional, ignored if `logger` is populated
        path: '/path/to/adb' //optional, if you have a custom path, this may be required
    });

SimpleADB Methods

N.B. All methods return a Promise.

var SimpleADB = require('simple-adb').SimpleADB;

var sadb = new SimpleADB();

// to connect to a device (only one device can be connected to at a time)
sadb.connect(ipAddress);

// to disconnect device
sadb.disconnect();

// to reboot device
sadb.reboot();

// to shutdown device
sadb.shutdown();

// to force stop an application
sadb.forceStopApp(packageName);

// to start an application
sadb.startApp(packageName, launchName);

// to restart an application
sadb.restartApp(packageName. launchName);

// to perform any other task with adb
sadb.execAdbCommand(args); //args in an array of augements

// to perform any other shell task with adb
sadb.execAdbShellCommand(args); //args in an array of augements

// copy a file to the android device
sadb.push(fromPath, toPath);

// copy a file from the android device
sadb.pull(toPath, fromPath);

sadb.captureScreenshot(pathToSaveScreenshot); // path is optional, will store to home directory if no path given

Tests

Coming soon

Contribute

Please only edit the contents of the src directory as on publish this will be compiled into the build directory.

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.