Whether screen lock exists in Android Setting

Source: Internet
Author: User

First, I wrote a blog in front of android to remove screen lock. Here I want to improve it, this is because in our cell phone we have selected whether to "unlock the screen lock" in the "Auxiliary Function" of "Settings" (that is, whether the screen lock exists when the screen is turned on by pressing the power key ). What I want to do here is to add this function to the native android source code, mainly to implement this function based on learning. Before reading this, I hope you can take a look at this blog about how to remove screen lock from android. First, after completing the desktop loop, add this item to the "Auxiliary Function" in "Settings": first look at an image: here, the screen lock is what we want to add. Let's talk about the idea first: first make the interface, and then save the selected value to the system (adb shell enters) data/com. android. providers. settings/databases/settings. in the system table of the db database, go to framework/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator. in the java source code, obtain whether or not the circular desktop is selected in the database to execute the relevant code. UI first: Add a checkbox: [java] To the accessibility_settings.xml file in the settings source code. <! -- Add by xxnan --> <CheckBoxPreference android: key = "lock_screen" android: title = "@ string/lock_screen_title" android: persistent = "false"/> Add the relevant code in res of the settings source code: In values/string. add in xml (displayed in English): <string name = "lock_screen_title"> Lock_Screen </string> in values-zh-rCN/string. add in xml (Chinese display): <string name = "lock_screen_title" msgid = "4676390750360727396"> "cyclic desktop" </string> In the AccessibilitySettings of the settings source code. onCrea in java Add in te: [java]/********************************** * ***/mLockScreen = (CheckBoxPreference) findPreference (LOCK_SCREEN); int LockScreen = Settings. system. getInt (this. getContentResolver (), "lock_screen", 0); // you can determine whether to select if (LockScreen = 1) mLockScreen. setChecked (true); // if selected, select else mLockScreen next time you open setting. setChecked (false); // if not selected, the next time you open setting, you will not select /******************************** * ********/Of course, the number of parameters must be defined. Quantity: private final String LOCK_SCREEN = "lock_screen"; private CheckBoxPreference mLockScreen; add: [java] // add by xxnan if (LOCK_SCREEN.equals (key) {Settings. system. putInt (getContentResolver (), "lock_screen", (CheckBoxPreference) preference ). isChecked ()? 1-0); // select whether to store the data in the system table} // add by xxnan. If yes, click "desktop loop". (adb shell enters) data/com. android. providers. settings. db database (sqlite3 settings. in db), lock_screen | 1 (select * from system;) is displayed in the system table ;). By now, the data is saved to the system table and UI, and then in framework/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator. java source code to get this value. In the framework/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator. in the private void handleShow () method in java: [java] mKeyguardViewManager. show (); mShowing = true; adjustUserActivityLocked (); adjustStatusBarLocked (); changed: [java]/********************************** * ************* // modifidy by xxnan lock_screen = Settings. system. getInt (mContext. getContentResolver (), "lock_screen", 0); // retrieve syst Whether to cancel the screen lock value in the em table if (lock_screen = 0) // if {mKeyguardViewManager is not canceled. show (); mShowing = true; adjustUserActivityLocked (); adjustStatusBarLocked ();} /*************************************** * **********/and in private void handleHide () the method must also be modified as follows: [java] mKeyguardViewManager. hide (); mShowing = false; adjustUserActivityLocked (); adjustStatusBarLocked (); changed: [java]/********************************** ***** * ************/Lock_screen = Settings. system. getInt (mContext. getContentResolver (), "lock_screen", 0); // set the value from the database to if (lock_screen = 0) {mKeyguardViewManager. hide (); mShowing = false; adjustUserActivityLocked (); adjustStatusBarLocked ();} /*************************************** * ************/Of course, a few quantities must be defined here, and Import several packages: import package: // add by xxnanimport android. content. contentResolver; // retrieves data from the system table import android. provid Er. settings; defines the variable: private int lock_screen; // you can modify all the obtained cyclic values here, also, compile the settings source code of package/apps in the source code and the policy source code of framework/base to generate out/target /... Use settings.apk in/system/appand android. policy. jar in system/framework to replace settings.apk in system/appand android. policy. jar in system/framework.

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.