[Vibrant Android Development] jeboo:
Update for ICS 4.0.3

This is one of my favorite mods, so it seems only appropriate to provide an updated guide for ICS. I won't rewrite the original post, but instead will point out changes in structures/code for each of the 3 "steps." This is based on LP3 for the Galaxy S2 btw.

Step 1.

The only change here is that we no longer need to allocate any resources for "reboot" since samsung has added it.

Step 2.

In ShutdownThread.smali, we NEED TO CHANGE our variable mReboot to mRecovery (Samsung added their own mReboot). Be sure to adjust any references to mReboot in the rest of the code we add!! Now, we will adjust the code inserted before Landroid/os/Power;->shutdown()V:

sget v1, Lcom/android/internal/app/ShutdownThread;->mRecovery:I

const/4 v2, 0x1

if-eq v1, v2, :rebootRecovery

const/4 v2, 0x2

if-eq v1, v2, :rebootDownload

Do note that recovery and d/l are now assigned 1, 2, respectively.

You also want to delete this fragment of code as well:

:reboot

const-string v4, "now"

invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void

Step 3.

This is where the patch becomes a bit more involved, as the structures have changed a bit.

In GlobalActions.smali, we will add two new variables at the top of the smali:

.field private mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

.field private mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

Now find:

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

and the following code will go directly after that line:

new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$15;

const v1, 0x10807d0 # recov icon resource id

const v2, 0x104064f # recov string resource id

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$15;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$16;

const v1, 0x10807d1 # dl icon resource id

const v2, 0x1040650 # dl string resource id

invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$16;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

NOTE the resource/string IDs..If you mess that up or forget, you will get reboots! Also note that the globalactions$15/16 may vary depending on your base firmware.

Just below the code you just pasted, you will see the array size line const/4 v0, 0x6. Change it to:

const/16 v0, 0x8

Below that line you will see the array filled with the various functions, so we want to insert our 2 new functions just before

invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList

const/4 v1, 0x6

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRecovery:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

const/4 v1, 0x7

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDownload:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

And that's all for GlobalActions.smali. Lastly, you want to create GlobalActions$15 & 16 based upon the proper singlepress template (for LP3, it was GlobalActions$5). And don't forget when you make the changes within those 2 files, to adjust the const/4 v2, 0x2/3 to 1/2.

Read over the OP a few times then follow this, and it should work out :)