Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simulate location for iOS17 #403

Merged
merged 1 commit into from
May 2, 2024

Conversation

kvs-coder
Copy link
Contributor

Why?

The current setlocation only works for iOS below 17, the iOS 17 introduces a new instrumentation service com.apple.instruments.dtservicehub with the channel id com.apple.instruments.server.services.LocationSimulation for the simulated location.

How?

By using DTX make a channel call:

  • imulateLocationWithLatitude:longitude: with args to start the location simulation
  • stopLocationSimulation to stop and clear the location simulation & data
    The response payloads for both methods are <nil>

@kvs-coder kvs-coder changed the title Simulate location for iOS17 feat: Simulate location for iOS17 Apr 25, 2024
dtxConn, err = dtx.NewTunnelConnection(device, serviceNameiOS17)
if err != nil {
return nil, err
}
Copy link
Contributor Author

@kvs-coder kvs-coder Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH looks not great with iOS 17 as a fallback, probably a proper check for iOS version would avoid potentially unlimited nesting :)

Maybe can be done as a separate refactoring PR

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actuall this part is solved already in #396 but unfortunately it's not merged yet, and I can't rebase someone else's PR. Maybe pinging @michal-przytarski works and he can rebase, after that I can merge it.

main.go Outdated
@@ -232,6 +233,7 @@ The commands work as following:
ios setlocation [options] [--lat=<lat>] [--lon=<lon>] Updates the location of the device to the provided by latitude and longitude coordinates. Example: setlocation --lat=40.730610 --lon=-73.935242
ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>] Updates the location of the device based on the data in a GPX file. Example: setlocationgpx --gpxfilepath=/home/username/location.gpx
ios resetlocation [options] Resets the location of the device to the actual one
ios simulatelocation [options] [--lat=<lat>] [--lon=<lon>] iOS 17 way to set location of the device to the provided by latitude and longitude coordinates. Example: simulatelocation --lat=55.75582600 --lon=37.61729990 --address=fd19:a731:684f::1 --rsd-port=61935

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a method automatically get address and rsd-port values?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using go-ios with go-ios tunnel start that's happening implicitly (and you can view the address and port of the managed tunnels with go-ios tunnel ls)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using go-ios with go-ios tunnel start that's happening implicitly (and you can view the address and port of the managed tunnels with go-ios tunnel ls)

thanks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using go-ios with go-ios tunnel start that's happening implicitly (and you can view the address and port of the managed tunnels with go-ios tunnel ls)

By the way, i'm using mac now, does it work with windows?

main.go Outdated
@@ -122,6 +122,7 @@ Usage:
ios setlocation [options] [--lat=<lat>] [--lon=<lon>]
ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>]
ios resetlocation [options]
ios simulatelocation [options] [--lat=<lat>] [--lon=<lon>]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are already these three commands to handle location simulation, lets re-use them

  ios setlocation [options] [--lat=<lat>] [--lon=<lon>]
  ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>]
  ios resetlocation [options]

dtxConn, err = dtx.NewTunnelConnection(device, serviceNameiOS17)
if err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actuall this part is solved already in #396 but unfortunately it's not merged yet, and I can't rebase someone else's PR. Maybe pinging @michal-przytarski works and he can rebase, after that I can merge it.

}

// Start sets geolocation with provided params
func (d *LocationSimulationService) Start(lat string, lon string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be a bit more verbose in the method name, Start/Stop are very generic. StartSimulateLocation and StopSimulateLocation are better understandable IMO.

main.go Outdated
@@ -232,6 +233,7 @@ The commands work as following:
ios setlocation [options] [--lat=<lat>] [--lon=<lon>] Updates the location of the device to the provided by latitude and longitude coordinates. Example: setlocation --lat=40.730610 --lon=-73.935242
ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>] Updates the location of the device based on the data in a GPX file. Example: setlocationgpx --gpxfilepath=/home/username/location.gpx
ios resetlocation [options] Resets the location of the device to the actual one
ios simulatelocation [options] [--lat=<lat>] [--lon=<lon>] iOS 17 way to set location of the device to the provided by latitude and longitude coordinates. Example: simulatelocation --lat=55.75582600 --lon=37.61729990 --address=fd19:a731:684f::1 --rsd-port=61935
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using go-ios with go-ios tunnel start that's happening implicitly (and you can view the address and port of the managed tunnels with go-ios tunnel ls)

}

// StartSimulateLocation sets geolocation with provided params
func (d *LocationSimulationService) StartSimulateLocation(lat string, lon string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I missed that before. This method should already receive numbers and not strings

Suggested change
func (d *LocationSimulationService) StartSimulateLocation(lat string, lon string) error {
func (d *LocationSimulationService) StartSimulateLocation(lat, lon float64) error {

main.go Outdated
Comment on lines 1756 to 1764
latitude, err := strconv.ParseFloat(lat, 64)
if err != nil {
exitIfError("location simulation failed to parse lat", err)
}

longitude, err := strconv.ParseFloat(lon, 64)
if err != nil {
exitIfError("location simulation failed to parse lon", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if check happens in exitIfError already

Suggested change
latitude, err := strconv.ParseFloat(lat, 64)
if err != nil {
exitIfError("location simulation failed to parse lat", err)
}
longitude, err := strconv.ParseFloat(lon, 64)
if err != nil {
exitIfError("location simulation failed to parse lon", err)
}
latitude, err := strconv.ParseFloat(lat, 64)
exitIfError("location simulation failed to parse lat", err)
longitude, err := strconv.ParseFloat(lon, 64)
exitIfError("location simulation failed to parse lon", err)

@fish-sauce fish-sauce force-pushed the simulate-location branch 2 times, most recently from 65bd522 to 4bc12cc Compare April 30, 2024 08:58
@dmissmann dmissmann merged commit fe5e60b into danielpaulus:main May 2, 2024
2 checks passed
michal-przytarski pushed a commit to bitbar/go-ios that referenced this pull request May 6, 2024
The current setlocation only works for iOS below 17, the iOS 17 introduces a new instrumentation service com.apple.instruments.dtservicehub with the channel id com.apple.instruments.server.services.LocationSimulation for the simulated location.

Co-authored-by: fish-sauce <victor.kachalov@saucelabs.com>
michal-przytarski added a commit to bitbar/go-ios that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants