I would like to explore exilit answer. From the source, we finally get into this:
mChooseLockSettingsHelper.utils().clearLock(false);
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled);
The utils is the com.android.internal.widget.LockPatternUtils
object and we can somehow get it by reflection. Here is the code:
try{
Class lockPatternUtilsCls = Class.forName("com.android.internal.widget.LockPatternUtils");
Constructor lockPatternUtilsConstructor =
lockPatternUtilsCls.getConstructor(new Class[]{Context.class});
Object lockPatternUtils = lockPatternUtilsConstructor.newInstance(MyActivity.this);
Method clearLockMethod = lockPatternUtils.getClass().getMethod("clearLock", boolean.class);
Method setLockScreenDisabledMethod = lockPatternUtils.getClass().getMethod("setLockScreenDisabled", boolean.class);
clearLockMethod.invoke(lockPatternUtils, false);
setLockScreenDisabledMethod.invoke(lockPatternUtils, true);
Log.d(TAG, "set lock screen to NONE SUC");
}catch(Exception e){
Log.e(TAG, "set lock screen to NONE failed", e);
}