Toggle wifi during execution on AWS device Farm

Currently I am executing Appium Java automation test cases in AWS device Farm real device.

There is a scenario where I need to toggle the WiFi On or Off during the execution like after certain steps. So how to toggle the WiFi of devices in AWS device Farm using Appium java code.

Also suggest if there are any alternate approach to achieve this scenario through automation in AWS device Farm devices(ios and Android)

Android:

https://medium.com/@appiumguide/133-appium-concepts-enabling-disabling-wifi-via-appium-built-in-method-at-runtime-88af690793b9

iOS:
No built in solution. You will need to open settings or swipe to get to the settings and then check state. 1 is on and 0 is off. Click the element to achieve the state you desire. Here is a good example:

https://qa-shujaatali.medium.com/how-to-toggle-wifi-on-ios-using-appium-from-settings-app-1ec2f72e4f74