Below code worked for me earlier, so give a try. Not sure if something is updated now.
AndroidDriver driver=null;
DesiredCapabilities caps=new DesiredCapabilities();
caps.setCapability("deviceName", "abc");
caps.setCapability("appPackage", "myapppackage");
caps.setCapability("appActivity", "myappactivity");
try
{
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),caps);
} catch (MalformedURLException e)
{
e.printStackTrace();
}
try
{
Runtime.getRuntime().exec("cmd /C " + "adb shell am start -n io.appium.settings/.Settings -e wifi off");
} catch (IOException e)
{
e.printStackTrace();
}
NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false);
System.out.println("Hello "+networkConnection.wifiEnabled());