-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
Conversation
ios/instruments/helper.go
Outdated
dtxConn, err = dtx.NewTunnelConnection(device, serviceNameiOS17) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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 withgo-ios tunnel ls
)
thanks
There was a problem hiding this comment.
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 withgo-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>] |
There was a problem hiding this comment.
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]
ios/instruments/helper.go
Outdated
dtxConn, err = dtx.NewTunnelConnection(device, serviceNameiOS17) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
func (d *LocationSimulationService) StartSimulateLocation(lat string, lon string) error { | |
func (d *LocationSimulationService) StartSimulateLocation(lat, lon float64) error { |
main.go
Outdated
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) | ||
} |
There was a problem hiding this comment.
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
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) |
65bd522
to
4bc12cc
Compare
4bc12cc
to
8474f7f
Compare
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>
This reverts commit 2024bf1.
Why?
The current
setlocation
only works for iOS below 17, the iOS 17 introduces a new instrumentation servicecom.apple.instruments.dtservicehub
with the channel idcom.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 simulationstopLocationSimulation
to stop and clear the location simulation & dataThe response payloads for both methods are
<nil>