With this option you can set up an amount of time after which your phone locks the screen.

Android 9
Step 1:  Open the  settings
Step 2:  Tap on  Security & location
Step 3:  Open the  settings
Step 4:  Tap on  Automatically lock
Step 5:  Choose an  option
  1. Open the settings
  2. Tap on Security & location
  3. Open the settings
  4. Tap on Automatically lock
  5. Choose an option

Android Instructions
Read more