Android OS Forum banner
1 - 20 of 62 Posts

·
Premium Member
Joined
·
422 Posts
Hello everyone! We all know and love the CRT on and off animation that is Gingerbread's trademark, but unfortunately we don't have this awesome feature in a lot of the manufacturer's stock roms that get released to the public. Some know how to enable the CRT OFF animation with little work, but if you're like me you don't want just one no you want the whole damn package. Well, I'm about to show you how to get just that.

This guide does assume you are familiar with decompiling jars and apks. There are many guides on this should you need more information. This guide is not perfect and will probably need some revising to be made more clear. If you have any suggestions please feel free to let me know. Thanks!

DO NOT PM ME WITH QUESTIONS! Instead, post in this thread so we can all learn together. If you have a question chances are somebody else will have the same one. Let's answer these for everyone.

First, let's start with the framework-res.apk

This is the easy part. Decompile the framework-res apk for the rom you wish to modify. Now navigate to the /res/values/bools.xml and open the xml in your preferred text editor.

Now look for this line
Code:
<br />
<bool name="config_animateScreenLights">true</bool><br />
Now you need to change true to false. Now compile your framework-res.apk if you had to change it (and don't forget to delete the resources.arsc in the keep folder!).

Now for the hard part. You need to decompile the classes.dex inside the SERVICES.jar. Navigate to /com/android/server/PowerManagerService.smali and open with text editor.

Now you need to add this method VERBATIM to the smali if it is not already present. Add it in just above the method "getPreferredBrightness()I"

Code:
<br />
.method static synthetic getContextZZ(Lcom/android/server/PowerManagerService;)Landroid/content/Context;<br />
	.registers 2<br />
	.parameter "x0"<br />
<br />
	.prologue<br />
	iget-object v0, p0, Lcom/android/server/PowerManagerService;->mContext:Landroid/content/Context;<br />
<br />
	return-object v0<br />
.end method<br />
Now to be honest I'm not 100% sure this part is necessary, but this is what I did so you should do it too. You need to alter a few values that are at the TOP portion of PowerManagerService.smali. Make sure yours matches this stuff listed below.

Code:
<br />
.field private static final ALL_BRIGHT:I = 0xf<br />
Code:
<br />
.field static final ANIM_STEPS:I = 0xa<br />
Code:
<br />
.field static final AUTOBRIGHTNESS_ANIM_STEPS:I = 0xf<br />
Code:
<br />
.field private static final LIGHT_SENSOR_DELAY:I = 0x7d0<br />
Code:
<br />
.field private static final [URL=mDebugLightSensor:Z]mDebugLightSensor:Z[/URL] = true<br />
Code:
<br />
.field private static final [URL=mDebugProximitySensor:Z]mDebugProximitySensor:Z[/URL] = true<br />
Everything match how mine is above? Ok good! Now save the PowerManagerService.smali.

Still with me? Hang on cause we're almost done!

Now we need to edit one last smali. I suppose this one is the hardest, but it's really not if you follow closely. Open the PowerManagerService$BrightnessState.smali. Add the following method in VERBATIM above "# virtual methods"

Code:
<br />
.method private getScreenAnimationMode(Landroid/content/Context;)I<br />
	.registers 7<br />
	.parameter "context"<br />
<br />
	.prologue<br />
	const v0, 0x0<br />
<br />
	const v3, 0x1<br />
<br />
	const v4, 0x10<br />
<br />
	invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;<br />
<br />
	move-result-object v1<br />
<br />
	const-string v2, "config_beam_screen_on"<br />
<br />
	invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I<br />
<br />
	move-result v2<br />
<br />
	if-eqz v2, :cond_22<br />
<br />
	const v0, 0x1<br />
<br />
	:goto_18<br />
	const-string v2, "config_beam_screen_off"<br />
<br />
	invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I<br />
<br />
	move-result v2<br />
<br />
	if-eqz v2, :cond_21<br />
<br />
	add-int/2addr v0, v4<br />
<br />
	:cond_21<br />
	return v0<br />
<br />
	:cond_22<br />
	const v0, 0x0<br />
<br />
	goto :goto_18<br />
.end method<br />
One more method, but this one requires some attention. The easiest way I've found is to copy this entire method and paste it in to replace your current one. The problem is all the "access$###" are not going to match up properly. So you will need to fix them to match the ones in your PowerManagerService.smali. I have took the liberty of calling these spots out. All you need to do is do a search for them in your PowerManagerService file and replace the word with the access$### given. Here, it will make more sense as we do it.

Code:
<br />
.method public run()V<br />
	.registers 10<br />
<br />
	.prologue<br />
	const/4 v8, 0x0<br />
<br />
	.line 2076<br />
	iget-object v4, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v4}, Lcom/android/server/PowerManagerService;->getContextZZ(Lcom/android/server/PowerManagerService;)Landroid/content/Context;<br />
<br />
	move-result-object v4<br />
<br />
	invoke-direct {p0, v4}, Lcom/android/server/PowerManagerService$BrightnessState;->getScreenAnimationMode(Landroid/content/Context;)I<br />
<br />
	move-result v4<br />
<br />
	if-nez v4, :cond_3b<br />
<br />
	iget-object v4, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	iget-boolean v4, v4, Lcom/android/server/PowerManagerService;->mAnimateScreenLights:Z<br />
<br />
	if-eqz v4, :cond_3b<br />
<br />
	.line 2077<br />
	iget-object v4, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v4}, Lcom/android/server/PowerManagerService;->access$500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$LockList;<br />
<br />
	move-result-object v4<br />
<br />
	monitor-enter v4<br />
<br />
	.line 2078<br />
	:try_start_1a<br />
	invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J<br />
<br />
	move-result-wide v2<br />
<br />
	.line 2079<br />
	.local v2, now:J<br />
	iget-object v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v5}, Lcom/android/server/PowerManagerService;->access$4500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$BrightnessState;<br />
<br />
	move-result-object v5<br />
<br />
	invoke-virtual {v5}, Lcom/android/server/PowerManagerService$BrightnessState;->stepLocked()Z<br />
<br />
	move-result v1<br />
<br />
	.line 2080<br />
	.local v1, more:Z<br />
	if-eqz v1, :cond_36<br />
<br />
	.line 2081<br />
	iget-object v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v5}, Lcom/android/server/PowerManagerService;->access$1800(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;<br />
<br />
	move-result-object v5<br />
<br />
	const-wide/16 v6, 0x10<br />
<br />
	add-long/2addr v6, v2<br />
<br />
	invoke-virtual {v5, p0, v6, v7}, Landroid/os/Handler;->postAtTime(Ljava/lang/Runnable;J)Z<br />
<br />
	.line 2083<br />
	:cond_36<br />
	monitor-exit v4<br />
<br />
	.line 2098<br />
	.end local v1		   #more:Z<br />
	.end local v2		   #now:J<br />
	:goto_37<br />
	return-void<br />
<br />
	.line 2083<br />
	:catchall_38<br />
	move-exception v5<br />
<br />
	monitor-exit v4<br />
	:try_end_3a<br />
	.catchall {:try_start_1a .. :try_end_3a} :catchall_38<br />
<br />
	throw v5<br />
<br />
	.line 2085<br />
	:cond_3b<br />
	iget-object v4, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v4}, Lcom/android/server/PowerManagerService;->access$500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$LockList;<br />
<br />
	move-result-object v4<br />
<br />
	monitor-enter v4<br />
<br />
	.line 2087<br />
	:try_start_42<br />
	iget-boolean v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->animating:Z<br />
<br />
	if-eqz v5, :cond_6b<br />
<br />
	iget v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->targetValue:I<br />
<br />
	if-nez v5, :cond_6b<br />
<br />
	const/4 v5, 0x1<br />
<br />
	move v0, v5<br />
<br />
	.line 2088<br />
	.local v0, animate:Z<br />
	:goto_4c<br />
	if-eqz v0, :cond_5d<br />
<br />
	.line 2091<br />
	iget-object v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	iget-object v6, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v6}, Lcom/android/server/PowerManagerService;->access$4300(Lcom/android/server/PowerManagerService;)I<br />
<br />
	move-result v6<br />
<br />
	const/4 v7, 0x4<br />
<br />
	if-ne v6, v7, :cond_6d<br />
<br />
	move v6, v8<br />
<br />
	:goto_5a<br />
	invoke-static {v5, v6}, Lcom/android/server/PowerManagerService;->access$4600(Lcom/android/server/PowerManagerService;I)V<br />
<br />
	.line 2095<br />
	:cond_5d<br />
	iget-object v5, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v5}, Lcom/android/server/PowerManagerService;->access$4500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$BrightnessState;<br />
<br />
	move-result-object v5<br />
<br />
	invoke-virtual {v5}, Lcom/android/server/PowerManagerService$BrightnessState;->jumpToTargetLocked()V<br />
<br />
	.line 2096<br />
	monitor-exit v4<br />
<br />
	goto :goto_37<br />
<br />
	.end local v0		   #animate:Z<br />
	:catchall_68<br />
	move-exception v5<br />
<br />
	monitor-exit v4<br />
	:try_end_6a<br />
	.catchall {:try_start_42 .. :try_end_6a} :catchall_68<br />
<br />
	throw v5<br />
<br />
	:cond_6b<br />
	move v0, v8<br />
<br />
	.line 2087<br />
	goto :goto_4c<br />
<br />
	.line 2091<br />
	.restart local v0	   #animate:Z<br />
	:cond_6d<br />
	:try_start_6d<br />
	iget-object v6, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v6}, Lcom/android/server/PowerManagerService;->access$1700(Lcom/android/server/PowerManagerService;)I<br />
	:try_end_72<br />
	.catchall {:try_start_6d .. :try_end_72} :catchall_68<br />
<br />
	move-result v6<br />
<br />
	iget-object v6, p0, Lcom/android/server/PowerManagerService$BrightnessState;->this$0:Lcom/android/server/PowerManagerService;<br />
<br />
	invoke-static {v6}, Lcom/android/server/PowerManagerService;->getContextZZ(Lcom/android/server/PowerManagerService;)Landroid/content/Context;<br />
<br />
	move-result-object v6<br />
<br />
	invoke-direct {p0, v6}, Lcom/android/server/PowerManagerService$BrightnessState;->getScreenAnimationMode(Landroid/content/Context;)I<br />
<br />
	move-result v6<br />
<br />
	goto :goto_5a<br />
.end method<br />
Take the above method and paste it into a blank word document. Now search it for "access$500" Ok found it? The line will look exactly like this
Code:
<br />
Lcom/android/server/PowerManagerService;->access$500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$LockList;<br />
See how at the end of that line it says "PowerManagerService$Locklist" ?? Now go look at your PowerManagerService.smali and search it for "access$500" when you find it make sure it reads
Code:
<br />
access$500(Lcom/android/server/PowerManagerService;)Lcom/android/server/PowerManagerService$LockList;<br />
See how access$500 = PowerManagerService$Locklist? You want to make sure that it's correct. If access$500 does not match Service$Locklist you will need to find the one that does. Chances are this one will match so you will be good, but lets say it was access$600 that matched Service.Locklist. Then you would need to go back to the method you are planning to copy into the PowerManagerService$BrightnessState.smali and change "access$500" to "access$600" Again, this one will probably not need to be changed.

The key is to go through this method and replace all the access$### with the one that matches the SERVICE it's calling out. This requires going back and forth between the PowerManagerService$BrightnessState.smali and the PowerManagerService.smali. Once you have all the access$###'s replaced with the correct ones paste the entire method in and REPLACE the one you already have in there. After that, you are finished.

Now compile your services.jar and move it to /system/framework, make sure permissions are set to rw-r--r-- and reboot. When your phone comes back you will have working CRT ON and OFF animation. If your phone gets stuck in boot loop or crashes when sleeping/waking screen then something was done wrong. You will need to run a logcat to determine what exactly.
 

·
Premium Member
Joined
·
110 Posts
Thank you for this bud! Very excited to get this going. I bet you had a couple face palms figuring this one out.

Sent from my SGH-T959V using Black RootzWiki Forums
 

·
Developer
Joined
·
161 Posts
I believe those extra steps will get CRT to work on Sense devices. My guide on my blog here on the site, doesn't cover those, and for the CRT animation to work you just need to edit bool. (At least that is what has worked on most devices.)
 

·
Premium Member
Joined
·
422 Posts
Webst3r said:
I believe those extra steps will get CRT to work on Sense devices. My guide on my blog here on the site, doesn't cover those, and for the CRT animation to work you just need to edit bool. (At least that is what has worked on most devices.)
True, but editing the bool only enables the CRT OFF animation. It doesn't do both. This is how I was able to enable both the off and ON animations. The extra steps are only necessary if you want the ON portion of the animation as well. ^^

This is confirmed working on G2x and Vibrant. I imagine it should work on most devices out there.
 

·
Android Beginner
Joined
·
7 Posts
I went through this tutorial meticulously. Everything checked out, but then when I went to put it on my phone, I got everything there and now when I hit the power button it only locks, the screen does not go off at all.

EDIT: I am on Droid X2. I tried it again without changing the .field static values that you said might not be necessary, and no difference. When the lock button is pushed, the screen gets bright, and locks. The display stays on.
 

·
Developer
Joined
·
25 Posts
Hi WhitehawkX not sure if you have heard of me, I am a developer over on the XDA forums.

Just registered when I found your post, I am trying to find a viable patch for CRT as our current method messes up wakelocks & autobrightness, I have attempted your method but it fails for me with the below error, resulting in a system freeze.

Code:
E/AndroidRuntime(  633): java.lang.NoSuchMethodError: com.android.server.PowerManagerService$BrightnessState.getScreenAnimationMode
Any chance you could take a look at the current PowerManagerService.smali and PowerManagerService$BrightnessState.smali and see if you can come up with a fix? Taken from the new HTC Sensation 2.3.4 build

would be more than happy to throw you a few beers in return ;)

PowerManagerService$BrightnessState.smali http://pastebin.com/ejb9TBpw

PowerManagerService.smali http://pastebin.com/H4fgVFsH
 

·
Premium Member
Joined
·
422 Posts
Discussion Starter · #7 ·
religi0n said:
I went through this tutorial meticulously. Everything checked out, but then when I went to put it on my phone, I got everything there and now when I hit the power button it only locks, the screen does not go off at all.

EDIT: I am on Droid X2. I tried it again without changing the .field static values that you said might not be necessary, and no difference. When the lock button is pushed, the screen gets bright, and locks. The display stays on.
Try running a logcat to see if it shows any errors when you lock your phone. I had to run logcats back in forth for awhile to get this to work the first time. Also, just to be sure, in your framework-res the bool is set to "true" correct?
 

·
Premium Member
Joined
·
422 Posts
Discussion Starter · #8 ·
LeeDrOiD said:
Hi WhitehawkX not sure if you have heard of me, I am a developer over on the XDA forums.

Just registered when I found your post, I am trying to find a viable patch for CRT as our current method messes up wakelocks & autobrightness, I have attempted your method but it fails for me with the below error, resulting in a system freeze.

Code:
E/AndroidRuntime(  633): java.lang.NoSuchMethodError: com.android.server.PowerManagerService$BrightnessState.getScreenAnimationMode
Any chance you could take a look at the current PowerManagerService.smali and PowerManagerService$BrightnessState.smali and see if you can come up with a fix? Taken from the new HTC Sensation 2.3.4 build

would be more than happy to throw you a few beers in return ;)

PowerManagerService$BrightnessState.smali http://pastebin.com/ejb9TBpw

PowerManagerService.smali http://pastebin.com/H4fgVFsH
The logcat error is showing that it can't find the method for "getScreenAnimationMode" in the "PowerManagerService$BrightnessState.smali." I checked yours and sure enough that method is missing. That method is listed above in the tutorial and needs to be added verbatim to the PowerManagerService$BrightnessState.smali. I copied that method in and placed it just ABOVE where it says "# virtual methods"

I'll add the method here again just to be clear.
Code:
<br />
.method private getScreenAnimationMode(Landroid/content/Context;)I<br />
    .registers 7<br />
    .parameter "context"<br />
<br />
    .prologue<br />
    const v0, 0x0<br />
<br />
    const v3, 0x1<br />
<br />
    const v4, 0x10<br />
<br />
    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;<br />
<br />
    move-result-object v1<br />
<br />
    const-string v2, "config_beam_screen_on"<br />
<br />
    invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I<br />
<br />
    move-result v2<br />
<br />
    if-eqz v2, :cond_22<br />
<br />
    const v0, 0x1<br />
<br />
    :goto_18<br />
    const-string v2, "config_beam_screen_off"<br />
<br />
    invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I<br />
<br />
    move-result v2<br />
<br />
    if-eqz v2, :cond_21<br />
<br />
    add-int/2addr v0, v4<br />
<br />
    :cond_21<br />
    return v0<br />
<br />
    :cond_22<br />
    const v0, 0x0<br />
<br />
    goto :goto_18<br />
.end method<br />
Put that in and see if it works after that. :wink2:
 

·
Premium Member
Joined
·
1,155 Posts
LeeDrOiD said:
Hi WhitehawkX not sure if you have heard of me, I am a developer over on the XDA forums.

Just registered when I found your post, I am trying to find a viable patch for CRT as our current method messes up wakelocks & autobrightness, I have attempted your method but it fails for me with the below error, resulting in a system freeze.

Code:
E/AndroidRuntime(  633): java.lang.NoSuchMethodError: com.android.server.PowerManagerService$BrightnessState.getScreenAnimationMode
Any chance you could take a look at the current PowerManagerService.smali and PowerManagerService$BrightnessState.smali and see if you can come up with a fix? Taken from the new HTC Sensation 2.3.4 build

would be more than happy to throw you a few beers in return ;)

PowerManagerService$BrightnessState.smali http://pastebin.com/ejb9TBpw

PowerManagerService.smali http://pastebin.com/H4fgVFsH
Hey Lee,

I'm birgertime over on XDA--

I'm also trying to get it to work (working off the 2.3.4 leak), but I'm porting over CM7 code so we can make it on/off toggle-able. I'll post up my code once I get it working. Been trying to get this for nearly 6 hours now. Damn smali.
 

·
Premium Member
Joined
·
422 Posts
Discussion Starter · #11 ·
LeeDrOiD said:
Thanks! I was using the 2nd method, il give it a blast now and try again :wink2:
Yea the are BOTH needed for it to work. I'm betting adding in that method should be the last thing needed. Please report back if you get it working. ^^
 

·
Developer
Joined
·
25 Posts
roman said:
Hey Lee,

I'm birgertime over on XDA--

I'm also trying to get it to work (working off the 2.3.4 leak), but I'm porting over CM7 code so we can make it on/off toggle-able. I'll post up my code once I get it working. Been trying to get this for nearly 6 hours now. Damn smali.
Ha.. Hi mate, yes its a pain in the a#@! I had thought about the toggle my self, should not be too difficult imo.

@Whithawkx > Clearly misread that one in my haste!
 

·
Android Beginner
Joined
·
7 Posts
Whitehawkx said:
Try running a logcat to see if it shows any errors when you lock your phone. I had to run logcats back in forth for awhile to get this to work the first time. Also, just to be sure, in your framework-res the bool is set to "true" correct?
Yes, my CURRENT framework-res is at true, so I have no effect as of now (that is how I originally enabled the effect on the X2 over at XDA). I will run a logcat with my modified services.jar, and see what I can come up with...I am no experienced dev, so I doubt I will be able to do much with it on my own.

Off topic: LeeDroid, I love your ROM. I do not use it myself, but I loaded it into my girlfriends phone and she loves it. Great work you have done.

EDIT: I logged while pushing the lock button a few times. This was a relevant looking part of the log.
http://pastebin.com/Tupj8487
 

·
Android Beginner
Joined
·
9 Posts
Uhh... my framework doesn't have a value folder or a bools.xml! I'm sure it's gingerbread though, 2.3.2

I'm on the sony Ericsson Xperia Play R800x

Sent from my R800x using Tapatalk
 

·
Developer
Joined
·
25 Posts
Whitehawkx said:
Here are the smali in my builds.

G2x
PowerManagerService - http://pastebin.com/afvbdWRu
PowerManagerService$BrightnessState - http://pastebin.com/863NHT33

Vibrant
PowerManagerService - http://pastebin.com/hxbca9f1
PowerManagerService$BrightnessState - http://pastebin.com/3v07NqWN

And of course I have the bool for "animateScreenLights" set to TRUE.
Thanks mate, had a breif look and there are a lot of differences in the sensation smalis, will see what I can come up with ;)
 

·
Premium Member
Joined
·
1,155 Posts
For the Sensation, I've narrowed it down to the brightness code and how they handle it in PowerManagerService.smali

I added some debugging code, and the run() method only gets called when autobrightness is ON AND when the screen turns on. Otherwise it doesn't run.

I feel like I know these smalis on the back of my hand now, so I think I'm going to start over from the fresh 2.3.4 services.jar and work from it.
 
1 - 20 of 62 Posts
Top