yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] MustGoFast:
I have confirmed root, and the email item worked fine on my device, but when I configure it it's still forcing me to set a PW and encrypt my device.

Any idea why the patch failed?

---------- Post added at 10:52 AM ---------- Previous post was at 10:45 AM ----------

Cleaning up ...

Waiting for USB connection...

Checking device...

Model: SCH-I545, build JDQ39.I545VRUAMDK, android 4.2.2 (API Level 16)

/system mounted on /dev/block/platform/msm_sdcc.1/by-name/system, mode ro

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

Pulling app(s) ...

Can't find Email app. Enter the name of your Email apk or press <Enter> to exit:

SecEmail_J.apk

Pulling libs ...

Decompiling SecEmail_J.odex ...

Applying patch ...

Patching com/android/email/SecurityPolicy.isActive(Lcom/android/emailcommon/serv

ice/PolicySet;)Z

Patching com/android/email/SecurityPolicy.isActiveAdmin()Z

Patching com/android/email/SecurityPolicy.isSupported(Lcom/android/emailcommon/s

ervice/PolicySet;)Z

Patching com/android/email/SecurityPolicy.getInactiveReasons(Lcom/android/emailc

ommon/service/PolicySet;)I

Recompiling ...

Building SecEmail_J.apk ...

Decompiling SecExchange.apk ...

Applying patch ...

- Already patched.

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.

Press any key to continue . . .
[Galaxy S II Themes and Apps] MustGoFast:
Did it again. The second time through it all worked like it was supposed to. Guess this is the first documented instance on the VZW GS4.
[Galaxy S II Themes and Apps] peeeeh:
Very big thanks! Works fine on I9100XWLSD italian firmware! :good:
[Galaxy S II Themes and Apps] karuru10:
wow lolz
[Galaxy S II Themes and Apps] musicfreak190:
Does the ROM have to be deodexed?
[Galaxy S II Themes and Apps] blulite:
no
[Galaxy S II Themes and Apps] musicfreak190:
Nice, thanks for the fast response.. I am going to apply this on mu stock GS4 as soon as I root it. Cant stand how corporate policy only lets you use a pin.
[Galaxy S II Themes and Apps] mattyv:
Can't get past Credentials

On Rooted Stock Galaxy s4

I am still caught under the Corporate credentials after patching! i.e. i am limited to only a "password" and cannot change to any other kind of unlock.

FYI - confirmed system/app/SecEmail_J.apk file date current as of date of patch so it seems like ti worked.

I've cleared credentials - didn't work

cleared all corporate accounts - still doesn't work

Cleared data from Email app - in program manager

Rebooted a zillion times - still doesn't work

Tried repatching and was told it was already patched.

tried re-clearing credentials

Restored old email client and then repatched - still doesn't work

any ideas?

Is SecEmail_J.apk for all devices? including Galaxy s4?
[Galaxy S II Themes and Apps] hamzer11:
I replied to your PM. Check under device administrators to make sure nothing is there requiring removal. Also, since you had an account setup previously perhaps the lock is just still setup from when it made you do it but you can simply go into lock screen settings and change to no lock. Try it.
[Galaxy S II Themes and Apps] skburke:
- hamzer11

I had the same issue. What did it for me was to remove the micro sd card. Remove your corporate email account. Make sure that under the security settings that there are no administrators and clear all credentials. Reboot and change lockscreen to no password. Once, you get to this step reinitialize you corporate email. If it forces the password setting than you did not patch correctly. When the patch asks for the fIle name you must type exactly SecEmail_J.apk as capitalization must be used. Your hint will be if the email link does not disappear off the home screen than you did not apply the patch properly.
[Galaxy S II Themes and Apps] hommiedaklown:
The files get placed correctly but are not installed after the reboot. When I drill down the the directory to install them I get "there is a problem parsing the package".

The option to install from unknown sources is enabled.
[Galaxy S II Themes and Apps] mattyv:
Did all of the above - still can't old credentials off the the device - have gone back and forth beween patched and un-patched. Is it possible another "account" could be holding the credentials?
[Galaxy S II Themes and Apps] hamzer11:
Remove all accounts that use exchange. Completely baffled, I've done this on 3 phones without any issues. Remove all security locks on the phone. Remove all device administrators. Restore stock exchange and odex files. Reboot. At this point you should have no lock enforcement and no exchange account setup. Check that the original apks are properly restored in system/app. Then report back before you try the script again. If all is restored and you still can't remove the lock, then it's something on your phone and you might have to restore to factory and try again.
[Galaxy S II Themes and Apps] saqaw:
guys is there a way to change the device id in the email app. actually I want to use a different phone to connect to my corporate email server but it won't allow as the device id gets changed with the other mobile
[Galaxy S II Themes and Apps] harrydey1:
ned to remove stock keyboard

how a remove stock keyboard
[Galaxy S II Themes and Apps] piyush7243:
Thanks a lot. It works great..
[Galaxy S II Themes and Apps] strikegun:
hi,

I got a GT-N8000 with stock 4.1.2 on it.

Sadly the patch creates two broken files: SecEmail_Tablet.apk and the SecExchange.apk.

The patch runs through without any issue.

Cleaning up ...
Waiting for USB connection...
Checking device...
Model: GT-N8000, build JZO54K.N8000XXCMA5, android 4.1.2 (API Level 16)
/system mounted on /dev/block/mmcblk0p9, mode ro
checking root access. root uid: 0, secure: yes, busybox: yes
Pulling app(s) ...
Can't find Email app. Enter the name of your Email apk or press <Enter> to exit: SecEmail_Tablet.apk
Pulling libs ...
Decompiling SecEmail_Tablet.odex ...
Applying patch ...
Patching com/android/email/SecurityPolicy.isActive(Lcom/android/emailcommon/service/PolicySet;)Z
Patching com/android/email/SecurityPolicy.isActiveAdmin()Z
Patching com/android/email/SecurityPolicy.isSupported(Lcom/android/emailcommon/service/PolicySet;)Z
Patching com/android/email/SecurityPolicy.getInactiveReasons(Lcom/android/emailcommon/service/PolicySet;)I
Recompiling ...
Building SecEmail_Tablet.apk ...
Decompiling SecExchange.odex ...
Applying patch ...
Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z

Recompiling ...
Building SecExchange.apk ...
Updating device ...
Rebooting device ...
Done.

Hope the chief can help me.

Thx
[Galaxy S II Themes and Apps] tbd@immigrantsong.de:
Unfortnately not for me. Hangs on "Decompiling SemcEmail.apk" forever.
[Galaxy S II Themes and Apps] mattyv:
My resolution. New rom. Thanks for all help but I gave up
[Galaxy S II Themes and Apps] Tallica21:
Worked great for me on stock AOSP email. Any reason it didn't work with a inverted version of the same app? Inverted email was working then ran script, after reboot Email app would not show in app drawer, it was in /system/app w/correct perms....strange
[Galaxy S II Themes and Apps] viperpiper:
Well I had the exact same issue as others on my SGH-i337. My phone is rooted, no accounts set up in the stock email client. I followed your instructions above but it says the patch is already applied. The email icon never appears on the last screen so I take that it really never did take the patch. I did make sure I typed in SecEmail_J.apk as well when it couldn't find Email.apk.

Anyone else get it working on a Galaxy S4 and if they did what's the secret.
[Galaxy S II Themes and Apps] hamzer11:
Did you try using root explorer and checking to see if the odex files are still in there? Go to system/app and go down to secEmail, you should have just the two apk files (email and exchange) and no odex files I believe. I think it also creates .bak of your original stuff so you should be able to delete the modded ones and rename the .bak to get back to stock. Not a dev so I'm not 100% on it but the patch worked for me with the same setup you have.
[Galaxy S II Themes and Apps] viperpiper:
What I do have there are odex.bak files. Are you saying you deleted the odex files or the patch removed the odex files. ?
[Galaxy S II Themes and Apps] hamzer11:
I believe you should have odex and apk backups there after running this. Are you sure you may have odex.bak files for email and exchange?
[Galaxy S II Themes and Apps] majormar:
ZipException?

I am getting the following when I run the script on my GS4. Anyone else getting this? I have the latest JDK and JRE installed.

Can't find Email app. Enter the name of your Email apk or press <Enter> to exit:

SecEmail_J.apk

Pulling libs ...

Decompiling SecEmail_J.odex ...

Applying patch ...

Patching com/android/email/SecurityPolicy.isActive(Lcom/android/emailcommon/serv

ice/PolicySet;)Z

Patching com/android/email/SecurityPolicy.isActiveAdmin()Z

Patching com/android/email/SecurityPolicy.isSupported(Lcom/android/emailcommon/s

ervice/PolicySet;)Z

Patching com/android/email/SecurityPolicy.getInactiveReasons(Lcom/android/emailc

ommon/service/PolicySet;)I

Recompiling ...

Building SecEmail_J.apk ...

java.util.zip.ZipException: invalid distance too far back

at java.util.zip.InflaterInputStream.read(Unknown Source)

at java.util.zip.ZipInputStream.read(Unknown Source)

at java.io.FilterInputStream.read(Unknown Source)

at jpatch.util.ZipUtils.copyStream(ZipUtils.java:72)

at jpatch.util.ZipUtils.updateZip(ZipUtils.java:44)

at jpatch.emailPolicy.Run.applyPatch(Run.java:471)

at jpatch.emailPolicy.Run.main(Run.java:581)
[Galaxy S II Themes and Apps] maumaus:
It workes flawless on my Samsung Galaxy S4 (I9505).

After the patch I setup the company mail and it asked for some security stuff which is aspected.

But i noticed that there was no Device Admin what so ever. Which is great, because the remote wipe is disabled that way ((I guess).

If I remember correct... With patch 3.2 you let the Remote Wipe in place. You removed keyguard and stuff... But there would always be a device admin with 3.2 and Remote Wipe was enabled.

Did you change that in 3.3? If so... Awesome!
[Galaxy S II Themes and Apps] geswek:
It doesn't work with ODEX roms.

I just found out the hard way.
[Galaxy S II Themes and Apps] Mr_Q:
It does for me!
[Galaxy S II Themes and Apps] geswek:
How so? Mine kept error with java crap.
[Galaxy S II Themes and Apps] bricenott:
It's working for me too, read the instructions... :D
[Galaxy S II Themes and Apps] geswek:
OMG you're so damn smart!

*shakes head*

It still does not work with CleanROM Ode--
[Galaxy S II Themes and Apps] bricenott:
Sorry if I hurt your feelings... :p
[Galaxy S II Themes and Apps] T0mmyL33:
Do you have the original Email.apk file for the Samsung GS4. I didn't backup and this hack is not working for me. I'd like to restore.

Thanks,
[Galaxy S II Themes and Apps] jsauder2:
just download the rom you are using and pull it from the zip file. likely located in system/app/

Sent from my Nexus 4
[Galaxy S II Themes and Apps] vladhall:
Works great on my LG VM701. Thanks!
[Galaxy S II Themes and Apps] chx:
Great work!

Any chances of doing the same with the Lotus Notes Traveler email client?
[Galaxy S II Themes and Apps] rustyx3:
Yes ODEX ROMs (i.e stock ROMs) are fully supported of course.
[Galaxy S II Themes and Apps] rustyx3:
Don't think so, sorry...
[Galaxy S II Themes and Apps] sinan.awad:
Thanks for the effort.

Tried it on an S3 with Omegas v7 (AOKP)

Now the email does not force PIN lock, but it still request administrative rights and receives them.

How can your patch remove this? I really don't want a bug in the exchange server to send a wipe command to my phone...

Thanks!
[Galaxy S II Themes and Apps] reissc1:
I've used this patch several times in the past, but I'm obviously overlooking something here while trying to do my s4. The phone is recognized by the computer but not by the patch script. What am I forgetting to do? Usb debugging is checked.
[Galaxy S II Themes and Apps] tiniwings:
Thanks Folk.. Its working for JB-Xperia P :)
[Galaxy S II Themes and Apps] Skv86:
I was wondering the same. My company is no longer a device admin, but is it also unable to remotely wipe my S4?
[Galaxy S II Themes and Apps] mpcjanssen:
I love this script and have been using it for quite some time on my Android devices now. However because I switch ROMs often, patching the APKs and reconfiguring email after each update became a bit tedious.

So I have used the Xposed Framework http://xdaforums.com/showthread.php?t=1574401 to patch the APKs at runtime. So now when I install a new version of CM10.1 I will only have to reapply the Xposed Framework (from the installed app) and the email is patched again.

You can download an APK which will probably only work for AOSP JB from http://mpcjanssen.nl/files/XposeEmailPolicy.apk

Source for those interested is at http://mpcjanssen.nl/cgi-bin/xpose/
[Galaxy S II Themes and Apps] ArtoD2:
Nice, thanks for sharing. I do the flashing always so, that I manually patch the email and exchange APK's and replace them on the CWM zip before flashing. No need to configure mail again etc.

Also Titanium backup on the Accounts, Exchange and email will restore the data so there is no need to reconfigure the email over and over.
[Galaxy S II Themes and Apps] bricenott:
True that... :thumbup:
[Galaxy S II Themes and Apps] dbenyakar:
Same here. It only recognizes my Galaxy S4 (i9500 rooted), where is says: "/system mounted on..." and does not continue beyond that point.

It is compatible with S4?
[Galaxy S II Themes and Apps] hamzer11:
I would say to both of you that it is definitely compatible. I have an AT&T S4 and I used this script with the stock ROM plus root, then with a custom ROM and now with an international ROM based on MF8 release. Worked each time on the same laptop and the same usb port. Are you getting prompts on your phone that you are connected? Definitely something localized to you guys.
[Galaxy S II Themes and Apps] dbenyakar:
Yes I am definitely connected. I got the prompt to connect and pressed OK, then it reached to the point where it says "/system mounted on /dev/block/mmcblk0p20, mode ro" and stopped there.

Im also on MF8, on i9500 international version.

What can it be then?

***** Part 2 ***********

OK I had a problem with my SuperSU. Sort that out and got to the point where is says: "Can't find Email app. Enter the name of your Email apk".

I had Galaxy S3 i9300 before that and none of this happened before. This is why I am asking these questions.

The names of the apps have not changed, have they?

***** Part 3 ***********

The name of the Email apk is not SecEmail.apk but SecEmail_J.apk. This is why it did not find the file.

The SecExchange.apk is the same.

So I entered the name of the email apk " SecEmail_J.apk", pressed enter and then it continued from there and now it works nicely.

Maybe on the i9500 International version the email filename has changed to SecEmail_J.apk.
[Galaxy S II Themes and Apps] hamzer11:
Sorry didn't reply earlier. Glad you figured it out, yeah it's SecEmail_J as you noted.
[Galaxy S II Themes and Apps] peikojose:
If I understand well this could fix this ?

http://xdaforums.com/showthread.php?t=2284743
[Galaxy S II Themes and Apps] the_liv80:
Unable to get this...

I'm attempting to do this via OS X and cannot seem to get anything going. I've downloaded the Java / Kies / Drivers etc and cannot run the patch.
[Galaxy S II Themes and Apps] dbenyakar:
What do you see on your command line prompt? Can you copy/paste the lines?
[Galaxy S II Themes and Apps] the_liv80:
still nothing...

I keep getting command not found.
[Galaxy S II Themes and Apps] jsauder2:
I imagine that means unix doesn't have the commands this is trying to run. you could always use virtualbox or vmware to set up a Windows environment and run it through that.

Sent from my Nexus 7
[Galaxy S II Themes and Apps] the_liv80:
Possibly...I don't feel like setting that up right now, so perhaps I'll try on a windows machine tomorrow. I've seen in other posts references to an APK, but don't see any patched APK's anywhere...might I have missed something?

(I'm running CM on a Galaxy S4, FWIW)
[Galaxy S II Themes and Apps] the_liv80:
Ok...I've tried on a windows maching and still not able to get this to work. The *.cmd runs however at the end I get:

Before the obvious questions, yes, I'm rooted and running CM.
[Galaxy S II Themes and Apps] BillGoss:
Have you enabled root access for ADB in settings/developer?

Sent from my GT-I9505
[Galaxy S II Themes and Apps] the_liv80:
You're a SAINT! That was it...all is good. I'll re-check again, but was there some guidance on how to avoid needing to re-run the CMD every time I install a nightly?
[Galaxy S II Themes and Apps] jsauder2:
Pretty sure if you backup accounts, email app, and exchange services, you can restore the data to avoid running it again.

Sent from my Nexus 4
[Galaxy S II Themes and Apps] the_liv80:
notifications not working

The patch worked however sync is off and I'm receiving no notifications for email. Anyone else experience this and have a solution?

EDIT: I ended up restoring and living with the PIN unlock. While the patch worked, nothing I did was able to generate notifications or a functioning sync.
[Galaxy S II Themes and Apps] hamzer11:
What phone are you using? I've used this patch on 3 phones and never had the issue you're reporting. Did you clear out all accounts before the patch? Did you manually add the account back in or restore it from something like tiBu?
[Galaxy S II Themes and Apps] tariq2kn:
Email admin has disabled the 'Unknown Sources' installations on my new S4 i9505.

Anybody pease provide a solution.
[Galaxy S II Themes and Apps] dbenyakar:
I have used the script on two phones and had no issues with the sync. Maybe you need to adjust the sync settings to always push even in non working hours.
[Galaxy S II Themes and Apps] the_liv80:
I may retry it tonight...on the off-chance it was a fluke. But yeah, I'm fairly certain I followed all instructions. Get's a little convoluted though when you're reading through 90+ pages of comments.
[Galaxy S II Themes and Apps] kelmar13:
Assuming you've tried rebooting? My S4 randomly has options "disappear" and a reboot always fixes it.
[Galaxy S II Themes and Apps] shuweee:
has anyone tried this on SGH-I337M Canada Version of S4?
[Galaxy S II Themes and Apps] hamzer11:
Give it a try. It should be the same SecEmail_J.apk manual entry and it should work. But make a backup first if you're worried.
[Galaxy S II Themes and Apps] bmflex:
Nexus 4 encryption?

I have used this with success on my Nexus 4, however after around a week or so of use, I receive the dreaded 'Security update Required' notification which requires me to encrypt the phone.

The only solution appears to be to reapply the patch each week when I get this message which means setting up my outlook account all over again.. Is there a way to avoid this?
[Galaxy S II Themes and Apps] valdezpa09:
It is because our adb is ./adb and that is not how the script was made.
[Galaxy S II Themes and Apps] the_liv80:
No, in my case it was because I didn't actually have Kies open nor had I enabled ADB correctly.
[Galaxy S II Themes and Apps] semon:
Does anyone know if this patch works on the leaked 4.3 nexus 4 ROM ?
[Galaxy S II Themes and Apps] madster:
Note 8

Have anyone tried on Note 8 N5120? I can't make it work unlike previously S3 and Note 2.
[Galaxy S II Themes and Apps] kuberchib:
after applying the patch (version 3.3) I always get "Android is Upgrading" message on every boot. reverted back to stock and applied the patch (v 3.2) and now it works fine.

I am using stock ROM 4.1.2 on Note 2
[Galaxy S II Themes and Apps] drjat:
I used this hack on my s3 omega rom and it worked perfectly. I have now flashed a new version of the rom.....without wipe.....do I need to use the hack again?

The email app after flashing has all the data and also syncs with server. I don't know if the security policies have been reimplemented. If the company updates security policies then do I have to re do the hack?
[Galaxy S II Themes and Apps] rustyx3:
Why do you even bother patching your email client if you experience no side effects from your company policies? The hack's only purpose is to stop annoyances such as the mandatory pin lock. If you don't notice any of such effects, then you don't need this patch.

Just to answer the question - yes, after flashing a new ROM the email app must be patched again.
[Galaxy S II Themes and Apps] VictorML:
I just applied this patch to the official 4.3 stock release (odexed) on my rooted Galaxy Nexus (GSM, maguro). This is, the official 4.3 factory image that you can download from Android website and the same version that you'll get through OTA updates. Just wanted to inform everyone:

The first time I ran it, it didn't seem to work:

Waiting for USB connection...
Checking device...
Model: Galaxy Nexus, build JWR66V, android 4.3 (API Level 16)
/system mounted on /dev/block/platform/omap/omap_hsmmc.0/by-name/system, mode ro

checking root access. root uid: 0, secure: yes, busybox: no
Pulling app(s) ...
Pulling libs ...
Decompiling EmailGoogle.odex ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Recompiling ...
work\out-EmailGoogle.apk\com\google\common\collect\Sets$CartesianSet$1.smali[0,0
] Must call setParent before comparing AnnotationDirectoryItem instances

Then the "Press any key to continue..." statement appeared.

But before giving up, I decided to give it a second try (same CMD window, just re-ran the command):

Cleaning up ...
Waiting for USB connection...
Checking device...
Model: Galaxy Nexus, build JWR66V, android 4.3 (API Level 16)
/system mounted on /dev/block/platform/omap/omap_hsmmc.0/by-name/system, mode ro
*** Warning: cannot set root (is device rooted?). uid=2000
Pulling app(s) ...
Pulling libs ...
Decompiling EmailGoogle.odex ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Recompiling ...
Building EmailGoogle.apk ...
Decompiling Exchange2Google.odex ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z
Recompiling ...
Building Exchange2Google.apk ...
Updating device ...
Rebooting device ...
Done.

So in the end it worked!!:D

I've been running it for a few minutes after reboot. Both Exchange mail and calendar correctly synced, no prompts for security policies so far... looks very very good!

I heavily rely on my Exchange account for work, but it's an absolute pain in the ass for me to be forced to use the lockscreen PIN protection since it completely kills the usability of my phone. But thanks to this patch, ever since ICS my life has been so much easier.

While everyone else is just flashing modified .apks, specific for each Android version, waiting for new versions every time Android receives an update... here we have this little script that simply digs into whatever Email.apk you throw at it, finds the relevant lines of code, changes them and compiles it back and pushes it to the device.

And it's so good it works on 4.3 without even being tested!

I just wanted to thank rustamabd, and I've also sent you a little donation. Not much but I hope you appreciate it and enjoy a couple of extra beers with it ;)

Thanks!
[Galaxy S II Themes and Apps] drjat:
Because if I don't apply the patch then I have to use pin lock on device which is annoying. I flashed new rom and the email works and syncs but I am not having to apply pin lock on my device. ....so I am confused.

There is no problem in reapplying the patch but do I have to remove account before using patch and redo mail setup?