yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] rustyx3:
There are many factors that may cause a slowdown, which I have no way to reproduce. I can only say that my company's Exchange server is 2003 and that it is the only non-google mail account that I have configured on my phone. I have push enabled. The hack works great with this setup, i.e. no slowdown of the phone, no extra battery drain.

If someone who is experiencing issues can post more details about the version of exchange, sync mode, and any other pop/imap mail accounts configured, I may be able to investigate the issue further.
[Galaxy S II Themes and Apps] ecefrm:
I am running your modded Email.apk in a Galaxy Tab with Gingerbread (Overcome Hermes) and I have no problems with slowdowns or battery drain either. However I am always getting a FC from the mail application when rebooting the Tab. Afterwards it works correctly. I guess it's natural since it is not the native mail application.

I have tried to mod myself the native Gingerbread Email.apk from the Galaxy Tab using your posted code, but it does not work (FC continuously). Although very similar to the Galaxy S II mail application, there must be some differences that make it impossible to just blindingly use your modifications.

Would you be so kind as to have a look at the original Email.apk from the Tab Gingerbread Overcome firmware and suggest a possible mod? Thanks in advance.
[Galaxy S II Themes and Apps] dorongr:
Excellent!

Works like a charm. It was pretty annoying having insert the pin code every time!

Now I can start and use Faceunlock.

Thanks!
[Galaxy S II Themes and Apps] taras.if.ua:
Thank you!!
[Galaxy S II Themes and Apps] rustyx3:
How do you normally gain root shell in MIUI? Apparently not via the su command.

But anyway, the script will create a patched Email.apk in the work directory, you can simply put it in your phone under /system/app manually.
[Galaxy S II Themes and Apps] burnout11:
Howdy, im trying this with dhd & ics 4. and i still get error for:

V/EAS Parser( 3351): Policy not supported: 936

V/EAS Parser( 3351): Policy not supported: 938

V/EmailServiceProxy( 3333): validate returns 8

how can i remove this 2 policys?
[Galaxy S II Themes and Apps] CaspaTheGhost:
Is it a HTC based ROM? They implemented their own EAS support, and with that goes the policies. Just use a different ROM...
[Galaxy S II Themes and Apps] burnout11:
for real? i dont know but i dont think that htc is building their own email.apk - or?

edit:

btw. its ics builded from source - so no htc inside :)
[Galaxy S II Themes and Apps] blackShawarma:
Awesome

So impressed. It worked beautifully. Epic4G (Sprint SGSII), rooted, w/CWM, EL29, 2.3.6

Ran the patch, watched it work its magic, then added my Exchange account. Warned me that I'd need to conform to the security policy, but wait.. No I don't :)

Mail, Calendar, and Contacts sync all good.

Well done, thanks for the great work.
[Galaxy S II Themes and Apps] CaspaTheGhost:
Strange, that was the first thing that came to mind from reading your post.

One for the OP me thinks as its worked on multiple ROMs and builds for me...
[Galaxy S II Themes and Apps] micione20:
Thanks.

it works fine for me. after a first tentative not good (maybe adb.exe has frozen) the second tentative was good.

unfortunately i lost all settings, and i have had resynch all contacts (and some contacts doesn't resynch ... i need to use them with google contacts (duplicated) :(

but the email app works fine and pin request has disappeared :)

thanks
[Galaxy S II Themes and Apps] bricenott:
Debug error

Darns it gives me an error, it sais that the email.apk file is not sopported archive ? I'm using version 2.2 and it looks like an error form the 7zip ??? Help anybody !!!:eek:
[Galaxy S II Themes and Apps] CaspaTheGhost:
Start a fresh, make sure your previous attempts haven't screwed the apk / make sure it is the original ROM apk that the patch can work its magic on...

Sent from my Galaxy Nexus
[Galaxy S II Themes and Apps] micione20:
the other things not working are:

- battery charged silencer

- BLN

i should reinstalled them, probably due to recompiling some apps
[Galaxy S II Themes and Apps] jdubau55:
SUCCESS!!!!!!!!!!!!!!!!!!!!!

Running AOKP Milestone 3 4.0.3 for the Fascinate with Glitch kernel.

I have tried many different combos of APK. Nothing worked. I am not sure why you need Kies though. I made sure that my device had USB debugging turned on. I think the biggest thing is making sure your device shows up in device manager as an Android ADB device. Easy as pie.
[Galaxy S II Themes and Apps] bricenott:
Please !!!

You are right again, for some reason I screwed my email.apk file and I don't even have and email application now... REFLASH??? Doesn't anybody has a original email.apk from this rom: I9100_CODE_I9100XXLPH_CL118559_REV02 ?
[Galaxy S II Themes and Apps] CaspaTheGhost:
Couple options mate. Restore the nandroid you performed before you started trying to do this, or just flash the ROM again then use the patch.

Sent from my Galaxy Nexus
[Galaxy S II Themes and Apps] joolui:
same with camera?

Hello!

I've installed the company policy to my private phone to test some applications.

I had to give unlock code etc. Then I removed app by disabling admin rights and uninstall. Could remove lock code, no problems. Checked device_policy.xml and it is almost empty, just basic xml tags. But if i want to start the camera it says security policy restricts. But it is an SGS2 with 2.3.5 (rooted). What the hell happened with the phone? Checked the security settings with company admin and there wan no restrictions applied for the camera at all. How can I reset this/ get back my camera? Any help would be appreciated.

Lu
[Galaxy S II Themes and Apps] malacoid:
Works on Incredible with ICS 4.0.3 (ICS-Dinc V.05)

apply-patch.cmd doesn't work in Recovery mode. Just run it while the phone is sitting at the desktop with no Exchange configured yet. Here's what is displayed by the program:

Cleaning up ...
Waiting for USB connection...
Checking device...
Model: Droid Incredible, build ev_inc-eng 4.0.3 IML74K eng.evervolv.20120220.030
419 test-keys, android 4.0.3 (API Level 15)
/system mounted on /dev/block/mtdblock3, mode ro
checking root access. root uid: 0, secure: no, busybox: yes
Pulling Email app ...
Pulling libs ...
Decompiling Email.apk...
Applying patch ...
Patching method isActive(Lcom/android/emailcommon/provider/Policy;)Z
Patching method isActiveAdmin()Z
Patching method isSupported(Lcom/android/emailcommon/provider/Policy;)Z
Recompiling ...
Building Email.apk ...
Updating device ...
Rebooting device ...
Done.

NOTES! PLEASE READ!

* All shortcuts to the Email app will disappear and will need to be re-created.
The Email app will appear on the last page of the application drawer.

* Delete any leftover Exchange device administrators!
(Settings -> Location and security -> Device administrators).

Press any key to continue . . .
[Galaxy S II Themes and Apps] BooDaddy:
Hmmm.

So I decided to try this on my Galaxy Nexus. It already had an exchange account setup, so I remove it before doing anything else.

Heres whats jacked up... after I removed the account (before even running the patch at all), I still couldnt enable any of the screen lock options...or even disable screen lock all together. The options were greyed out and marked as disabled by my administrator. Anyone know how to clear this?
[Galaxy S II Themes and Apps] CaspaTheGhost:
Strange, should be back to normal if you've deleted the account. Nothing else enforcing it?

I'd just run the patch and see what happens, I've run it many times with an account setup and haven't had any issues as it deletes it anyway.

Just make sure you backup before you try, but its worked perfectly for me multiple times.

Sent from my Galaxy Nexus
[Galaxy S II Themes and Apps] Loftus:
In: Settings, Security, Device Administrators - remove any enabed DA
[Galaxy S II Themes and Apps] dumbo79:
I have the same problem and I'm running rom CM9 (ICS 4.0.3) with stock e-mail app.
[Galaxy S II Themes and Apps] Bolick:
rustamabd,

do you think if we may find sources of this pretty helpful utility?

Actually what I want is to run this patch utility in Linux (Ubuntu) environment. But as I learnt from failed attempt to run it in linux there're hard-coded paths to some external executables etc.

In general prebuilt jar for linux may also work for me, but if you don't want to spend your own time sources will work as well.

Thanks in advance.
[Galaxy S II Themes and Apps] Bolick:
Well, for some reasons ADB is not working properly in VirtualBox - https://www.virtualbox.org/ticket/6620

Spent few hours - and no luck.

So I decided to get some luck in Ubuntu. And after some attempts succeed here.

And here's how:

1. Install wine (is needed to run "7z.exe" later)

2. Install Android SDK from Google for Linux. Then install platform tools from there. The goal is to install native "adb".

2. Create "work" folder right near "lib" folder. And copy "lib" folder to "work" folder.

3. Set permissions for files in "work/lib" folder to RO

4. Run in root folder (email-policy-patch-2.2):

=========

java -Xmx512m -jar lib/email-policy-patch.jar patch %*

=========

For my Nexus S worked flawlessly and I got not even notification about policies applied by admins)

Thanks a lot for this nice patch!
[Galaxy S II Themes and Apps] boost252525:
For the folks still getting "EAS Parser" errors running 4.0.3, I've disovered the problem.

This patch ONLY patches Email.apk, in 4.0.3 we also have an Exchange.apk (or com.android.exchange.apk) which needs to be patched. Specificlly the Policy Parser.

I decompiled the OP's patch and made some changes, it worked perfect. If I can get it to jar up I'll try to published a revised version, in the mean time... either manually edit the patch to do this, or manually use smali/baksmali to do this:

Edited PatchSecurityPolicy.java to return zero in the getInactiveReasons method of SecurityPolicy.smali (just in case... not sure if it mattered)

Added " (static)?" to the regex used in PatchSecurityPolicy.java to look for static or not-static methods (exchange.apk uses static methods)

Added a PolicyParser patch that changes assignment of mIsSupported to true. When your phone parses the policies, if it finds a policy it cannot support it drops into a block of code that sets mIsSupported to fase, this patch overrides that. It's around line 310 in the smali file.

Changed Run.java to run the patches against email.apk then repeat the patches against exchange.apk
[Galaxy S II Themes and Apps] rustyx3:
@boost252525 and @Bolick,

If you guys (or anyone else) want to improve the patch to make it work better for your situation, you're welcome to. I'm attaching the source, feel free to send me a patch, I will incorporate it and publish a new version :D

See this thread's 3rd post for the source zip.
[Galaxy S II Themes and Apps] boost252525:
Modified source for 4.0.3 and Exchange.apk attached. Many thanks - I finally have email again!!

(The error handling could use some cleanup before you publish a new build)

EDIT rev1: Added ProvisionParser.smali to the test files

EDIT rev2: Spotted a possible bug, resolved it. rev2 has been tested on my local device as functional.
[Galaxy S II Themes and Apps] dumbo79:
This sounds great! Now I have just to wait for the new version.
[Galaxy S II Themes and Apps] andyrynk:
removing corporate microsoft exchange policy restrictions

Hi rustamabd - I just wanted to thank you for your excellent work. Ran this on my I9100 with ICS android 4.0.3 (LPH) and it has worked perfectly and smoothly. I did try to make a donation viaPayPal using the stated e-mail address but PayPal did not recognise it?

Anyway, thanks for the excellent service – I can now go back to using my wonderful, personal, S2 for work as well as everything else.
[Galaxy S II Themes and Apps] hamshank4eva:
thanks for the hard work guys!

work got me a galaxy nexus and expected exchange to just work out of the box. how wrong they were.

so far i'm down to 1 'null' with the current patch here's hoping a new one can get rid of that
[Galaxy S II Themes and Apps] woodsdog:
Boost, how do you build this?

I've tried to build this with Maven, but I am missing dependencies....
[Galaxy S II Themes and Apps] rustyx3:
Thanks!

Regarding ProvisionParser patch, line 310 - based approach doesn't sound very future proof. Maybe there is a better solution? Unfortunately I can't test it, but I think that if you just patch hasSupportablePolicySet()Z to return 1, it might also work, according to the source. Could you give it a try?

Something like this:

.method public hasSupportablePolicySet()Z
.locals 1

.prologue
[B] const/4 v0, 0x1
return v0
[/B]
[Galaxy S II Themes and Apps] rustyx3:
Incorporated Boost's changes to support Exchange.apk in version 2.3.

Re-implemented ProvisionParser patch (untested!)

Let me know if it works!
[Galaxy S II Themes and Apps] dumbo79:
I have tried the latest patch and it seems to solve my problem. Thanks!

But when I run the patch I get the following errors:

Cleaning up ...

Waiting for USB connection...

Checking device...

Model: GT-I9100, build IML74K, android 4.0.3 (API Level 15)

/system mounted on /dev/block/mmcblk0p9, mode rw

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

Pulling app(s) ...

Pulling libs ...

Decompiling Email.apk...

Applying patch ...

ERROR! com/android/email/SecurityPolicy.smali already patched.

ERROR! com/android/exchange/adapter/ProvisionParser.smali not found.

Decompiling Exchange.apk...

Applying patch ...

ERROR! com/android/email/SecurityPolicy.smali not found.

ERROR! com/android/exchange/adapter/ProvisionParser.smali already patched.

*** Patch aborted.

I don't know if it something important?
[Galaxy S II Themes and Apps] boost252525:
It's an Eclipse project, just "import existing project" in the File menu.

The maven stuff was OP's, I just left it there to make his source merge easier.

---------- Post added at 11:09 PM ---------- Previous post was at 10:57 PM ----------

I concur, it is *definitly* not future proof (it's looking for a specific line number... poor form!). It was a quick and dirty hack, I would have liked to spend more time on it and do something like you did with the RegEx loops.

Your suggestion might work, but one thing has me worried. According to the ProvisionParser source it:

Gets a list of policy requests from the server

Loops the list and checks each one with a policy specific method.

If it hits one it cannot support, it sets a GLOBAL variable to false.

I'm not sure if that global variable is initialized to true or false, but if it never sets set to true then you'll still have the "cannot support all the policies" error.

I think what you would need to do to be 100% future proof is:

Declare the pointer to the global var (it's v12 in the .smali)

Set the global var to true (0x1)

return true (0x1) and exit the method
[Galaxy S II Themes and Apps] rustyx3:
Not important. Just uploaded a cleaner version, 2.3.1, that shouldn't report these situations as errors.

That global var seems to be read in just one place, hasSupportablePolicySet(). So if I just patch that the var won't be read at all, and it won't matter if its set to true or false.
[Galaxy S II Themes and Apps] dumbo79:
With version 2.3.1 I get the following errors:

Waiting for USB connection...

Checking device...

Model: GT-I9100, build IML74K, android 4.0.3 (API Level 15)

/system mounted on /dev/block/mmcblk0p9, mode rw

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

Pulling app(s) ...

Pulling libs ...

Decompiling Email.apk...

Applying patch ...

Unable to apply patch. Pattern not found.

Decompiling Exchange.apk...

Error occured while loading boot class path files. Aborting.

org.jf.dexlib.Util.ExceptionWithContext: Cannot initialize ClassPath multiple ti

mes

at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.j

ava:127)

at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)

at jpatch.emailPolicy.Run.baksmali(Run.java:685)

at jpatch.emailPolicy.Run.main(Run.java:477)
[Galaxy S II Themes and Apps] rustyx3:
Please try version 2.4, it should work better.

Also, the source code is now available in the 3rd post of this thread.
[Galaxy S II Themes and Apps] dumbo79:
This works perfect!
[Galaxy S II Themes and Apps] haroonie:
So far so good, ran just fine on my AT&T Galaxy Note. Going to use it and see if there any problems. Thanks!
[Galaxy S II Themes and Apps] rustyx3:
New version released: 2.5! It has both windows and non-windows support.

See apply-patch-nix.sh.

Requires some manual work, but is better than nothing :p
[Galaxy S II Themes and Apps] dinoc:
Hi mate.

On OS 2.3.4 I've been using your Email.apk and everything worked great.

Since yesterday I've upgraded to ICS 4.0.3 and installed this patch.

Now the email is not working properly with the same exchange server. I get a lot of errors like "

Connection error"

Some emails have been downloaded but only 1 today out of 20 as i keep receiving this error.

Not sure how to debug this, any idea?
[Galaxy S II Themes and Apps] rustyx3:
What is the exact ROM you're using?

You are advised to first try out a 4.0.3 Email app unmodified, to see if it works for you or not.

It is

very

buggy!

The "Connection error" message is not a result of my patch. Feel free to restore your original Email app, and you'll get the exact same error.

The problem is in com/android/emailcommon/provider/EmailContent$Message at lines 2142 and 2176. Both lines contain only debugging code, but it sometimes fails with a NullPointerException.

A possible temporary workaround is to set the email sync period to 1 day.
[Galaxy S II Themes and Apps] tcortinag:
Working perfectly with Acer Iconia A200 ICS 4.0.3
[Galaxy S II Themes and Apps] dinoc:
I have the official 4.0.3 on my Galaxy S2.

Yes is not your patch. The patch worked fine and a BIG thank you for that by the way !

I've tried without the patch but I have the same issues.

I did not have this issue with 2.3.4 so it looks to me they broke it in ICS or something ...
[Galaxy S II Themes and Apps] MattRob:
Looks promising ! Will this not be noticed by the Exchange administrator ? And do I understand it correctly, that I can go with v2.4 (and v2.5 is only for non-Windows users) ?
[Galaxy S II Themes and Apps] rustyx3:
v2.5 is not only for non-windows, it supports windows as well. Just use the latest version. I updated my post to be more clear about version 2.5.
[Galaxy S II Themes and Apps] MattRob:
Txs, will go for v2.5 then. Again, just to be sure, can the administrator notice that I use a patch to remove the security policy ? Or will that not be noticeable ?
[Galaxy S II Themes and Apps] dinoc:
This solved my Exchage server issue :) : http://xdaforums.com/showthread.php?p=23648945#post23648945
[Galaxy S II Themes and Apps] JustusIV:
does anyone know what

[9:43:13] EAS Parser| Policy not supported: 936

actually is?
[Galaxy S II Themes and Apps] MattRob:
I have a problem. Everything looked ok, untill the end, it could not copy the new patched apk's to system/app. No access ? Looking with ES' File Explorer, I saw the old email apk's with .BAK behind it. I cannot rename them and I cannot copy the patched apk's to system/app. What could be THE problem ? I have no email at this moment. Thanks.
[Galaxy S II Themes and Apps] dinoc:
Well I was wrong it didn;t fix it ... tried again a wipe and ICS stock without root, the issue is there , the Email.apk is not working as it should in ICS.
[Galaxy S II Themes and Apps] Hostfile:
interesting

quite interesting stuff
[Galaxy S II Themes and Apps] rustyx3:
Check debug.log. Then run restore-backup.cmd.
[Galaxy S II Themes and Apps] rustyx3:
No, the admin won't notice that you're bypassing the policy. But certain policies like the maximum download size for example, can cause warnings to be logged on exchange side, which can be an indication that something is wrong, but it's no direct proof that the policy is being bypassed, IMO.
[Galaxy S II Themes and Apps] Fuzeless:
This is the BESTEST mod/hack ever. thank you sir for your efforts. I just wish the fix wouldn't need an additional some 80 mb download (CWM flash maybe?).

could you please change the java link to

http://www.oracle.com/technetwork/java/javase/downloads/index.html

instead of the current one ?
[Galaxy S II Themes and Apps] MattRob:
Hard resetted and tried to install again; working now ! Thanks for the great work !
[Galaxy S II Themes and Apps] jorgeszabo:
Great job. I just installed and works well on GNEX 4.0.4

Had one simple issue when installing. The update failed and it asked for me to manually update the emailgoogle.apk and exchangegoogle.apk. The program had patched the apk's and placed them in the /sdcard directory but it did not copy them to /system/app so I did that manually and then rebooted. It is now updating email and calendar.

Cheers!
[Galaxy S II Themes and Apps] burnout11:
awesome. can now confirm working with http://xdaforums.com/showthread.php?t=1450962
[Galaxy S II Themes and Apps] pietjepuk:
Works on CM9

Just patched the latest CyanogenMod 9 (20120320) with this hack and it works perfectly.
[Galaxy S II Themes and Apps] athex:
You sir are a god among men! You rock!
[Galaxy S II Themes and Apps] pentafive:
Tried to apply the patch but it just hangs on Decompiling. Left it along for 20 min with no change.

Running Windows 7 64bit

java version "1.7.0_03"

Java(TM) SE Runtime Environment (build 1.7.0_03-b05)

Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

Cleaning up ...

Waiting for USB connection...

Checking device...

Model: Galaxy Nexus, build AXI0M CROSSBREED, android 4.0.4 (API Level 15)

/system mounted on /dev/block/platform/omap/omap_hsmmc.0/by-name/system, mode rw

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

Pulling app(s) ...

Pulling libs ...

Decompiling EmailGoogle.apk ...

Thanks for any help!

-Penta
[Galaxy S II Themes and Apps] rustyx3:
can you press ctrl-break and send me the output (at least the part that contains jpatch or smali). thx
[Galaxy S II Themes and Apps] solar666:
Hi Pentafive,

if you are successful at the end it would be really nice if you could please send me the patched EmailGoogle.apk file.

It would be nice if you could PM me.

I am currently running ICS 4.0.4 (dark knight v3) on a Galaxy S where Samsung is not offering anymore an ICS update.

Apperently the tool is not working for such a combination of phone/rom.

It does not recognize the USB connection and therefore doesn't start :-(

Cleaning up ...

Waiting for USB connection...

Connect your device!

Enable USB debugging (Settings -> Applications -> Development -> USB debugging)

Did you have a connection before but not anymore? Try rebooting your PC.

Thanks upfront.

@rustamabd:

Or are there any chances for supporting this device by fixing the tool?

---------- Post added at 08:06 PM ---------- Previous post was at 07:25 PM ----------

Hi rustamabd,

I did now use the manual mode to patch my email.apk from an ICS 4.0.4.

The patching was applied successfuly without any problems.

But the now the Email.apk is FC'ing as soon as I start it on my phone.

It is obviously not working anymore.

What do you need in order to analyse the issue?

Please let me know. I really would like to use your patch and see it working on my rom ;-)

Thanks
[Galaxy S II Themes and Apps] solar666:
Now, by today, I was successful. I used a different set of emailgoogle.apk and exchangegoogle.apk file and it successfully completed the patching. Using this 2 new patched apks I encounter no FC anymore and was able to connect to active sync without any security policy enabled.

One question left.

I am now using a patch exchange as well. Is it really not needed?

Thanks anyhow for your great work.

:)
[Galaxy S II Themes and Apps] autoexec101:
So happy i found this thread.

I can confirm it works great on my Galaxy S2 with Ressurection. Only issue i had is that with latest ressurection ( 1.0 ), it doesn't work because of stock kernel. Had to put a different kernel.

Removes all policies, especially Encryption which is the one i wanted, as i never managed to encrypt my phone without it crashing and reverting to factory default :|