I have to check whether system lock was enabled or not in settings.
I used below line code
boolean b = android.provider.Settings.System.getInt(
@Peter Pint
int lockProtectionLevel = (int)method.invoke(lockUtils);
...should instead be...
int lockProtectionLevel = Integer.valueOf(String.valueOf(method.invoke(lockUtils)));
But otherwise, right on! I've upvoted your answer.