[HTC Sensation] shantur:
[MOD][APP]Exchange Security Disabled - JB, ICS AOSP, Sense 3.6, 4.0 & 4.5 -WITH HOWTO

Some of the guys using Mike's excellent ARHD 6.3.0 (now ARHD 6.5.0 ) thread like me were are having problems with Exchange mail security. If you are one of them, then this is for you.

I have modified the Mail.apk to disable the Exchange Device Administrator completely. It is working for my Exchange Server (i dont know what version is used by my office )

No more passwords, device encryptions, sd encryptions and hidding of Unknown sources (in case of other administrators it will still hide )

Requirements :

1. HTC Sense 3.6 ( Tested on ARHD 6.5.0 ) or ICS AOSP or HTC Sense 4.0 ( Tested on Virtuous S4X ) Thanks EDD!E

2. Rooted Phone

3. Android SDK ( adb.exe )

** YOUR CURRENT EXCHANGE / MAIL ACCOUNTS WILL BE DELETED **

** BACKUP YOUR CURRENT ROM INCASE OF PROBLEMS **

To use it,

Manual Method - HTC Sense ROM

1. Download the attached Mail-<Rom Version>-<Mod Version>.apk for your Rom to folder.

2. On Phone : Goto Settings > Account & Sync. Select All Mail accounts and Select Remove Account.

3. On Phone : Goto Settings > Apps > All > Mail.

4. Do a Force Stop and Clear Data (Important Step)

5. Make sure your phone is in debug mode.

6. On PC : Goto Start > Run. Type cmd and enter

7. Enter <path to adb>\adb remount

8. Enter <path to adb>\adb push <path of downloaded apk> /system/app/Mail.apk

9. Add your exchange account.

10. No More Exchange Device Administrator Dialog.

11. Be happy and hit Thanks ;)

Automatic Script Method (Windows) - HTC Sense

1. Download and extract attached MailPatch-Script.zip

2. Download APK for your Rom and Copy it to MailPatch folder which was extracted in Step 1.

3. Rename Mail-<Rom Version>-<Mod Version>.apk to Mail.apk or Mail+nonprime.apk for Sense JB

4. Connect Phone with USB Debug Enabled ( Settings > Develop Option > USB Debugging )

5. Double Click updatemail.bat

6. Add your exchange account on phone

7. No More Exchange Device Administrator dialog.

Be happy and hit Thanks ;)

Incase of any problem, post the contents of log.txt generated in the same folder.

Manual Method - JB AOSP ROM (CM10)

1. Download the attached Exchange2_AOSP_JB.apk.

2. Make sure you have Root access to ADB in Settings > Developer Options > Root access > Apps and ADB

3. Delete your exchange account if any

4. In command prompt do following

adb root
adb remount
adb shell rm -f /system/app/Exchange2.apk
adb push Exchange2_AOSP_JB.apk /system/app/Exchange2.apk

5. Add your exchange account, it might ask you to enable the device admin if not enabled already, just enable it.

It should not ask you for device passwords or encryption.

Manual Method - ICS AOSP ROM

1. Download the attached com.android.exchange.apk.

2. Remove your exchange email account from your phone. Using email app.

3. Confirm no exchange account is there in Settings.

4. In command prompt do following

adb remount
adb uninstall com.android.exchange
adb shell rm /system/app/com.android.exchange.apk
adb push com.android.exchange /system/app/

5. Add your exchange account, it might ask you to enable the device admin if not enabled already, just enable it.

It should not ask you for device passwords or encryption.

For now it just ignores the passwords and encryption, it doesn't disable the admin completely.

You can also use ES File Explorer with Root access. If someone shares the steps I will update here...

Change Log

[B]9.July.2013[/B]

- Added Mail+nonprime-Sense4.5-Revelation1.0.0.apk for Sense JB.
Its a different mod than others, you will get the Exchange Device Admin prompt, enable it. It will not activate the security features.
You will need to use the new MailPatch-Script-JBSense.zip or replace manually with /system/app/Mail+nonprime.apk

[B]21.January.2013[/B]

- Added Mail-Sense4.5-ViperS-1.6.3 for all Sense 4.5 fans

[B]24.August.2012[/B]

- Added Exchange2_AOSP_JB.apk. Do not use script with this apk
- Added JB patch steps

[B]17.July.2012[/B]

- Added Mail-ARHD-6.7.0-v2.apk. APK taken from ARHD 6.7.0 for Sensation

[B]26.June.2012 Version2.0[/B]

- Added Mail-Amaze-Stock.apk. APK taken from Deodexed Stock Rom
- Added a simple How to for curious ones

[B]18.June.2012 Version2.0[/B]

- Added Mail-Stock-EvoLTE.apk. APK taken from Deodexed Stock Rom

[B]31.May.2012 Version2.0[/B]

- Added Mail-Sense4-OneX-Energy.apk. APK taken from OneX Energy Rom

[B]23.Apr.2012 Version2.0[/B]

- Added Mail-Sense3.6-ARHD-6.6.3-v2.0.apk. APK taken from ARHD 6.6.3 XE

[B]18.Apr.2012 Version2.0[/B]

- Added Mail-Sense4-orDroid-2.1.1.apk

[B]05.Apr.2012 Version2.0[/B]

- Added Mail-Sense3.6-ARHD-6.6-v2.0.apk. APK taken from ARHD 6.6

[B]28.Mar.2012 Version2.0[/B]

- Added Android 4.0 ICS AOSP Mod

[B]26.Mar.2012 Version2.0[/B]

- Updated Mail-Sense4.0 apk. This should fix Sense 4.0 issues.

[B]04.Mar.2012 Version2.0[/B]

- Added Mail-Sense3.6-ARHD-6.5.0-v2.0.apk for ARHD 6.5.0
- Updated Script to v2.0 for Automatic Deletion of accounts.

[B]02.Mar.2012 Version2.0[/B]

- New mod disables the Exchange Device Administrator completely.
** THIS WILL DISABLE THE REMOTE WIPE CAPABILITY TOO **
- No more hiding of "Unknown Sources" in Security Settings.
- From Version 2.0 Mail Patch script and APK are separated.
- Updated Steps according to new Version
- Discontinued ARHD 6.3.0 version

[B]02.Mar.2012 Version1.1[/B]

- Updated Mail.apk from ARHD 6.4.0.
I would recommend to use this one for 6.4.0. Apk is different from 6.3.0 and
This mod ignores all restrictions not just password and sd encryption.

- Remove all .apk attachments. APK is available in Patch only.

How to mod your own

Many people are asking me how to mod their own apks and I am not able to keep up modding all the apks myself. So, I am trying to explain steps to modify the apk. Following this method you will be able to Mod any Sense 3.5, 3.6 or 4.0 apk. ( It is Sense version not Android OS version)

I will not be teaching you the basics of apk modification and will try to be as explainatory as possible.

Requirements

APK Multitools : I use this tool for decompiling / recompiling apks.

Text Editor with File Searching capability : I use Notepad++

Modified apktool.jar for some new ics version apks.

Knowledge of smali

Patience... in bigger amounts

Steps

Use APK Multitool to decompile apk : Sources only

Goto the projects folder where the apk is decompiled and in side this folder you will find a smali folder.

In this folder using Notepad++ search for "isAdminActive" ( without quotes )

It should give you 6-7 results in 3 files. Like

invoke-virtual {v5, v0}, Landroid/app/admin/DevicePolicyManager;->isAdminActive(Landroid/content/ComponentName;)Z

move-result v5

Now we need to add a line after "move-result v5" line, so the complete becomes

invoke-virtual {v5, v0}, Landroid/app/admin/DevicePolicyManager;->isAdminActive(Landroid/content/ComponentName;)Z

move-result v5

const/4 v5, 0x1

The variable name in const line ( ie v5 ) should be same as the one in move-result line.

Add this const line to all the search results. This makes Mail.apk think that DeviceAdmin is active even if it is inactive.

Now search for "processProvisionData", you will get some results in SyncManager.smali

Out of these results few are method declaration starting with ".method" and some are constants starting with "const-string". The remaining ones are method calls which have "SyncManager;->processProvisionData25" and "SyncManager;->processProvisionData121". Select the first "SyncManager;->processProvisionData" in the search results.

These are the methods that parse the security data sent from server, we need to skip them. If you scroll up a bit you will see that there are few conditions like "if-eqz v13, :cond_a". This means if condition is fulfilled goto the tag ":cond_a"

You have to find the condition which leads to a tag skipping both SyncManager;->processProvisionData25 and SyncManager;->processProvisionData121.

In my case it is "if-eqz v13, :cond_b". Once identified, add a line after this line "goto :cond_b". This makes Mail.apk to jump the provisioning data in any condition.

Save all your files

Compile using APK multitool

When asked for system apk answer yes

Sign and try the signed-Mail.apk (or other with signed- pre-appended to file name )

Enjoy..