yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] paalkr:
I tried the hack with Omega v.6 ICS rom, and that did not work. The phone was not able to sync any emails or calendar entries. I did not get any error messages though, either when running the tool or when launching the exchange sync setup.

Is it suppose to work, or is XWLP2 not supported yet?
[Galaxy S II Themes and Apps] romracer:
This patch works for the ICS leak for the AT&T SGS2 Skyrocket. I had to manually edit the two Smali files to have ".prologue" in the necessary functions and recompile those into the APK. Then run the patcher so it could find those lines.

Maybe in a future version, you could look for the ".registers" line instead? ".prologue" is a debug statement and not all dex files have debug information (ours for example).
[Galaxy S II Themes and Apps] rustyx3:
Maybe. Can you send me your original smali files? Tks
[Galaxy S II Themes and Apps] romracer:
Sure, attached. They are deodexed so you shouldn't need the framework to baksmali them to peak inside.
[Galaxy S II Themes and Apps] haroonie:
Thanks, this worked great on my stock Galaxy Nexus version 4.0.4 IMM76D-yakju!
[Galaxy S II Themes and Apps] zenkinz:
anybody work on the patch for HTC-one-X?
[Galaxy S II Themes and Apps] colibri2:
Great post, thank you rustamabd!

Worked smoothly, just had to copy recompiled files manually.

Windows 7 x64 JRE 7 Galaxy Nexus 4.0.4
[Galaxy S II Themes and Apps] JoeSmoo:
Am I doing something wrong?

Waiting for USB connection...
Checking device...
Model: SAMSUNG-SGH-I727, build Stock Revamped , android 4.0.3 (API Level 15)
/system mounted on /dev/block/mmcblk0p24, mode ro
checking root access. root uid: 0, secure: no, busybox: yes
Pulling app(s) ...
Pulling libs ...
Decompiling Email.apk ...
Applying patch ...
Unable to apply patch. Pattern not found.
Decompiling Exchange.apk ...
Applying patch ...
Unable to apply patch. Pattern not found.

*** Patch aborted.

I am running the Stock revamped ICS rom but every time I run the patch I get these results, any ideas? Let me know if you need more info.

Thanks!
[Galaxy S II Themes and Apps] mousse04:
I tried your patch on galaxy nexus ... and it worked very fine. A little bit too much, because of course I don't have the keyguard anymore, but I don"t have the lockscreen shortcut (camera, unlock shortcuts) :( !!!!

How to fix that?

Edit: my fault ... sorry. Great mod :)
[Galaxy S II Themes and Apps] scarbon:
+1

Running ICS (Litening ROM 2.X), email 4.0, Exchange 3.1
[Galaxy S II Themes and Apps] rustyx3:
New version 2.6 is released which should fix the "pattern not found" issue.

Let me know if it works! :)
[Galaxy S II Themes and Apps] nunuxx:
hi, is anyone getting a corrupted download for email-policy-patch-2.6.zip??
[Galaxy S II Themes and Apps] rustyx3:
Re-uploaded version 2.6. Pls try again now.
[Galaxy S II Themes and Apps] nunuxx:
thank you so much for the quick reply rustamabd. the attachment download is now working but more importantly the hack works perfectly with foxhound 4.0.3.

Thanks so much man! you're a life saver! i thought i had to go learn how to do the apktool myself! i'm so glad i found this thread and will share this to others. thanks again for your work and i will make a donation.
[Galaxy S II Themes and Apps] JoeSmoo:
Thanks So MUCH! Now I can use my favorite ROM without having to enter that screen lock! You rock!
[Galaxy S II Themes and Apps] ArtoD2:
Any change or possibility to patch the needed files BEFORE updating ROM? This would ease the Titanium BU usage.... weekly update process to new MIUI would be tad easier.
[Galaxy S II Themes and Apps] rustyx3:
I have no plans for this functionality, as I always flash official signed ROMs, patching such a ROM before flashing would break the signature.

If you still want this, you're welcome to do it yourself; use the manual mode in which the script patches a given .apk, and create a script to update your ROM image with the patched apk.
[Galaxy S II Themes and Apps] brandoncampbell:
wish it would work for BlurEmail

I installed ics rom on my Droidx and ran this and it worked fine.. but I've always had issues with 2ndinit roms working as well as the orignal. So I went back thinking it "may" work.. but it didn't. Think it's possible to patch BlurEmail.apk?

Another thing I just tried and noticed it doesn't work on is source built email app from gingerbread Vortex rom. I noticed it had a MSExchangeService.apk so that may be the reason. It patched the Email.apk fine, rebooted and then tried to connect to my work exchange and it gave me the standard not supported by my exchange server msg... I noticed that it never acknowledged the MSExchangeService.apk so I decided to try and name it Exchange.apk and it found it but couldn't alter it..

I was soo hoping it would work... since it worked great on ICS Gummy Rom.. It was actually the first thing that ever bypassed my work exchange settings..
[Galaxy S II Themes and Apps] rustyx3:
Sorry, Motorola Blur is not based on AOSP code, and thus is not supported atm.
[Galaxy S II Themes and Apps] romracer:
Thanks, it works fine.

I noticed the Bash shell script for Linux says this:

$ cat apply-patch-nix.sh
#!/bin/sh

java -jar lib/email-policy-patch.jar patch-manual $*

I think the "patch-manual" is an accident. Since the "$*" means "take all the parameters passed to me and append them here", if you run:

$ ./apply-patch-nix.sh patch-manual work 15 Email.apk Exchange.apk

you get an error because it expands to:

java -jar lib/email-policy-patch.jar patch-manual patch-manual work 15 Email.apk Exchange.apk

(the error is that "patch-manual" must be a directory).

I think the shell script should just read:

#!/bin/sh

java -jar lib/email-policy-patch.jar $*

which then works fine.

Anyways, thanks for a great patch. Even though I can do this stuff by hand, its so much easier with your patcher :)
[Galaxy S II Themes and Apps] nomenquis:
Hi,

It seems that also the download for the source code is broken, could you please also re-upload this one?

kind regards
[Galaxy S II Themes and Apps] dewey1973:
Just an FYI if you are on CM9 on the Epic Touch 4G. You need to go to the developer settings and make sure root access is allowed for both apps and adb. For me it was defaulted to apps only. I was getting "are you rooted?" messages in the script. Now that the script completed without issue I'm off to test the results! Wish me luck!
[Galaxy S II Themes and Apps] rustyx3:
patch-manual in the shell script is not an accident, as it is the only command that works under linux. But I agree that documentation can be improved. You should not need to supply patch-manual as a parameter.
[Galaxy S II Themes and Apps] dewey1973:
Worked successfully on my Epic Touch 4g on CM9 alpha 3! I'm so happy! Bye bye Touchdown!
[Galaxy S II Themes and Apps] JoeSmoo:
Got things working reliably on different roms finally but I do have one small problem... when I read email on the phone it does not show as being read on the server...

I know this is VERY minor but if there is a way to fix this it would be great.

Thanks!
[Galaxy S II Themes and Apps] Pharaohnough:
Client Certificates

Has anyone managed to get this working with Client Certificates (for Exchange)?

Installing client certificates requires the use of a pattern, pin or password lock (an ICS feature not an Email.apk feature) but there are third party apps that allow the use of Client Certificates without any kind of lock.

Sadly, none of these are as good as stock Email.apk
[Galaxy S II Themes and Apps] rustyx3:
Yep, this "feature" in ICS is quite disappointing indeed. If a client certificate store is used, then slide unlock or face unlock are not allowed. This kinda sux because slide unlock was allowed with a cert store in GB just fine. I guess that's because the client cert store in ICS can also store trusted CA certs now, but honestly I do not care, as my phone is rooted and as such has got practically no security anyway..
[Galaxy S II Themes and Apps] Pharaohnough:
I found a workaround which I've been using since yesterday and I must say it's been quite smooth although I don't normally like 3rd party apps to get over such issues. The workaround uses Tasker and an app called Secure Settings and works silently in the background. I found it on a post here on XDA.
[Galaxy S II Themes and Apps] MattRob:
Working great for me until my recent upgrade to AOKP 4.0.4. I get the fault that it can not be recovered; patching works fine but file is put in the sdcard directory and email is not functioning at all. I tried full install again and doing this from scratch, but do not get the email.patched.apk working ... Is this due to the new AOKP 4.0.4, or should I do something else/new ? Txs !
[Galaxy S II Themes and Apps] CaspaTheGhost:
Working fine here... Build 33 maguro but with Black Exodus theme... Actually, think I'm running 2.2 of the path though.

Sent from my Galaxy Nexus
[Galaxy S II Themes and Apps] Muskito87:
Works great on AOKP Hydra2o!!! tnx! will donate as soon as I can!
[Galaxy S II Themes and Apps] MattRob:
Hm, got it working by manually copy the patched files to /system/app This was not working as well in first instance, but finally managed it. So happy user here again !
[Galaxy S II Themes and Apps] globalVariable:
Works on Galaxy Nexus ICS Stock 4.0.4

First off, thanks to all the smart people who offer their expertise for the benefit of others. Kudos!

For the record, this patch worked in that it could bypass the phone encryption requirement. I have a GSM Galaxy Nexus with ICS - Google's Stock Firmware 4.0.4. The Email app connects and works fine. However, I could not get the Calendar to sync. The account shows no calendars. I don't know if its the exchange server I am connecting to or the patches that I have been trying. (I have tried other patches on XDA too, which worked for email but not for calendar).

I could not get the *nix script to work on my Mac (forget the specific exception, but I think it printed some stacktrace), but then tried on Windows 7 and that worked. After decompiling/patching/recompiling steps were successfully completed, the script couldn't copy the patched files in place, but printed a message saying that they need to be manually copied - no big deal.

Thanks once again to the author!
[Galaxy S II Themes and Apps] tetzlav:
THX!

Many thx! It works perfectly with Semcemail.apk/Exchange.apk from stock Xperia ray ICS 4.0.3 (build 4.1.A.0.562).

The only thing: I had to copy the patched files manually.
[Galaxy S II Themes and Apps] eryen:
Is there any possibility to patch downloading zip file attachments.
[Galaxy S II Themes and Apps] rustyx3:
I do not understand what it is you want exactly? What is the issue?
[Galaxy S II Themes and Apps] varunmagical:
Thanks a zillion man .. worked like a charm .. thanks a lottt .. this is really helpful .. I hate putting password every time I have to change a song!
[Galaxy S II Themes and Apps] eduncan911:
To the OP: Worked perfectly! The first (when reading this on Page 29!) is constantly updated with the latest version.

Grab it, make sure you have everything setup, and run it.

Sprint Galaxy Nexus 4.0.4 FD02

CM9 ROM

Microsoft Office 365 Exchange account
[Galaxy S II Themes and Apps] DarkDvr:
rustamabd

Could you hypothetically hack Sense 4.0 Email app?

Shouldn't be much different.

I can send you all the files you need, along with a donation if it's done =)

So far nobody hacked it, you wanna give it a whirl?
[Galaxy S II Themes and Apps] rustyx3:
It is totally different. HTC Email app has its own Exchange EAS implementation, it has nothing in common with AOSP EAS code. Plus I don't have a Sense 4.0 device, without it it's kinda hard to create a patch.
[Galaxy S II Themes and Apps] eduncan911:
@rustamabd: Again, kudos for patch! And after 29 pages, you are still active!

Question, how would I automate this patching process during a ROM update?

I automate my ROM updates and flashes with Windows cmd-line scripts.

After a nightly update of a ROM, I get flooded with alerts for Exchange demanding that big-brother needs to control my entire device - that is until I patch with your HACK here and that clears it up.

I have a few options, but I need you to confirm:

Option 1)

Before updating ROM, copy the Email.apk and Exchange.apk from /system/apps/ to somewhere like /sdcard.

Flash the updated ROM normally.

Then copy the modified Email and Exchange.apk files back to /system/apps/.

Reboot.

Option 2)

Copy the files as in Option 1), but modify the ROM's update ZIP first by side loading the apk files directly into the zip.

Flash as normal.

Option 3)

If it is possible, can I apply your patch to a local ROM zip or local system image somehow?

The issues with 1 and 2 is that I am not sure if you are modifying other files in the system. If you are, could I just copy them like 1 and 2 describe above?

I'm currently calling your batch file from within batch file, after the system boots and it yells at me.

Thanks!

Ps, I am going to be installing Google Apps. How does that affect this patching process? Does Gapps overwrite the Email and Exchange? I would hope so, because the Email and Exchange that comes with the ROM I am using (CM9) is nothing like the Sprint Galaxy Nexus versions with push notifications and such.

Thank again!
[Galaxy S II Themes and Apps] fastguy:
without root?

Would it be possible to install this version side-by-side with the system version, without root requirement? (ie without replacing?)

If the app could download & patch the version, then could it upload as a user app?
[Galaxy S II Themes and Apps] MosysX:
No chance without root..

@fastguy

No chance without root, because you have to modify files (Email.apk) in the system/app.. folder and this not possible without root.
[Galaxy S II Themes and Apps] rustyx3:
I think its possible, you need to at least change the app name in the manifest, and make sure it doesn't conflict anywhere else. But it might simply not run if it's not a system app, since system apps get more privileges than user apps.
[Galaxy S II Themes and Apps] rustyx3:
Yes, this is possible by running my script in manual mode. There is a file apply-patch-nix.sh which shows how to use this mode. You can write a similar .cmd file for windows. In this mode the script patches the .apks from the local filesystem, without accessing the device.
[Galaxy S II Themes and Apps] hypetaxx:
Did not work the first time, well tried it again and guess what i WORKED brilliantly with ARC 4.0.4 - no need to do anything manually, other than tell the script the name of my email apk (SemcEmail.apk)

Thank you, you made my life so much easier :-)
[Galaxy S II Themes and Apps] evanovici:
Hello rustamabd,

this works great for the email app, but my company caught on to this and added a third party software, Afaria which screws up everything and brings back the pin unlock. Any chance you can have a look into hacking that?

Thanks again for the awesome work on this so far, never failed me, no matter the ROM I used!
[Galaxy S II Themes and Apps] striker76:
Does this hack work on the Email app in MIUI?
[Galaxy S II Themes and Apps] ArtoD2:
V4, yes. For GB I don't know.
[Galaxy S II Themes and Apps] arovik:
Can you do something to make this work with the newest 4.0.3 release for SGS2? (XWLPD)
[Galaxy S II Themes and Apps] shizah:
CM9 note

Alright, so I ran across an issue that I didn't see any fix for. I was able to figure it out myself and want to leave this here for anybody that may come across the issue.

I am running CM9. When I attempted to run the patch the first time I got an error:

*** Warning: cannot set root (is device rooted?). uid=2000​

Phone is rooted. What could possibly be the issue?

Go into Settings > Developer Options > Root access > and set it to Apps and ADB. Obviously Android debugging should be checked.

That should do it. Run the CMD file again and you are all patched up.

Hope this helps somebody.
[Galaxy S II Themes and Apps] mo046:
I also can't get it installed on my XWLPD device. The original email app has gone and the new patched version can't be installed. The compiled apk's have been copied to the device on /sdcard and the installation can be started, but it is terminated with an error message that the app is not installed.

Now, how can I restore the stock email and exchange apk's? (Edit: found it, I have to use the restore.cmd)(Edit #2: the restore function didn't work. It couldn't find the email apk.)

And please can you fix the patch for the XWLPD firmware?

Thanks!
[Galaxy S II Themes and Apps] wonderstoat:
AOSP latest version with Search?

Hi

I installed this patch a couple of months ago and it's worked great, in fact since applying it I haven't had to repatch, even through multiple versions of Wanam's ICS ROM.

However, I've never had search functionality in AOSP mail, I even tried flashing another ICS ROM (F1) but still no search field available in the app.

Would any of you knowledgeable people have an idea what's going on here?

The various AOSP email.apks do not have any version number on them (or visible in the app itself). Can anyone confirm what the latest version of the AOSP email is?

I'm not technically knowledgeable like the rest of you guys, but could anyone recommend the following:

A good, lite ICS ROM for GS2 (I currently use Wanamlite 11.6)

The most recent AOSP email.apk which has working "Search"

How to combine the two above with a no-exchange security patch

Sorry for asking for so much info, but I've flashed so many things recently, I'm not sure now which apks I'm using, I've read the various forum threads but I'm now completely confused and I think I need to totally start from scratch.
[Galaxy S II Themes and Apps] JoeSmoo:
I'm using the SkyICS 4.2E rom right now and everything you've mentioned works perfectly for me.

If you want to see what version of the email app you're running look under Applications>All and find the app in the list the SkyICS rom uses 4.1. I re-installed this ROM last night and this email patch worked perfectly.

The 4.1 version seems to have a search, I've never seen one without though...
[Galaxy S II Themes and Apps] rustyx3:
New release (2.8) is available that should fix the issue with XWLPD.
[Galaxy S II Themes and Apps] marshalllaw:
Anything I should backup before running this patch?
[Galaxy S II Themes and Apps] ardeban:
Works flawless on a rooted Galaxy S3.

Just have to specify the email app name "SecEmail.apk"

Maybe you can fix the app so it searchs for that app directly? I guess this will be a very popular device.

Great work!
[Galaxy S II Themes and Apps] rustyx3:
Cool, thanks, will do. Can you also tell me the name of Exchange apk?
[Galaxy S II Themes and Apps] ardeban:
That one does not change (Exchange.apk).

BR!
[Galaxy S II Themes and Apps] rustyx3:
A new version is available! This one will also look for SecEmail.apk to better support Galaxy S III. Also tested on an S III system image, seems to work.
[Galaxy S II Themes and Apps] aneurysm-:
hi, my company (maybe the same one :) ) did the same thing. First time I ran afaria .. it didn't complete well and put me on the page for adding a pincode. I clicked cancel there, ran the afaria app again ... and got a "succesfull" ... since then no problems (or cyber mails :) )

Hope it works for you too
[Galaxy S II Themes and Apps] Monu123:
Afaria is too easy to tricked. Follow the complete procedure and let afaria do what it wants to do. After that go to security setting / administrator and disable afaria by just unchecking it. Now you can set the lock screen the way you want
[Galaxy S II Themes and Apps] aneurysm-:
prolly a stupid question .. security settings where ?

EDIT: found it ..
[Galaxy S II Themes and Apps] aneurysm-:
I get a device update failed ... Update manually.

okay, that's no problem .. but where did the patch store the "updated" apk's ?

EDIT: ran patch again .. and this time it did work it seems, device rebooted
[Galaxy S II Themes and Apps] PrXenon:
Galaxy Note... ?

with ICS 4.0.3 don't work :-(

help?
[Galaxy S II Themes and Apps] aneurysm-:
got it working ... except my agenda, it won't sync it .. weird
[Galaxy S II Themes and Apps] rustyx3:
In the latest Exchange apk calendar sync works only in push mode.. not sure why, needs to be investigated...
[Galaxy S II Themes and Apps] rameshzombie:
Beauty.... Worked like charm... Thanks alot for this patch :)
[Galaxy S II Themes and Apps] pentafive:
Just wanted to update since I posted a while ago..

This has been working with no issues since I used it on another computer. I have been using this on my GNex running 4.0.2 and now 4.0.4. I haven't found a ROM it won't work on yet. I am currently using AXI0M CMPLX B1ACK (was on PZ M3).

Thanks for this.. it is a big help!

-Penta
[Galaxy S II Themes and Apps] dannykul:
Excellent !!!

Excellent tool :) Applied the patch in a few minutes and works like a charm !
[Galaxy S II Themes and Apps] bucaneer:
Keylock still on

Hi,

I am using ParanoidAndroid rom which is based on CM9. I used your patch. The patch was successful(Thanks a lot for that). When I was configuring my exchange account I added a user certificate. The certificate forced me to enter a numeric pin. However my phone was not encrypted which is great.

Is this normal behavior? Will I be forced to enter a numeric password?
[Galaxy S II Themes and Apps] lpasq:
I would greatly appreciate some help. I am a rookie Linux user and need a noob level understanding of the command line and installation packages required for running a patch.cmd ...I have Java 6 and do know it is correctly installed since my ROM kitchen works flawlessly.
[Galaxy S II Themes and Apps] devilbob:
Gapps

I'm looking to evade the device policy for a gapps account. Tried this and it didn't seem to work. Still requires me to download Device Policy and set 8 character password. Galaxy Nexus with IMM30b 4.0.4.

Any help would be appreciated.
[Galaxy S II Themes and Apps] dewey1973:
+1

I hate having to borrow the in-laws' Windows laptop to apply this every time I change ROMs.
[Galaxy S II Themes and Apps] maverickzz:
Any hope this supports Honeycomb? 3.2 Galaxy Tab 10.1
[Galaxy S II Themes and Apps] rustyx3:
For Mac/Linux/Unix the patch package contains a shell script that will patch the necessary .apks on a local file system. But there is some manual work involved: download the .apks and framework libs from your phone to your PC, run the patch, and then upload patched .apks back onto the device. When you run the shell script, it'll tell you what to do.
[Galaxy S II Themes and Apps] rustyx3:
Have you tried it? Does it not work?
[Galaxy S II Themes and Apps] rustyx3:
Adding a client certificate to the system credential storage will require a keylock, this is a new feature of ICS and has nothing to do with the Exchange sync policy. To remove keylock, you need to disable credential storage (Settings -> Security), but then you'll lose your client cert.
[Galaxy S II Themes and Apps] lpasq:
I will hack away. Thanks for reply. Does this post describe the mod? http://xdaforums.com/showthread.php?p=15986878

Awesome contribution. Thanks!
[Galaxy S II Themes and Apps] maverickzz:
Galaxy Tab 10.1 HC 3.2

It works like a charm on SGS2.

However when I tried on my HC tab, the patching process works fine, but when I configure my exchange server it fails to initialize after the 2nd step. It gets stuck and never asks to enforce a policy.

I tried to clear data of both email and exchange services, no luck also.

When I revert to backup apks, everything works again, but of course policy is enforced.
[Galaxy S II Themes and Apps] johnuopini:
First of all, thanks SO much!!!

Then, feature request, could you please make this patch able to work during recovery? I usually apply this after updating CM9 and it would be nice to run it before reboot however even if you mount /system the patch will loop saying "waiting for USB connection" even if ADB shell is perfectly working.

Hope this is an easy fix because it would make my updates less painful and probably would avoid reconfiguring the mail account anytime i upgrade.

ANYWAY, this rocks! Thanks!!
[Galaxy S II Themes and Apps] ryrobert:
Thank you so much. Just want to confirm this worked flawlessly on ASUS Transformer Prime running stock Android 4.0.3 email app. You're a genius!