[Galaxy S III Themes and Apps] sorg:
Here is manual, how to make CRT-OFF mod without glitches on JB.

Originally, it has been released in my UNIROM ROM in 4PDA.ru community.

Here is the guide. Instruction is based on I9300XXDLIB, but it's easy to adjust it to other ROMS.

To make CRT-OFF working, you need to decompile services.jar.

in file com\android\server\PowerManagerService$ScreenBrightnessAnimator.smali

find following code and modify it according to red colored part:

.line 2906
.end local v0 #delta:I
:cond_1
:goto_1
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;

#getter for: Lcom/android/server/PowerManagerService;->mScreenBrightnessHandler:Landroid/os/Handler;
invoke-static {v7}, Lcom/android/server/PowerManagerService;->access$7300(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;

move-result-object v7

[COLOR=Red] if-eqz p2, :cond_2xx

const/16 v9, 0xb

const/4 v10, 0x0

const v2, 0x10

invoke-virtual {v7, v9, v2, v10}, Landroid/os/Handler;->obtainMessage(III)Landroid/os/Message;

move-result-object v9

invoke-virtual {v9}, Landroid/os/Message;->sendToTarget()V

:cond_2xx
[/COLOR] const/16 v9, 0xa

invoke-virtual {v7, v9}, Landroid/os/Handler;->removeMessages(I)V

Black color is original code, you need to find.

Effect will start to work, but u will notice glitch: if you turn on screen by power button and then put it to sleep again by button without unlocking then phone will wake up just after CRT effect finishes.

Here is workaround part.

decompile android.policy.jar.

in file com\android\internal\policy\impl\PhoneWindowManager.smali

Find following parts (black is original code) and modify according to red text:

.class public Lcom/android/internal/policy/impl/PhoneWindowManager;
.super Ljava/lang/Object;
.source "PhoneWindowManager.java"

# interfaces
.implements Landroid/view/WindowManagerPolicy;
[COLOR=Red].implements Ljava/lang/Runnable;[/COLOR]

# annotations

.line 5411
.end local v9 #isAllowed:Z
.end local v16 #kioskMode:Landroid/app/enterprise/kioskmode/KioskMode;
:cond_1
:goto_2
[COLOR=Red] and-int/lit8 v0, v19, 0x4

if-eqz v0, :cond_2xx

and-int/lit8 v19, v19, -0x5

move-object/from16 v0, p0

invoke-virtual {v0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->sleepDelay()V

:cond_2xx
[/COLOR] return v19

at the end of file add following code:

[COLOR=Red].method public sleepDelay()V
.locals 10

iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

const-wide v2, 0x64

check-cast p0, Ljava/lang/Runnable;

invoke-virtual {v0, p0, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

return-void
.end method

.method public run()V
.locals 10

.prologue
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

const-string v1, "power"

invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

move-result-object v0

check-cast v0, Landroid/os/PowerManager;

invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

move-result-wide v2

const-wide/16 v6, 0x3e8

add-long/2addr v2, v6

invoke-virtual {v0, v2, v3}, Landroid/os/PowerManager;->goToSleep(J)V

return-void
.end method
[/COLOR]

That's all.

My method doesn't require patches for libsurfaceflinger.so library.

P.S.: I didn't put much effort to investigate of possibility for CRT-ON effect. I'm not sure if this effect is even compiled inside stock libsurfaceflinger.so. I'm happy that i could achieve fully working CRT-OFF without patching library. I remember how much time i've spent to patch libsurfaceflinger.so for I9100 ICS ROM against flicker, so it's real deal breaker for me to go through reversing and patching of .so file again.

I've attached mod for XXDLIB version.

Install in CWM recovery to DEODEXED ROM.

This is for stock deodexed I9300XXDLIB ROM. If you use any custom made ROM and there are some additional modifications in android.policy.jar or services.jar then you will loose all those mods.

I have neither time no ability to make flashable zips for other ROMs. I cannot download every ROM, integrate this mod and test. So, ask custom ROMs authors to integrate it into their ROMs by themself.