[REF] Choosing between GlassLock and Android's stock lock screen

Ateisti

Member
Aug 25, 2010
36
19
0
Hi guys,

Since there seems to be some demand for this kind of thing, I decided to post instructions on a mod I made a while back. This gives you the option of choosing between Samsung's GlassLock (i.e. the default TW lockscreen) or the stock keyguard of Android 2.1.

The method involves de- and re-compiling /system/framework/android.policy.odex, and you should have some basic knowledge of the tools involved (i'm not gonna spell out every step). Before beginning, take a backup of android.policy.jar and android.policy.odex (or preferably the whole framework folder). You should issue the commands in recovery mode.

Required tools: rooted SGS (I've done this only with JM2, and the code *might* need modifying for other roms, though I doubt it), adb, smali/baksmali, dexopt-wrapper, text & hex editor, winrar (or any jar editor).

Here we go:

1. Use adb to pull out /system/framework/android.policy.odex and other framework .odexes (required for de-odexing). Might be wise to backup the whole /system/framework/ directory at this point.
2. Use baksmali to deodex the file (java -jar baksmali.jar -x android.policy.odex -o android.policy). Baksmali will let you know if you are missing any of the framework .odexes.
3. Open LockPatternKeyguardView.smali and find the method getLockScreenMode()Lcom/android/internal/policy/impl/LockPatternKeyguardView$LockScreenMode;
4. Replace the contents of this method with the attached file getLockScreenMode.txt.
5. Save LockPatternKeyguardView.smali.
6. Use smali to compile the files back to classes.dex (java -jar smali.jar android.policy -o classes.dex)
7. Pull /system/framework/android.policy.jar, add the newly created classes.dex to it, and push it back to the device.
8. On your phone, do:

# cd /system/framework
# dexopt-wrapper android.policy.jar patched.odex /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar

Ouput should be:
--- BEGIN 'android.policy.jar' (bootstrap=0) ---
--- would reduce privs here
--- waiting for verify+opt, pid=3105
--- END 'android.policy.jar' (success) ---

9. You now have odexed the file into patched.odex. However, the signature of the file is not compatible with the other framework files, so you need to fix it. I think the proper way should be to re-odex all the framework files, but I haven't encountered any issues with just patching the signature.
10. Open the original android.policy.odex in a hex editor, and copy signature bytes from offsets 0x34-0x47 to the new patched.odex, and save it. Optionally, you can also do this on your device by issuing the command:

# dd if=original.android.policy.odex of=patched.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

Where if="..." is the original file, and of="..." is the file you want to patch.
11. Push the patched and hex-edited file to /system/framework/android.policy.odex and restore the original /system/framework/android.policy.jar.
12. Reboot and enjoy your good ol' keyguard :)

Some notes:
- If you want to revert back to Samsung's lock screen, just create a file called /data/local/enable_glass_lock ("adb touch /data/local/enable_glass_lock").
- By default, the menu button will also unlock the screen. To disable this behavior, you have to modify /res/values-hdpi-v4/bools.xml in /system/framework/framework-res.apk, and change the value of <bool name="config_disableMenuKeyInLockScreen">false</bool> to true. Can also be done by modifying code.

On a side note, the code for Smart Unlock (present in some Samsung phones) seems to be in there... it would be an interesting project to get that working :)
 

Attachments

Last edited:

toca79

Senior Member
Oct 12, 2009
114
4
0
Great stuff, i've been waiting for someone to find out how to get rid of the glass screeen since first day.
Sadly i'm a real noob so it is useless for me.
Maybe someone can create an apk or a win program out of this.
 

kjusiel

Member
Feb 7, 2010
7
0
0
I want to do 6-step but I see:

Code:
C:\Users\Konrad>"C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar "C
:\Users\Konrad\Desktop\smali.jar" android.policy -o classes.dex

android.policy\com\android\internal\policy\impl\LockPatternKeyguardView$LockScre
enMode.smali[0,-1] The file must contain a .class directive
What's wrong?

EDIT:

I've changed a wrong smali.
 
Last edited:

qwas00

Member
Jul 25, 2010
17
6
0
Stockholm
In step 10, how do i copy the signature bytes with my hex editor? I dont understand what offsets 0x34-0x57 is...

10. Open the original android.policy.odex and copy signature bytes from offsets 0x34-0x47 to the new patched.odex, and save it.
 

tonyb12

Member
Mar 7, 2010
10
0
0
Can anyone who successfully coped with getting this done following the instructions above please do a video showing us how to do it, I think that might help us a lot... thanks a lot on behalf of us noobs :)
 

Ateisti

Member
Aug 25, 2010
36
19
0
Could you provide links to this?
Or are those sw included in the Android SDK?
ADB is included in the SDK, Smali and Baksmali can be downloaded here and dexopt-wrapper for example here.

In step 10, how do i copy the signature bytes with my hex editor? I dont understand what offsets 0x34-0x57 is...
It means to seek to the 52nd byte (or 0x34 in hex) of the file, and then copy and replace the following 20 bytes to the second file. But you can also do it on the device by issuing this command (I think busybox is required):

dd if=original.android.policy.odex of=patched.android.policy.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

...where "if=..." is the original file and "of=..." is the file you want to patch.
 

devabhishek

Senior Member
Sep 2, 2009
1,084
2,094
0
pune
Hi guys,

Since there seems to be some demand for this kind of thing, I decided to post instructions on a mod I made a while back. This gives you the option of choosing between Samsung's GlassLock (i.e. the default TW lockscreen) or the stock keyguard of Android 2.1.

The method involves de- and re-compiling /system/framework/android.policy.odex, and you should have some basic knowledge of the tools involved (i'm not gonna spell out every step). Before beginning, take a backup of android.policy.jar and android.policy.odex (or preferably the whole framework folder). You should issue the commands in recovery mode.

Required tools: rooted SGS (I've done this only with JM2, and the code *might* need modifying for other roms, though I doubt it), adb, smali/baksmali, dexopt-wrapper, text & hex editor, winrar (or any jar editor).

Here we go:

1. Use adb to pull out /system/framework/android.policy.odex and other framework .odexes (required for de-odexing). Might be wise to backup the whole /system/framework/ directory at this point.
2. Use baksmali to deodex the file (java -jar baksmali.jar -x android.policy.odex -o android.policy). Baksmali will let you know if you are missing any of the framework .odexes.
3. Open LockPatternKeyguardView.smali and find the method getLockScreenMode()Lcom/android/internal/policy/impl/LockPatternKeyguardView$LockScreenMode;
4. Replace the contents of this method with the attached file getLockScreenMode.txt.
5. Save LockPatternKeyguardView.smali.
6. Use smali to compile the files back to classes.dex (java -jar smali.jar android.policy -o classes.dex)
7. Pull /system/framework/android.policy.jar, add the newly created classes.dex to it, and push it back to the device.
8. On your phone, do:

# cd /system/framework
# dexopt-wrapper android.policy.jar patched.odex /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar

Ouput should be:
--- BEGIN 'android.policy.jar' (bootstrap=0) ---
--- would reduce privs here
--- waiting for verify+opt, pid=3105
--- END 'android.policy.jar' (success) ---

9. You now have odexed the file into patched.odex. However, the signature of the file is not compatible with the other framework files, so you need to fix it. I think the proper way should be to re-odex all the framework files, but I haven't encountered any issues with just patching the signature.
10. Open the original android.policy.odex and copy signature bytes from offsets 0x34-0x47 to the new patched.odex, and save it.
11. Push the patched and hex-edited file to /system/framework/android.policy.odex and restore the original /system/framework/android.policy.jar.
12. Reboot and enjoy your good ol' keyguard :)

Some notes:
- If you want to revert back to Samsung's lock screen, just create a file called /data/local/enable_glass_lock ("adb touch /data/local/enable_glass_lock").
- By default, the menu button will also unlock the screen. To disable this behavior, you have to modify /res/values-hdpi-v4/bools.xml in /system/framework/framework-res.apk, and change the value of <bool name="config_disableMenuKeyInLockScreen">false</bool> to true. Can also be done by modifying code.

On a side note, the code for Smart Unlock (present in some Samsung phones) seems to be in there... it would be an interesting project to get that working :)
THANX TO ALL YOUR EFFORTS........ can you please attach a screen shot of the lock what you are talking about.. and does it work flawlessly without any sort of a lag.. and is it 100% bugs free?????
 

qwas00

Member
Jul 25, 2010
17
6
0
Stockholm
It means to seek to the 52nd byte (or 0x34 in hex) of the file, and then copy and replace the following 20 bytes to the second file. But you can also do it on the device by issuing this command (I think busybox is required):

dd if=original.android.policy.odex of=patched.android.policy.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

...where "if=..." is the original file and "of=..." is the file you want to patch.
Thanks, that worked fine :)
 

Tharfrin

Member
Sep 5, 2010
25
7
0
Bergen
Thanks! This method worked like a charm. I hated that glass unlock thingy.

However my /system/framework/framework-res.apk doesn't have a value folder, so I can't remove the possibility to unlock with the menu button.

Couldn't find any bools.xml in there at all.
 

mobilx

Senior Member
May 17, 2007
292
123
0
Jagodina
This is replacing the music player controls when the screen is locked, right? It's a nice functionality and would be a pity to loose it.
Otherwise its a great mod and it would be cool if someone can make the One Click LockScreen Changer ;-)
Sent from my GT-I9000 using Tapatalk
 

Ateisti

Member
Aug 25, 2010
36
19
0
Could you also choose any other lockscreen, like WidgetLocker or SimplyLockscreen?
That would be great :D
Not as such, but technically it should be possible with some additional coding. I however don't have the time to undertake such a task.

Thanks! This method worked like a charm. I hated that glass unlock thingy.

However my /system/framework/framework-res.apk doesn't have a value folder, so I can't remove the possibility to unlock with the menu button.

Couldn't find any bools.xml in there at all.
This might be a ROM version thingy. On my system there are actually two XML files with that same setting, but only one of them works (the one I mentioned in my original post). Just search all your framework-res xml files for "config_disableMenuKeyInLockScreen", and change every instance to true. Should do the trick.

Or if all else fails, just edit the file LockScreen.smali, method "shouldEnableMenuKey()", and make it always return 0 ("return v4" -> "return v6").

This is replacing the music player controls when the screen is locked, right? It's a nice functionality and would be a pity to loose it.
Otherwise its a great mod and it would be cool if someone can make the One Click LockScreen Changer ;-)
That is unfortunately the case. The music controls (as well as the puzzle pieces) are coded into the GlassLock class, so it would required some additional reverse engineering to implement those in the stock keyguard.
 

kjusiel

Member
Feb 7, 2010
7
0
0
4 hours working and it works (jm2).

I'm going to test on the jpc.

EDIT:

I put it on the jpc and it doesn't work.
 
Last edited:

billytcf

Member
Aug 22, 2010
13
2
0
hi guy thanks for your instruction. However I'm using samset's 1.9f which has the ROM deodexed and i found no .odex files but .jar files. Is there a way to workaround this? I'd really love to revert back to stock eclair lockscreen~!
 

iZz0s

Member
Aug 5, 2010
49
6
0
hi guy thanks for your instruction. However I'm using samset's 1.9f which has the ROM deodexed and i found no .odex files but .jar files. Is there a way to workaround this? I'd really love to revert back to stock eclair lockscreen~!
same here :( no odex files...
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone