[Galaxy S 5 Android Development (Snapdragon)] txr33:
This is a how to add a toggle to bypass email exchange security. It has been tested and working on s3, s4, s5, s6, note 2, note 3 and note 4. And is basically the same for lollipop, kitkat and jelly bean.

This is a guide for people to add it themselves, not for people to upload their files and expect it done for them. It does require the ability to decompile and compile apks and is done with making a toggle for it in custom settings which can be found in this great thread here so it can be toggled on or off depending on what people want to use.

For this mod we will be modifying two apks. SecEmail (SecEmail_K for s5) and SecExchange. For s6 it requires SecEmailProvider and SecEmailSync.

This is a short and pretty straight forward change but decompile both apks and we will start with SecExchange or SecEmailSync.

Navigate and open the following smali

For S5: com/android/exchange/adapter/ProvisionParser

For S6: com/samsung/android/email/sync/exchange/adapter/ProvisionParser

now search for the following method.

.method public hasSupportablePolicySet()Z

and add this code to the start of it

For S5

const/4 v0, 0x1

iput-boolean v0, p0, Lcom/android/exchange/adapter/ProvisionParser;->mIsSupportable:Z

For S6

const/4 v0, 0x1

iput-boolean v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mIsSupportable:Z

so it will look something like this

Before

.method public hasSupportablePolicySet()Z

.locals 1

.prologue

.line 89

iget-object v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mPolicySet:Lcom/samsung/android/emailcommon/service/PolicySet;

if-eqz v0, :cond_0

iget-boolean v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mIsSupportable:Z

if-eqz v0, :cond_0

const/4 v0, 0x1

:goto_0

return v0

:cond_0

const/4 v0, 0x0

goto :goto_0

.end method

After

.method public hasSupportablePolicySet()Z
.locals 1

.prologue
.line 89
const/4 v0, 0x1

iput-boolean v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mIsSupportable:Z

iget-object v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mPolicySet:Lcom/samsung/android/emailcommon/service/PolicySet;

if-eqz v0, :cond_0

iget-boolean v0, p0, Lcom/samsung/android/email/sync/exchange/adapter/ProvisionParser;->mIsSupportable:Z

if-eqz v0, :cond_0

const/4 v0, 0x1

:goto_0
return v0

:cond_0
const/4 v0, 0x0

goto :goto_0
.end method

We are now done with that apk you can recompile it and move on to SecEmail_* or SecEmailProvider

Navigate to and open the following smali

S5: com/android/email/SecurityPolicy

S5: com/samsung/android/email/provider/SecurityPolicy

Look for the following method

S5

.method public isActive(Lcom/android/emailcommon/service/PolicySet;)Z

S6

.method public isActive(Lcom/samsung/android/emailcommon/service/PolicySet;)Z

Increase the locals from 4 to 7 marked in BLUE

Remove the code in RED

Add the code in GREEN

S5

.method public isActive(Lcom/android/emailcommon/service/PolicySet;)Z
[COLOR="Blue"].locals 7[/COLOR]
.param p1, "policies" # Lcom/android/emailcommon/service/PolicySet;

.prologue
.line 734
invoke-virtual {p0, p1}, Lcom/android/email/SecurityPolicy;->getInactiveReasons(Lcom/android/emailcommon/service/PolicySet;)I

move-result v0

.line 735
.local v0, "reasons":I
const-string v1, "SecurityPolicy"

new-instance v2, Ljava/lang/StringBuilder;

invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

const-string v3, "getInactiveReasons returns : "

invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v2

invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

move-result-object v2

invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v2

invoke-static {v1, v2}, Lcom/android/email/Log;->e(Ljava/lang/String;Ljava/lang/String;)V

.line 736
if-nez v0, :cond_0

const/4 v1, 0x1

:goto_0
return v1

:cond_0
[COLOR="Red"]const/4 v1, 0x0[/COLOR]

[COLOR="Lime"] invoke-static {}, Lcom/android/email/SecurityPolicy;->getContext()Landroid/content/Context;

move-result-object v4

invoke-virtual {v4}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v4

const-string v5, "email_security"

const v6, 0x1

invoke-static {v4, v5, v6}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v1[/COLOR]

goto :goto_0
.end method

S6

.method public isActive(Lcom/samsung/android/emailcommon/service/PolicySet;)Z
[COLOR="blue"] .locals 7[/COLOR]
.param p1, "policies" # Lcom/samsung/android/emailcommon/service/PolicySet;

.prologue
.line 397
invoke-virtual {p0, p1}, Lcom/samsung/android/email/provider/SecurityPolicy;->getInactiveReasons(Lcom/samsung/android/emailcommon/service/PolicySet;)I

move-result v0

.line 398
.local v0, "reasons":I
const-string v1, "SecurityPolicy"

new-instance v2, Ljava/lang/StringBuilder;

invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

const-string v3, "getInactiveReasons - reasons : "

invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v2

invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

move-result-object v2

invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v2

invoke-static {v1, v2}, Lcom/samsung/android/emailcommon/utility/Log;->d(Ljava/lang/String;Ljava/lang/String;)V

.line 399
if-nez v0, :cond_0

const/4 v1, 0x1

:goto_0
return v1

:cond_0
[COLOR="Red"]const/4 v1, 0x0[/COLOR]

[COLOR="Lime"]invoke-static {}, Lcom/samsung/android/email/provider/SecurityPolicy;->getContext()Landroid/content/Context;

move-result-object v4

invoke-virtual {v4}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v4

const-string v5, "email_security"

const v6, 0x1

invoke-static {v4, v5, v6}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v1[/COLOR]

goto :goto_0
.end method

That is it.

For the toggle add the following code to CustomSettings preferences and all done.

<CheckBoxPreference android:title="Email Exchange Security" android:key="email_security" android:summaryOn="Disabled " android:summaryOff="Enabled" />