Android lock screen control

Source: Internet
Author: User

1. Lock screen time

Lock screen time controlCodeLocation: frameworks/base/packages/settingsprovider/src/COM/Android/providers/settings/databasehelper. Java

Private void loadsystemsettings (sqlitedatabase dB ){
......
Loadintegersetting (stmt, settings. system. screen_off_timeout, R. Integer. def_screen_off_timeout );
......

Control Data in: Frameworks/base/packages/settingsprovider/RES/values/defaults. xml

<Integer name = "def_screen_off_timeout"> 60000 </Integer>

60000 is measured in milliseconds, that is, 1 minute. If it is set to-1, the screen is not locked. If this parameter is modified, the screen is still locked after the instance is started, and the screen is no longer locked after the instance is unlocked.

2. Disable lock screen upon startup

The boot screen lock code is located at: Frameworks/base/policy/src/COM/Android/Internal/policy/impl/keyguardviewmediator. Java

/**
* External apps (like the phone app) can tell us to disable the keygaurd.
*/
Private Boolean mexternallyenabled = true;

It can be seen that the screen is locked by default.

The following code is displayed when you search for this variable:

Public void setkeyguardenabled (Boolean enabled ){
Synchronized (this ){
If (Debug) log. D (TAG, "setkeyguardenabled (" + Enabled + ")");

Mexternallyenabled = enabled;
So you canProgramCall setkeyguardenabled to control the screen lock status.

3. Other settings related to lock screen

Pay attention to the Code in step 2 and you will find that many default parameters are set here.

For example:

/*** How long to wait after the screen turns off due to timeout before
* Turning on the keyguard (I. e, the user has this much time to turn
* The screen back on without having to face the keyguard ).
*/
Private Static final int keyguard_delay_ms = 5000;

If you press a button to activate the screen within five seconds after the backlight is disabled, you do not need to unlock it again.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.