[Galaxy S II Android Development] shoman94:
I've been having many PM's on how to create this toggle and honestly I have been meaning to post this for a while.

Firstly thanks to Mirko-ddd for enabling Crt-Off Animation which allowed me to do this. Thank him HERE

No need to enable from the link above as I have included it with this toggle How-To.

Also Thanks to my teammate Jeboo for teaching me some smali and helping me with this function!

So I'm not a posting master and I do have 2 kids buzzing around me while I type this!.. LOL :highfive:

Here we start with SecSettings.apk

/res/values/Strings.xml

<string name="crtanimation_title">CRT Animation</string>
<string name="crtanimation_summary">Enables animation when powering off screen</string>

/res/xml/Display_Settings.xml (Input this line where you want it to show.)

<CheckBoxPreference android:title="@string/crtanimation_title" android:summary="@string/crtanimation_summary" android:key="crtanimation_toggle" />

\SecSettings\smali\com\android\settings\DisplaySettings.smali

Add the RED

.field mSupportFolderType:Z

.field private mTouchKeyLight:Landroid/preference/ListPreference;

[COLOR="red"].field private mCrtAnimationPreference:Landroid/preference/CheckBoxPreference;[/COLOR]

.line 548
const-string v12, "key_multi_window"

invoke-virtual {p0, v12}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v12

check-cast v12, Landroid/preference/CheckBoxPreference;

iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mMultiWindowPref:Landroid/preference/CheckBoxPreference;

[COLOR="red"] const-string v12, "crtanimation_toggle"

invoke-virtual {p0, v12}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v12

check-cast v12, Landroid/preference/CheckBoxPreference;

iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mCrtAnimationPreference:Landroid/preference/CheckBoxPreference;[/COLOR]

.line 549
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getPackageManager()Landroid/content/pm/PackageManager;

move-result-object v12

const-string v13, "com.sec.feature.multiwindow.phone"

invoke-virtual {v12, v13}, Landroid/content/pm/PackageManager;->hasSystemFeature(Ljava/lang/String;)Z

move-result v12

sput-boolean v12, Lcom/android/settings/DisplaySettings;->UseMultiWindow:Z

.line 984
:cond_15
iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mMultiWindowPref:Landroid/preference/CheckBoxPreference;

invoke-virtual {p2, v0}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, [COLOR="red"]:cond_new[/COLOR]

.line 985
iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mMultiWindowPref:Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

.line 986
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

const-string v4, "multi_window_enabled"

if-eqz v0, :cond_16

:goto_a
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

goto/16 :goto_1

:cond_16
move v1, v2

goto :goto_a

[COLOR="red"] :cond_new
iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mCrtAnimationPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {p2, v0}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_0

.line 987
iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mCrtAnimationPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

.line 988
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

const-string v4, "crtanimation_toggle"

if-nez v0, :cond_newA

const/4 v0, 0x0

goto :cond_newB

:cond_newA

const/4 v0, 0x1

:cond_newB
invoke-static {v3, v4, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

goto/16 :goto_1
[/COLOR]
.end method

.line 818
invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "multi_window_enabled"

invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

move-result-object v1

iget-object v3, p0, Lcom/android/settings/DisplaySettings;->mMultiWindowModeObserver:Landroid/database/ContentObserver;

invoke-virtual {v0, v1, v2, v3}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

.line 820
:cond_2

[COLOR="red"] iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mCrtAnimationPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

const-string v4, "crtanimation_toggle"

const/4 v1, 0x0

invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v3

if-eqz v3, :goto_2b

const/4 v1, 0x1

goto :goto_2c

:goto_2b
const/4 v1, 0x0

:goto_2c
invoke-virtual {v0, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V[/COLOR]

return-void

:cond_3
move v0, v2

.line 792
goto :goto_0

That's it for SecSettings.

Recompile and test it functions before continuing.

Once that works lets enable the function.

I'm including the function to enable as previously linked to mirko_ddd's thread.

Next we mod services.jar

\services\smali\com\android\server\PowerManagerService$ScreenBrightnessAnimator.smali

.line 3022
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$7200(Lcom/android/server/PowerManagerService;)Landroid/os/Handler;

move-result-object v7

[COLOR="Red"] move-object v0, p0

iget-object v2, v0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;

#getter for: Lcom/android/server/PowerManagerService;->mContext:Landroid/content/Context;
invoke-static {v2}, Lcom/android/server/PowerManagerService;->access$2700(Lcom/android/server/PowerManagerService;)Landroid/content/Context;

move-result-object v2

invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v2

const-string v9, "crtanimation_toggle"

const/4 v10, 0x0

invoke-static {v2, v9, v10}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v2

if-eqz v2, :cond_new2

if-eqz p2, :cond_new2

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_new2
[/COLOR]
const/16 v9, 0xa

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

move-result-object v2

.line 3024
.local v2, msg:Landroid/os/Message;
iget-object v7, p0, Lcom/android/server/PowerManagerService$ScreenBrightnessAnimator;->this$0:Lcom/android/server/PowerManagerService;

And that's it!

Recompile and enjoy.