In the development of the Android system, there are certain situations that require the system to never lock the screen and never sleep. This article to introduce Android never lock screen, turn on the screen, delete settings in the Sleep time option, need friends to study together.
Android 6.0.1
create:2016-02-29
1.Settings Erase screen Standby option
Packages/apps/settings/res/xml/display_settings.xml
<!--Hide screen sleep
<listpreference
android:key= "Screen_timeout"
android:title= "@string/screen_timeout"
android:summary= "@string/screen_ Timeout_summary "
android:persistent=" false "
android:entries=" @array/screen_timeout_entries "
Comment out this listpreference
Packages/apps/settings/src/com/android/settings/displaysettings.java
Add an if condition, if not found this preference do not perform the relevant operations; You can refer to the hidden Night_mode
Mscreentimeoutpreference = (listpreference) findpreference (key_screen_timeout);
if (mscreentimeoutpreference!=null) {
final long currenttimeout = Settings.System.getLong (resolver, screen_off_ TIMEOUT,
fallback_screen_timeout_value);
Mscreentimeoutpreference.setvalue (string.valueof (currenttimeout));
Mscreentimeoutpreference.setonpreferencechangelistener (this);
Disableunusabletimeouts (mscreentimeoutpreference);
Updatetimeoutpreferencedescription (currenttimeout);
}
2. No lock screen
Frameworks/base/packages/settingsprovider/res/values/defaults.xml
<bool name= "def_lockscreen_disabled" >false</bool> to true; The default is to disable the lock screen
frameworks/base/core/res/res/values/config.xml
<integer name= "Config_multiusermaximumusers" >1</integer> does not allow multiple users, that is, the maximum number of users is 1
Compile Frameworks/base/packages/settingsprovider and Frameworks/base separately
After compiling push to system/priv-app/settingsprovider/settingsprovider.apk System/framework/framework.jar
Delete the corresponding oat catalogue in the machine. Reboot or restore the factory settings. The first time the boot, will appear the status Bar,launcher to wait a while before coming out.
After the reboot, you can go directly into the launcher. The machine will not lock the screen by default. But it's still going to sleep.
SOURCE Flow:
Frameworks/base/packages/settingsprovider/src/com/android/providers/settings/databasehelper.java if ( UpgradeVersion = = 54)//version 54 will be set timeout ... private void upgradescreentimeoutfromnever (Sqlitedatabase db) {//IF
The timeout is-1 (for "Never"). Cursor C = db.query (Table_system, new string[] {"_id", "Value"}, "Name=?
And value=? ", new string[] {Settings.System.SCREEN_OFF_TIMEOUT,"-1 "}, NULL, NULL, NULL);
Sqlitestatement stmt = null; if (C.getcount () > 0) {c.close (); try {stmt = db.compilestatement (INSERT OR REPLACE into system (Name,value) "+" VAL
UES (?,?); "); Set the timeout to minutes in milliseconds loadsetting (stmt, Settings.System.SCREEN_OFF_TIMEOUT, integer.tostring (3
0 * 60 * 1000)); finally {if (stmt!= null) Stmt.close ();}}
else {c.close ();}} ... if (Systemproperties.getboolean ("Ro.lockscreen.disable.default", false) = = True) {loadsetting (stmt,
Settings.System.LOCKSCREEN_DISABLED, "1"); else {loadbooleansetting (stmt, Settings.System.LOCKscreen_disabled, r.bool.def_lockscreen_disabled); }
If the timeout is 1, the screen will never be locked.
Reads "Ro.lockscreen.disable.default" and sets the prohibit lock screen if the default is true; otherwise read configuration from XML
Frameworks/base/packages/settingsprovider/res/values/defaults.xml
<integer name= "Def_screen_off_timeout" >60000</integer>
Prevent lock screen defaults to False
The above content is small set to introduce the installation of Android system never lock screen never sleep method, hope to help everyone.