Lock Screen + Connection

I need to lock/unlock my app screen for tests (Android app).

I saw there is a method lockScreen() but i can’t find proper documation -
calling driver.lockScreen() isn’t working.

Does lockScreen() deprecated? and if so, is there any alternative?

Also - Is there a way to enable/disable connection using Appium? (also Android app)

Thanks.

@shani
there are:

        ((AndroidDriver) driver).lockDevice();
        ((AndroidDriver) driver).unlockDevice();

they both send adb command to device. check your appium logs what is actually sending to device.

@Aleksei
The unlockDevice doesn’t work in our case

[HTTP] --> POST /wd/hub/session/2f2caf8d-1439-4290-b1a9-4a776d8f1d67/appium/device/unlock {}
[debug] [MJSONWP] Calling AppiumDriver.unlock() with args: ["2f2caf8d-1439-4290-b1a9-4a776d8f1d67"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/ie54553/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","emulator-5554","shell","dumpsys","window"]
[debug] [ADB] Running '/Users/ie54553/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","emulator-5554","shell","dumpsys","window"]
[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command '/Users/ie54553/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys window' timed out after 20000ms'; Stderr: ''; Code: 'null'
    at ADB.execFunc$ (../../../lib/tools/system-calls.js:317:13)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session/2f2caf8d-1439-4290-b1a9-4a776d8f1d67/appium/device/unlock 500 40086 ms - 373 

Do you familiar with the error ?