Appium C# test internet connection

How to Check Internet Connection on Android Real Device
I tried several options:

    • AndroidDriver.ExecuteScript(“mobile: shell”, “{‘command’: ‘ping’, ‘args’: [’-c1’, ‘www.google.com’]}”).ToString();
    • AndroidDriver.ExecuteScript(“mobile: shell”, new object[] { “ping”, “www.google.com” }).ToString();

Everyone gets an error message:
error: command’ argument is mandatory

If you want to execute adb command, here is C# example

var resp = androidDriver.ExecuteScript("mobile: shell", new Dictionary<string, object> { { "command", "ping" }, { "args", new List<string>() { "-c1", "www.google.com", } } }).ToString();