forked from danielpaulus/go-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Simulate location for iOS17 (danielpaulus#403)
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>
- Loading branch information
1 parent
ac4e40b
commit fe5e60b
Showing
5 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package instruments | ||
|
||
import ( | ||
"github.com/danielpaulus/go-ios/ios" | ||
dtx "github.com/danielpaulus/go-ios/ios/dtx_codec" | ||
) | ||
|
||
const locationSimulationIdentifier = "com.apple.instruments.server.services.LocationSimulation" | ||
|
||
// LocationSimulationService gives us access to simulate device geo location | ||
type LocationSimulationService struct { | ||
channel *dtx.Channel | ||
conn *dtx.Connection | ||
} | ||
|
||
// StartSimulateLocation sets geolocation with provided params | ||
func (d *LocationSimulationService) StartSimulateLocation(lat, lon float64) error { | ||
_, err := d.channel.MethodCall("simulateLocationWithLatitude:longitude:", lat, lon) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// StopSimulateLocation clears simulated location | ||
func (d *LocationSimulationService) StopSimulateLocation() error { | ||
_, err := d.channel.MethodCall("stopLocationSimulation") | ||
if err != nil { | ||
return err | ||
} | ||
defer d.Close() | ||
|
||
return nil | ||
} | ||
|
||
// NewLocationSimulationService creates a new LocationSimulationService for a given device | ||
func NewLocationSimulationService(device ios.DeviceEntry) (*LocationSimulationService, error) { | ||
dtxConn, err := connectInstruments(device) | ||
if err != nil { | ||
return nil, err | ||
} | ||
processControlChannel := dtxConn.RequestChannelIdentifier(locationSimulationIdentifier, loggingDispatcher{dtxConn}) | ||
return &LocationSimulationService{channel: processControlChannel, conn: dtxConn}, nil | ||
} | ||
|
||
// Close closes up the DTX connection | ||
func (d *LocationSimulationService) Close() { | ||
d.conn.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters