yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] w0rdie:
First I wanted to thank rustamabd! -- This script is a top priority for me any time I flash or get a new device. Donation inbound.

Secondly -- For anyone who's is using a RAZR device -- Put your deviece into MTP mode before you start the process, run the script, ignore the exchange.apk error and enjoy!

Keywords: droid razr disable exchange pin policy security
[Galaxy S II Themes and Apps] guru_floyd:
Thanks for this great MOD!! Its a life saver everytime i flash a new ROM. It works fine on JB ROM's. For me atleast its worked without any FC's on Supernexus!
[Galaxy S II Themes and Apps] GalaxyHeart:
As others have said, this does work on JB. Ignore the command line error, and hit Enter.

Two Exchange FCs after adding an account, then email didn't want to sync.

Rebooted, and all is well. :good:
[Galaxy S II Themes and Apps] QLF:
Confirmed working on JB ROMS (http://xdaforums.com/showthread.php?t=1810042)

Thanks!
[Galaxy S II Themes and Apps] weslyr:
It took me a while, but I have a screenshot and logcat for you.

Background info: i'm using a HTC Desire with the Evervolv JellyBeans p7 ROM

The screenshot is of the patching process:

As you see, the exchange apk in /system/app/ was named: exchange2.apk (very weird indeed).

After the patching, I'm setting up the exchange account (including agreeing to the security policies) and after that the first initialization occurs which shows a popup (exchange crash). The initialization then doesn't seem to progress further.

After going to the homescreen a second exchange crash occurs (probably the same situation as the first one).

But after opening the email client I can get the email messages and everything now seems to work fine (without any annoying security policies forced upon me :) ).

Here is the full logcat: http://pastebin.com/ciBxSvH3

I hope this is helpful to you. I can provide the apk's too if you need it.
[Galaxy S II Themes and Apps] rustyx3:
Thanks. yes, can you please PM or email me the apk's and odex's.
[Galaxy S II Themes and Apps] freeman9911:
Thank you so much, it worked for me I have skyrocket ICS 4.0.4 I727UCLF6

I can access my work email now without the security warning.
[Galaxy S II Themes and Apps] weslyr:
No problem. pm sent
[Galaxy S II Themes and Apps] OSully:
Thank you for continuing to look into this.
[Galaxy S II Themes and Apps] jchauncey:
does this allow the gmail app to sync to corp google app accounts that require the device policy app to be installed?
[Galaxy S II Themes and Apps] bounxiong:
The attached files in the OP should work with JB correct? The attached files a few post before this one has an apk. Should I use this instead?

Update: I found the answer. Op's post should work find on JB/cm 10
[Galaxy S II Themes and Apps] alalni:
Please Share patched Email.apk

Dear Could you please share the patched Email.apk

Galaxy SIII
[Galaxy S II Themes and Apps] rustyx3:
I'm getting mixed reports about JB. Apparently, the patch is working fine on JB, the only issue is the initial crashes, but after a while (and/or a reboot) it is working fine. Is there anyone on JB for whom the patch does not work at all, not even after an extra reboot? Pls post your device type and ROM version.
[Galaxy S II Themes and Apps] skylenorman:
I've had great success running this on CM9 on my Epic 4g Touch, and moderate success with my CM10 Xoom WiFi. Usually it'll FC right after I configure my Xoom's email address, but a quick reboot fixes it.

I don't suppose there's a way to run this on a mac so I don't have to keep dusting off my PC every time I update a rom is there?
[Galaxy S II Themes and Apps] fastguy:
Hi Rustamabd, I'm using the nightly builds of CM10 JB for N7000. The patch succeeded after specifying Exchange2.apk rather than Exchange.apk.

I am routinely seeing FCs even after reboots,but I insist on using it and it works.(after a while, it crashes again).

How can I help debug it?

fast
[Galaxy S II Themes and Apps] dewey1973:
I doubt it as it is only patching the Exchange and Email apks and doesn't touch the gmail apk.
[Galaxy S II Themes and Apps] OSully:
Same here. Works but I get FCs frequently.
[Galaxy S II Themes and Apps] rustyx3:
Please someone try the attached version on JB. (backup your Email and Exchange apps first!). It contains a cleaner method that will keep the device admin in place. By keeping the admin in force the device shouldn't get confused about whether or not the policy is in force.

=== EDIT ===

Seems to work, removing attachment.

Refer to first post for download of version 3.2.
[Galaxy S II Themes and Apps] OSully:
Give me an hour or so to get on a laptop and I'll be all over this. :D
[Galaxy S II Themes and Apps] Kostazu:
Seemed to work just fine on a brand new CM10 install.
[Galaxy S II Themes and Apps] ZedBR:
works great here

Rootbox JB 2.2 :laugh:

thx a lot !!! :good:
[Galaxy S II Themes and Apps] h4rr0d:
Tried the 3.2 beta on CM10-2012081. Device asks for the security thingy now, however nothing is enforced, so works for me. Awesome job.
[Galaxy S II Themes and Apps] rustyx3:
Version 3.2 is released, now with JB support! :laugh:
[Galaxy S II Themes and Apps] rafaelxc:
Hello All,

My superuser app is denying the shell.

When i run the apply patch i receive the message

Is your device rooted?

When i look at superuser on log i can see the shell being denied.

How can i grant root access to shell?

Thanks,
[Galaxy S II Themes and Apps] rustyx3:
Are you using a CM build? In CM, you need to explicitly allow ADB root access in Settings > Developer Options > Root access
[Galaxy S II Themes and Apps] rafaelxc:
Thanks

I'm using CM, just done that

Thanks
[Galaxy S II Themes and Apps] Haul:
Thanks for the work, but now how can we verify that the patch is actually working? Previously, the lack of a Device Administrator served as proof that the EAS policies were not being enforced, but now, we can no longer tell.
[Galaxy S II Themes and Apps] Bolick:
rustamabd, do you think if we may leave ability to wipe device remotely?

I believe since we now have local admin active we may leave this sometimes vital functionality.

Note that if one has MS Exchange 2010 installed on their server users may wipe their devices from OWA (Outlook Web Access).
[Galaxy S II Themes and Apps] rustyx3:
The latest JB patch in fact does exactly that. It disables only the following restrictions:

PasswordMode

PasswordMaxFails

PasswordMinLength

PasswordComplexChars

PasswordHistory

PasswordExpirationDays

MaxScreenLockTime

RequireEncryption

RequireEncryptionExternal

RequireManualSyncWhenRoaming

DontAllowCamera

DontAllowAttachments

DontAllowHtml

Other things like RemoteWipe, MaxCalendarLookback, MaxEmailLookback, etc. are left unchanged.

Note - this new behavior is there only for JB. For ICS and GB, the complete policy is removed. But I'm thinking to change that, the rationale behind it is to only disable the most annoying and useless restrictions, but keep restrictions that are either not noticeable or have an impact on exchange server operation intact.
[Galaxy S II Themes and Apps] rustyx3:
You can tell the patch is working because before the patch a PIN lock was required, and after the patch you can again use slide unlock.
[Galaxy S II Themes and Apps] Bolick:
Well, that note makes me completely happy.

Thanks a bunch for your work!
[Galaxy S II Themes and Apps] QLF:
Used v3.1 on super nexus ROM for gs2 (jb) - works great after the reboot. Tnx!
[Galaxy S II Themes and Apps] fastguy:
V3.2 seems to work fine on CM10 JB fine now, no FCs. Great job! Thanks a lot again.
[Galaxy S II Themes and Apps] jchauncey:
hrm then is anyone aware of a way to patch the gmail apk so i can continue to use gmail without having to use the device policy app?
[Galaxy S II Themes and Apps] OSully:
Thank you so much for the update... working like a charm. Goodbye stupid six digit pin.
[Galaxy S II Themes and Apps] QLF:
What's the gmail device policy? This is only for exchange email.
[Galaxy S II Themes and Apps] mpegripper:
i'm trying to use this on my att gs3, but adb fails to recognize my phone. i'm running the 8-14 cm9 nightly on it and can connect via adb from the android sdk...any tips?

here's my output:

D:\email-policy-patch-3.2>apply-patch.cmd

Cleaning up ...

Waiting for USB connection...

Checking device...

*** Device check failed. Unable to reach adb shell.

Debug log written to debug.log

Press any key to continue . . .

I do have usb debugging turned on and the adb root allowed since i'm on cm9
[Galaxy S II Themes and Apps] QLF:
Un then reinstall the USB drivers per the op. Reboot PC in between.
[Galaxy S II Themes and Apps] K0NRT15:
installed on PARANOIDANDROID 1.99 with no issues in case anyone was wondering

Sent from my Sprinting Paranoid SGSIII *K0NRT15*
[Galaxy S II Themes and Apps] mpegripper:
i ran it again after a reboot of my PC and got the following:

D:\email-policy-patch-3.2>apply-patch.cmd

Cleaning up ...

Waiting for USB connection...

Checking device...

Model: SAMSUNG-SGH-I747, build cm_d2att-userdebug 4.0.4 IMM76L eng.jenkins.20120

816.024321 test-keys, android 4.0.4 (API Level 15)

/system mounted on /dev/block/mmcblk0p14, mode ro

checking root access. root uid: 0, secure: yes, busybox: yes

Pulling app(s) ...

Pulling libs ...

Decompiling Email.apk ...

Applying patch ...

Patching com/android/emailcommon/provider/Policy.normalize()V

Recompiling ...

Building Email.apk ...

Decompiling Exchange.apk ...

Applying patch ...

Patching com/android/emailcommon/provider/Policy.normalize()V

Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z

Recompiling ...

Building Exchange.apk ...

Updating device ...

*** Device check failed. Unable to reach adb shell.

It never rebooted my phone and i tried manually rebooting as well as deleting and readding my exchange account, but I'm still unable to remove the screen lock with pin option
[Galaxy S II Themes and Apps] Bolick:
Please check:

1. if "adb.exe" is in your PATH

2. If you have Google's USB driver installed - http://developer.android.com/sdk/win-usb.html
[Galaxy S II Themes and Apps] mrhaboobi:
HI,

Could anyone confirm if this would work on an i9000 ( Galaxy s ) running CM9?

ive skimmed through this entire thread and have seen some mixed messages.

Thanks
[Galaxy S II Themes and Apps] maumaus:
"Note - this new behavior is there only for JB. For ICS and GB, the complete policy is removed."

Are you sure? Im on ICS (Mimicry v1.40) and with 3.2 i get the notifiction again so it can remote wipe and stuff...

Or does it also keep the device admin in place on ICS? And the ability to remote wipe is fake?

Im going back to 3.1 to be sure :( Cause i really dont want that.

Add:

I see you added a patch-manual.cmd... in this version. How does this one works? Where should I place the apk's?
[Galaxy S II Themes and Apps] OSully:
So the patch worked great for me, but now my sync settings keep getting removed. Seems to happen every so often. Anyone else with this behavior? I'm going to try removing and readding my account.
[Galaxy S II Themes and Apps] r0ckvn:
Hi,

After upgrade to CM10, i use the version 3.2 to apply again but receive a issue:

Applying patch ...

Recompiling ...

Building Email.apk ...

Decompiling Exchange2.apk ...

Applying patch ...

Recompiling ...

Building Exchange2.apk ...

Updating device ...

> lib/adb.exe remount

remount failed: Operation not permitted

Thank you so much,
[Galaxy S II Themes and Apps] rustyx3:
Yes, I'm sure, but my statement applies only to stock ROMs. Custom ROMs tend to mix up features from ICS and JB, so I can't say what behavior you'll get. It looks like the ROM you have contains at least parts of JB code, so you're getting JB behavior.

The ability to remote wipe is not fake, its real. I don't think you should worry, because employers normally never exercise remote wipe unless you report your phone to them as lost/stolen.

Regarding patch-manual.cmd, just run it and it'll tell you how to use it...
[Galaxy S II Themes and Apps] solar666:
Yes, confirmed. Already had it working with different CM9 versions.

Use the manual mode and copy email, exchange & framework directory manually to your PC and start the script, afterwards move the modified apks back to the system/app folder and check the correct rights/ownership.
[Galaxy S II Themes and Apps] maumaus:
Sorry with fake I ment it was maybe a placebo...

patch-manual.cmd stops in 1 sec without showing a message on Win XP Pro 32-bit SP3 with admin rights. The "normal" patch works excellent.

Maybe there can be a "force" option? At least in the custom version?

And I know the policy... and they only should do it when I report something. But trust me, they can make mistakes here ;)

And then you could also say they use a pin as security if its stolen ;) I just dont like the idea, cause its my own bought phone, with my pictures and stuff... i do backup, but not every moment. And with that permission they can also wipe SD.

I use pin and 3rd party in app protection, so im pretty good in securing it enough

in my opinion

. Its just a mind set for me.

But thanks for everything :)
[Galaxy S II Themes and Apps] fastguy:
Yes I confirm the same issue. I'm using nightly CM10 builds so it's an hassle to re setup the account everyday.

Any way we can keep account settings intact on patching?
[Galaxy S II Themes and Apps] OSully:
I readded my account and so far its okay. Hasn't been too long though.
[Galaxy S II Themes and Apps] r0ckvn:
I am have the same problem with you. The cmd windows stopping at "Updating device ..." for around 5 mins. I unplug the cable and it output a message that everything is done.

After reboot, I can bypass the security policy

Using Galaxy S3-i747

Room CM9
[Galaxy S II Themes and Apps] McAwesome:
I have been getting an error when it returns to uploading the patched apk's. When it first starts up it says cannot obtain root is device rooted but it certainly is. I am running a GS3 ATT Variant with CM10 Nightly 8/21 am running the most current binary of superuser and also BB. Any thoughts or ideas?? USB debugging is enabled btw.

Mc2992
[Galaxy S II Themes and Apps] r0ckvn:
In USB debugging have 1 option about Apps + ADB root permission. I just guess :D
[Galaxy S II Themes and Apps] dkrants:
I'm having exactly the same problem. Any suggestions on how to resolve it?

Model: SAMSUNG-SGH-I727, build IMM76D.UCLF6, android 4.0.4

Says it can't find com.att.vvm.sharedlib.jar , however this file is being pulled into the /work folder.
[Galaxy S II Themes and Apps] DarkDvr:
Donating second time for awesome JB support =)

Thank you! This hack really makes my life easier.

19L793220N7974003
[Galaxy S II Themes and Apps] squire23:
I'm on Resurrection ROM 3.0.5 - the v3.2 patch seems to work fine but when I add the Exchange account & complete all the info, the app goes into a 'Waiting for Sync' when trying to load the email. Nothing else seems to happen. Anyone got a solution for this.
[Galaxy S II Themes and Apps] malhor:
No need to use the manual mode. I've done it several times on cm9 (a few nightlies until stable) with equal succes :thumbup:

Sent at hyperdroid speed from a Galaxy far far away from the others
[Galaxy S II Themes and Apps] Sardo Numspa:
just tried this out and it worked great. thanks.
[Galaxy S II Themes and Apps] HPT:
Gents, I've ICS4.0.4 Stock ROM-Rooted on a Galaxy Note & I want to share my experience with this update - It works finally, I had the same issue with :

Recompiling ...

Building Exchange.apk ...

Updating device ...

*** Device check failed. Unable to reach adb shell...

After numerous trials with different setups/configs/switching cables ed, I succeeded by updating my device via Win XP PC instead of Win7 PC.

Result : No PIN required anymore.

A big tx to the developer.
[Galaxy S II Themes and Apps] mrnicotra:
Hopefully someone might be able to help me here. I tried the manual method. Email does work (doesn't FC) but I am still getting the message saying "This server requires security features that your Android device doesn't support".

I am on a Galaxy Nexus running on JB 4.1.1 (I tried both stock and AOKP).

Please get back to me if you have any clues.

Thanks
[Galaxy S II Themes and Apps] TuxDude:
Tried this on stock Galaxy Nexus 4.0.4 and worked perfectly :)

Though I had to reconfigure the email accounts once again - no issue with that since all emails are anyways stored on the server :)

Also liked the fact that this method consists of scripts which actually apply the patch on the files downloaded from the device, and you get to copy them on the TARGET. Since you've shared the sources as well, gives a clearer picture of what is going on for interested enthusiasts :)
[Galaxy S II Themes and Apps] Sonnylow:
You are a genius ! I have been looking for this since moving JB ROM... it works !

Thanks a lot.:thumbup:
[Galaxy S II Themes and Apps] mrkaasa:
I used to get a security error about 80% of the time I synced my email, even I had the account set up by IT with pin and everything.

After I installed this, problem disappeared, and don't need to use the annoying pin anymore. Thanks!

Phone: Nordic Galaxy SIII ICS 4.0.4
[Galaxy S II Themes and Apps] Fluffster:
First let me say.. Thank you.. I applied this and worked like a champ on my SGSII running Parandroid JB..

Question: It still makes Email an Administrator.. Can my exchange people push a format to my phone and it will do it? Or will it ignore ALL requests from them including Disabling Camera and so on??

Thanks again BTW!
[Galaxy S II Themes and Apps] Tubifex:
See this post http://xdaforums.com/showpost.php?p=30311260&postcount=462
[Galaxy S II Themes and Apps] Fluffster:
Thanks,

Is there a way to completely remove their ability? Considering my IT staff are all idiots and I don't trust them, they have already wiped 4 phones "on accident"?
[Galaxy S II Themes and Apps] XfrostX:
Hey, after getting the patched Apks on my phone, can I just back up Exchange.apk and Exchange2.apk and replace them each time I update my phone? (I run nightlies so I have to reapply the patch every time.)

Thanks
[Galaxy S II Themes and Apps] rustyx3:
Of course, but if there are any nightly fixes in the Exchange app you won't get them.

Actually it is possible to avoid losing exchange settings when applying the patch. The loss of the settings occurs when the email apk is deleted while the system is running (this is how the patch works now - deletes/renames the old apk and uploads the new one). By running the patch in manual mode and packaging the patched apk's as a CWM update file, the step of deleting and replacing the apk can be done at boot time, which won't delete any settings. If I find time, I will look into automating this process, but I'm sure someone with sufficient skills can easily implement a script for this.
[Galaxy S II Themes and Apps] ArtoD2:
This would be highly appreciated.

EDIT: Would it be sufficient to be able to run this batch, while in CWM? Or is this completely out of reach? This would make things easy. Reboot to CWM, wipe Caches -> Flash new Nightly -> Run this patch...
[Galaxy S II Themes and Apps] jdubau55:
Used the 3.2 patch and it's a little different as stated for previous version. It will still give you the popup that you have to enable security. It will also give a notification about the server needing to put those in place. If you select yes all the more useful ones will remain. No PIN, camera blocks or anything remain. Things like remote wipe and what not will stay.
[Galaxy S II Themes and Apps] fastguy:
Can we just overwrite the existing apps without deleting them first? Won't this be possible to keep settings and accounts?
[Galaxy S II Themes and Apps] the_mentor:
Remote Wipe

Is there a way to disable the remote wipe as well?

I dont want my employer to be able to wipe my phone remotely since its my personal device.

thank you.
[Galaxy S II Themes and Apps] rustyx3:
Yes, but Android still picks this up as a delete/replace and deletes app settings.
[Galaxy S II Themes and Apps] jimhaddon:
Doesn't work on CM10
[Galaxy S II Themes and Apps] deim:
While i was on MCR JB (Galaxy Nexus) push emails never worked. I gave up after a while.

Just flashed Android Revolution HD - everything works perfectly!!!
[Galaxy S II Themes and Apps] ArtoD2:
Yes it does.
[Galaxy S II Themes and Apps] MynticeLX:
Trying this on a Galaxy Note 10.1 and it doesn't seem to want to work. Getting an error "Cant find the file work/Exchange.odex". It seems to go through the decompiling/recompiling process fine, but then errors out when it gets to Exchange.odex.. Thoughts?
[Galaxy S II Themes and Apps] mpegripper:
with this patch my att gs3 on cm10 now enforces a pin whether or not i have the exchange account on my device...guess its time to wipe now
[Galaxy S II Themes and Apps] Sardo Numspa:
each time you flash a new rom, or rom update, you'll need to do the hack again since the new rom / update will replace your hacked apk with original ones.

what i did was remove the security, saved a copy of email.apk and exchange2.apk on my pc. then i download the new rom / rom update on my pc, unzip, replace the email.apk and exchange2.apk with the hacked versions, rezip and flash. this way i dont have to reset up the email account every flash.
[Galaxy S II Themes and Apps] CaspaTheGhost:
I do it slightly differently in that I have my patched apks as part of my own Gapps package, so I just flash a new nightly (CM10 kang in my case) followed by Gapps and just carry on as normal.

Mine is inverted version also.

Sent from my GT-I9300
[Galaxy S II Themes and Apps] cool400:
Thanks for this awesome patch - I used it with my GS3 running ICS 4.0.4 and it works perfectly!

Maybe I will update to JB 4.1.1 soon. Is there anything I have to consider? Or can I simply start the patch the same way I did it on ICS 4.0.4?

Best regarda and thanks for your good work

cool400
[Galaxy S II Themes and Apps] mpegripper:
couldn't i just backup the hacked email and exchange apps in titanium backup and then restore them after i update the rom? might be easier
[Galaxy S II Themes and Apps] ArtoD2:
I have not been able to do this with tb. Seems that there are some other apps / settings to be backed up also. Accounts etc.

Also you lose modification to email, if done by devs.
[Galaxy S II Themes and Apps] Sardo Numspa:
I dont know. i do know that by replacing the apks in the rom zip file, it works. i've done it through two rom updates now and have not had any issues, nor have i had to re-set up the email account.
[Galaxy S II Themes and Apps] jimhaddon:
Not for me.
[Galaxy S II Themes and Apps] K0NRT15:
+1

Sent from my SGSIII running AOK...P *K0NRT15*
[Galaxy S II Themes and Apps] jimhaddon:
This works for all of 5 mins on new install of CM10... then whenever you try to update mail, it just says it couldn't due a security error. Do you need anything from me to investigate this?
[Galaxy S II Themes and Apps] Scalee:
EDIT:

After some looking i noticed i have:

Email.apk & EmailGoogle.apk & Exchange2.apk & Exchange2Google.apk

Not exactly sure what to do, going to attempt and remove EmailGoogle.apk and Exchange2Google.apk.

If that doesn't work vice versa.

Didn't work. Tried clean rom empty rom, didnt work either.

Attached email and exchange2.apk (which come with a clean rom)
[Galaxy S II Themes and Apps] CaspaTheGhost:
Not needed, patch works fine on those. I've an inverted version (email and exhange2) as part of my Gapps, I flash it over CM10 nightly kangs no problem.

You must have the other two apks in the Gapps zip you're flashing, they must be coming from somewhere.

Sent from my GT-I9300
[Galaxy S II Themes and Apps] jimhaddon:
I've noticed this only seems to work for me if I've got auto sync switched on. Switch it off, and I just get security errors. On jellybean that is.
[Galaxy S II Themes and Apps] arbitarytwist:
All security errors seem fine, but i keep getting FC when trying to send emails.

Had the same problem on LPT, and again with LPX installed after a wipe.