[Galaxy Note GT-N7000 Themes and Apps] majdinj:
<< Power Menu Safe Mode Reboot Addon >>

​

Hi xda mates,,

Have anyone of you heard about the android safe mode and for what it is used?

Well the safe mode does exist in android device to help you to uninstall any third party application that causes lag or trouble in your android OS or even boot loop that prevents you from uninstalling that app which causes the problem by the normal way.. This should be your first attempt to fix your phone before doing a full wipe..!!

To get into Safe Mode, you need to power off your phone then turn it on and then hold volume up and down until it boots completely,, You will find a little black babble in the left lower side of the phone that indicates that you are in safe mode.

To boot into safe mode using adb shell, you can try these commands:

setprop persist.sys.safemode 1
reboot

The following video will show how is the buttons combination done..

[YOUTUBE]X_wuJxhWw_s[/YOUTUBE]​

OK, I know the buttons combination could be like a pain in a$$, and because most of manufactures had disabled the long press way to boot into safe mode (thanks Samsung..!!!), so I thought of integrating it into power menu as in above screenshots using the shell commands as a source of my smali codes.. So here we go :laugh:

The Guide:

Needed Tools:

1) APK Tool. You can use APK Multi-Tool from here.

2) Baksmali Tool. You can use my manager from here.

3) Notepad++ for editing xml and smali from here.

4) And of course little amount of patience..!!!

The procedure:

The procedure will not be different from the usual integrating addons into power menu..!!

First of all, download the resources [View attachment 2324325].

1) framework-res.apk

- Decompile framework-res.apk

- Go to res\drawable-xhdpi folder and put the image resources there [tw_ic_lock_safemode.png]

- Go to res\values folder and open strings.xml file and add the following line at the end before </resources> and save:

<string name="global_action_safemode_txt">Reboot to safe mode</string>

- Now Recompile your framework-res.apk to create new ids.. Now DECOMPILE the NEW framework-res.apk and go to res\values and open public.xml file and locate these 2 ids:

<public type="drawable" name="tw_ic_lock_safemode" id="0x01080a98" />
<public type="string" name="global_action_safemode_txt" id="0x01040785" />

Keep the public.xml file opened for the moment and let's go to the next step.

2) android.policy.jar

- Baksmali android.policy.jar

- Go to classout\com\android\internal\policy\impl folder and paste the smali resource there [GlobalActions$SafeMode.smali]

- Now in the same folder find GlobalActions.smali and open it.

- In GlobalActions.smali, find the instance fields section and go to its end and add the following blue line just after ".field private mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;":

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

[B][COLOR="Blue"].field private mSafeMode:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR][/B]

.field private mRingerModeReceiver:Landroid/content/BroadcastReceiver;

- Now, Search for "[Lcom/android/internal/policy/impl/GlobalActions$Action;" for power menu arrays and increase the number of arrays (the line above it) to accommodate the total number of new arrays:

.line 418
const/4 v1, 0x[B][COLOR="Red"]5[/COLOR][/B] [B][COLOR="Green"]<!--- You need to increase the arrays number here[/COLOR][/B]

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

so it will be:

.line 418
const/4 v1, 0x[B][COLOR="Blue"]6[/COLOR][/B]

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

- Now, above the newly modified "const/4 v1, 0x6" add these action lines:

new-instance [B][COLOR="Red"]v1[/COLOR][/B], Lcom/android/internal/policy/impl/GlobalActions$99;

const [B][COLOR="Red"]v2[/COLOR][/B], 0x10808ad

const [B][COLOR="Red"]v3[/COLOR][/B], 0x1040193

move-object/from16 [B][COLOR="Red"]v0, p0[/COLOR][/B]

invoke-direct {[B][COLOR="Red"]v1, v0, v2, v3[/COLOR][/B]}, Lcom/android/internal/policy/impl/GlobalActions$99;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

move-object/from16 [B][COLOR="Red"]v0, p0[/COLOR][/B]

iput-object [B][COLOR="Red"]v1, v0[/COLOR][/B], Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

[B][COLOR="Blue"]new-instance v1, Lcom/android/internal/policy/impl/GlobalActions$SafeMode;

const v2, [COLOR="SeaGreen"]0x1080a98[/COLOR]

const v3, [COLOR="SeaGreen"]0x1040785[/COLOR]

move-object/from16 v0, p0

invoke-direct {v1, v0, v2, v3}, Lcom/android/internal/policy/impl/GlobalActions$SafeMode;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

move-object/from16 v0, p0

iput-object v1, v0, Lcom/android/internal/policy/impl/GlobalActions;->mSafeMode:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;[/COLOR][/B]

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

.line 418
const/4 v1, 0x6

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

Here, the ids above are obtained from public.xml file from framework-res.apk. The first id will represent the image resource and the second id will represent the string resource (don't forget to omit the first 0).

Also pay attention to variables and parameters, it should be matched (the red v and p)

- Now we will add new array to show in power menu. So bellow modified "const/4 v1, 0x6" add new arrays to show after the last array:

.line 418
const/4 v1, 0x6

new-array v1, v1, [Lcom/android/internal/policy/impl/GlobalActions$Action;

...
...

const/4 [B][COLOR="Red"]v2[/COLOR][/B], 0x4

move-object/from16 [B][COLOR="Red"]v0, p0[/COLOR][/B]

iget-object [B][COLOR="Red"]v3, v0[/COLOR][/B], Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object [B][COLOR="Red"]v3, v1, v2[/COLOR][/B]

[B][COLOR="Blue"]const/4 v2, 0x5

move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mSafeMode:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v3, v1, v2[/COLOR][/B]

Again, you should match all variables and parameters (v and p values)

- Save changes.. smali (recompile)

Now push the finished framework-res.apk and android.policy.jar to framework folder in your device, fix permissions to 644 and reboot and viola you made it,,, :o

Pre-made mod:

You don't have technical skills to do all these complicated things..!! Here you can download the mod and flash it in your GT-N7000 device..

The mod is based on LT9 firmware and I suppose it will work on any LTx firmware increment number.

I have included:

- PM ScreenShot mod

- PM Safe mode reboot mod

- PM Fixed Hot reboot mod

- Volume rocker mod

All in one flashable file,, so what you are waiting for,, backup your phone and give it a try :cool:

Download

(md5 sum: 8f764c74e8ec63fc6072015668811fac)

Any ROM's developer can include this mod in his/her ROM without asking for permission, although small credit in the OP will be nice.. :good:

N.B:

For toggle on and off of Power Menu addons, see post #3

Cheers,,