Quantcast
Channel: How To's | Everything Tech - Appuals.com
Viewing all articles
Browse latest Browse all 4542

How to Add Reboot Recovery button to Galaxy S7 Edge Power Menu

$
0
0

Many Android users wish there was a simpler way to reboot into Recovery mode, without needing to turn off their device first. This guide for the Samsung Galaxy S7 Edge will help you add a Reboot Recovery button to the Power menu from inside the Android system.

We’re going to be working within the framework-res.apk and services.jar files of stock ROM, so if you’re on a custom ROM, this guide is not intended for you. I have provided links to download the stock framework-res.apk and services.jar files below.

Requirements:

  1. So first thing you need to do is download and extract the above .zip files onto your desktop.
  2. Also download the APK Easy Tool.
  3. Now enable USB Debugging on your Galaxy S7 by going to Settings > About > tap ‘Build Number’ 7 times, until Developer Mode is activated. Now go to Settings > Developer Options > enable USB Debugging.
  4. Connect your Galaxy S7 to your PC via USB, and hold Shift + Right click inside your main ADB folder, and choose “Open a command window here”.
  5. Now make sure ADB recognizes your device by typing ‘adb devices’ without the quotes. If successful, the command terminal should display your device’s serial number.
  6. Now type the following commands into the ADB window:

adb pull /system/framework/framework-res.apk <Destination Directory>
adb pull /system/framework/services.jar <Destination Directory>

Change the <Destination Directory> to a folder of your choice.

  1. Now open APK Easy Tool, and choose Select next to “APK file to work on”. Choose the framework-res.apk you pulled from your Galaxy S7. Now click the Decompile button.

  1. Now go into the directory of the decompiled .APK file, and paste the files from the framework-res .zip file I provided into the decompiled folder of your framework-res.apk.
  2. Now using a text editor, I really recommend something like Notepad++ that can organize XML code, open the res/values/arrays.xml
  3. Now here is where we are going to get really technical. You need to add all the lines I display in bold in the following snips of code.
  4. Find <string-array name=”config_globalActionsList”> and add what I’ve bolded.

<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>
        <item>rebootrecovery</item>
        <item>emergencymode</item>
<item>subscreen</item>
<item>screenrec</item>

</string-array>

  • Now go to res/values/strings.xml and add the bold.

<string name=”charging_connected_via_usb”>Charging connected device via USB…</string>
<string name=”config_tspstate_threshold”>10,32,768,10,60</string>
<string name=”tw_ic_do_rebootrecovery”>Reboot Recovery</string>

  • Okay, we’re done with framework-res.apk. You can now recompile it in APK Easy Tool.
  • Now we’re going to work on Services.jar, so decompile Services.jar with APK Easy Tool, and copy the files from the Services jar .zip file I provided above into the newly decompiled Services.jar folder.
  • Now using a text editor, open smali/com/android/server/policy/GlobalActions.smali, and again you are going to add the bolded line in the # instance fields

.field mEmergencyStringId:I
.field private mRebootRecovery:Lcom/android/server/policy/GlobalActions$SinglePressAction;

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

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;->(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;
    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;->(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;
    invoke-static {}, Lcom/samsung/android/feature/SemCscFeature;->getInstance()Lcom/samsung/android/feature/SemCscFeature;
    move-result-object v4
    const-string/jumbo v5, "CscFeature_Common_ConfigBikeMode"
  • The next part is tricky, you need to add the bold lines and modify the underlined.
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;->(Lcom/android/server/policy/GlobalActions;)V
    move-object/from16 v0, p0
    iget-object v5, v0, Lcom/android/server/policy/GlobalActions;->mItems:Ljava/util/ArrayList;
	const/16 v6, 0x100
    move-object/from16 v0, p
    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
    const/16 v6, 0x200 #before was 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
  • Now search for const-string/jumbo v4, “silent” and add these lines above it. The two bolded lines must match.
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 :goto_7
    :cond_15
    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 :goto_7
    :cond_asc1
    const-string/jumbo v4, "silent"

Next we need add a missing part of Android 7 services.jar, so we’re going to re-add it for this mod to work.
Find the line for .method private addCustomDialogItems(Landroid/graphics/drawable/BitmapDrawable;Ljava/lang/String;Landroid/content/Intent;ILjava/util/ArrayList;)Z

And 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

That’s it, now recompile the services.jar, and you can push both the recompiled framework-res.apk and services.jar back onto your phone, either with adb push command or with APK Easy Tool “Install to Phone” button.

If you get boot loop after pushing to phone, boot into custom recovery and wipe Dalvik + Cache.

The post How to Add Reboot Recovery button to Galaxy S7 Edge Power Menu appeared first on Appuals.com.


Viewing all articles
Browse latest Browse all 4542

Trending Articles