When using UIAutomator2 the screen does not turn off when Appium session is created

When I this setup:

  • Appium version: 1.7.1
  • Windows 7:
  • Node.js version: v6.9.2
  • Mobile platform/version: Android 7.0
  • Real device: Samsung J5 2017 model
    and when I start appium like this:
    C:>appium --session-override --address --port 4723 --log-no-colors --l
    og-timestamp --local-timezone --suppress-adb-kill-server --default-capabilities C:\workspa
    ce\default-capabilities.json --log appium.log

and default-capabilities.json contains this:
“newCommandTimeout”: 300,
“noReset”: true,
“fullReset”: false,
“udid”: “12345”,
“automationName”: “uiautomator2”,
“session_override”: true,
“systemPort”: 8200
When my device screen timeout is set to 1min and I run this code:
import time
from appium import webdriver

url = 'http://localhost:4723/wd/hub'
caps = {"platformVersion": "7.0.0",
        "appPackage": "com.android.settings",
        "platformName": "android",
        "appActivity": ".Settings",
        "deviceName": "Samsung_J5"}

driver = webdriver.Remote(url, caps)
print driver.session_id

Then the screen is not turned off when the driver is active. I see on the screen goes dims but it does not turn of completely. When I call driver.quit(), the screen is turned off. Is it possible to somehow configure, in the desired capabilities or somewhere that screen would be turned off when device screen timeout is met?
This is how the screen look like when the

and this is how it looks like when it