create stub for adb push

This commit is contained in:
2022-07-27 02:26:23 -07:00
parent d17e55a04f
commit e5068d7b3f

12
adb.go
View File

@@ -3,6 +3,7 @@ package adb
import ( import (
"context" "context"
"net" "net"
"os"
) )
type Serial string type Serial string
@@ -65,7 +66,7 @@ func (d Device) Disconnect(ctx context.Context) error {
// Kill the ADB Server // 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 // 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. // 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 // 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. // 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 { 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 return nil
} }