Giter Site home page Giter Site logo

adblib's People

Contributors

cgutman avatar ckesc avatar sampalmer avatar tananaev 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

adblib's Issues

Re-prompt to allow USB debugging

I am using your adblib, thank you very much for being open source.
I met a question and wanted to ask for your help. I use your project on Android, the code as same as your demo, the interface is AdbCrypto.loadAdbKeyPair.However,when I re-open my application, it need to re-prompt to allow USB debugging, but the computer's RSA key as same as last RSA.

Wireless Debugging

Android 11 introduces wireless debugging which greatly simplifies the process of using ADB. However, before making the ADB connection, it needs an additional pairing, meaning it needs extra work to make the pairing first.

OutOfMemoryError

I've seen this on two devices at least, occurs at AdbProtocol.java#L323:

java.lang.OutOfMemoryError: Failed to allocate a 1598575456 byte allocation with 7544583 free bytes and 248MB until OOM, target footprint 15089167, growth limit 268435456
	at com.cgutman.adblib.AdbProtocol$AdbMessage.parseAdbMessage (AdbProtocol.java:276)

cgutman/AdbLib#13

Enhancements

Hi,

Firstly, thanks for making this library available through Gradle.

I'm using this library in a new project and would like to add a number of enhancements to the library. But before I do the coding and pull requests, I want to run them by you to make sure we're on the same page.

Enhancements I want to make are:

  1. AdbConnection.openStreams is a regular HashMap but has a race condition when read from the connection thread and updated from main thread at the same time. I'm thinking of changing it to a ConcurrentHashMap or possibly adding some locks in the code that accesses it.
  2. Add timeout parameter to AdbConnection.connect() since this method will never return in the following situations:
    • The auth popup appears on the target device and the protocol version is 0x01000000
    • The auth popup appears on the target device but is cancelled by the user
    • The auth popup appears on the target device but the user ignores it
  3. Add an option to AdbConnection.connect() to throw an AdbAuthenticationFailedException if we receive a second AUTH message after we've already sent our signature. This way we get instant feedback about whether we are "always allowed" from a previous auth attempt, and this is exactly how the adb command line tool handles the situation. (The adb tool assumes authentication failed in this situation, but then if the user accepts the auth popup and the adb tool receives a subsequent CNXN, then it changes its mind and decides the connection was ok after all.) Or the other option is, instead of throwing an exception, to at least provide status updates about the current state (eg connecting vs authenticating vs connected) so our app can respond to them in real-time.
  4. Update client protocol version from 0x01000000 to 0x01000001. The main benefit of this is, when the target device gets an auth popup, then when the user presses the "OK" button, then we receive a CNXN message and the connection establishes. Whereas if we're on the old version, then we never receive a CNXN message when the user presses "OK", so connection attempts always fail unless the user has previously checked the "always allow" box on the auth popup.

This is based on testing against an NVIDIA Shield TV Pro 2019 and Google Pixel 3 XL. Maybe older Android devices that run the older 0x01000000 protocol version have less issues?

Can you let me know what you think of these ideas? And do you need unit tests or any other specific checks and balances before I raise the pull request?

Lastly, how long would the review and release process take before the changes are live and ready to pull into an app through Gradle?

Thanks!

Call ctrl+c on remote device?

I know it's possible as the original app developer has a Ctrl+C send option in his adb app built in, but I was wondering how to send such a command for myself using this library. I can't seem to find out how.

delay in commands

Hi

there is a delay every time I send a command and until i see the reaction on the device.
is there a way to solve it?

thanks

Usage guide

A usage guide would be really helpful here! I've been trying to understand the sort of commands I can send across, and am struggling.
Say I need to call a binary in a remote adb device. How would I do so?
Essentially all I want to do is call the following ->

  1. connect via adb.
  2. call ./path/to/my_binary

What is the destination of 'AdbStream object corresponding to the specified destination'?

I'm doubt about what is destination at AdbConnection$open(String destination) , the code:


/**
   * Opens an AdbStream object corresponding to the specified destination.
   * This routine will block until the connection completes.
   *
   * @param destination The destination to open on the target
   * @return AdbStream object corresponding to the specified destination
   * @throws UnsupportedEncodingException If the destination cannot be encoded to UTF-8
   * @throws IOException                  If the stream fails while sending the packet
   * @throws InterruptedException         If we are unable to wait for the connection to finish
   */
public AdbStream open(String destination) throws UnsupportedEncodingException, IOException, InterruptedException {

}

i don't clearly that how many the specified destination ; I want to execute adb forward tcp:$port localabstract: $remotePort, what should I set destination ? why ?

Question

Hello, i'm using your adblib and i'm trying using local command (push, pull or install for example) but I've only found examples that use "adbConnection.open("shell:")"
It's possible using this library to use local command ?
I am looking forward to your response.

adb root

Hi @cgutman, @tananaev, @sampalmer, @ckesc
I would like to run a command "adb root" and not passing through adb shell (which works):
using adb shell: getprop ro.build.version.incremental it is working:

                            String getpropCommand = "getprop ro.build.version.incremental";
                            AdbStream streamGetpropCommand = connection.open("shell:" + getpropCommand);

                            while (!streamGetpropCommand .isClosed()) {
                                try {
                                    String result = new String(streamGetpropCommand.read(), StandardCharsets.US_ASCII);
                                    // Print each thing we read from the shell stream
                                    System.out.println("-->step1: getprop result: " + result);
                                    if (!result.isEmpty()) {
                                        streamGetpropCommand.close();
                                    }

                                } catch (InterruptedException | IOException e) {
                                    e.printStackTrace();
                                    return;
                                }
                            }

and when using adb root does not work:

                                    String rootCommand = "adb root";
                                    AdbStream streamRootCommand = connection.open(rootCommand);
                                    while (!streamRootCommand.isClosed()) {
                                        try {
                                            String result = new String(streamRootCommand.read(), StandardCharsets.US_ASCII);
                                            // Print each thing we read from the shell stream
                                            System.out.println("--> step2: adb root result: " + result);
                                            if (!result.isEmpty()) {
                                                streamRootCommand.close();
                                            }

                                        } catch (InterruptedException | IOException e) {
                                            e.printStackTrace();
                                            return;
                                        }
                                    }

New version

Hi,

Just wondering if you have any plans to release a new version with the latest changes?

Thanks

adb root

Hi @cgutman, @tananaev, @ckesc, @sampalmer
I would like to run a command "adb root" and not passing through adb shell (which works):
using adb shell: getprop ro.build.version.incremental it is working:

                            String getpropCommand = "getprop ro.build.version.incremental";
                            AdbStream streamGetpropCommand = connection.open("shell:" + getpropCommand);

                            while (!streamGetpropCommand .isClosed()) {
                                try {
                                    String result = new String(streamGetpropCommand.read(), StandardCharsets.US_ASCII);
                                    // Print each thing we read from the shell stream
                                    System.out.println("-->step1: getprop result: " + result);
                                    if (!result.isEmpty()) {
                                        streamGetpropCommand.close();
                                    }

                                } catch (InterruptedException | IOException e) {
                                    e.printStackTrace();
                                    return;
                                }
                            }

and when using adb root does not work:

                                    String rootCommand = "adb root";
                                    AdbStream streamRootCommand = connection.open(rootCommand);
                                    while (!streamRootCommand.isClosed()) {
                                        try {
                                            String result = new String(streamRootCommand.read(), StandardCharsets.US_ASCII);
                                            // Print each thing we read from the shell stream
                                            System.out.println("--> step2: adb root result: " + result);
                                            if (!result.isEmpty()) {
                                                streamRootCommand.close();
                                            }

                                        } catch (InterruptedException | IOException e) {
                                            e.printStackTrace();
                                            return;
                                        }
                                    }

the result of stream read contains some special character?

there are example code in order to get os version of device as belows: use cmd: getprop ro.build.version.release
AdbStream stream = adb.open("shell:");
stream.write("getprop ro.build.version.release" +'\n');

when stream read
String bufStr = new String(stream.read(), StandardCharsets.UTF_8);
//...

the output of bufStr contains some special character: like ^@, / $...

does any wrong when I use adblib?

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.