Giter VIP home page Giter VIP logo

goadb's Introduction

#goadb

Build Status GoDoc

A Golang library for interacting with the Android Debug Bridge (adb).

See demo.go for usage.

goadb's People

Contributors

codeskyblue avatar ltpquang avatar phil9909 avatar zach-klippenstein 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

goadb's Issues

exception

Some exception happend when many devices plugged in the computer, I guess it is because of the socket response data not completed.
image

Mismatch number of devices returned from `goadb`

I have 4 devices plugged in, and can successfully retrieve with adb CLI

cpu12454@cpu12454-B360M-AORUS-Gaming-3:~$ adb devices -l
List of devices attached
330055a244c72319       device usb:1-5 product:a5xeltexx model:SM_A510F device:a5xelte transport_id:2
3300b0e061f593e9       device usb:1-1 product:on7xeltedd model:SM_G610F device:on7xelte transport_id:1
52004c98eea95419       device usb:1-2 product:j7y17ltedx model:SM_J730G device:j7y17lte transport_id:3
c9acd3c9               device usb:1-6 product:j6primeltedd model:SM_J610F device:j6primelte transport_id:4

But goadb only return 3 of them:

Nov 23 18:40:15 cpu12454-B360M-AORUS-Gaming-3 device-manager[2040320]: {"Serial":"330055a244c72319","Product":"a5xeltexx","Model":"SM_A510F","DeviceInfo":"a5xelte","Usb":"1-5"}
Nov 23 18:40:15 cpu12454-B360M-AORUS-Gaming-3 device-manager[2040320]: {"Serial":"3300b0e061f593e9","Product":"on7xeltedd","Model":"SM_G610F","DeviceInfo":"on7xelte","Usb":"1-1"}
Nov 23 18:40:15 cpu12454-B360M-AORUS-Gaming-3 device-manager[2040320]: {"Serial":"52004c98eea95419","Product":"j7y17","Model":"","DeviceInfo":"","Usb":"1-2"}

I have 2 machines, each has 4 devices plugged in. Both of them have the same problem. It seems that they are ignoring the last device returned from adb.

Any idea how to resolve this problem?

(DirEntry).Size not returning correct value for sizes >= 5GB

It seems there is a sort of integer overflow when attempting to query sizes of large files (>5GB).

For example:

$ du -b 5gb.img
5368709120 5gb.img

(Trying to get size for this file via (DirEntry).Size returns 1073741824)
$ du -h 6gb.img
6442450944 6gb.img

(Trying to get size for this file via (DirEntry).Size returns -2147483648)
$ du -h 10gb.img
10737418240 10gb.img

(Trying to get size for this file via (DirEntry).Size returns -2147483648)

Note: Range of int32 is -2147483648 through 2147483647.

Any workarounds/solutions to get the proper sizes?

@zach-klippenstein

An error occurred when more than two devices!

Command Line:

adb devices -l
List of devices attached
9591163035000RU        device product:PD2085 model:V2085A device:PD2085 transport_id:24
a9bdcc8c               device product:PD1821 model:V1821A device:PD1821 transport_id:23
10.13.209.82:9999      device product:PD2085 model:V2085A device:PD2085 transport_id:19
demo.go:

Starting server…
Server version: 41
panic: runtime error: index out of range [1] with length 1                                                                         
                                                                                                                                   
goroutine 1 [running, locked to thread]:                                                                                           
github.com/zach-klippenstein/goadb.parseKeyVal(...)                                                                                
        ~/go/pkg/mod/github.com/zach-klippenstein/[email protected]/device_info.go:86       
github.com/zach-klippenstein/goadb.parseDeviceAttributes({0xc0004a40e0, 0x4, 0xc0004aa000?})                                       
        ~/go/pkg/mod/github.com/zach-klippenstein/[email protected]/device_info.go:77 +0x125
github.com/zach-klippenstein/goadb.parseDeviceLong({0xc0004aa000?, 0xc0004a20b0?})                                                 
        ~/go/pkg/mod/github.com/zach-klippenstein/[email protected]/device_info.go:70 +0x4f 
github.com/zach-klippenstein/goadb.parseDeviceList({0xc0004a0100, 0xff}, 0xa21a68)                                                 
        ~/go/pkg/mod/github.com/zach-klippenstein/[email protected]/device_info.go:47 +0x132
github.com/zach-klippenstein/goadb.(*Adb).ListDevices(0xc00033aaa0)                                                                
        ~/go/pkg/mod/github.com/zach-klippenstein/[email protected]/adb.go:130 +0x56
main.main()
        ~/test_goadb.go:39 +0x2b1

ListDevices Error

Hello,when i launch 3 emulator i received error from ListDevices function while in terminal adb devices command working nice.
When i run 2 device there is no like issue
Any help about this problem?
My code for listing devices

client,err := adb.New()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error New adb: %v\n", err)
		return
	}
	b_devices,err := client.ListDevices()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error ListDevices adb: %v\n", err)
		return
	}

received error message

error ListDevices adb: ParseError: error performing ListDevices on *adb.Adb (&{server:0xc0001320f0})

Screenshot 2019-12-27 16 59 13

@zach-klippenstein

Support shell out/err splitting and exit codes

adb is getting support for differentiating stdout and stderr streams, and process exit codes.

Implementation:
https://github.com/android/platform_system_core/blob/ac50d0cc5789d8462fcd2d9f6cb225e0edf9a12f/adb/shell_service.h
https://github.com/android/platform_system_core/blob/ac50d0cc5789d8462fcd2d9f6cb225e0edf9a12f/adb/shell_service.cpp

Usage: https://github.com/android/platform_system_core/blob/ac50d0cc5789d8462fcd2d9f6cb225e0edf9a12f/adb/commandline.cpp#L291

RunCommand should still be supported for combined stdin/stdout streams, but there should be an API like exec.Cmd. The old mode is called "PTY" mode, and RunCommand should probably use that. The new mode is called "protocol" mode, and multiplexes out/err streams over a single connection with a simple protocol that sends packets with stream ID headers.

The exit code is sent as a single raw byte on the kIdExit stream.

Cannot build on windows

Get the below error when I try to go build on windows:

$ go build
# github.com/zach-klippenstein/goadb
.\server.go:140: undefined: unix.Access
.\server.go:140: undefined: unix.X_OK

The unix package is not available on windows. Need conditional compilation. I don't see any reason this library cannot be supported on windows.

Building demo.go

Sorry in advance for the newbie question. I am new to go and new to goadb.

I am trying to build the demo.go app on Windows and while I did do the requisite go get's for both goadb and the internal/errors I see this error:

C:\goadb>go build demo.go
demo.go:11:2: no required module provides package github.com/zach-klippenstein/goadb: working directory is not part of a module
demo.go:12:2: no required module provides package github.com/zach-klippenstein/goadb/internal/errors: working directory is not part of a module

Can someone help or point me to any link to get me started?

Thanks,
Will

opening cmd window on every adb command execution(in windows os only)

whenever we try to execute adb command on windows using goadb .. it is opening command line for sometime and then closing it after the adb command execution.
how can i change this behaviour and stop goadb from opening cmd window ?

we are using "windows 10". and goadb version "v0.0.0-20201208042340-620e0e950ed7"

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.