/adb-mobile

Android Debug Bridge (adb) ported version for mobile apps, the goal of this project is supporting both iOS App and Android App to connect to Android devices in developer mode (TCP/IP Mode) and execute supported ADB commands by integrating the libraries generated by this project.

Primary LanguageC++

adb-mobile

Android Debug Bridge (adb) ported version for mobile apps, the goal of this project is supporting both iOS App and Android App to connect to Android devices in developer mode (TCP/IP Mode) and execute supported ADB commands by integrating the libraries generated by this project.

Currently only iOS platform is supported, Android version is under development.

中文文档

Build Library

The project has already finished the build scripts to generate libadb in a few simple steps:

# 1. checkout all the submodules
git submodule update --init --recursive

# 2. build
make

The generated libadb product can be found in the output folder of the project directory, for iOS is "libadb.a" that you can located at output folder.

Integrate

iOS Project:

# Build Settings - Header Search Paths
HEADER_SEARCH_PATHS = $(SRCROOT)/../../output/include

# Build Settings - Library Search Paths
LIBRARY_SEARCH_PATHS = $(SRCROOT)/../../output

# Build Settings - Other Linker Flags
OTHER_LDFLAGS = -ladb -lc++ -lz

API Usage

iOS App:

#import "adb_puiblic.h"

// Enable trace debug message
adb_enable_trace();

// Setup the ADB listening port, the default is 5037
adb_set_server_port("15037");

// Setup the ADB private key and data directory, which is usually the Documents directory of the App
NSArray <NSString *> *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
const char *document_home = documentPaths.lastObject.UTF8String;
adb_set_home(document_home);

// Connecting Android devices
const char *argv[] = { "connect", "x.x.x." };
const char *output = null;
int ret = adb_commandline_porting(2, argv, &output);

// Execute the ADB commands
const char *argv[] = { "shell", "ip", "route" };
const char *output = null;
int ret = adb_commandline_porting(2, argv, &output);

ADB Status Callback:

// By define the adb_connect_status_updated callback method to get the adb connection status
void adb_connect_status_updated(const char *serial, const char *status) {
    NSLog(@"ADB Status: %s, %s", serial, status);
}

You can also see how to use this library in the example/adb-demo project.