[Android General] asc1977:
How to add Reboot Recovery to power menu with toggle

Credits goes to [MENTION=5096388]sagitt67[/MENTION] and [MENTION=4714483]daxgirl[/MENTION] .

Credits for toggle goes to [MENTION=1042140]tdunham[/MENTION]

Now after some fc and logcats of old guides i finished sucessfull the mod and share what i have done

We work in framework-res.apk and services.jar

Framework-res.apk

Download framework.zip

Paste files in same folders of decompiles freamework-res.apk

now open res/values/arrays.xml

find <string-array name="config_globalActionsList"> and add blue

<string-array name="config_globalActionsList">
<item>power</item>
<item>datamode</item>
<item>airplane</item>
<item>restart</item>
<item>lockdown</item>
<item>bugreport</item>
<item>users</item>
[COLOR="Blue"]<item>rebootrecovery</item>[/COLOR]
<item>emergencymode</item>
<item>subscreen</item>
<item>screenrec</item>
</string-array>

now go to res/values/strings.xml and add blue

<string name="charging_connected_via_usb">Charging connected device via USB...</string>
<string name="config_tspstate_threshold">10,32,768,10,60</string>
[COLOR="Blue"]<string name="tw_ic_do_rebootrecovery">Reboot Recovery</string>[/COLOR]
</resources>

done with framework-res.apk

recompile and push to phone

Services.jar

download services.zip and paste files in same folders of decompiles services.jar

open smali/com/android/server/policy/GlobalActions.smali

add blue line in # instance fields

.field mEmergencyStringId:I

[COLOR="Blue"].field private mRebootRecovery:Lcom/android/server/policy/GlobalActions$SinglePressAction;[/COLOR]

.field private mGlobalActionsFrameLayout:Landroid/app/GlobalActionsFrameLayout

find .method private createDialog()Lcom/android/server/policy/GlobalActions$GlobalActionsDialog;

add blue

if-eqz v4, :cond_8

const v4, 0x10809f4

:goto_4
const v6, 0x10406e2

move-object/from16 v0, p0

invoke-direct {v5, v0, v4, v6}, Lcom/android/server/policy/GlobalActions$20;-><init>(Lcom/android/server/policy/GlobalActions;II)V

move-object/from16 v0, p0

iput-object v5, v0, Lcom/android/server/policy/GlobalActions;->mRestart:Lcom/android/server/policy/GlobalActions$SinglePressAction;

[COLOR="blue"]new-instance v4, Lcom/android/server/policy/GlobalActions$47;

move-object/from16 v0, p0

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

invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

move-result-object v0

const-string v1, "tw_ic_do_rebootrecovery"

const-string v2, "drawable"

const-string v3, "android"

invoke-virtual {v0, v1, v2, v3}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

move-result v5

move-object/from16 v0, p0

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

invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

move-result-object v0

const-string v1, "tw_ic_do_rebootrecovery"

const-string v2, "string"

const-string v3, "android"

invoke-virtual {v0, v1, v2, v3}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

move-result v6

move-object/from16 v0, p0

invoke-direct {v4, v0, v5, v6}, Lcom/android/server/policy/GlobalActions$47;-><init>(Lcom/android/server/policy/GlobalActions;II)V

move-object/from16 v0, p0

iput-object v4, v0, Lcom/android/server/policy/GlobalActions;->mRebootRecovery:Lcom/android/server/policy/GlobalActions$SinglePressAction;[/COLOR]

invoke-static {}, Lcom/samsung/android/feature/SemCscFeature;->getInstance()Lcom/samsung/android/feature/SemCscFeature;

move-result-object v4

const-string/jumbo v5, "CscFeature_Common_ConfigBikeMode"

Now next part is tricky, add lines in blue and changes in green

const/16 v6, 0x80

const/4 v7, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v6, v4, v5, v7}, Lcom/android/server/policy/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/server/policy/GlobalActions$Action;Ljava/util/ArrayList;Z)Z

new-instance v4, Lcom/android/server/policy/GlobalActions$BugReportAction;

move-object/from16 v0, p0

invoke-direct {v4, v0}, Lcom/android/server/policy/GlobalActions$BugReportAction;-><init>(Lcom/android/server/policy/GlobalActions;)V

move-object/from16 v0, p0

iget-object v5, v0, Lcom/android/server/policy/GlobalActions;->mItems:Ljava/util/ArrayList;

[COLOR="Blue"]const/16 v6, 0x100

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/server/policy/GlobalActions;->mRebootRecovery:Lcom/android/server/policy/GlobalActions$SinglePressAction;

move-object/from16 v0, p0

iget-object v5, v0, Lcom/android/server/policy/GlobalActions;->mItems:Ljava/util/ArrayList;

const/4 v7, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v6, v4, v5, v7}, Lcom/android/server/policy/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/server/policy/GlobalActions$Action;Ljava/util/ArrayList;Z)Z [/COLOR]

const/16 v6, 0x200 [COLOR="Magenta"]#before was 0x100[/COLOR]

const/4 v7, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v6, v4, v5, v7}, Lcom/android/server/policy/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/server/policy/GlobalActions$Action;Ljava/util/ArrayList;Z)Z

now search for const-string/jumbo v4, "silent" and add blue line above it and delete red ones

green parts must match yellow part

const-string/jumbo v4, "emergencymode"

invoke-virtual {v4, v11}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v4

if-eqz v4, :cond_15

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/server/policy/GlobalActions;->mItems:Ljava/util/ArrayList;

move-object/from16 v0, p0

iget-object v5, v0, Lcom/android/server/policy/GlobalActions;->mEmergency:Lcom/android/server/policy/GlobalActions$ToggleAction;

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

goto/16 :[COLOR="Yellow"]goto_7[/COLOR] #look that green part match this

:cond_15
[COLOR="Blue"]const-string/jumbo v4, "rebootrecovery"

invoke-virtual {v4, v11}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v4

if-eqz v4, :cond_asc1

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/server/policy/GlobalActions;->mItems:Ljava/util/ArrayList;

move-object/from16 v0, p0

iget-object v5, v0, Lcom/android/server/policy/GlobalActions;->mRebootRecovery:Lcom/android/server/policy/GlobalActions$SinglePressAction;

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

goto/16 :[COLOR="Green"]goto_7 [/COLOR]

:cond_asc1[/COLOR]
const-string/jumbo v4, "silent"

next part is missing in Android 7 services.jar so we need to readd it for mod

find .method private addCustomDialogItems(Landroid/graphics/drawable/BitmapDrawable;Ljava/lang/String;Landroid/content/Intent;ILjava/util/ArrayList;)Z

add this above method

.method static synthetic access$500(Lcom/android/server/policy/GlobalActions;)Landroid/content/Context;
.locals 1

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

return-object v0
.end method

thats it, recompile and push to phone

Note: For me one time i get after reboot a loop of phone restarts, only one time happens. If it happen i solved it with wipe dalvik-cache and cache

RomControl V2

<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Reboot Recovery Button" android:key="reboot_recovery" android:defaultValue="false" android:summaryOn="Reboot Recovery will be shown" android:summaryOff="Currently removed" />