How to keep service application working in screen off state

Locks and releases the given lock state for a specified time.