From e5068d7b3f8a2b1e06d52fc064800aa8648d12c6 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Wed, 27 Jul 2022 02:26:23 -0700 Subject: [PATCH] create stub for adb push --- adb.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/adb.go b/adb.go index e712054..923678b 100644 --- a/adb.go +++ b/adb.go @@ -3,6 +3,7 @@ package adb import ( "context" "net" + "os" ) type Serial string @@ -16,7 +17,7 @@ const ( // Create a Device with Connect() or a slice with Devices() // -// Device contains the information necessary to connect to and +// Device contains the information necessary to connect to and // communicate with a device type Device struct { SerialNo Serial @@ -25,7 +26,7 @@ type Device struct { FileHandle string // TODO change this to a discrete type } -// Provides a connection string for Connect() +// Provides a connection string for Connect() type ConnOptions struct { Address net.IPAddr SerialNo Serial @@ -65,7 +66,7 @@ func (d Device) Disconnect(ctx context.Context) error { // Kill the ADB Server // -// Warning, this function call may cause inconsostency if nto used properly. +// Warning, this function call may cause inconsostency if not used properly. // Killing the ADB server shouldn't ever technically be necessary, but if you do // decide to use this function. note that it may invalidate all existing device structs. // Older versions of Android don't play nicely with kill-server, and some may @@ -79,6 +80,15 @@ func KillServer(ctx context.Context) error { // // Returns an error if src does not exist or there is an error copying the file. func (d Device) Push(ctx context.Context, src, dest string) error { + _, err := os.Stat(src) + if err != nil { + return err + } + stdout, stderr, errcode, err := execute(ctx, []string{"push", src, dest}) + if err != nil { + return err + } + // TODO check the return strings of the output to determine if the file copy succeeded return nil }