[HTC Sensation] f948lan:
Modded apk for HTC One X+ (JB, Sense 4+)

All,

Thanks for the great info.

I've been Windows Mobile (HD, HD2) for a few years, and have finally made the Jump to Android (been waiting for TomTom on Android). So I'm a bit of a noob, but the instructions here were enough to get me on the learning curve and here's the result...

I'm pleased to provide a working Mail-nonprime.apk for HTC One X + (International). This phone is running JB and Sense 4+. If you have one of these on the stock ROM, this should work to remove the Exchange policy for you (works for me anyway).

There were a few extra steps I had to take above the tutorial on page 1. As a noob it took me a lot of reading and trial and error to get to this, so I'll put it all here in the hope of helping others working on a JB/Sense 4+ or similar config:

It's Mail-nonprime.apk (Not Mail.apk) you need to patch.

This, (like many stock ROMs apparently) is an odexed ROM, ie. there are both Mail-nonprime.apk and Mail-nonprime.odex files. Trying to decompile just the apk won't work, as it only has resources in, the code is in the odex file.

So the next step is to to de-odex:

Get a recent version of xUltimate (2.4.2 worked for me)

With it (main.exe), grab all the frameworks off the device (might be safe to skip this step - not sure if they are needed to de-odex the apps or not)

In the folder "origi_app" under the xUltimate, place the Mail-nonprime.apk and Mail.nonprime.odex

Tell xUltimate to deodex the apps - this will leave you one Mail-nonprime.apk in the done-app folder

The frameworks from the APK multitool site were not suitable for me, so I grabbed:

com.htc.resources.apk and framework-res.apk from /system/framework on my device (adbfileexplorer is your friend here)

and imported these into APK multitool (put in "other" folder, then run setup and tell it to setup frameworks)

The deoxed apk from above now contained the code, but no resources so I:

Decompiled (Source only) the original Mail-nonprime.apk with APKMultiTool - this gets a folder with the binary resources etc.

Decompiled (Source only) the de-oxed Mail-nonprime.apk with APKMultiTool - rename it to something different so you end up with 2 projects in the output.

Copy all the files from the second (deoxed decompile) project to the first Mail-nonprime.apk project folder, don't overwrite files that are already there.

It's important to do the renaming this way around, as when you come to compile again, you want it looking for the signature on the original Main-nonprime.apk - not the de-oxed one (which didn't have a signature).

Make the changes to the smali as described on the first post. EXCEPT:

In ProvisionUtil.smali, there is a "DevicePolicyManager;->isAdminActive" in a method called "enforcePolicyToAdmin". For this method, insert

const/4 v2, 0x0​

after the move-result line (note the ending 0x0 rather than 0x1 used elsewhere). Without this is will try to enforce the policy and fail due to no admin, resulting in an error trying to add a mail account.

The second instructions in the OP for the "goto" blocks were not very clear to me - I had to decompile other stock and patched apks from this thread to understand that I had to add a new goto point, not use an existing one. This means:

Find the method downloadPolicy in SyncManager.smali.

Check through the method for an unused number for goto_X (X being the number) - goto_4 worked for me.

Find "processProvisionData25" in the method

Look above for "if-eqz v13, :cond_b" (not "if-eqz v13, :cond_a which was closer but didn't work).

Put "goto :goto_4" just below it (without the quotes).

Search down the method for "processProvisionData121"

Look below for ":cond_b"

Put ":goto_4" just below it (without the quotes).

Save the files, use APKMultiTool to do a system compile, check the log to ensure there are no errors then pop the file on your device.

When copying the new Mail-nonprime.apk to my phone, move Mail-nonprime.odex out of /system/apps to avoid issues.

Didn't even have to restart - added a new mail account and it worked great!

Hope this helps someone.

Regards,

Graham