1 Principle
Android has three screen unlocking protections: Pattern unlocking, PIN password unlocking, and password unlocking.
The interface is as follows:
Chart 1 pattern unlocking page
Figure 2 PIN password unlock page
Figure 3 password unlock page
We can use java. lang. object. android. app. keyguardLock, a subclass of KeyguardManger, can control the Disable screen lock interface, so as to directly go through the screen lock interface without entering a password to use the mobile phone. disableKeyguard () and KeyguardLock. enableKeyguard () method for Disable and enable screen lock Interface
2. Code Description
The main code of the Demo program is as follows:
// Obtain KeyguardManagerKeyguardManager manager = (KeyguardManager) getSystemService (KEYGUARD_SERVICE );
If (manager. inKeyguardRestrictedInputMode ()){
// In the locked interface, the interface is unlocked through the KeyguardLock Class Method
KeyguardLock keyguard = manager. newKeyguardLock (getLocalClassName ());
Keyguard. disableKeyguard ();
}
Permission required:
3 conclusion
1. Use this method on the pattern lock Interface
After the disableKeyguard () method is called to lock the screen with the disable pattern, pressing the home key will trigger the screen lock Interface enable to re-display the screen lock interface.
2. Pin password lock interface using this method
After the disableKeyguard () method is called and the disable pattern interface is displayed, a pop-up screen is displayed when you press the home Key. Does not return to the home page
3. Use this method on the password lock Interface
After the disableKeyguard () method is called and the disable pattern interface is displayed, a pop-up screen is displayed when you press the home Key. Does not return to the home page
Although I don't know why Google provides such an api, developers can use this api to almost make the screen lock protection function of Android useless, the exception of the home key after this method is called should be a bug.
4 Demo
Because the screen lock can only install Apk through the software such as the pea pod on the computer at regular intervals, and cannot start apk, this Demo program is written as start-up, that is, when the screen lock is enabled, after installing the software, such as a computer pea pod, restart the software to implement the Pass screen lock interface.
Android 2.2, 2.3, and 4.0 platforms passed the test.