Add get screen resolution code

This commit is contained in:
2022-08-02 21:29:10 -07:00
parent 0bf89f9a2d
commit cab458ce53
4 changed files with 95 additions and 2 deletions

36
examples/taps/main.go Normal file
View File

@@ -0,0 +1,36 @@
package main
import (
"context"
"fmt"
"github.com/taigrr/adb"
)
var command string
func init() {
// TODO allow for any input to be used as the command
command = "ls"
}
func main() {
ctx := context.TODO()
devs, err := adb.Devices(ctx)
if err != nil {
fmt.Printf("Error enumerating devices: %v\n", err)
return
}
for _, dev := range devs {
if !dev.IsAuthorized {
fmt.Printf("Dev `%s` is not authorized, authorize it to continue.\n", dev.SerialNo)
continue
}
w, h, err := dev.GetScreenResolution(ctx)
if err != nil {
// handle error here
fmt.Printf("Error: %v\n", err)
}
fmt.Printf("%s screen resolution: %dx%d\n", dev.SerialNo, w, h)
}
}