[Android Software/Hacking General [Developers Only]] titanic_fanatic:
Hey guys,

I have a stock de-odexed 4.1.2 rom from samsung for my SGH-I757M (S2HDLTE). I want to apply some tweaks to the system, such as adding an extended power menu, and additional toggles.

I have made modifications to the framework-res.apk to include two new string resources (Recovery, Download) and two new image resources (for the Recovery and Download entries). I compiled and decompiled that to get the hex values for the new resources and copied the new classes.dex file to my existing framework-res.apk (backed up of course).

I then decompiled android.policy.jar and copied GlobalActions$5.smali (this is the one that takes care of reboot) twice as GlobalActions$98.smali and GlobalActions$99.smali and made the necessary changes changing GlobalActions$5 to GlobalActions$98/GlobalActions$99 where applicable (did not add code to handle recover or download yet as I wanted to test it). I then recompiled that and pulled the new classes.dex into my existing android.policy.jar file.

I pushed both files to my phone, chmodded 644 and rebooted the phone. Success... I now have the extended power menu setup with the 2 new entries while they still perform the same action as GlobalActions$5.smali (reboot), at least I know I'm headed in the right direction.

Now I added the following smali code to my GlobalActions$98.smali and GlobalActions$99.smali in hopes of using the reboot(String reason) method to handle a "Reboot to Recovery" and "Reboot to Download":

const-string v2, "power"

invoke-virtual {p1, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

move-result-object v1

check-cast v1, Landroid/os/PowerManager;

.local v1, pm:Landroid/os/PowerManager;
const-string v2, "recovery"

invoke-virtual {v1, v2}, Landroid/os/PowerManager;->reboot(Ljava/lang/String;)V
.end local v1

This code was found here:

http://www.thriveforums.org/forum/toshiba-thrive-development/13690-ics-reboot-recovery-shutdown-menu-3.html#post126616

This compiles without issue and the phone boots up without issue, but now when I long press the power button, it vibrates and nothing pops up, then after a couple of seconds, the phone reboots. Looking in my logcat provides me with this error message:

E/AndroidRuntime( 518): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManagerPolicy
E/AndroidRuntime( 518): java.lang.VerifyError: com/android/internal/policy/impl/GlobalActions$98
E/AndroidRuntime( 518):	at com.android.internal.policy.impl.GlobalActions.createDialog(GlobalActions.java:389)
E/AndroidRuntime( 518):	at com.android.internal.policy.impl.GlobalActions.handleShow(GlobalActions.java:184)
E/AndroidRuntime( 518):	at com.android.internal.policy.impl.GlobalActions.showDialog(GlobalActions.java:179)
E/AndroidRuntime( 518):	at com.android.internal.policy.impl.PhoneWindowManager.showGlobalActionsDialog(PhoneWindowManager.java:1649)
E/AndroidRuntime( 518):	at com.android.internal.policy.impl.PhoneWindowManager$6.run(PhoneWindowManager.java:1527)
E/AndroidRuntime( 518):	at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime( 518):	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 518):	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 518):	at com.android.server.wm.WindowManagerService$PolicyThread.run(WindowManagerService.java:957)

I'm brand new to smali (not to programming though), and have not found much useful information in the way of smali editing and would like some help resolving this java.lang.VerifyError if possible. I've attached GlobalActions.smali, GlobalActions$5.smali, GlobalActions$98.smali, GlobalActions$99.smali as a context for my edits above.

Any ideas what could be causing a java.lang.VerifyError?