Skip to content

Commit

Permalink
Reset accessibility settings to default
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sauce committed Jan 13, 2025
1 parent f5b5d81 commit b921242
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
1 change: 0 additions & 1 deletion ios/accessibility/accessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ func New(device ios.DeviceEntry) (ControlInterface, error) {
return ControlInterface{}, err
}
control := ControlInterface{conn.GlobalChannel()}
err = control.init()
return control, err
}
10 changes: 9 additions & 1 deletion ios/accessibility/accessibility_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (a ControlInterface) readhostInspectorNotificationReceived() {
}

// Init wires up event receivers and gets Info from the device
func (a ControlInterface) init() error {
func (a ControlInterface) Init() error {
a.channel.RegisterMethodForRemote("hostInspectorCurrentElementChanged:")
a.channel.RegisterMethodForRemote("hostInspectorMonitoredEventTypeChanged:")
a.channel.RegisterMethodForRemote("hostAppStateChanged:")
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
21 changes: 20 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Usage:
ios runxctest [--xctestrun-file-path=<xctestrunFilePath>] [--log-output=<file>] [options]
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--log-output=<file>] [--arg=<a>]... [--env=<e>]... [options]
ios ax [--font=<fontSize>] [options]
ios resetax [options]
ios debug [options] [--stop-at-entry] <app_path>
ios fsync (rm [--r] | tree | mkdir) --path=<targetPath>
ios fsync (pull | push) --srcPath=<srcPath> --dstPath=<dstPath>
Expand Down Expand Up @@ -238,6 +239,7 @@ The commands work as following:
ios runwda [--bundleid=<bundleid>] [--testrunnerbundleid=<testbundleid>] [--xctestconfig=<xctestconfig>] [--log-output=<file>] [--arg=<a>]... [--env=<e>]...[options] runs WebDriverAgents
> specify runtime args and env vars like --env ENV_1=something --env ENV_2=else and --arg ARG1 --arg ARG2
ios ax [--font=<fontSize>] [options] Access accessibility inspector features.
ios resetax [options] Reset accessibility settings to defaults.
ios debug [--stop-at-entry] <app_path> Start debug with lldb
ios fsync (rm [--r] | tree | mkdir) --path=<targetPath> Remove | treeview | mkdir in target path. --r used alongside rm will recursively remove all files and directories from target path.
ios fsync (pull | push) --srcPath=<srcPath> --dstPath=<dstPath> Pull or Push file from srcPath to dstPath.
Expand Down Expand Up @@ -1046,6 +1048,12 @@ The commands work as following:
return
}

b, _ = arguments.Bool("resetax")
if b {
resetAx(device)
return
}

b, _ = arguments.Bool("debug")
if b {
appPath, _ := arguments.String("<app_path>")
Expand Down Expand Up @@ -1771,7 +1779,10 @@ func timeFormat(device ios.DeviceEntry, operation string, force bool) {
func startAx(device ios.DeviceEntry, arguments docopt.Opts) {
go func() {
conn, err := accessibility.New(device)
exitIfError("failed starting ax", err)
exitIfError("failed creating ax service", err)

err = conn.Init()
exitIfError("failed init ax", err)

conn.SwitchToDevice()

Expand Down Expand Up @@ -1799,6 +1810,14 @@ func startAx(device ios.DeviceEntry, arguments docopt.Opts) {
<-c
}

func resetAx(device ios.DeviceEntry) {
conn, err := accessibility.New(device)
exitIfError("failed creating ax service", err)

err = conn.ResetToDefaultAccessibilitySettings()
exitIfError("failed resetting ax", err)
}

func printVersion() {
versionMap := map[string]interface{}{
"version": version,
Expand Down

0 comments on commit b921242

Please sign in to comment.