[MOD] 4-Way Reboot - How to (GB) (ICS) (JB)

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
Thanks to snq- for original 4-way reboot.

Got the idea from THIS thread.



This is just simple mod that adds 4 booting options behind power menus "power off" -button ( 1. reboot 2. hot boot 3. recovery 4. download ).
So, compared to advanced power menu, this has only one new button. But I made this because now there is no need for framework.jar/framework-res changes. This is much more friendly to update.


I only make this tutorial and attach needed files. Everyone can use it way they want to, but give credit to original maker.



Check THIS post for Samsung ICS roms
Check THIS post for Samsung JB roms




Problem? Check THESE for help.



What you need to do is:
-Decompile android.policy.jar of your rom
-Copy attached folder to yours
-Open GlobalActions.smali
-Search line "Lcom/android/internal/policy/impl/GlobalActions$4;" ( some roms might have different number on shutdown button. You find right one by for example tracing shutdown icon id )
-Change number 4 to 99 ( two of them )

Before
Code:
    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$4;

    const v3, 0x1080030

    const v4, 0x1040150

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$4;->(Lcom/android/internal/policy/impl/GlobalActions;II)V
After
Code:
    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$99;

    const v3, 0x1080030

    const v4, 0x1040150

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$99;->(Lcom/android/internal/policy/impl/GlobalActions;II)V
-Open GlobalActions$SinglePressAction.smali
-Before line "# instance fields"
paste following code
Code:
# static fields
.field protected static rebootMode:I

.field protected static final rebootOptions:[Ljava/lang/String;
-Then after line "# direct methods"
paste following code
Code:
.method static constructor ()V
    .registers 3

    const/4 v0, 0x5

    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, "Download"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    const-string v2, "Recovery"

    aput-object v2, v0, v1

    const/4 v1, 0x4

    const-string v2, "Shutdown"

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

    return-void
.end method
-So your file should look something like this after those changes
Code:
.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


# static fields
.field protected static rebootMode:I

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


# instance fields
.field private final mIconResId:I

.field private final mMessageResId:I


# direct methods
.method static constructor ()V
    .registers 3

    const/4 v0, 0x5

    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, "Download"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    const-string v2, "Recovery"

    aput-object v2, v0, v1

    const/4 v1, 0x4

    const-string v2, "Shutdown"

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

    return-void
.end method

.method protected constructor (II)V
    .registers 3
    .parameter "iconResId"
    .........
    .........
-Compile .jar and your done.


 

Attachments

Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
Additional

If you don't want that "Shutdown Method" text on top of that menu then:
-Open GlobalActions$99.smali
-Remove following code
Code:
    const-string v2, "Shutdown Method"

    invoke-virtual {v1, v2}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    move-result-object v1
 
Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
Hi, i tried to do this mod but not work....the option menu disappears and system reboot...
I renamed the file and his path in GlobalActions$15.smali but I can not make it work...
Hi!

You have to change those three files names then. In your case like 15, 15$1, 15$2. Then you changed that path in globalactions from 4 to 15? Great so far. Now you need to change every name called globalactions$10 to that $15 inside those three files i attached. You might want to use notepad++ for this. There's addon that can do this easily.

Maybe i rename those files to something else, since people have so big numbers on globalactions.

EDIT. I uploaded new source files. Now It's named $99, so i bet that none have that already existing. Edited tutorial also, so you name 4 to 99 in GlobalActions.smali :)
 
Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
What rom is that? is it ICS?
My bad that i have not been using ICS yet. Atleast your rom have build that global.actions differently. Your power off button is number $5. So instead of changing that 4 to 99, you should change 5 to 99. There can be something else changed also, but you can try just that if you like. Or since you have restart button already(?) then if i was you i would replace that button ($6) and then remove that shutdown from my files.

I should flash ICS and test this on it.
 
Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
Samsung ICS roms

What you need to do is:
-Decompile android.policy.jar of your rom
-Copy attached ICS folder to yours (POST 1)
-In file "GlobalActions$99.smali" there is id 0x1110008, you might want to check that this id is same in you roms puplic.xml ( config_sf_slowBlur ). In gingerbread roms this did not change, but not I'm not sure about these ICS roms.
( check also that ids 0x104000a = "ok" -string and 0x104 = "cancel" -string matches in your framework. )
-Open GlobalActions.smali
-Search line "new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$6;" ( some roms might have different number on reboot button. You find right one by for example tracking mRestart. See example below. )
-Change number 6 to 99 ( two of them )

Before
Code:
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$6;

    const v1, 0x1080640

    const v2, 0x1040165

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

    iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
After
Code:
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$99;

    const v1, 0x1080640

    const v2, 0x1040165

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

    iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
-Open GlobalActions$SinglePressAction.smali
-Before line "# instance fields"
paste following code
Code:
# static fields
.field protected static rebootMode:I

.field protected static final rebootOptions:[Ljava/lang/String;
-Then after line "# direct methods"
paste following code
Code:
.method static constructor <clinit>()V
    .registers 3

    const/4 v0, 0x4

    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, "Download"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    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
-So your file should look something like this after those changes
Code:
.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


# static fields
.field protected static rebootMode:I

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


# instance fields
.field private final mIconResId:I

.field private final mMessageResId:I


# direct methods
.method static constructor <clinit>()V
    .registers 3

    const/4 v0, 0x4

    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, "Download"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    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

.method protected constructor <init>(II)V
    .registers 3
    .parameter "iconResId"
    .........
    .........
-Compile .jar and your done.


 
Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
I'm sorry but can not seem to make it work:(
I follow your instructions to the letter.....i don't understand:confused:

EDIT: ok ok.....finally I succeeded

Thanks 10000000


It should work. Tested it on couple of ICS roms. Attach logcat with error, then maybe i could help you.

Edit. Great man. :)
 
Last edited:

interpol2050

Member
Feb 10, 2012
7
0
0
I can't decompile android.policy.jar. It said it doesn't contain classes.dex. I opened it with winrar, it only has 1 folder META-INF. It's a SGS2 with ICS LP3
 

interpol2050

Member
Feb 10, 2012
7
0
0
I tried to deodex android.policy.jar but got this error. Could you help?

C:\Users\Q*****\Documents\Samsung\Deodex-Odex>java -Xmx1024m -jar baksmali.jar
-c :core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:framework2.j
ar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar -x android.policy
.odex


UNEXPECTED TOP-LEVEL EXCEPTION:
org.jf.dexlib.Util.ExceptionWithContext: Unknown opcode: f1
at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithCont
ext.java:54)
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(Instructio
nIterator.java:87)
at org.jf.dexlib.CodeItem.readItem(CodeItem.java:157)
at org.jf.dexlib.Item.readFrom(Item.java:76)
at org.jf.dexlib.OffsettedSection.readItems(OffsettedSection.java:48)
at org.jf.dexlib.Section.readFrom(Section.java:143)
at org.jf.dexlib.DexFile.<init>(DexFile.java:431)
at org.jf.baksmali.main.main(main.java:250)
Caused by: java.lang.RuntimeException: Unknown opcode: f1
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(InstructionIterator.java:51)
... 6 more
Error occured at code address 28
code_item @0x12c04
 
Last edited:

kahvitahra

Senior Member
Oct 19, 2010
1,022
1,143
0
I tried to deodex android.policy.jar but got this error. Could you help?

C:\Users\Q*****\Documents\Samsung\Deodex-Odex>java -Xmx1024m -jar baksmali.jar
-c :core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:framework2.j
ar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar -x android.policy
.odex


UNEXPECTED TOP-LEVEL EXCEPTION:
org.jf.dexlib.Util.ExceptionWithContext: Unknown opcode: f1
at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithCont
ext.java:54)
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(Instructio
nIterator.java:87)
at org.jf.dexlib.CodeItem.readItem(CodeItem.java:157)
at org.jf.dexlib.Item.readFrom(Item.java:76)
at org.jf.dexlib.OffsettedSection.readItems(OffsettedSection.java:48)
at org.jf.dexlib.Section.readFrom(Section.java:143)
at org.jf.dexlib.DexFile.<init>(DexFile.java:431)
at org.jf.baksmali.main.main(main.java:250)
Caused by: java.lang.RuntimeException: Unknown opcode: f1
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(InstructionIterator.java:51)
... 6 more
Error occured at code address 28
code_item @0x12c04
DL latest baksmali/smali 1.3.2 and for ICS files you also need to use API Level: 15. So add "-a 15" command when baksmalin. See HERE.
 

interpol2050

Member
Feb 10, 2012
7
0
0
I did this: Deodex -> decompile -> modify -> compile -> reodex -> copy signature. No error occured and all seem fine as expected. I placed original android.policy.jar and patched and signed android.policy.odex to /system/framework but my SG2 stuck at boot animation. Any idea? ( I restored my SG2 btw )