Adb command(s) to get screen state and locked state
I am a Windows fanboy, so the solution contains find instead of using grep, just replace find with grep.

adb shell dumpsys power | find "mWakefulness="
adb shell dumpsys power | find "mHoldingWakeLockSuspendBlocker=" 



  Screen OFF and Locked = mWakefulness=Asleep &amp; 
  mHoldingWakeLockSuspendBlocker=false
  
  Screen ON and Locked = mWakefulness=Awake &amp; 
  mHoldingWakeLockSuspendBlocker=false
  
  Screen ON and Unlocked = mWakefulness=Awake &amp; 
  mHoldingWakeLockSuspendBlocker=true


P.S: I've tested it on Android 7.0, don't know if it'll work with other versions.