Giter Club home page Giter Club logo

jadb's Introduction

JADB

ADB client implemented in pure Java.

The Android Debug Bridge (ADB) is a client-server architecture used to communicate with Android devices (install APKs, debug apps, etc).

The Android SDK Tools are available for the major platforms (Mac, Windows & Linux) and include the adb command line tool which implements the ADB protocol.

This projects aims at providing an up to date implementation of the ADB protocol.

Build Status jitpack badge codecov first timers friendly

Example

Usage cannot be simpler. Just create a JadbConnection and off you go.

JadbConnection jadb = new JadbConnection();
List<JadbDevice> devices = jadb.getDevices();

Make sure the adb server is running. You can start it by running adb once from the command line.

It's very easy to send and receive files from your android device, for example as below.

JadbDevice device = ...
device.pull(new RemoteFile("/path/to/file.txt"), new File("file.txt"));

Some high level operations such as installing and uninstalling packages are also available.

JadbDevice device = ...
new PackageManager(device).install(new File("/path/to/my.apk"));

Protocol Description

An overview of the protocol can be found here: Overview

A list of the available commands that a ADB Server may accept can be found here: Services

The description for the protocol for transferring files can be found here: SYNC.TXT.

Using JADB in your application

Since version v1.1 Jadb support maven as a build system. Although this project is not presented in official apache maven repositories this library can be used as dependencies in your maven/gradle project with the help of jitpack. Jitpack is a system which parses github public repositories and make artifacts from them. You only need to add jitpack as a repository to let maven/gradle to search for artifacts in it, like so

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

After that you will need to add actual dependency. Jitpack takes groupId, artifactId and version id from repository name, project name and tag ignoring actual values from pom.xml. So you need to write:

<dependency>
    <groupId>com.github.vidstige</groupId>
    <artifactId>jadb</artifactId>
    <version>v1.2.1</version>
</dependency>

Troubleshooting

If you cannot connect to your device check the following.

  • Your adb server is running by issuing adb start-server
  • You can see the device using adb adb devices

If you see the device in adb but not in jadb please file an issue on https://github.com/vidstige/jadb/.

Workaround for Unix Sockets Adb Server

Install socat and issue the following to forward port 5037 to the unix domain socket.

socat TCP-LISTEN:5037,reuseaddr,fork UNIX-CONNECT:/tmp/5037

Contributing

This project would not be where it is, if it where not for the helpful contributors supporting jadb with pull requests, issue reports, and great ideas. If you would like to contribute, please read through CONTRIBUTING.md.

  • If you fix a bug, try to first create a failing test. Reach out to me for assistance or guidance if needed.

Authors

Samuel Carlsson [email protected]

See contributors for a full list.

License

This project is released under the Apache License Version 2.0, see LICENSE.md for more information.

jadb's People

Contributors

anthonyflynn avatar bryant1410 avatar cfig avatar danielfriederich avatar dependabot[bot] avatar dllewellyn avatar fashioncj avatar giemsa avatar gwpantazes avatar janosvitok avatar jevalen4868 avatar js6pak avatar muhikhsan101 avatar nuumio avatar phantamanta44 avatar raiman avatar root-intruder avatar skart1 avatar smieras avatar tg44 avatar tmyroadctfig avatar vidstige avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jadb's Issues

java.io.EOFException: null in JadbDevice.pull and SyncTransport.readChunk() when reading file from a device

Hi,

We ran into an issue today while using JADB. The phone took over 40 minutes to respond while trying to read the pull to retrieve around a 15mb file. It looks to fail when trying to readChunk() in the SyncTransport.

    java.io.EOFException: null
  at java.io.DataInputStream.readFully(DataInputStream.java:197)
  at se.vidstige.jadb.SyncTransport.readChunk(SyncTransport.java:83)
  at se.vidstige.jadb.SyncTransport.readChunksTo(SyncTransport.java:101)
  at se.vidstige.jadb.JadbDevice.pull(JadbDevice.java:126)
  at se.vidstige.jadb.JadbDevice.pull(JadbDevice.java:131)
  at com.test.executors.VideoCaptureExecutor.copyFile(VideoCaptureExecutor.java:130)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
  at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
14:57:13.014 [device-Runner-18] ERROR c.m.m.a.e.VideoCaptureExecutor - Device samsung SAMSUNG-SM-G920A 351807070178804: Error trying to process videoExecutor
se.vidstige.jadb.JadbException: command failed: device '1215fc9b507f3504' not found
  at se.vidstige.jadb.Transport.verifyResponse(Transport.java:63)
  at se.vidstige.jadb.JadbDevice.getTransport(JadbDevice.java:32)
  at se.vidstige.jadb.JadbDevice.executeShell(JadbDevice.java:53)
  at se.vidstige.jadb.JadbDevice.executeShell(JadbDevice.java:49)
  at com.test.executors.VideoCaptureExecutor.copyFile(VideoCaptureExecutor.java:137)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
  at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)

We wanted to know if you have ran into any issues with this or if you would be able to take a look?

Thank you

Getting the state of a device

When getting the list of devices (with JadbConnection.getDevices()), ADB closes the connection (as per protocol), so the next call (to JadbDevice.getState()), fails with

se.vidstige.jadb.JadbException: command failed: closed

    at se.vidstige.jadb.Transport.verifyResponse(Transport.java:39)
    at se.vidstige.jadb.JadbDevice.getState(JadbDevice.java:46)

That is also true with a device acquired with JadbConnection.getAnyDevice().
There doesn't seem to be any other way getting hold of a device.

What gives? Are there circumstances in which JadbDevice.getState() works?

PS: Thanks for this library. Installing packages work, so it does help quite a lot.

Remove IDE specific files

In repo there is current a lot of files which may help sometimes to import project more easy in IDE, but sometimes they may cause errors in import. In my opinion pure pom.xml is enough - it allows to import project in any IDE without problems.

Also changing this files make git diffs have garbage

Quote arguments with e.g. tabs

When executing commands on the android device e.g. adb shell ls /strings without spaces are not quoted at all, just to give better error-messages, log printouts, etc.

This breaks down if a tab character is passed to the execute() function, e.g. like so device. execute("echo", "a\tb");

To fix this the Bash.quote function should be little bit more clever and also quote strings containing tabs or newlines, see more here.

Let me know if you have any questions.

implement AutoCloseable in Transport

I think implementation of Socket should implement interface AutoCloseable (introduced in Java 7) to make it possible to use try-with-resources idiom.

What do you think?

ConnectException when unauthorized.

When I try to connect to my device on a new computer, I am greeted with a connection error when just using the following code:

JadbConnection jadb = new JadbConnection();
        List<JadbDevice> devices = jadb.getDevices();
        if (devices.size() == 0) {
            System.out.println("No android device running ADB was found. Please connect an android device and enable ADB.");
        }

Java ADB java.net.ConnectException: Connection refused: connect

I am not being prompted to allow access for this computer on my phone. When using adb separately first, and allowing access, jadb works. Is there a way jadb could ask for access first? This is on a Windows machine.

CONTRIBUTING.md is outdated

The CONTRIBUTING.md is bit outdated - you can't build with ant now, you should with maven, etc.

Also: build.xml should be updated (at least update java version to match maven) or deleted

Also: coding guidelines would be appreciated

  • what Java version compatibility do you go for? Can we use Java 7/8/9/10/... features? From maven config I guess 1.7...

Connection Refused on simple example

I have been experiencing the Connection Refused, with the simple two-line example of:
JadbConnection jadb = new JadbConnection();
List devices = jadb.getDevices();

  • This is on a Raspberry Pi3 in which if have installed the adb tools through apt-get and can access the android device through adb and get a shell
  • I built jadb through the maven POM and included it's jar output as an external jar to an Eclipse project.
  • I also get a connection refused with a "telnet localhost 5037" command
  • using Oracle Java 8

This suggests that I might have some form of permissions incorrect, by default, but I don't know what that might be.

Any suggestions?

Thanks in advance - Tom

ECONNREFUSED on Android

I am trying to use an ADB library on an Android app. I tried another lib and it worked, but is not maintained anymore. That's why I want to use this one. I am always getting ECONNREFUSED on Android. I have granted all necessary permissions, but i can't connect to the phone. Neither from a real device nor from the emulator, but it works from the PC. Of course I have wireless USB-Debugging on port 5555. This is my source code and this is the stacktrace (sry for quality). Othrewise I just have a simple activity wth a button and granted the INTERNET permission in the manifest.

SocketException after copying many photos

I'm trying to use JADB to automatically offload photos from my (various) Android devices. I've found it very easy to use and have got up and running in an hour or so.

But I'm encountering a socket exception about every 250 or so photos that I pull across; I'm guessing that something is incapable of coping with 800+MB of file transfer (probably failing to clear something from memory), but I'm not really sure. The pull method returns void, so it doesn't seem like I am failing to clean anything up myself, and I don't see any cleanup method in the RemoteFile structure.

I tried googling for anybody else with this problem but didn't see anything.

The exact exception I'm seeing is:

java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:189)
	at java.net.SocketInputStream.read(SocketInputStream.java:121)
	at java.io.DataInputStream.readFully(DataInputStream.java:195)
	at java.io.DataInputStream.readFully(DataInputStream.java:169)
	at se.vidstige.jadb.Transport.readString(Transport.java:46)
	at se.vidstige.jadb.Transport.verifyResponse(Transport.java:36)
	at se.vidstige.jadb.JadbDevice.getTransport(JadbDevice.java:52)
	at se.vidstige.jadb.JadbDevice.pull(JadbDevice.java:183)
	at se.vidstige.jadb.JadbDevice.pull(JadbDevice.java:192)
	at com.gmmapowell.mediabackup.Main.backupAdb(Main.java:115)
	at com.gmmapowell.mediabackup.Main.main(Main.java:62)

I'm using v1.1.0 from the jitstack maven repo.

DeviceDetectionListener onDetect fires double times

DeviceDetectionListener onDetect fires double times
capture
Connecting device.. onDetect fires with 'device offline'
capture111
And then immediately onDetect fires second time with 'device online'
capture112
Is it a bug or feature?

Host

windows 10 x64, java 8

$ adb version
Android Debug Bridge version
1.0.32 Revision eac51f2bb6a8-android

jadb version : commit 0cb9550
new JadbConnection().getHostVersion() -> 0020

Android

Samsung galaxy s4 (i9505)
CyanogenMod 14.1 (android version 7.1.1)

PS

Thanks for the library, it is very helpful โญ

Android 10, exception in PackageManager.forceInstall(...)

When I try to force install any application on an emulator with Android 10 using Jadb API call PackageManager.forceInstall, it throws the following exception:

se.vidstige.jadb.JadbException: Could not install <APP NAME>.apk: 
Exception occurred while executing:
java.lang.IllegalArgumentException: No argument expected after "-r "
	at android.os.ShellCommand.getNextOption(ShellCommand.java:266)
	at com.android.server.pm.PackageManagerShellCommand.makeInstallParams(PackageManagerShellCommand.java:2383)
	at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1057)
	at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
	at android.os.ShellCommand.exec(ShellCommand.java:104)
	at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21729)
	at android.os.Binder.shellCommand(Binder.java:881)
	at android.os.Binder.onTransact(Binder.java:765)
	at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
	at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4014)
	at android.os.Binder.execTransactInternal(Binder.java:1021)
	at android.os.Binder.execTransact(Binder.java:994)

	at se.vidstige.jadb.managers.PackageManager.verifyOperation(PackageManager.java:47)
	at se.vidstige.jadb.managers.PackageManager.install(PackageManager.java:65)
	at se.vidstige.jadb.managers.PackageManager.installWithOptions(PackageManager.java:78)
	at se.vidstige.jadb.managers.PackageManager.forceInstall(PackageManager.java:82)

I've assumed that PackageManager uses simple pm install -r call under the hood, and this command changed in format in Android 10, but, surprisingly, calling pm install -r <PKNAME> manually from adb shell still works, as well as calling adb install -r <PKNAME>

JadbConnection(ip,port)

Hello! I use your library and I can not understand ...
When you connect to the phone by "adb connect ip" - All OK.
But if you use jadb in java - nothing happens ...
log:
test
test2
Android Device with serial null
test3;

I tried both with the included adb server and without it...
What do I do not so?
P.s.Forgive for awful English

`
th = new Thread(new Runnable() {

		@Override
		public void run() {
			System.out.println("test");
			try {
				jadb = new JadbConnection(textip.getText(), 5555);
				System.out.println("test2");
				System.out.println(jadb.getAnyDevice());
				System.out.println("test3");
				BufferedReader br = new BufferedReader(new InputStreamReader(jadb.getDevices().get(0).executeShell("uname -a"), "UTF-8"));
				System.out.println(br.lines().collect(Collectors.joining(System.lineSeparator())));
			//	List<JadbDevice> devices = jadb.getDevices(); //not work too
				System.out.println("test33");
				System.out.println(jadb.getDevices().get(0).getSerial());
				System.out.println("test4");
				//System.out.println(devices.get(0).getState());
			} catch (IOException | JadbException e) {
				e.printStackTrace();
			}
			System.out.println("test1");
		}
	});	
		th.start();`

Host:
Windows 10.
java version "1.8.0_161"
IDE - eclipse

Phone:
Blackview A7; android 7.0(root); I used the different WiFi adb programs

conflict access modifier

createTransport() is public, but return class Transport is package access.

public Transport createTransport() throws IOException {
        return new Transport(new Socket(host, port));
    }

How do I even connect to a device?

Because there is no documentation I honestly can't figure out how to connect to my device.

I did:

JadbConnection jadb = new JadbConnection();
 List<JadbDevice> devices = jadb.getDevices();

and it picks up my phone in the console but I cannot for the life of me figure out how to connect to it.

JadbDevice dev = jadb.getAnyDevice(); does not work.

and if I try a simple command:

dev.executeShell("input keyevent keyboard \"G\""); there is no effect either.

Running ADB commands inside Android App

I have requirement like i need to take a UI dump of each activity that appears on my android app to verify resource-id given is unique. I was thinking to use this adb command "adb pull uiautomator dump" and verify the same. So i created a java class in my android app, that uses jadb and it works fine when i run as java application.

But when i run my android app, i am calling the same class with the following details,

        jadb=new JadbConnection("my_ip",5037);
        List<JadbDevice> devices = jadb.getDevices();
        for(JadbDevice device:devices){
            device.executeShell("shell:uiautomator dump");
        }

and the below is my error:

01-23 14:23:41.138 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: java.net.ConnectException: failed to connect to /<my_ip> (port 5037): connect failed: ECONNREFUSED (Connection refused)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:124)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.Socket.startupSocket(Socket.java:590)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.Socket.tryAllAddresses(Socket.java:128)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.Socket.(Socket.java:178)
01-23 14:23:41.178 23845-23845/com.example.gokulpalanisamy.firstapp W/System.err: at java.net.Socket.(Soc

Note:
I am using real device and not emulator.

My question is will i be able to run adb command from/inside an android app like i m trying to do here. ?

I can't get my devices

Can you tell me how can i recognize my device with adb enabled?
i have tried getAnyDevice method but nothing to do.. help me please!!

Problem with connection to VirtualBox by Genymotions

Hi. I have last Genymotion installation:
Genymotion: 2.12.2
Genymotion emulator: Custom Phone - 6.0.0 - API 23 - 768x1280
VBox: 5.2

Adb running inside the emulator on localhost:5555. SimpleAdbClient works fine. But Jadb with the same input and environment hangs up. Tryed other local and external IPs without any effect.

I also using Jadb in vanila emulators on port 5037 without any problem.

Thx.

Getting permission error when pulling from device

//String path = "/data/user/0/com.package/files/";
    String path = "/data/user/0/com.package/files/";
String file = "TEST2.txt";

JadbConnection jadb = new JadbConnection();
JadbDevice device = jadb.getDevices().get(0);

device.executeShell("run-as", "com.package");
try {
	device.pull(new RemoteFile(path), new File(file));
} catch (Exception e) {
                //Keep getting a Permission denied exception
	System.err.println("Error while pulling: " + e.getMessage());
}

I keep getting Permission denied error when trying to pull a file from the device.
Do you have any ideas on why this is happening and how to solve it?

Thank you

DeviceDetectionListener useless

My steps:

  1. Run java program with listener
  2. adb connect ip:port
  3. We get nothing

If i create new thread with while loop and delay printing connection.getDevices().size() - it updated and print me newer devices list. But to listener it doesn't go.

How to block until "am dumpheap" via executeShell until the dump actually finishes?

I use the following groovy code to do a heapdump and pull dump file from device:

    File getHeapDump(String packageName, String tag) {
        String fileName = packageName + '-'+ tag + '.hprof'
        String dumpFilePath = '/data/local/tmp/' + fileName
        String localFilePath = System.getProperty('java.io.tmpdir') + File.separator + fileName

        // Delete any old dumpfile matching name
        jadbDevice.executeShell('rm', '-f', dumpFilePath)
        jadbDevice.dump()

        // get pid for process matching package name
        int pid = getPidForProcess(packageName)

        jadbDevice.executeShell('am', 'dumpheap', pid.toString(), dumpFilePath)

        String str = jadbDevice.executeShell('am', 'dumpheap', pid.toString(), dumpFilePath)
                .withCloseable { inputStream ->
            String str = IOUtils.toString(inputStream, StandardCharsets.UTF_8).trim()
            if (!str.isEmpty()) {
                throw new ClientException(String.format("Error getting heap dump: %s", str))
            }
            return str
        }

        // Pull heap dump file from device
        RemoteFile remoteFile = new RemoteFile(dumpFilePath)
        File localFile = new File(localFilePath)

        jadbDevice.pull(remoteFile, localFile)

        return localFile
    }

The file exists as non-zero bytes file in remote.
The localFile is created with zero bytes.

However, if I run my test in a debugger and hit a breakpoint at the return statement at the end then localFile is created with non-zero (correct) bytes.

After some testing it turns out that the executeShell does not wait for "am dumpheap" to actually finish. The pull happens too early and that is why the zero bytes.

Adding a sleep before the pull command fixes the problem.

Is there a way for executeShell to block until the dump is finished?

sending unicode characters

one of those days where "not even thinking about it, assumed it'd be a no-op" turned into "where'd the day go ๐Ÿ˜ฎ" ๐Ÿ˜…
curious how you'd go about sending unicode characters/emoji to the execute command?
thought it'd be as simple as jadbDevice.execute("input", "text", "๐Ÿ˜€")
then came across this stackoverflow and this repo
that seemed to work on the shell (with the exception of mixing in some special characters () ') but i ended up stumped on how to get it working from the jvm ๐Ÿ˜ญ
any ideas?

val shades: String = """(โ€ข_โ€ข)
( โ€ข_โ€ข)>โŒโ– -โ– 
(โŒโ– _โ– )
"""
val processArgs = Seq("adb", "shell", "am", "broadcast", "-a", "ADB_INPUT_TEXT", "--es", "msg", "'" ++ shades ++ "'")
val executeArgs = processArgs.drop(3) // just from `broadcast` through `shades`
val process = new ProcessBuilder(processArgs:_*)
process.start // works
jadbDevice.execute("am", executeArgs:_*) // /system/bin/sh: no closing quote

that was the gnarliest example (newlines, spaces, parens AND unicode chars) but just regular solo emoji also work from the process builder but fail from the execute method

Support for connect and disconnect commands

Support for commands like this:

$ANDROID_HOME/platform-tools/adb connect 127.0.0.1:10002
connected to 127.0.0.1:10001
$ANDROID_HOME/platform-tools/adb disconnect 127.0.0.1:10002
disconnected 127.0.0.1:10001

They allow to communicate with devices on non standard ports and even on other hosts

Adb querying functions

I've been working with jadb for a little while and I was wondering if you'd be interested in some of the features I've added. Mostly it's just wrappers around executeShell in order to get some information about the device;

  • Retrieve battery information
  • Retrieve device temperature
  • Retrieve architecture, android version, brand and manufacturer (etc)
  • Enable adb over WiFi
  • Connect to a device over Wifi (adb connect :

Are any of these things of interest to the project?

Maven Central

Any plan to add the dependency to Maven Central? Needing to add jitpack isn't necessarily an option for everyone (including myself). Furthermore, depending on a separate service as opposed to the defacto host (Maven Central) is a bit of a concern for longevity in case jitpack goes away.

Java 8 source and target

Java 1.8 has better performance and also have some cool stuff like lambdas. And according to latest reports java 1.8 already used in 62% of projects

PackageManager problems

Issue 1: all options get space appended

Issue 2: option parameter is joined with the value:

stringBuilder.append(str).append(" ");

WITH_FORWARD_LOCK.getStringRepresentation() -> "-l "
WITH_INSTALLER_PACKAGE_NAME("aaa bbb").getStringRepresentation() -> "-t aaa bbb"

that JadbDevice.buildCmdLine turns to

'-l '
'-t aaa bbb'

while most probably it should be

-l
-t 'aaa bbb'

Issue 3: Bash.quote() in PackageManager.remove() probably causes double quoting.

Issue 4: Bash.quote itself propably does not quote well

Bash.quote("-t 'aaa'") ->"'-t '\'aaa\'''"
Edit: I've learned that the code is correct.
I've create PR #90 with a test for this.

Possible fixes

Easy fix Issue 1 is to add

            stringBuilder.deleteCharAt(stringBuilder.length() -1);

at the end of InstallOption constructor.

Fix for Issue 2 (will fix Issue 1) is to store String[] and just pass unprocessed them from installWithOptions() through install() to executeShell() that will add spaces and quotes anyway.

Make maven part of travis build

To make sure the Maven build keeps green, it would be great to have the maven build run as part of the travis build. This would catch problems such as the one caused by pull request #22

Incorrect references to contained artifacts on JitPack?

I'm attempting to use jadb as a JitPack enabled dependency on a Maven project.
I have this on the POM file:

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.vidstige</groupId>
            <artifactId>jadb</artifactId>
            <version>v1.1</version>
        </dependency>
    </dependencies>

The message I get when trying to compile looks like this:

Could not resolve dependencies for project com.example:example:jar:0.0.1-SNAPSHOT: Failure to find com.github.vidstige:jadb:jar:v1.1 in https://jitpack.io was cached in the local repository, resolution will not be reattempted until the update interval of jitpack.io has elapsed or updates are forced

When I look at JitPack in order to get the available version, I don't see the version v1.1.

Also I tried with the version V1.0 but I get the same error:

Could not resolve dependencies for project com.example:example:jar:0.0.1-SNAPSHOT: Failure to find com.github.vidstige:jadb:jar:v1.0 in https://jitpack.io was cached in the local repository, resolution will not be reattempted until the update interval of jitpack.io has elapsed or updates are forced

Am I missing something?

Regards.
Henry

Double quoting

Bash.quote() in PackageManager.remove() probably causes double quoting.

Separate unit tests from integration test 2.0

#26 was not the best decision separating unit and integration test by hardcoded package name.

This breaks Java feature of package visibility - which allows tests to use package visible methods and fields of application classes in test classes which have same package name

Various methods can be made less accessible to increase encapsulation

I have noticed that the following methods are declared public:

  • AdbProtocalHandler.send()
  • DeviceWatcher.watch()
  • SyncTransport.readInt() and readString()
  • Transport.readString() on line 43 and getCommandLength()

Unless these methods are called by name via reflection, these members should be private to improve information hiding.

If this change is indeed regarded as desirable, I could make a PR for it.

Connect to tcp host "Connection refused"

Hi,
I am trying to useJadb to connect to a remote android board. I have enabled the tcpip mode and I can connect to it from my laptop using

adb connect :5555
connected to :5555

However, when I try to do the same using Jadb I get the following messages :

01-21 02:03:26.874 2056 2089 W System.err: java.net.ConnectException: Connection refused 01-21 02:03:26.875 2056 2089 W System.err: at java.net.PlainSocketImpl.socketConnect(Native Method) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.Socket.connect(Socket.java:605) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.Socket.connect(Socket.java:554) 01-21 02:03:26.876 2056 2089 W System.err: at java.net.Socket.<init>(Socket.java:431) 01-21 02:03:26.876 2056 2089 W System.err: at java.net.Socket.<init>(Socket.java:210) 01-21 02:03:26.876 2056 2089 W System.err: at se.vidstige.jadb.JadbConnection.createTransport(JadbConnection.java:27) 01-21 02:03:26.876 2056 2089 W System.err: at se.vidstige.jadb.JadbConnection.connectToTcpDevice(JadbConnection.java:41) 01-21 02:03:26.876 2056 2089 W System.err: at com.example.audric.jadbtest.MainActivity$1$1.run(MainActivity.java:44) 01-21 02:03:26.876 2056 2089 W System.err: at java.lang.Thread.run(Thread.java:761)

Can you help me resolve this issue ? I do not have socat on my board currently, but I do not thing it would help, as the connection is successful using the shell command.

Thanks,
Audric

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.