[Galaxy S II Themes and Apps] mmulq:
Works on Galaxy S4

******Warning! Follow these instructions at your own risk. I am not responsible for any damage done to your phone*********

Just got this working on my GS4 and wanted to put some clear instructions up here. However, I want to preface this by letting everyone know some of the reasons an Exchange administrator will implement these security measures. So here's a short story. In my previous job, I handled system administration and security for a small IT company. I was in charge of their Exchange server. This company was developing applications/hosting databases for several local hospitals and doing some rather top secret development for a corporation whose name I won't mention. We had a tremendous amount of sensitive data on our servers. As much as I emphasized the importance of encrypting e-mails (PGP) you only want certain people to read, I knew users were still passing around a lot of sensitive information via e-mail without taking the time to encrypt. Had someone's phone with a corporate e-mail account fallen into the wrong hands and any of our client's data been compromised, we would have lost the client contract and been sued. Had this been one of our hospital clients (medical records), we would have been fined by the government as well. Both situations would have resulted in me losing my job. So, I had to keep it all safe. My Exchange security policies were strict and compliance was audited monthly. Corporate accounts weren't allowed on personal phones. If I ever found someone had modified Email.apk and Exchange.apk in the way I'm about to describe (An Exchange admin can see that they don't actually have control of your device), they would have two choices:

1. Hand the device over to me so I could wipe it. After returning the device to them, I would block mobile devices on their account and they would never be able to have a corporate e-mail account on their device again. Then, I'd let them know just how close they came to being fired and alert the CEO and general counsel. The first offense was not something you'd be fired for unless you made the second choice.

2. Refuse to hand the device over to me. At that point, I would alert my bosses, the Federal marshalls would be called (Luckily, they were right in our building because we rented space in a Federal building) to assist me in getting the device back because they were all corporate owned, and the user would be fired.

These days, my job is more relaxed. I'm not the Exchange admin here but I know him. We both know that I don't have sensitive data on my phone and I know that I won't be fired for this little workaround. This is why I've decided to go ahead and hack my GS4's email app. Before you go violating your corporate security policy, assess your situation. A good Exchange admin will find your device is out-of-compliance during a security audit.

For this to work, you must root your phone. If you're not a power user, you might not want to do this. It will void your warranty and you can mess up your phone easily with root access. You have to install the Android SDK. I used a Mac but am trying to keep these instructions as platform agnostic as I can. I am not a Windows user but hope this can serve as a guide even if some of the commands need to be edited a little.

1. To root your GS4, see here

2. To download and install the Android SDK, see here

3. Download the email-policy-patch found at the beginning of this thread and extract the contents. I extracted to my /home/Downloads/ folder to keep it simple.

4. Run the following commands from a terminal/command prompt, editing the email-policy-patch version number and the path to your Android SDK platform-tools folder as needed.

cd ~/Downloads/email-policy-patch-3.3
mkdir workdir backup
cd workdir
/android-sdk/adb pull /system/app/SecExchange.apk
/android-sdk/adb pull /system/app/SecExchange.odex
/android-sdk/adb pull /system/app/SecEmail_J.apk
/android-sdk/adb pull /system/app/SecEmail_J.odex
/android-sdk/adb pull /system/framework
cp ./* ../backup/
cd ..
./apply-patch-nix.sh workdir 16 SecEmail_J.apk SecExchange.apk

5. Output should look something like this.

Decompiling SecEmail_J.odex ...
Applying patch ...
Patching com/android/email/SecurityPolicy.isActive(Lcom/android/emailcommon/service/PolicySet;)Z
Patching com/android/email/SecurityPolicy.isActiveAdmin()Z
Patching com/android/email/SecurityPolicy.isSupported(Lcom/android/emailcommon/service/PolicySet;)Z
Patching com/android/email/SecurityPolicy.getInactiveReasons(Lcom/android/emailcommon/service/PolicySet;)I
Recompiling ...
Building SecEmail_J.apk ...
Decompiling SecExchange.odex ...
Applying patch ...
Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z
Recompiling ...
Building SecExchange.apk ...
2 apk(s) patched.
* Updated: SecEmail_J.apk
* Deleted: SecEmail_J.odex (must be deleted from device)
* Updated: SecExchange.apk
* Deleted: SecExchange.odex (must be deleted from device)
Done.

6. Now, SecEmail_J.apk and SecExchange.apk have been patched but not moved to your phone. You need to use adb to push the two apk files from your computer to your phone, remount /system/ on your phone with read/write permissions, delete the two odex files still on your phone, and move the apk files you transferred to the phone to /system/app/. Be careful with this step as you can do a lot of damage here.

/android-sdk/adb push workdir/SecEmail_J.apk /sdcard/
/android-sdk/adb push workdir/SecExchange.apk /sdcard/
/adroid-sdk/adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/system /system
cd /system/app
rm SecExchange.odex
rm SecEmail_J.odex
cp /sdcard/SecEmail_J.apk /system/app/
cp /sdcard/SecExchange.apk /system/app/

7. Reboot your phone and enjoy.

Should anything go wrong here, remember that you made a backup of your workdir in step #4 before patching. So you still have the original SecEmail_J.apk/odex and SecExchange.apk/odex. You just need to put them back.