During Development (for simulators) or when using a mobile phone (for Android phones), the lock screen password is sometimes forgotten. What should I do?
There are two solutions: (here I mainly consider for developers (both for modifying the source code )):
Solution 1:
Disable the display of the screen lock interface, that is, the screen lock interface that appears after the launcher is started when the simulator or mobile phone is enabled ). Then, go to the system settings page to reset the password. However, when we enter the system settings page, an unlock password will pop up and we need to enter the lock screen password again for confirmation. So what should we do? Oh, of course, the source code is modified.
The procedure is as follows:
1. Disable the screen lock page that appears after startup ~ /Android2.3/frameworks/base/policy/src/COM/Android/Internal/policy/impl/keyguardupdatemonitor. handleshow () method in Java class. After re-compilation, the screen lock page will not appear after the restart, so that we can go to the home page to perform operations.
2. Let the screen lock and password reset interface appear on the settings page always go through. Both, let the password verification be established here, modify ~ /Android2.3/packages/apps/settings/src/COM/Android/settings/confirmlockpattern. onpatterndetected () method in the Java class.
Public void onpatterndetected (list <lockpatternview. cell> pattern) {</P> <p> If (mlockpatternutils. checkpattern (pattern) {<br/> setresult (result_ OK); <br/> finish (); <br/>} else {<br/> If (pattern. size ()> = lockpatternutils. min_pattern_register_fail & <br/> ++ mnumwrongconfirmattempts> = lockpatternutils. failed_attempts_before_timeout) {<br/> long deadline = mlockpatternutils. setlockoutattemptdeadline (); <br/> handleattemptlockout (deadline); <br/>} else {<br/> updatestage (stage. needtounlockwrong); <br/> postclearpatternrunnable (); <br/>}< br/>}
In addition, you only need to let mlockpatternutils. checkpattern (pattern) determine the condition is true, and then re-compile, start the simulator or mobile phone, enter the setting interface to reset the password.
Solution 2:
Generate a new gesture. key or password. key, etc. This file is generated based on the password type you set (there are nine cells of the pattern/password/pin type ), import the file to the simulator to overwrite the original password file. Then how can we regenerate this. Key File? Here I will take the pattern and password type as an example. The details are as follows:
Check the system source code to see how the system saves the pattern and password. The source code is as follows:
Private Static byte [] patterntohash (list <lockpatternview. cell> pattern) {<br/> If (pattern = NULL) {<br/> return NULL; <br/>}< br/> final int patternsize = pattern. size (); <br/> byte [] res = new byte [patternsize]; <br/> for (INT I = 0; I <patternsize; I ++) {<br/> lockpatternview. cell cell = pattern. get (I); <br/> res [I] = (byte) (Cell. getrow () * 3 + cell. getcolumn (); <br/>}< br/> try {<br/> messagedigest MD = messagedigest. getinstance ("SHA-1"); <br/> byte [] hash = md. digest (RES); <br/> return hash; <br/>} catch (nosuchalgorithmexception NSA) {<br/> return res; <br/>}< br/>}
Source code of lockpatternview. Cell:
Public static class cell {<br/> int row; <br/> int column; <br/> // keep # objects limited to 9 <br/> static cell [] [] scells = new cell [3] [3]; <br/> static {<br/> for (INT I = 0; I <3; I ++) {<br/> for (Int J = 0; j <3; j ++) {<br/> scells [I] [J] = new cell (I, j ); <br/>}< br/>/** <br/> * @ Param row the row of the cell. <br/> * @ Param column the column of the cell. <br/> */<br/> private cell (INT row, int column) {<br/> checkrange (row, column); <br/> This. row = row; <br/> This. column = column; <br/>}< br/> Public int getrow () {<br/> return row; <br/>}< br/> Public int getcolumn () {<br/> return column; <br/>}< br/> ...... <br/>}
Oh, you should have understood it. In the past, the system regarded every cell as the corresponding value in a two-dimensional array. Then save the cell in a list, but the maximum number is 9. Note: It is not that there are only 9 types of passwords, because the password is set based on the route we have drawn, so there are many. Then convert each cell into an array of byte type. Then, the SHA-1 method is used for encryption.
At this point, we should be clear, as long as we define a two-dimensional array. In the two-dimensional array, save the settings we want to set the password, and then encrypt the above method to generate a. Key File. Then replace the original password file in the import simulator. OK. The password has been modified successfully. For the first time, I posted a meager post. If anything is wrong, please forgive me and ask for help.