Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set lockscreen to "None" programmatically?

I have the requirement to disable the lock screen and set the lock screen type to "None". My device is rooted (can run with SU permission) + can run as a system application with system permissions (under /system/app).

I have tried a few things to no avail.

Try 1

This seems to be deprecated and not working.

KeyguardManager manager = (KeyguardManager) this.getSystemService(KEYGUARD_SERVICE);
KeyguardLock lock = manager.newKeyguardLock("abc");
lock.disableKeyguard(); 

Try 2

This didn't work either.

  1. Mount system partition as writable
  2. Edit /data/data/com.android.providers.settings/databases/settings.db
  3. Execute the following SQL.

    INSERT OR REPLACE INTO system (name, value) VALUES ('lockscreen.disabled', '1');
    INSERT OR REPLACE INTO secure (name, value) VALUES ('lockscreen.disabled', '1');

Try 3

Rebooted the machine but still no luck.

android.provider.Settings.Secure.putLong(mContentResolver, Settings.Secure.LOCK_PATTERN_ENABLED, false);`
android.provider.Settings.Secure.putLong(mContentResolver, "lockscreen.password_type", DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);`
android.provider.Settings.Secure.putLong(mContentResolver, "lockscreen.password_type_alternate", DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
android.provider.Settings.Secure.putLong(mContentResolver, "lockscreen.disabled", true);

Is there anything else that I can try?

Please note that I do not want to disable the keyguard only when application is running.

like image 771
Ranhiru Jude Cooray Avatar asked Mar 03 '14 09:03

Ranhiru Jude Cooray


1 Answers

You can try this:

adb shell sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '1' WHERE name = 'lockscreen.disabled'"

adb shell sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '0' WHERE name = 'lockscreen.password_type'"

adb shell sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '0' WHERE name = 'lockscreen.password_type_alternate'"

It works on my rooted Nexus 4.

like image 102
superb Avatar answered Sep 22 '22 18:09

superb