Check this class : com.android.internal.policy.impl.LockScreen
Referenced from here: Can you lock screen from your app?
Also check code for enabling and disabling lock Screen in Android. (Referenced from here)
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
For locking the screen use,
lock.reenableKeyguard();
and for disabling the lock use,
lock.disableKeyguard()