Pattern Lock: "locked out permanently"-fix - Desire Android Development

hi there
maybe someone had the problem being locked out (not temporarily!)
my complete solution now is:
Code:
adb -d shell
sqlite3 data/data/com.android.providers.settings/databases/settings.db
sqlite> update secure set value=0 where name='lock_pattern_autolock';
sqlite> update secure set value=2726148 where name='lockscreen.lockoutattemptdeadline';
sqlite> delete from secure where name='lockscreen.lockedoutpermanently';
sqlite> .exit
# exit
detailed step-by-step instruction on demand.
troubleshooting:
if you get an "sqlite3 not found" error (like me) you can use titanium backup's sqlite3 (only pro? can somebody confirm?) by replacing "sqlite3" by "/data/data/com.keramidas.TitaniumBackup/files/sqlite3" in the 2nd line of code.
disabled usb debugging:
boot into recovery (clockworkmod in my case) and plugin the phone
my solution is a bit different from haykuro's one here -> G1 General > Pattern Lock.. Defeated! as you can see below:
the key 'lock_pattern_autolock' has been moved from system to secure
added some more sql (maybe you aren't forced to execute them but i recommend it)
regards
auipga

Related

[HOWTO] Use pattern lock and device encryption

Normally, a pattern/gesture lock is not available when device encryption is activated.
But the lockscreen can be reactivated by changing the corresponding settings in /data/data/com.android.providers.settings/databases/settings.db to the values used for the pattern lock before enabling device encryption, namely resetting lockscreen.password_type to PASSWORD_QUALITY_SOMETHING.
If you don't run Android 4.0.4, you may verify that android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING still corresponds to 0x10000.
Enter a root shell and execute:
Code:
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='65536' WHERE name = 'lockscreen.password_type'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lockscreen.patterneverchosen'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lock_pattern_autolock'"
Generate a new gesture.key with the attached perl script (call it without arguments for help) and transfer it to the device:
Code:
mv gen-gesture.key.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
./gen-gesture.key.pl 01258 > gesture.key
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^C
Reboot the device.
This was tested on my Samsung Galaxy S3 with Android 4.0.4.
Thanks to robberknight who initiated a thread about PIN locks and encryption.
Thanks for the post!
I tried this today with my Samsung Galaxy Note 2 but it didn't work (Android 4.1)
The only thing I couldn't do (regarding to your how-to) was using the sqlite3 command from the shell, because there is no sqlite3 on my device (installing it with "SQLite Installer for root" didn't work either, I'm getting a "CANNOT LINK EXECUTABLE" error). So I just pulled the settings.db to my computer, editied it with an sqlite-manager and pushed it back. But I guess this shouldn't make any difference ...
I simply can't get rid of the password unlock screen, no matter what I enter in the sqlite database.
And I would be happy if I could even use a PIN instead of an alphanumeric password (which is the only option for encryption now)
By the way, what did you mean with "If you don't run Android 4.0.4, you may verify that android.app.admin.DevicePolicyManager.PASSWORD_QUA LITY_SOMETHING still corresponds to 0x10000."?
On my phone this constant is 65536
Right now this would be my lock-settings from the settings.db:
"103","lock_after_timeout_rollback","60000"
"35","lock_motion_tilt_to_unlock","0"
"107","lock_pattern_autolock","1"
"108","lock_pattern_visible_pattern","0"
"104","lock_screen_lock_after_timeout","60000"
"94","lock_screen_owner_info","..."
"95","lock_screen_owner_info_enabled","1"
"59","lock_screen_quick_note","1"
"36","lock_signature_visible_pattern","1"
"29","lockscreen.disabled","0"
"109","lockscreen.lockexchange.enable","0"
"34","lockscreen.options","enable_facelock"
"105","lockscreen.password_type","65536"
"106","lockscreen.patterneverchosen","1"
Found the solution on my own: Just delete the /data/system/locksettings.db (this one was empty on my device anyway)
After a restart the lock-keys of settings.db now finally work. I guess there is some caching in place and removing the locksettings.db forces Android to update the settings of the lock-screen.
Hello!
This sounds very interesting.
How to define the unlock pattern:
Does the perl-script create a pattern/gesture that corresponds to the digits you entered. In your example:
gen-gesture.key.pl 01258 > gesture.key - This makes your pattern 01258? (Since there is no dot inte 3x3 pattern matrix to represent a "0" then this cannot be correct.)
How do I define the pattern I want to use then? Is this done separately by going in to the settings later when the phone is booted? I don't dare to do this in fear of "locking" the device with a pattern/gesture that I don't know.
I hope to get your help here...
Thank you!
Thank you very much mod23! My phone is finally usable again
Works as described on Galaxy R with leaked ICS.
-Android Freak- said:
This makes your pattern 01258? (Since there is no dot inte 3x3 pattern matrix to represent a "0" then this cannot be correct.)
Click to expand...
Click to collapse
Was confused at first as well, but running the perl script without arguments tells us:
0 1 2
3 4 5
6 7 8
Afterwards, you won't be able to change it in the settings. I think you have to newly generate the gesture.key
Warning
I do not want to give lessons to anybody, but just to highlight how the unlock pattern protection is low, thwarting almost certainly the extra layer of protection that is supposed to be brought by Android full-phone encryption. Just consider the following remarks:
1) Contrary to a PIN code, pattern lock equivalent digits will be linked to each other (except if you are really really cunning). For example, if you start at digit 0, the following digits are to be 1,4 or 3. Thus decreasing dramatically the entropy of the underlying number.
2) You can't use the same digit two times. As an example, try the greek PHI symbol. The equivalent PIN code can't be 03452147, because 4 can't be used two times. The equivalent code must be simpler: 034521 7. You will agree that this greatly reduces the number of possible equivalent PIN codes you can achieve with pattern lock.
3) The protection mechanism offered by Android is way too weak in my opinion for such lock mechanism. After 3 failed attempts, your phone just ask you to wait for 30 sec. It does not shutdown.
4) But the killing argument is: you have grease under your fingers. Except if you systematically think to wipe the screen of your phone after unlocking your phone, the gesture will let a fingerprint corresponding to the gesture you will repeat several times per day. Try by yourself, and see how easy it is to see the lock pattern used with an oblique light source.
So, if I was to steal your phone to have access to your personal data you think secured by encryption, I would
1) Steal your phone when it is on
2) Realize that it is "protected" by lock pattern
2) Use an oblique light with the almost certainty that I will see the fingerprint of the pattern lock (except if you wipe systematically your screen, or you wash your hands always before unlocking your phone).
3) Try to draw the pattern in one direction.
4) Try it in the other direction if it fails. Almost sure to unlock the phone at this point (except if the pattern is really really intricate).
5) Once your phone is unlocked, I could do whatever I would want to with it. So no need to be the king of crackers.
I hope, after reading this, you will reconsider using pattern lock in parallel to encryption. In my opinion, it is a total nonsense. But it is my only personal opinion. Just judge by yourself.
Edit:
------
For me, the only way, both secure and practical, to secure your phone is by using a PIN code of at least 4 numbers (6 is better). PIN codes let fingerprints much harder to "interpret" than unlock pattern. Then use a handy tool like EncPassChanger to have a true complex password for decryption at boot time. And, if you are clearly paranoid, follow this great tip: http://forum.xda-developers.com/showpost.php?p=26730989&postcount=2.
And, something that people may forget, always double check that USB debugging is disabled.
lolo250612 said:
For me, the only way, both secure and practical, to secure your phone is by using a PIN code of at least 4 numbers (6 is better). PIN codes let fingerprints much harder to "interpret" that unlock pattern. Then use a handy tool like EncPassChanger to have a true complex password for decryption only at boot time. And, if you are clearly paranoid, follow this great tip: http://forum.xda-developers.com/showpost.php?p=26730989&postcount=2.
Click to expand...
Click to collapse
There is one big problem with your solution: The SD card. The SD card is encrypted with your PIN Code as well, which is stored in the same file as your screen-unlock-PIN code. I have no idea why the Google developers choose to use the same file for everything, but they did. So your solution is a good idea as long as you don't care about the security of your SD card.
On my phone (Lenvo A789, with ICS 4.0.4), the sdcards (both internal and external) are not encrypted at all. Only /data and other "system" partitions. You can view them with Terminal Emulator, by typing the mount command. The encrypted partitions correspond to /dev/block/dm-x (x is a number). Just to be clear, I mean "sdcards", the partition /mnt/sdcard or /mnt/sdcard2 as reported by Android and mounted as such.
Anyway. I am certainly not an expert in security. I am just trying to document myself to have an overview of the security mechanisms I use. But, if I am right, your encrypted partitions are not encrypted directly with your password or your PIN code. They are encrypted by a random key generated by Android when you start the encryption process. This master key is then encrypted itself at first by your PIN code (if you choose this option) before being saved in a file. That's what allows the user to change his password without having to re-encrypt everything. And I agree with you, this is a major security flaw, as a password with only digits can be cracked in a few µsec by a casual PC, if somebody has access physically to the content of your phone memory and this key file.
This is where EncPassChanger acts. It reencrypts your master key (not the data itself) with a password that can be complex as you don't type it everytime you unlock your phone.
So you have your PIN code to unlock your phone when it is on ( and only when it is on); it does not decrypt anything, decryption only occurs at boot time; it just gives you access to the UI and allows you to interact with your phone. And you have a strong password for the encryption of the data that lay physically on the memory (even when the phone is off), that allows Android to decrypt your master encryption key at boot, and therefore your data. And the PIN code cannot be used to decrypt your encryption master key any longer.
"Online" protection (phone lock) and "offline" protection (encryption of data lying "physically" on the memory) are really two different things. They become completely disconnected from each other once you use EncPassChanger to make the encryption/decryption password different from the initial PIN code. The only thing you have to be careful about, is that if you change your PIN code for whatever reasons, Android reencrypts the master encryption key with this new PIN code, droping the job done previously by EncPassChanger. So you have to use it again.
And the fact that, for a reason I don't see clearly, your sdcard would be encrypted as well as /data, does not change anything to that.
But I may be wrong, don't I ?
For more extensive details, see: http://nelenkov.blogspot.fr/2012/08/changing-androids-disk-encryption.html and http://source.android.com/tech/encryption/android_crypto_implementation.html
And even more details (Android encryption is in fact more or less Linux LUKS): http://www.markus-gattol.name/ws/dm-crypt_luks.html
Confirmed working on Nexus 10 and Nexus 4 with 4.2.2
Check for records in settings.db first!
If they don't exist, use this method.
On newer devices, the fields above do not exist in the settings.db file once encryption has been activated. The proper way to do this for a device is to confirm the settings are there, and if not, go through the below process (note the INSERTs instead of UPDATEs).
Create gesture.key using the Perl script and copy to SDCARD
Ensure device is unlocked and keep screen active while running the below code. If the device locks, you can get stuck on a black screen after removing /data/system/locksettings.db.
Run the below code.
Code:
su -
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.password_type', '65536')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.patterneverchosen', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_autolock', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_visible_pattern', '1')"
cat /mnt/sdcard/gesture.key > /data/system/gesture.key
rm /data/system/locksettings.*
Reboot
Lastly, combine with EncPassChanger to use a 20+ character encryption password at boot to ease your mind about brute force attempts.
Thanks,
Ben
Fmstrat said:
Confirmed working on Nexus 10 and Nexus 4 with 4.2.2
Check for records in settings.db first!
If they don't exist, use this method.
On newer devices, the fields above do not exist in the settings.db file once encryption has been activated. The proper way to do this for a device is to confirm the settings are there, and if not, go through the below process (note the INSERTs instead of UPDATEs).
Create gesture.key using the Perl script and copy to SDCARD
Ensure device is unlocked and keep screen active while running the below code. If the device locks, you can get stuck on a black screen after removing /data/system/locksettings.db.
Run the below code.
Code:
su -
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.password_type', '65536')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.patterneverchosen', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_autolock', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_visible_pattern', '1')"
cat /mnt/sdcard/gesture.key > /data/system/gesture.key
rm /data/system/locksettings.*
Reboot
Lastly, combine with EncPassChanger to use a 20+ character encryption password at boot to ease your mind about brute force attempts.
Thanks,
Ben
Click to expand...
Click to collapse
Thanks for the update. I want to give this a try on my Razr Maxx HD running 4.1.1, any idea if this will work? Also, in your info here, your code says:
Code:
('lockscreen.password_type', '65536')"
But isn't it impossible to use the same number twice? Not sure I understand this correctly if that is a true pattern lock sequence.
gadsden said:
Thanks for the update. I want to give this a try on my Razr Maxx HD running 4.1.1, any idea if this will work? Also, in your info here, your code says:
Code:
('lockscreen.password_type', '65536')"
But isn't it impossible to use the same number twice? Not sure I understand this correctly if that is a true pattern lock sequence.
Click to expand...
Click to collapse
I don't see any reason why it wouldn't work, but of course, no guarantees. As for the password_type, 65536 is a code saying "use the pattern lock", it is not the same as the string of numbers used with the python file to create your gesture.key file.
Thanks,
Ben
Fmstrat said:
Confirmed working on Nexus 10 and Nexus 4 with 4.2.2
Check for records in settings.db first!
If they don't exist, use this method.
On newer devices, the fields above do not exist in the settings.db file once encryption has been activated. The proper way to do this for a device is to confirm the settings are there, and if not, go through the below process (note the INSERTs instead of UPDATEs).
Create gesture.key using the Perl script and copy to SDCARD
Ensure device is unlocked and keep screen active while running the below code. If the device locks, you can get stuck on a black screen after removing /data/system/locksettings.db.
Run the below code.
Code:
su -
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.password_type', '65536')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lockscreen.patterneverchosen', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_autolock', '1')"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name, value) values ('lock_pattern_visible_pattern', '1')"
cat /mnt/sdcard/gesture.key > /data/system/gesture.key
rm /data/system/locksettings.*
Reboot
Lastly, combine with EncPassChanger to use a 20+ character encryption password at boot to ease your mind about brute force attempts.
Thanks,
Ben
Click to expand...
Click to collapse
Ok, I'm ready to do this, but I am afraid I have no idea what I'm doing! I couldn't find the settings.db like you said might happen. I tried running the perl script, but got permission denied when it tried to create /data/system/gesture.key. It did create the key and push it to the device, but then it stopped there.
After I verified it did push the gesture.key, I tried running the sqlite3 code in root shell. Some of the commands said adb does not recognize this command as an internal or external command. I have never ran commands like the ones shown here for sqlite3. My adb experience is pretty limited to following directions to root. I have done manual roots in adb, so I understand some basic commands, but this is out of my league! Can you help me a little bit to do this with some steps that are more beginner-ish? If you can help me out (PM is fine), I'll be glad to type out the instructions in an organized way for others to follow in the future. I really want to be able to set this up, any help would be greatly appreciated.
Ok, I think I need to stop messing with this now, been working on it all day! I ran all the sqlite3 commands you said, and got stuck at the cat command. It says no such file or directory. I think I did the perl script wrong and never got the gesture key done right. It pushed a file called gesture.key, but I don't know if it's right. I am not sure how to run the perl script, really. I have to get back to my job that I haven't done anything at today, yikes! Any help is appreciated.
Ok, I didn't quite understand the concept of how this worked yesterday, so I spent some more time on it today. I thought the perl script was to be ran from the PC. I didn't understand that I was supposed to be loosely following the steps in the other thread referenced here. Having no experience whatsoever with python, I didn't know what to do. Now, I understand the process, I am just having a little trouble. So far I have followed these instructions.
Fmstrat said:
Check for records in settings.db first!
If they don't exist, use this method.
Click to expand...
Click to collapse
I looked and could not find this, so I proceeded as described.
azoom1 said:
1) Load SLA4
2) Menu-View-Interpreters
3) Menu-Add
4) Select Python 2.6.2 - the SLA4 app will go get Python and intall it with the correct linking
5) Exit SLA4, then start Python and select Install, and when finished, exit Python
6) Put the pin_change.py file in the SLA4 "scripts" directory
7) Start SLA4
After that, when SLA4 is run you should see the script in the pick list. Upon selection SLA4 will pop-up an icon select-list. Pick the gear, which will run the script.
Click to expand...
Click to collapse
(I pasted this from the other thread, I did not use the script name here, I did use gen-gesture.key.py)
I installed SLA4 as described here and went to run the script with the gear icon. When I run it, all I get is a notification that gen-gesture.key.py was exited. Reading that I am supposed to generate the key, then copy it to the SD card, I thought maybe it did generate the gesture.key and I just have to find it, but I looked everywhere through files and couldn't find the file anywhere. I did locate a log file, gen-gesture.key.py.log, but it was blank, nothing to see.
Thinking there might have been a problem with the script, I tried to use the QR code here, but python said "Invalid QR code content". I double checked my script and I don't appear to have missed anything when I copied it, so I am lead to believe there is something else I am missing about how to use python. Only other thing I can think of that's wrong is the script extension, I used .py to run it in python, but wonder if it's supposed to be .pl since it's perl, or if I need .py to run it in python and the script runs as a perl script like that.
So, I am trying really hard to do this, I'm trying to learn on my own, but a little help would be really nice if anyone is able.
Bumped for help!
gadsden said:
Bumped for help!
Click to expand...
Click to collapse
You should not need to follow any directions in another thread. The Perl script is intended to be run on a PC, not on the phone, so there is no need for Perl to be installed. Running the script with out any arguments prints out the pattern of the android lock screen but instead of dots it has numbers. Run the script with the numbers after it as provided in the example in post number 1 to create the gesture.key file on your PC. Then copy that file over to the phone as described.
I'm also a little confused by your comment about not finding settings.db. I can think of no reason why the file would not exist, unless you mean that the records were not in the database file.
Thanks,
Ben
Fmstrat said:
You should not need to follow any directions in another thread. The Perl script is intended to be run on a PC, not on the phone, so there is no need for Perl to be installed. Running the script with out any arguments prints out the pattern of the android lock screen but instead of dots it has numbers. Run the script with the numbers after it as provided in the example in post number 1 to create the gesture.key file on your PC. Then copy that file over to the phone as described.
I'm also a little confused by your comment about not finding settings.db. I can think of no reason why the file would not exist, unless you mean that the records were not in the database file.
Thanks,
Ben
Click to expand...
Click to collapse
You said to check for records in settings.db first. When I search through my files, I can locate the directory data/data/com.android.providers.settings, but there is nothing inside of it. So, I did run the sqlite codes. I ran each line separately, and it said Error:too many options. So, I ran them all together and no errors came back. However, I still can't find anything in the directory.
Then to run the script, there is an attached file here called gen-gesture.key.pl.txt. Am I supposed to put that file into my platform tools folder and use the mv gen-gesture.key code to call the script? Or do I paste the text in the txt file into adb? I have tried running everything explained here in root shell in adb, I thought that was how I am supposed to do it, but I seem to be missing something. Sorry for the basic questions, but I'm still learning here.
Fmstrat said:
You should not need to follow any directions in another thread. The Perl script is intended to be run on a PC, not on the phone, so there is no need for Perl to be installed. Running the script with out any arguments prints out the pattern of the android lock screen but instead of dots it has numbers. Run the script with the numbers after it as provided in the example in post number 1 to create the gesture.key file on your PC. Then copy that file over to the phone as described.
I'm also a little confused by your comment about not finding settings.db. I can think of no reason why the file would not exist, unless you mean that the records were not in the database file.
Thanks,
Ben
Click to expand...
Click to collapse
Here's what I did so far.
1) Installed perl because it wasn't on my computer
2) changed permissions on /data/data/com.android.providers.settings/databases/settings.db to 777 so I could view the files in DDMS. Checked the settings.db and when I outputted it as a text file, all I got was a blank document
3) installed sqlite3 on my phone with sqlite installer
4) Entered root shell and entered
Code:
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='65536' WHERE name = 'lockscreen.password_type'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lockscreen.patterneverchosen'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lock_pattern_autolock'"
I didn't know if I was supposed to run each line individually, or all at once, so I did it both ways. neither one had an error
5) Saved the gen-gesture.key.pl.txt file to my platform tools folder. Ran
Code:
perl gen.gesture.key.pl.txt
It came back with this
Code:
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>perl C:\Android\ad
t-bundle-windows-x86-20130219\sdk\platform-tools\gen-gesture.key.pl.txt
Usage: gen-gesture.key.pl <sequence>
With sequence as number sequence drawn on this keypad:
0 1 2
3 4 5
6 7 8
The generated binary output has to be put into: /data/system/gesture.key
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>
6) then entered this all at once
Code:
mv gen-gesture.key.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
./gen-gesture.key.pl 01258 > gesture.key
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^C
it came back with a bunch of errors and left me at root shell. I figured maybe I was supposed to run it from root shell anyway, so I entered it again. The very first command came back as "mv" is not a recognized internal or external command. I tried it a couple more times, but I'm not following what's supposed to happen here. I did do a reboot of the phone and when I did so, the lock settings were disabled. So, something is happening, but not everything that needs to. I I've probably spent over 12 hours on this over the past week and I am sure I'm doing it wrong. The OP doesn't describe in detail how a beginner needs to do this. I've learned as much as I can, but seeing as how I even got stuck on not knowing I needed to install perl, I'm positive that I'm missing more. The post just isn't beginner friendly. I'm trying hard to understand this but I'm becoming really discouraged here. Can someone provide a little more info here.
Here's the whole session if it helps
Code:
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>perl C:\Android\ad
t-bundle-windows-x86-20130219\sdk\platform-tools\gen-gesture.key.pl.txt
Usage: gen-gesture.key.pl <sequence>
With sequence as number sequence drawn on this keypad:
0 1 2
3 4 5
6 7 8
The generated binary output has to be put into: /data/system/gesture.key
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ # mv gen-gesture.key.pl.txt gen-gesture.key.pl && chmod +x gen-g
esture.key.pl
./gen-gesture.key.pl 01258 > gesture.key
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
n-gesture.key.pl && chmod +x gen-gesture.key.pl <
sh: ^Cmv: not found
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
127|[email protected]:/ # ./gen-gesture.key.pl 01258 > gesture.key
sh: can't create gesture.key: Read-only file system
1|[email protected]:/ # adb push gesture.key /mnt/sdcard/Download/
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
error: device not found
1|[email protected]:/ # adb shell
error: device not found
1|[email protected]:/ # su -
re.key > /data/system/gesture.key <
[email protected]:/ #
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ # exit
^Cexit
sh: ^Cexit: not found
127|[email protected]:/ # exit
exit
127|[email protected]:/ $ exit
exit
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ #
Been working on this for a whole week now, just wondering if I'm even on the right track here?
gadsden said:
Here's what I did so far.
1) Installed perl because it wasn't on my computer
2) changed permissions on /data/data/com.android.providers.settings/databases/settings.db to 777 so I could view the files in DDMS. Checked the settings.db and when I outputted it as a text file, all I got was a blank document
3) installed sqlite3 on my phone with sqlite installer
4) Entered root shell and entered
Code:
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='65536' WHERE name = 'lockscreen.password_type'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lockscreen.patterneverchosen'"
sqlite3 -batch /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='1' WHERE name = 'lock_pattern_autolock'"
I didn't know if I was supposed to run each line individually, or all at once, so I did it both ways. neither one had an error
5) Saved the gen-gesture.key.pl.txt file to my platform tools folder. Ran
Code:
perl gen.gesture.key.pl.txt
It came back with this
Code:
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>perl C:\Android\ad
t-bundle-windows-x86-20130219\sdk\platform-tools\gen-gesture.key.pl.txt
Usage: gen-gesture.key.pl <sequence>
With sequence as number sequence drawn on this keypad:
0 1 2
3 4 5
6 7 8
The generated binary output has to be put into: /data/system/gesture.key
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>
6) then entered this all at once
Code:
mv gen-gesture.key.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
./gen-gesture.key.pl 01258 > gesture.key
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^C
it came back with a bunch of errors and left me at root shell. I figured maybe I was supposed to run it from root shell anyway, so I entered it again. The very first command came back as "mv" is not a recognized internal or external command. I tried it a couple more times, but I'm not following what's supposed to happen here. I did do a reboot of the phone and when I did so, the lock settings were disabled. So, something is happening, but not everything that needs to. I I've probably spent over 12 hours on this over the past week and I am sure I'm doing it wrong. The OP doesn't describe in detail how a beginner needs to do this. I've learned as much as I can, but seeing as how I even got stuck on not knowing I needed to install perl, I'm positive that I'm missing more. The post just isn't beginner friendly. I'm trying hard to understand this but I'm becoming really discouraged here. Can someone provide a little more info here.
Here's the whole session if it helps
Code:
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>perl C:\Android\ad
t-bundle-windows-x86-20130219\sdk\platform-tools\gen-gesture.key.pl.txt
Usage: gen-gesture.key.pl <sequence>
With sequence as number sequence drawn on this keypad:
0 1 2
3 4 5
6 7 8
The generated binary output has to be put into: /data/system/gesture.key
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ # mv gen-gesture.key.pl.txt gen-gesture.key.pl && chmod +x gen-g
esture.key.pl
./gen-gesture.key.pl 01258 > gesture.key
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
n-gesture.key.pl && chmod +x gen-gesture.key.pl <
sh: ^Cmv: not found
adb push gesture.key /mnt/sdcard/Download/
adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
127|[email protected]:/ # ./gen-gesture.key.pl 01258 > gesture.key
sh: can't create gesture.key: Read-only file system
1|[email protected]:/ # adb push gesture.key /mnt/sdcard/Download/
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
error: device not found
1|[email protected]:/ # adb shell
error: device not found
1|[email protected]:/ # su -
re.key > /data/system/gesture.key <
[email protected]:/ #
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ # exit
^Cexit
sh: ^Cexit: not found
127|[email protected]:/ # exit
exit
127|[email protected]:/ $ exit
exit
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>mv gen-gesture.key
.pl.txt gen-gesture.key.pl && chmod +x gen-gesture.key.pl
'mv' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>./gen-gesture.key.
pl 01258 > gesture.key
'.' is not recognized as an internal or external command,
operable program or batch file.
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb push gesture.k
ey /mnt/sdcard/Download/
C:\Android\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb shell
su -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
^Csu -
cat /mnt/sdcard/Download/gesture.key > /data/system/gesture.key
[email protected]:/ $ su -
re.key > /data/system/gesture.key <
[email protected]:/ #
Click to expand...
Click to collapse
thx

[GUIDE] Changing your WIFI/Bluetooth MAC address

Hi All
In my quest of trying to restore my phone to its original state after a hard-brick resurrection, I came up with a procedure to restore/change the WIFI-BT mac addresses.
So hoping that it could be helpful to the community, I'm sharing it with you.
I'm also writing a post about my investigations concerning the Radio/WLAN low level configuration.
As soon as it is ready I'll add a link here, so if you're willing to help or if you're interested in my investigations, stay tuned !!!
1. Prerequisite:
- Rooted and S-OFF Desire S
- USB Debug must be enabled on the phone
- Fast Boot must be disabled on the phone
- Android tools installed (look for tutorial in this forum on how to install them.)
- I assume that you already know how to use the android tools.
2. Disclaimer
- I decline all responsibilities for bricked phone and such.
- You're using this procedure at your own risk.
3. The Theory:
The Radio/WLAN configuration is stored in the mmcblk0p23 partition.
3.a. Changing the WIFI MAC address.
The WIFI configuration is located at the beginning of the partition:
Offset 0x0000000C : the length of the wifi configuration file. (2 bytes little-endian)
Offset 0x00000010 : 32bits CRC checksum of the wifi configuration file
Offset 0x00000040 : the actual wifi configuration file.
Offset 0x000110CC : the wifi mac address (Only informative - not used by the system).
The WIFI configuration "file" contains the MAC address along with other configuration parameters. And these other parameters depends on the revision of your phone's motherboard (and maybe other parameters as well)
The integrity of this "file" is also protected by the CRC checksum located at offset 0x00000010.
So you cannot just change the MAC address in this file as HBOOT will detect it at boot time and restore a "factory" default configuration.
The trick is to have HBOOT restore a "factory" default configuration with the MAC address you want to use.
For this, you should look in the HBOOT partition (mmcblk0p18) and find the "factory" default configuration that EXACTLY match the file of your Radio/WLAN partition (except for the mac address).
BE SURE TO FIND THE CORRECT ONE as the HBOOT partition contains several "factory" default configuration for the various motherboard revisions.
Then change the MAC address of this "factory" configuration file (which should be 00:11:22:33:44:55 if you never modified it).
Then you should alter the configuration file in the Radio/WLAN partition (change the mac address for example) so that the CRC checksum will fail and so that HBOOT will restore the new "factory" default configuration (with your new MAC address) during next reboot.
For consistency, you should also change the MAC address at offset 0x000110CC. (All the information contained at offset 0x00011000 seems to be only informative).
3.b Changing the Bluetooth MAC address.
The BT configuration is much more simple (no CRC or other parameters...)
Offset 0X00006000 : BT mac address (binary format !)
Offset 0x000110BC : the BT mac address (Only informative - not used by the system).
So you just need to put your new BT MAC address at this two offsets
4. The quick procedure...
- download the wlan_config tool I wrote
- open a command line console
- cd into the directory where you've put the wlan_config tool
- Then type:
Code:
> adb push wlan_config /data/local/tmp/
> adb shell chmod 777 /data/local/tmp/wlan_config
> adb shell /data/local/tmp/wlan_config --dry-run wf=<the new WIFI macaddr> bt=<the new BT macaddr>
******************************************************************************
***** HTC Desire S WLAN Configuration tool 1.0 by RXBoucher... *****
******************************************************************************
[!] **************************************************************************
[!] >>>>>> dry-run mode: no change will be made to partitions <<<<<<
[!] **************************************************************************
[*] **************************************************************************
[+] Reading partition(s)
[+] partition mmcblk0p23....................................................OK
[+] partition mmcblk0p18....................................................OK
[*] **************************************************************************
[+] Analyzing partition mmcblk0p23...
[+] ModelID : PG8810000
[+] Current WIFI mac address: 7C:61:--:--:--:--
[+] Current BT mac address: 7C:61:--:--:--:--
[*] **************************************************************************
[+] Backing up partition(s)...
[!] partition mmcblk0p23...............................................SKIPPED
[!] partition mmcblk0p18...............................................SKIPPED
[*] **************************************************************************
[+] Configuring WIFI -> 7C:61:DD:DD:DD:DD
[+] Looking up matching "factory" default WIFI configuration................OK
[+] Updating "factory" default WIFI configuration...........................OK
[+] Updating WIFI configuration.............................................OK
[*] **************************************************************************
[+] Configuring BT -> 7C:61:FF:FF:FF:FF
[+] Updating BT mac address.................................................OK
[*] **************************************************************************
[+] Writing partitions...
[!] partition mmcblk0p23...............................................SKIPPED
[!] partition mmcblk0p18...............................................SKIPPED
[*] **************************************************************************
[!] dry-run successful...
This will run the wlan_config tool in dry-run mode (will not actually perform any changes to the partitions.)
If the dry-run mode is successful then you can re-run the command without the --dry-run option
Code:
>adb shell /data/local/tmp/wlan_config wf=<the new WIFI macaddr> bt=<the new BT macaddr>
******************************************************************************
***** HTC Desire S WLAN Configuration tool 1.0 by RXBoucher... ****
******************************************************************************
[+] Reading partition(s)
[+] Analysing partition mmcblk0p23...
[+] Backing up partition(s)...
[+] Configuring WIFI -> 7C:61:DD:DD:DD:DD
[+] Configuring BT -> 7C:61:FF:FF:FF:FF
[+] Writing partitions...
[!] WLAN configured...
[!] please reboot phone
Then you must reboot your phone and enjoy your new WLAN configuration.
If the dry-run mode fails, it means that the tool was unable to find where or how to change the WLAN configuration.
In this case, maybe you should read the Long Procedure and try to perform the changes manually.
If you want to see the various options and parameters of the wlan_config tool
Code:
> adb shell /data/local/tmp/wlan_config --help
******************************************************************************
***** HTC Desire S WLAN Configuration tool 1.0 by RXBoucher... ****
******************************************************************************
USAGE:
wlan_config [OPTIONS] <PARAMETERS>
OPTIONS:
-d, --dry-run : test mode. The configuration tool will be run without
actually modifying partition(s)
-v : verbose mode. The configuration tool will output more
detailed information.
Can be added several times to increase verbosity
--help : display this usage message.
PARAMETERS:
wf=<macaddr>: the configuration tool will change the WIFI mac address
bt=<macaddr>: the configuration tool will change the BT mac address
with <macaddr>=XX:XX:XX:XX:XX:XX
5. The long procedure (manual)
Connect your phone to your PC using the Charger Only option.
Then open a command line console and dump the mmcblk0p18 (HBOOT) and the mmcblk0p23 (wlan/radio config) partitions:
Code:
>adb shell dd if=/dev/block/mmcblk0p18 of=/sdcard/mmcblk0p18.img
>adb shell dd if=/dev/blocl/mmcblk0p23 of=/sdcard/mmcblk0p23.img
>adb pull /sdcard/mmcblk0p18.img
>adb pull /sdcard/mmcblk0p23.img
>copy mmcblk0p18.img mmcblk0p18-org.img
>copy mmcblk0p23.img mmcblk0p23-org.img
You should keep the "org" files safe in case you need to restore them.
Now we're going to edit/modify the 2 files mmclkk0p18.img and mmcblk0p23.img with HexEdit:
- Go in the mmcblk0p23.img tab
- Select, in the Hex View (not Text View), everything starting at offset 0x0000005B (sromrev=) up to the last 0D 0A 00
- Copy it to clipboard (Ctrl+C)
- Go in the mmcblk0p18.img tab
- Open the search dialog box (Ctrl+F)
- In the "Search For" text field, paste the clipboard (Ctrl+F)
- In the "Datatype" drop down list select "Hex-values"
- Click OK
HedEdit should then find and highlight the corresponding match.
Just before the highlighted selection, you should have the factory default MAC address: macaddr=00:11:22:33:44:55
-Change this MAC address with the one you want to use (in the text-view)
-Save the file (Ctrl+S)
-Go back to the mmcblk0p23.img tab
-Put the new MAC address at offset 0x00000048 (in the text-view)
-Go to offset 0x000110CC (Ctrl+G)
-Put your WIFI MAC address here also (in the text-view)
-Go to offset 0x00006000
-In the hex-view type in you're new BT MAC address
-Got to offset 0x000110BC
-Put your BT MAC Address here to (in the text-xiew)
Save the file.
You're done with the editing.
You should now replace your partitions with the modified images.
Go back to your command line console then type:
Code:
>adb push mmcblk0p23.img /data/local/tmp/mmcblk0p23.img
>adb push mmcblk0p18.img /data/local/tmp/mmcblk0p18.img
>adb shell dd if=/data/local/tmp/mmcblk0p23.img of=/dev/block/mmcblk0p23
>adb shell dd if=/data/local/tmp/mmcblk0p18.img of=/dev/block/mmcblk0p18
Reboot your phone and enjoy your new WLAN configuration !!!
Can i use it for Desire
hi....
Can i use this method for htc desire
my desire has no bleutooth and wifi mac address...
i uses usb bricked method but all in vain.... sam problem...
could you please tell me how can i write mac addresses in htc desire...i have rooted and cm7 rom is installed
bootloader is cm7r2
i also tried radio update...
sorry for bad english...
Please help me thx....
Hi, thanks for this great tool!
I'm getting this error:
error: Android 5.0 and later only support position-independent executables (-fPIE)

[Tut] Fast Change Kernel Paramteres

This is a very simple guide for build a script that manipulates the kernel parameters. Using SManager we will add it on us home or dock.
No specific skills are required, only patient.
What You Need:
- Root Permissions
- a customizable kernel
- SManager & SMWidgets
- Busybox
------------------------------------------------
1) First make your personal script for manipulating the kernel parameters.
Make a new file without extension on your computer and open it with a text editor
a) write this two line (IMPORTANT !!!)
#!/system/bin/sh
busybox mount -o remount,rw /system
the first line is the standard initialization of a sh script in Linux-Unix system. The second line allows the writing of the file system.
b) Now add the code. All the kernel parameters are text file located in the /sys/ folder. Is possible to edit such parameters writing
echo NEWVALUE > / PATH / OF / THE / DESTINATION / PARAMETER
for example, for changing the minimum frequency
# CPU Min Freq
echo 700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
In sh scripts the line with # symbol won't be execute, so you can write whatever you wants.
c) The most important parameters are located in:
# CPU Min Freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
# CPU Max Freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# CPU Governor
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# IO Scheduler (ALL THIS PARAMETERS MUST BE CHANGED FOR THE SCHEDULER)
/sys/block/mmcblk0/queue/scheduler
/sys/block/mmcblk0boot0/queue/scheduler
/sys/block/mmcblk0boot1/queue/scheduler
/sys/block/mtdblock0/queue/scheduler
I attached a simple script in this form here. You can found other parameters here, or A complete documentation of a kernel linux here. Other scripts and information about the Android kernel can be found here, here. A complete documentation of a kernel linux is here
BE CAREFUL WITH EDITING KERNEL PARAMETERS. ALWAYS READ THE DOCUMENTATION OF YOUR KERNEL AND CHECK THE PARAMETERS
d) Add this line at the end of the file for remount the system folder as read-able only
busybox mount -o remount,ro /system
now your script is done.
You can check and control the parameters by typing on the terminal or via ADB
cat / PATH / OF / THE / PARAMETER / YOU / ARE / CHECKING
------------------------------------------------
2) push the file on your phone. Set executable permission of file with an explorer or with chmod comand. Now open SManager, navigate to the path of the script and add it on its database. You can check it and test if everything works fine.
------------------------------------------------
3) the last step consists to add the shortcut of the script your home. With the most advanced launcher you can change the icon and the name and personalize it.
------------------------------------------------
4) optional: after the execution of the script with SWmanager the terminal will be open. To automatically return on the home you must add at the end of the script a line with the activity of your launcher related to the home button (this is a method I found, if someone has a better idea please tell me )
For Nova Launcher the code is:
am start -a android.intent.action.MAIN -n com.teslacoilsw.launcher/com.android.launcher2.Launcher
The method is used to found this activity was:
a) Open an app, and then return the to the home by pusching the central button
b) With the terminal emulator, or via adb, launch the logcat command
c) look for the last activity related to your launcher
d) replace the part after the -n with the string you have found
------------------------------------------------
All is done, if you have questions or some advice please contact me.
...The english will improve during my android experience :angel:

Crontab Setup for Note II (Needs Root)

This is a tutorial for setting up crontab on Samsung Galaxy Note II. This is intended for native unix users to be able to use cron on their phones for scheduling various tasks such as reminders, backups, scheduled reboots, wifi on-off, etc.
Installation Instructions:
What you need:
Rooted Galaxy Note II with latest busybox installed
Ability to run scripts at startup [not required if you are willing to manually start crond every time you reboot.]
Step 1: Create a directory /data/root, and create a text file name root inside it. Your cron entries should go inside /data/root/root.
Step 2: Download the attached crontab.sh and place it in your mobile phone. You need to execute this script on startup. So if you have /etc/init.d folder, please it there. If you dont, you should contact your dev to check if your rom supports executing user scripts on startup.
Step 3: Understanding the (attached) script.
Any unix program including crontab references a users details from the /etc/passwd file. So we create a passwd file with root user's credentials. (Android does not have this by default).
Crontab is a compiled binary that looks for sh shell in the directory /bin/sh - a standard for unix. Unfortunately bin directory is inside /system in our phones, so we symlink it.
Set Timezone. TZ variable is sources by crontab to know the local timezone. Please modify the script to set it according to your location.
And finally, crond -c /data/root will start cron daemon on your phone sourcing crontab files from /data/root directory.
Step 4: Write your crontab file (Below is a typical crontab file). Please visit this link for an awesome tutorial on crontab.
Code:
[B][email protected]:/data/root # cat /data/root/root[/B]
# Script to make sure crontab is running
* * * * * echo "Crontab last ran on `date`" >> /storage/sdcard0/.crontab
# Script to backup whatsapp databases at 5 am everyday.
0 5 * * * cp /data/data/com.whatsapp/databases/* /storage/extSdCard/backups/whatsapp/
### FREQUENTLY ASKED QUESTIONS ###
How to make sure it is working
In terminal - type pgrep -l crond (lower case L). If it return a process id and command name, crontab is running. If you see more than one "crond" running, it is likely that executed your script twice. kill the other script using command kill -9 <process id>
[*]My tasks are executing twice
Please re-read FAQ #1.
[*]It stopped working after i rebooted my phone.
You are probably not executing this script on startup. Reread this thread properly again.
kkoolpatz said:
This is a tutorial for setting up crontab on Samsung Galaxy Note II. This is intended for native unix users to be able to use cron on their phones for scheduling various tasks such as reminders, backups, scheduled reboots, wifi on-off, etc.
Installation Instructions:
What you need:
Rooted Galaxy Note II with latest busybox installed
Ability to run scripts at startup [not required if you are willing to manually start crond every time you reboot.]
Step 1: Create a directory /data/root, and create a text file name root inside it. Your cron entries should go inside /data/root/root.
Step 2: Download the attached crontab.sh and place it in your mobile phone. You need to execute this script on startup. So if you have /etc/init.d folder, please it there. If you dont, you should contact your dev to check if your rom supports executing user scripts on startup.
Step 3: Understanding the (attached) script.
Any unix program including crontab references a users details from the /etc/passwd file. So we create a passwd file with root user's credentials. (Android does not have this by default).
Crontab is a compiled binary that looks for sh shell in the directory /bin/sh - a standard for unix. Unfortunately bin directory is inside /system in our phones, so we symlink it.
Set Timezone. TZ variable is sources by crontab to know the local timezone. Please modify the script to set it according to your location.
And finally, crond -c /data/root will start cron daemon on your phone sourcing crontab files from /data/root directory.
Step 4: Write your crontab file (Below is a typical crontab file). Please visit this link for an awesome tutorial on crontab.
Code:
[B][email protected]:/data/root # cat /data/root/root[/B]
# Script to make sure crontab is running
* * * * * echo "Crontab last ran on `date`" >> /storage/sdcard0/.crontab
# Script to backup whatsapp databases at 5 am everyday.
0 5 * * * cp /data/data/com.whatsapp/databases/* /storage/extSdCard/backups/whatsapp/
### FREQUENTLY ASKED QUESTIONS ###
How to make sure it is working
In terminal - type pgrep -l crond (lower case L). If it return a process id and command name, crontab is running. If you see more than one "crond" running, it is likely that executed your script twice. kill the other script using command kill -9 <process id>
[*]My tasks are executing twice
Please re-read FAQ #1.
[*]It stopped working after i rebooted my phone.
You are probably not executing this script on startup. Reread this thread properly again.
Click to expand...
Click to collapse
Interresting indeed,
Will digg this based on your informations, thank you
thx, can confirm it`s working on cm7.

How to modify your APN to support an MVNO (FreedomPop, etc)

This guide will cover enabling a custom APN to support MVNO's (FreedomPop, Ting, etc) on your LG Urbane 2 for Android Wear 2.0.
Prerequisites:
Root watch (I recommend this thread)
ADB minimal and fastboot
Linux system
A little bit of SQL knowledge
Shoutouts:
zbask - Rooting the LG Urbane 2
majdinj - Dumping ROMs
hoodred - Changing APNs
Enable USB debugging on the watch
- Settings -> System -> About -> keep tapping Build Number until developer options are enabled
- Developer Options -> ADB Debugging
- Connect charger, then connect charger to computer
- Click "OK" on watch face for "Allow Debugging"
Extract /system from watch
The watch uses squashfs for /system, which is a compressed filesystem, and read-only, even if you have root. Therefore, it is not possible to directly make changes to /system through adb. However, we can dump the filesystem to an image, decompress it on a computer, modify it, and put it back on the watch.
Steps:
Code:
adb shell
su
ls -al /dev/block/platform/msm_sdcc.1/by-name
msm_sdcc.1 may be different on your watch. look for this line:
Code:
lrwxrwxrwx 1 root root 21 1970-01-02 00:25 system -> /dev/block/mmcblk0p27
The watch actually has 1GB or so of internal storage. Let's dump the system file there so we can get it with adb pull.
Code:
dd if=/dev/block/mmcblk0p27 of=/sdcard/system.img
Remember to erase this file later, since it's very large and you don't want it taking up all the internal storage on your watch.
Extract telephony database from watch
The watch's telephony database is under /data. On my watch it is /data/user_de/0/com.android.providers.telephony/databases/telephony.db. Your location might vary. I found this by going to root (cd /) and typing
Code:
find | grep telephony.db
Since this file is only accessible by root, let's copy it to the sdcard as well so we can get it off.
Code:
cp /data/user_de/0/com.android.providers.telephony/databases/telephony.db /sdcard
Copy files to computer
Code:
adb pull /sdcard/system.img
adb pull /sdcard/telephony.db
On your Linux computer - modify the telephony database
We're going to put our MVNO APN into the telephony database. The telephony database is a .db file, which is sqlite3. You'll have to install sqlite3 support on your Linux computer.
Code:
sudo apt-get install sqlite3
sqlite3 telephony.db
A useful SQLite3 command is
Code:
.schema
which shows the table structure.
Code:
sqlite> select * from siminfo;
1|890XX_MY_ICC_ID__|0|CARD 1|AT&T|0|-16746133||1|1|310|170|1|1|1|1|4|0|1|1|0|1|0|1
sqlite> select mcc,mnc from siminfo;
310|170
Take note of the MCC and MNC for your SIM card.
In my case, the carrier exists in the telephony database already as AT&T. My MVNO, Freedompop, is on the same MCC and MNC, so I am going to modify the record.
Code:
sqlite> select * from carriers where mcc = 310 and mnc = 170;
744|ATT Phone|310170|310|170|phone||||||proxy.mobile.att.net|80|http://mmsc.mobile.att.net|-1|default,mms,supl,fota,hipri|1|IPV4V6|IPV4V6|1|0|0|||-1|0|1|0|0|0|1410|0|1
Your carrier may not exist in the telephony DB. If that's the case, you'll have to insert a record with a SQL command, which is left as an exercise for the reader.
In my case, since the record exists already, just under the wrong name (AT&T), I updated its info:
Code:
sqlite> update carriers set name = 'FreedomPop', apn = 'fp.com.attz', mmsproxy = null, mmsport = null, mmsc = null where mcc = 310 and mnc = 170;
On your Linux computer - Decompress system.img
We are going to modify our /system image now. Your Linux system should have the squashfs tools installed. You can usually get these with:
Code:
sudo apt-get install squashfs-tools
Put system.img in a directory and decompress it.
Code:
sudo unsquashfs system.img
This creates a directory named squashfs-root with the contents of system.img. Modify the file squashfs-root/etc/apns-conf.xml. You will want to add your desired APN information here. You'll need to know your carrier's MCC and MNC. You can get it from the siminfo table in the prior telephony database step or look it up at http://mcc-mnc.com. My carrier is Freedompop, so I inserted this info:
Code:
<apn carrier="FreedomPop"
mcc="310"
mnc="170"
apn="fp.com.attz"
type="default,mms,supl,fota,hipri"
protocol="IPV4V6"
roaming_protocol="IPV4V6"
profile_id="0"
modem_cognitive="true"
mtu="1410"
/>
Now that apns-conf.xml is modified, it's time to recompress the file system into system.img so we can flash it back to the watch. First let's get some parameters from the original system.img:
Code:
unsquashfs -s system.img
Found a valid SQUASHFS 4:0 superblock on system.img.
Creation or last append time Fri Aug 3 20:22:45 2018
Filesystem size 333522.78 Kbytes (325.71 Mbytes)
Compression lz4
High Compression option specified (-Xhc)
Block size 131072
Filesystem is exportable via NFS
Inodes are compressed
Data is compressed
Fragments are not stored
Xattrs are compressed
Duplicates are not removed
Number of fragments 0
Number of inodes 1475
Number of ids 4
Check the block size and the compression, in this case it's 131072 and lz4. Recompress using that as a parameter:
Code:
sudo mksquashfs squashfs-root system-modified.img -comp lz4 -b 131072 -no-fragments -no-duplicates -Xhc
Replace the telephony database on the watch
Code:
adb push telephony.db /sdcard/
adb shell
cp /sdcard/telephony.db /data/user_de/0/com.android.providers.telephony/databases/telephony.db
rm /sdcard/telephony.db
rm /sdcard/system.img
Flash your modified system.img
Code:
adb reboot bootloader
fastboot flash system system-modified.img
After the watch reboots, you should be able to pick the new APN.
Settings -> Connectivity -> Cellular -> Advanced -> Access Point Names
Congratulations, your watch is now on an MVNO cellular network!

Categories

Resources