[Galaxy S III Android Development] shoman94:
I'm posting this here as I helped Kryten2k35 make this for his base XXEMB5 (4.1.2) but they are all likely very similar.

The code is very similar to the SGS2 and I have edited it for this base. My original thread is here: http://xdaforums.com/showthread.php?t=2194003

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

1)

/res/values/Strings.xml

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

2)

/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" />

3)

\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]

4)

const-string v13, "key_multi_window"

move-object/from16 v0, p0

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

move-result-object v13

check-cast v13, Landroid/preference/CheckBoxPreference;

move-object/from16 v0, p0

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

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

move-object/from16 v0, p0

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

move-result-object v13

check-cast v13, Landroid/preference/CheckBoxPreference;

move-object/from16 v0, p0

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

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

move-result-object v13

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

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

5)

: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

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

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

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

move-result v0

if-eqz v0, :cond_16

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

move-result-object v0

const-string v2, "multi_window_enabled"

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

goto/16 :goto_1

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

move-result-object v0

const-string v1, "multi_window_enabled"

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

goto/16 :goto_1

[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

6)

const-string v4, "multi_window_enabled"

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

move-result v3

if-ne v3, v1, :cond_5

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

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

: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

goto :goto_0

:cond_4
iget v0, p0, Lcom/android/settings/DisplaySettings;->mDirect:I

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

7)

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

#setter for: Lcom/android/server/PowerManagerService;->mHighestLightSensorValue:I
invoke-static {v7, v9}, Lcom/android/server/PowerManagerService;->access$8202(Lcom/android/server/PowerManagerService;I)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"] 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$2300(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}, Landroid/os/Handler;->removeMessages(I)V

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

const/16 v9, 0xa

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

move-result-object v2

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

And that's it!

Recompile and enjoy.

All I ask is for credit in your Mod or Rom.