Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cli/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ var deviceInfoCmd = &cobra.Command{
Short: "Get device info",
Long: `Get detailed information about a connected device, such as OS, version, and screen size.`,
RunE: func(cmd *cobra.Command, args []string) error {

// Find the target device
targetDevice, err := commands.FindDeviceOrAutoSelect(deviceId)
if err != nil {
response := commands.NewErrorResponse(fmt.Errorf("error finding device: %v", err))
printJson(response)
return fmt.Errorf("%s", response.Error)
}

// Start agent
err = targetDevice.StartAgent()
if err != nil {
response := commands.NewErrorResponse(fmt.Errorf("error starting agent: %v", err))
printJson(response)
return fmt.Errorf("%s", response.Error)
}

response := commands.InfoCommand(deviceId)
printJson(response)
if response.Status == "error" {
Expand Down
5 changes: 3 additions & 2 deletions devices/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func getDeviceInfo(deviceEntry goios.DeviceEntry) (IOSDevice, error) {
if err != nil {
return IOSDevice{}, fmt.Errorf("failed to create tunnel manager for device %s: %w", udid, err)
}

device.tunnelManager = tunnelManager
device.wdaClient = wda.NewWdaClient("localhost:8100")
return device, nil
Expand Down Expand Up @@ -318,7 +319,7 @@ func (d IOSDevice) LaunchWda(bundleID, testRunnerBundleID, xctestConfig string)
utils.Verbose("No bundle ids specified, falling back to defaults")
bundleID, testRunnerBundleID, xctestConfig = "com.facebook.WebDriverAgentRunner.xctrunner", "com.facebook.WebDriverAgentRunner.xctrunner", "WebDriverAgentRunner.xctest"
}

utils.Verbose("Running wda with bundleid: %s, testbundleid: %s, xctestconfig: %s", bundleID, testRunnerBundleID, xctestConfig)

device, err := d.getEnhancedDevice()
Expand All @@ -327,7 +328,7 @@ func (d IOSDevice) LaunchWda(bundleID, testRunnerBundleID, xctestConfig string)
}

ctx, cancel := context.WithCancel(context.Background())

// start WDA in background using testmanagerd similar to go-ios runwda command
go func() {
defer cancel()
Expand Down
5 changes: 0 additions & 5 deletions devices/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
// runSimctl executes xcrun simctl with the provided arguments
func runSimctl(args ...string) ([]byte, error) {
fullArgs := append([]string{"simctl"}, args...)
cmd := exec.Command("xcrun", fullArgs...)

Check failure on line 98 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / lint

G204: Subprocess launched with variable (gosec)
output, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("failed to execute xcrun simctl command: %w", err)
Expand Down Expand Up @@ -174,7 +174,7 @@
func (s SimulatorDevice) LaunchAppWithEnv(bundleID string, env map[string]string) error {
// Build simctl command
fullArgs := append([]string{"simctl", "launch"}, s.UDID, bundleID)
cmd := exec.Command("xcrun", fullArgs...)

Check failure on line 177 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / lint

G204: Subprocess launched with variable (gosec)

// Set environment variables with SIMCTL_CHILD_ prefix for this command only
cmd.Env = os.Environ()
Expand Down Expand Up @@ -423,7 +423,7 @@
}

func (s *SimulatorDevice) OpenURL(url string) error {
return exec.Command("xcrun", "simctl", "openurl", s.ID(), url).Run()

Check failure on line 426 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / lint

G204: Subprocess launched with a potential tainted input or cmd arguments (gosec)
}

func (s *SimulatorDevice) ListApps() ([]InstalledAppInfo, error) {
Expand Down Expand Up @@ -469,11 +469,6 @@
}

func (s *SimulatorDevice) Info() (*FullDeviceInfo, error) {
err := s.StartAgent()
if err != nil {
return nil, fmt.Errorf("failed to start agent: %w", err)
}

wdaSize, err := s.wdaClient.GetWindowSize()
if err != nil {
return nil, fmt.Errorf("failed to get window size from WDA: %w", err)
Expand Down
10 changes: 10 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,16 @@ func handleDeviceInfo(params json.RawMessage) (interface{}, error) {
return nil, fmt.Errorf("invalid parameters: %v. Expected fields: deviceId", err)
}

targetDevice, err := commands.FindDeviceOrAutoSelect(infoParams.DeviceID)
if err != nil {
return nil, fmt.Errorf("error finding device: %w", err)
}

err = targetDevice.StartAgent()
if err != nil {
return nil, fmt.Errorf("error starting agent: %w", err)
}

response := commands.InfoCommand(infoParams.DeviceID)
if response.Status == "error" {
return nil, fmt.Errorf("%s", response.Error)
Expand Down
Loading