Android Keypad Lock

I am working on an application that will replace the default lock screen (swipe to unlock) for Android devices. I successfully did this by disabling the keyboard manager and showing my activity using a broadcast receiver to turn off the screen and turn on the screen. Now the problem is that I set the default screen lock again for some reason, then my application will not turn off the key lock if I do not close it and start it again.

km = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); if( km.inKeyguardRestrictedInputMode()) { //it is locked km = (KeyguardManager) getApplicationContext().getSystemService(KEYGUARD_SERVICE); kl=km.newKeyguardLock("com.example.helloworld.MainActivity"); kl.disableKeyguard(); } else { Intent i = getIntent(); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(i); } 
+4
source share
2 answers

You cannot replace the lock screen with a user application. All you do is hack and may or may not work on any device, and will most likely break with new releases. You can create something similar to a screen lock, but that will not work. In addition, in recent versions of Android (after ICS), unlocking the screen does extra things, such as unlocking the credential storage, which your application cannot do (because it does not have system permissions).

If you really want to replace the screen lock, you need to create your own Android-ROM by changing / replacing it.

+4
source

The accepted answer may be outdated.

As a result, it is theoretically possible to protect the actual lockscreen with the password generated by the application (providing real security), to float the user lock screen above the Android lock and, when the correct password is provided, to unlock and fire the real lock screen. Finally, you must use the receiver to recover or clear the password on relevant events, such as SCREEN_OFF or SCREEN_ON - the latter can automatically clear the password if the timeout has not yet been reached.

FWIW, I do not recommend this approach, because a failure or uninstallation will leave the user with a locked device with a password that they do not know.

+2
source

Source: https://habr.com/ru/post/1440395/


All Articles