[Sony Cross-Device Development Themes and Apps] venkat kamesh:
Hello guys Here is a small tut on how to add 5 way advanced reboot menu

This is only for Deodexed files

The Files which need work are

Framework-res.apk

android.policy.jar

framework.jar

services.jar

Things You need are Baksmali version of 1.5

Here you can get it Click here

Apktool

signer tool

Thinking Brain and Patience

First We start with Framework-res.apk

Decompile it

Add these lines here in file /res/values/strings.xml

<string name="apm_reboot">Reboot</string>
<string name="apm_hotreboot">Hot reboot</string>
<string name="apm_recovery">Recovery</string>
<string name="apm_bootloader">Bootloader</string>
<string name="apm_safemode">Safe mode</string>

Then add these files to images to framework-res.apk View attachment 3531725

Then Compile and Decompile again ( for public ids )

Ok Now Decompile android.policy.jar ( using Baksmali )

After Decompile Place the files to ( com/android/internal/policy/impl ) path View attachment 3531728

Now After Placing These 7 files open them in NotePad++ ( all 7 files )

Look For the .method private constructor <init> now Replace the Public Ids as per framework-res.apk created ( dont confuse everything was written )

Now Look For GlobalActions.smali and open it on notepad++

Look for

Lcom/android/internal/policy/impl/GlobalActions$PowerAction;

Then add these lines Above that

Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsReceiver;,
Lcom/android/internal/policy/impl/GlobalActions$PowerActionBootloader;,
Lcom/android/internal/policy/impl/GlobalActions$PowerActionHotReboot;,
Lcom/android/internal/policy/impl/GlobalActions$PowerActionReboot;,
Lcom/android/internal/policy/impl/GlobalActions$PowerActionRecovery;,
Lcom/android/internal/policy/impl/GlobalActions$PowerActionSafemode;,

Look For

.field private mHandler:Landroid/os/Handler;

Add Below

.field private mGlobalActionsReceiver:Landroid/content/BroadcastReceiver;

Look For

new-instance v4, Lcom/android/internal/policy/impl/GlobalActions$7;

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

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

Add After That These lines

new-instance v4, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsReceiver;

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

iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mGlobalActionsReceiver:Landroid/content/BroadcastReceiver;

Look for

iget-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

invoke-virtual {p1, v4, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

Add after that code These lines

new-instance v1, Landroid/content/IntentFilter;

invoke-direct {v1}, Landroid/content/IntentFilter;-><init>()V

const-string v4, "android.intent.action.GLOBAL_ACTION_DIALOG"

invoke-virtual {v1, v4}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

iget-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mGlobalActionsReceiver:Landroid/content/BroadcastReceiver;

invoke-virtual {p1, v4, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

Look For

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerAction;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

Add After that

invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/GlobalActions;->getSysAPMTweak()Z

move-result v2

if-eqz v2, :cond_skip

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialogAdv;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
:cond_skip

Find this Method

.method private createDialog()Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;

After that Add this method ( meant after .end method )

.method private createDialogAdv()Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;
.locals 13

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

const v2, 0x1080377 #drawable ic_lock_airplane_mode

const v3, 0x1080379 #drawable ic_lock_airplane_mode_off

const v4, 0x10400fe #string global_actions_toggle_airplane_mode

const v5, 0x10400ff #string global_actions_airplane_mode_on_status

const v6, 0x1040100 #string global_actions_airplane_mode_off_status

move-object v1, p0

invoke-direct/range {v0 .. v6}, Lcom/android/internal/policy/impl/GlobalActions$1;-><init>(Lcom/android/internal/policy/impl/GlobalActions;IIIII)V

new-instance v0, Ljava/util/ArrayList;

invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerActionReboot;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerActionHotReboot;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerActionBootloader;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerActionRecovery;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$PowerActionSafemode;

const/4 v2, 0x0

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

invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

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

const/4 v1, 0x0

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

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

new-instance v12, Lcom/android/internal/app/AlertController$AlertParams;

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

invoke-direct {v12, v0}, Lcom/android/internal/app/AlertController$AlertParams;-><init>(Landroid/content/Context;)V

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAdapter:Lcom/android/internal/policy/impl/GlobalActions$MyAdapter;

iput-object v0, v12, Lcom/android/internal/app/AlertController$AlertParams;->mAdapter:Landroid/widget/ListAdapter;

iput-object p0, v12, Lcom/android/internal/app/AlertController$AlertParams;->mOnClickListener:Landroid/content/DialogInterface$OnClickListener;

const/4 v0, 0x1

iput-boolean v0, v12, Lcom/android/internal/app/AlertController$AlertParams;->mForceInverseBackground:Z

new-instance v10, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

invoke-direct {v10, v0, v12}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;-><init>(Landroid/content/Context;Lcom/android/internal/app/AlertController$AlertParams;)V

const/4 v0, 0x0

invoke-virtual {v10, v0}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->setCanceledOnTouchOutside(Z)V

invoke-virtual {v10}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->getListView()Landroid/widget/ListView;

move-result-object v0

const/4 v1, 0x1

invoke-virtual {v0, v1}, Landroid/widget/ListView;->setItemsCanFocus(Z)V

invoke-virtual {v10}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->getListView()Landroid/widget/ListView;

move-result-object v0

invoke-virtual {v10}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->getWindow()Landroid/view/Window;

move-result-object v0

const/16 v1, 0x7d9

invoke-virtual {v0, v1}, Landroid/view/Window;->setType(I)V

invoke-virtual {v10, p0}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->setOnDismissListener(Landroid/content/DialogInterface$OnDismissListener;)V

return-object v10
.end method

Now find

# virtual methods

Add after this below code

.method public getSysAPMTweak()Z
.locals 4

const/4 v0, -0x1

iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

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

move-result-object v1

const-string v2, "tweaks_apm"

const/4 v3, -0x2

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

move-result v1

if-nez v1, :cond_0

const/4 v0, 0x1

:goto_0
return v0

:cond_0
const/4 v0, 0x1

goto :goto_0
.end method

Now Find this method

.method public showDialog(ZZ)V

After that Add this method (after .end method )

.method public showDialogAdv()V
.locals 2

invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->createDialogAdv()Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;

move-result-object v0

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

invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->prepareDialog()V

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDialog:Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;

invoke-virtual {v0}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->show()V

iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mDialog:Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;

invoke-virtual {v0}, Lcom/android/internal/policy/impl/GlobalActions$GlobalActionsDialog;->getWindow()Landroid/view/Window;

move-result-object v0

invoke-virtual {v0}, Landroid/view/Window;->getDecorView()Landroid/view/View;

move-result-object v0

const/high16 v1, 0x10000

invoke-virtual {v0, v1}, Landroid/view/View;->setSystemUiVisibility(I)V

return-void
.end method

Now recompile Classes and replace the classes.dex with android.policy.jar and sign it

Here it was end with the Android.policy.jar ( be sure with Public ids )

If you have any doubts or conflict as not found just compare my file to fix this ( compile file View attachment 3532039 )

Next step will be in second post (below )