Skip to content

Commit

Permalink
Merge branch 'main' into remove_ios16_log_tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpaulus authored Jan 24, 2025
2 parents 2fb1267 + 376dba1 commit f8d1d03
Show file tree
Hide file tree
Showing 11 changed files with 632 additions and 18 deletions.
11 changes: 11 additions & 0 deletions ios/accessibility/accessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import (

const serviceName string = "com.apple.accessibility.axAuditDaemon.remoteserver"

// NewWithoutEventChangeListeners creates and connects to the given device, a new ControlInterface instance
// without setting accessibility event change listeners to avoid keeping constant connection.
func NewWithoutEventChangeListeners(device ios.DeviceEntry) (ControlInterface, error) {
conn, err := dtx.NewUsbmuxdConnection(device, serviceName)
if err != nil {
return ControlInterface{}, err
}
control := ControlInterface{conn.GlobalChannel()}
return control, nil
}

// New creates and connects to the given device, a new ControlInterface instance
func New(device ios.DeviceEntry) (ControlInterface, error) {
conn, err := dtx.NewUsbmuxdConnection(device, serviceName)
Expand Down
14 changes: 11 additions & 3 deletions ios/accessibility/accessibility_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a ControlInterface) readhostInspectorNotificationReceived() {
}
}

// Init wires up event receivers and gets Info from the device
// init wires up event receivers and gets Info from the device
func (a ControlInterface) init() error {
a.channel.RegisterMethodForRemote("hostInspectorCurrentElementChanged:")
a.channel.RegisterMethodForRemote("hostInspectorMonitoredEventTypeChanged:")
Expand Down Expand Up @@ -150,6 +150,14 @@ func (a ControlInterface) UpdateAccessibilitySetting(name string, val interface{
log.Info("Setting Updated", resp)
}

func (a ControlInterface) ResetToDefaultAccessibilitySettings() error {
err := a.channel.MethodCallAsync("deviceResetToDefaultAccessibilitySettings")
if err != nil {
return err
}
return nil
}

func (a ControlInterface) awaitHostInspectorCurrentElementChanged() map[string]interface{} {
msg := a.channel.ReceiveMethodCall("hostInspectorCurrentElementChanged:")
log.Info("received hostInspectorCurrentElementChanged")
Expand Down Expand Up @@ -194,15 +202,15 @@ func (a ControlInterface) deviceCapabilities() ([]string, error) {
if err != nil {
return nil, err
}
return convertToStringList(response.Payload), nil
return convertToStringList(response.Payload)
}

func (a ControlInterface) deviceAllAuditCaseIDs() ([]string, error) {
response, err := a.channel.MethodCall("deviceAllAuditCaseIDs")
if err != nil {
return nil, err
}
return convertToStringList(response.Payload), nil
return convertToStringList(response.Payload)
}

func (a ControlInterface) deviceAccessibilitySettings() (map[string]interface{}, error) {
Expand Down
9 changes: 7 additions & 2 deletions ios/accessibility/utils.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package accessibility

func convertToStringList(payload []interface{}) []string {
import "fmt"

func convertToStringList(payload []interface{}) ([]string, error) {
if len(payload) != 1 {
return nil, fmt.Errorf("invalid payload length %d", len(payload))
}
list := payload[0].([]interface{})
result := make([]string, len(list))
for i, v := range list {
result[i] = v.(string)
}
return result
return result, nil
}
4 changes: 2 additions & 2 deletions ios/dtx_codec/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (g GlobalDispatcher) Dispatch(msg Message) {
"msg": logmsg[0],
"pid": msg.Auxiliary.GetArguments()[1],
"time": msg.Auxiliary.GetArguments()[2],
}).Info("outputReceived:fromProcess:atTime:")
}).Debug("outputReceived:fromProcess:atTime:")
}
return
}
Expand All @@ -131,7 +131,7 @@ func (g GlobalDispatcher) Dispatch(msg Message) {
if msg.HasError() {
log.Error(msg.Payload[0])
}
if msg.PayloadHeader.MessageType == UnknownTypeOne {
if msg.PayloadHeader.MessageType == UnknownTypeOne || msg.PayloadHeader.MessageType == ResponseWithReturnValueInPayload {
g.dtxConnection.Dispatch(msg)
}
}
Expand Down
26 changes: 26 additions & 0 deletions ios/testmanagerd/proxydispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,32 @@ func (p proxyDispatcher) Dispatch(m dtx.Message) {
}

p.testListener.testCaseDidStartForClass(testClass, testMethod)
case "_XCT_testCaseDidStartWithIdentifier:iteration:":
argumentLengthErr := assertArgumentsLengthEqual(m, 2)
if argumentLengthErr != nil {
decoderErr = argumentLengthErr
break
}

testIdentifier, decoderErr := extractTestIdentifierArg(m, 0)
if decoderErr != nil {
break
}

p.testListener.testCaseDidStartForClass(testIdentifier.C[0], testIdentifier.C[1])
case "_XCT_testCaseDidStartWithIdentifier:":
argumentLengthErr := assertArgumentsLengthEqual(m, 1)
if argumentLengthErr != nil {
decoderErr = argumentLengthErr
break
}

testIdentifier, decoderErr := extractTestIdentifierArg(m, 0)
if decoderErr != nil {
break
}

p.testListener.testCaseDidStartForClass(testIdentifier.C[0], testIdentifier.C[1])
case "_XCT_testCaseDidStartWithIdentifier:testCaseRunConfiguration:":
argumentLengthErr := assertArgumentsLengthEqual(m, 2)
if argumentLengthErr != nil {
Expand Down
Loading

0 comments on commit f8d1d03

Please sign in to comment.