[Samsung Galaxy S8 ROMs, Kernels, Recoveries, & Oth] afaneh92:
Credits goes to [MENTION=5096388]sagitt67[/MENTION] and [MENTION=4714483]daxgirl[/MENTION] .

Credits for toggle goes to [MENTION=1042140]tdunham[/MENTION] main guide is here and [MENTION=4596062]asc1977[/MENTION] for the guide here big thanks to them.

In this Guide we'll modify framework-res.apk and services.jar

framework-res.apk:

Download framework-res.zip that is attached below, extract and copy it in your decompiled framework-res.apk folder

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>rebootsafestrap</item>[/COLOR]
<item>emergencymode</item>
<item>subscreen</item>
</string-array>

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

<string name="wifi_extender_notification_title">Wi-Fi extender on</string>
<string name="wifi_extender_notification_message">Tap here to set up.</string>
<string name="config_tspstate_threshold" />
[COLOR="blue"]<string name="tw_ic_do_restart_safestrap">Reboot Safestrap</string>[/COLOR]
</resources>

done with framework-res.apk recompile

Services.jar:

download services.zip that is attached below, extract and copy it in your decompiled services.jar folder

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

add blue line in # instance fields

.field private mRestart:Lcom/android/server/policy/GlobalActions$SinglePressAction;

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

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

add blue

if-eqz v4, :cond_27b

const v4, 0x1080a58

.line 1642
:goto_11c
const v6, 0x104070e

.line 1639
move-object/from16 v0, p0

invoke-direct {v5, v0, v4, v6}, Lcom/android/server/policy/GlobalActions$21;-><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$99;

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_restart_safestrap"

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_restart_safestrap"

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$99;-><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]

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

move-result-object v4

const-string/jumbo v5, "CscFeature_Common_ConfigBikeMode"

invoke-virtual {v4, v5}, Lcom/samsung/android/feature/SemCscFeature;->getString(Ljava/lang/String;)Ljava/lang/String;

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

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

.line 1767
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

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

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;[/COLOR]

const/16 v6, [COLOR="Green"]0x200[/COLOR] [COLOR="Red"]#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 green parts must match orange 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_381

.line 1835
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="orange"]goto_2d9[/COLOR] #look that green part match this

.line 1836
:cond_381
[COLOR="Blue"]const-string/jumbo v4, "rebootsafestrap"

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

move-result v4

if-eqz v4, :cond_3da

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_2d9 [/COLOR]

:cond_3da[/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

[COLOR="Blue"].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[/COLOR]

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

Credits goes to [MENTION=4469503]TheDriller[/MENTION] for this part in this guide

Note: no need to change the code in GlobalActions$99.smali already done

GlobalActions$99.smali:

find .method public onPress()V and replace blue lines with red one

move-result-object v0

check-cast v0, Landroid/os/PowerManager;

[COLOR="Red"]const-string v1, "recovery"

invoke-virtual {v0, v1}, Landroid/os/PowerManager;->reboot(Ljava/lang/String;)V[/COLOR]

to

move-result-object v0

check-cast v0, Landroid/os/PowerManager;

[COLOR="Blue"]const-string v1, "su -c echo 1 > /data/.recovery_mode && su -c reboot now"

invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;

move-result-object v2

invoke-virtual {v2, v1}, Ljava/lang/Runtime;->exec(Ljava/lang/String;)Ljava/lang/Process;[/COLOR]