[Galaxy Y GT-S5360 Android Development] bumslayer:
Reversing android.policy.jar

If you haven’t done so, change back to your work folder (cd \temp\epm if you are following my example).

Decompile android.policy.jar with apktool. By this time, I presume you now know how to do this.

Place copies of the GlobalActions*.smali files you extracted previously inside the android.policy.jar.out\smali\com\android\internal\policy\impl\ folder.

Open android.policy.jar.out.smali\com\android\internal\policy\impl\GlobalActions.smali with notepad++.

We will be modifying codes inside .method private createDialog()Landroid/app/AlertDialog;. Begin by searching for the method name.

We need to increase the size of the array for the power menu dialog. Do this by replacing

const/4 v11, 0x4

with

const/4 v11, [B]0x5[/B]

just a few lines after the method header (line 432).

Now, search for

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

aput-object v2, v0, v1

Insert the following codes after the aput-object v2, v0, v1 line:

const/4 v1, 0x4

new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$99;

const v3, 0x10803ef # id of ics_bum_restart

const v4, 0x10404d3 # id of bum_restart

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

aput-object v2, v0, v1

Make note of the ids of v3 and v4. They should match the ids you have generated after working with framework-res.apk and which you previously saved in Step II.7. Also note that the ids of resources in smali codes are not preceded with zeros after 0x. Thus,

const v3, 0x10803ef

corresponds to

[COLOR="blue"]<public [COLOR="Red"]type[/COLOR]=[COLOR="Purple"]"drawable"[/COLOR] [COLOR="red"]name[/COLOR]=[COLOR="purple"]"ic_bum_restart"[/COLOR] [COLOR="red"]id[/COLOR]=[COLOR="purple"]"0x010803ef[/COLOR]" />[/COLOR]

Once you have ensured that your codes are in order, save and close GlobalActions.smali.

Now, open android.policy.jar.out.smali\com\android\internal\policy \impl\GlobalActions$SinglePressAction.smali

Add the following codes before the line # instance fields:

# static fields
.field protected static rebootMode:I

.field protected static final rebootOptions:[Ljava/lang/String;

Add the following codes after the line # direct methods

.method static constructor <clinit>()V
.locals 3

const/4 v0, 0x3

new-array v0, v0, [Ljava/lang/String;

const/4 v1, 0x0

const-string v2, "Reboot"

aput-object v2, v0, v1

const/4 v1, 0x1

const-string v2, "Hot Boot"

aput-object v2, v0, v1

const/4 v1, 0x2

const-string v2, "Recovery"

aput-object v2, v0, v1

sput-object v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootOptions:[Ljava/lang/String;

return-void
.end method

Your modifications should look as follows after your changes:

.class abstract Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
.super Ljava/lang/Object;
.source "GlobalActions.java"

# interfaces
.implements Lcom/android/internal/policy/impl/GlobalActions$Action;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lcom/android/internal/policy/impl/GlobalActions;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x40a
name = "SinglePressAction"
.end annotation

[B][COLOR="Blue"]# static fields
.field protected static rebootMode:I

.field protected static final rebootOptions:[Ljava/lang/String;[/COLOR][/B]

# instance fields
.field private final mIconResId:I

.field private final mMessageResId:I

# direct methods
[B][COLOR="blue"].method static constructor <clinit>()V
.locals 3

const/4 v0, 0x3

new-array v0, v0, [Ljava/lang/String;

const/4 v1, 0x0

const-string v2, "Reboot"

aput-object v2, v0, v1

const/4 v1, 0x1

const-string v2, "Hot Boot"

aput-object v2, v0, v1

const/4 v1, 0x2

const-string v2, "Recovery"

aput-object v2, v0, v1

sput-object v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootOptions:[Ljava/lang/String;

return-void
.end method[/COLOR][/B]

.method protected constructor <init>(II)V
.locals 0
.parameter "iconResId"
.parameter "messageResId"
. . .

Save and close GlobalActions$SinglePressAction.smali.

Compile android.policy.jar.out. You know how to do it, right?

Open the original android.policy.jar with winrar. Replace the classes.dex inside with the one in android.policy.jar.out/build/apk/.

You are done.

Final Steps

There is really nothing left to do but to push the modified framework-res.apk and android.policy.jar back into your /system/framework/ folder. If you are doing it using root explorer, I recommend pushing framework-res.apk first, change its permission to 644 and reboot your phone. Then, do the same for android.policy.jar.