yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] gunigugu:
I don't believe the new version works on Nexus 7 v4.4.2 with ART run time compliler.

Force closes on application startup. Nexus 5 is running fine however.
[Galaxy S II Themes and Apps] rustyx3:
Did it work with ART before you applied this patch?
[Galaxy S II Themes and Apps] SantaSerge:
I tried to apply the patch version 4 to Galaxy S4 (GT-I9500) Android 4.3, unfortunately it's failed on the Updating device step with error:

*** adb command 'su -c 'mount'' failed: java.net.ConnectException: Connection refused:

Could you please help me on the subject?

Thank you in advance!
[Galaxy S II Themes and Apps] SantaSerge:
never mind, has found workaround already, mount and copied files through SD card manually

Thank you for the great tool!
[Galaxy S II Themes and Apps] gunigugu:
You mean the stock email app? Of course it did...
[Galaxy S II Themes and Apps] dragonash:
I am getting the same error

*** adb command 'su -c 'mount'' failed: java.net.ConnectException: Connection refused:

where do i go from there?
[Galaxy S II Themes and Apps] jsauder2:
Running into issues with 4.0 (see the log). 3.4 works fine. Using a Nexus 4 on 4.4.2 stock.
[Galaxy S II Themes and Apps] jsauder2:
Go into the work folder that the script created, and pull the email and exchange apk's (these will differ depending on what device you are using). Then transfer them to your phone. Backup the original apk's from system/app/ then delete those files and put the patched ones in system/app/. Make sure the permissions are set to the same as other apps in that folder, wipe data for the email and exchange apps and reboot. Then you should be good to go.
[Galaxy S II Themes and Apps] dragonash:
I did that just now with no luck :(

I'm using the Note 2 with the new stock 4.3 version (rooted)
[Galaxy S II Themes and Apps] os2baba:
Doesn't work on LG G2 stock

I have been using this for many years and I just wouldn't have used my corporate email without this. So thanks a lot!

I have been on either Nexus or Samsung devices so never had any problems.

But it doesn't work on the LG G2 stock (running 4.2.2). I tried both apply-patch and patch-manual. Neither worked. The first time I tried it, I got an error.

But I was unable to reproduce that error. I installed busybox and tried again. Now I get the error (in both cases)

Doesn't mention which file was not found. It would be good to put that in the log.

Here's the full output of the manual patch.

No work/init.rc. Using default BOOTCLASSPATH.
Decompiling LGEmail.odex ...
Applying patch ...
Unable to apply patch. File not found.
0 apk(s) patched.
Done.

Should I be pulling in init.rc as well in the work directory?

Edit: I pulled init.rc (first to /sdcard since adb pull doesn't work) into the work directory. But that didn't help any except getting rid of the first line in the output
[Galaxy S II Themes and Apps] cschmitt:
+1, no joy on CM11 with ART, email app FCs. Works fine with dalvik. Will grab a logcat.
[Galaxy S II Themes and Apps] dkrants:
Did't work on rooted Moto X ATT

Didn't work on rooted stock ATT Moto X v 4.2.2 (w/camera update)

Patch runs without an error but when I re-add Exchange account it still requires me to enable PIN.

Model: Moto X XT1058, build 13.9.0Q2.X-116-X-17-54, android 4.2.2 (API Level 15)

I've tried v3.3, v3.4 and v4.0 with the same result.

Did anyone have the same experience?
[Galaxy S II Themes and Apps] xpanmanx:
v3.4 seems to have worked on my AT&T Galaxy S 4 running 4.3 aka MK2.

ETA: Nope, while I can connect to one of my two Exchange organizations, I cannot connect to the other. During account setup, the client returns, "Authentication failed." I've tried it a dozen times over the last few hours, double-checking and verifying settings against those on my S 2 and iPad Mini (they're both working). I'm not sure what's going on.....

ETA, after waiting a half-day: It's working. I must've hit my account lockout limit, and it freed up during the downtime. Thanks again.
[Galaxy S II Themes and Apps] rustyx3:
A logcat would be great, thanks
[Galaxy S II Themes and Apps] rustyx3:
2 theories:

* Either the dalvik-cache isn't refreshed properly (BTW why is it looking at /cache/dalvik-cache/system@app@Email.apk@classes.dex and not at /system/app/Email.apk@classes.dex?).

* Or it is checking the signature of classes.dex in the manifest (however dalvik never did before, and I'd expect an entry in the logs about this which I couldn't find)

So probably it's 1 (however would be interesting to check the logs during the patch application - maybe classes.dex is rejected then?). Can you compare /cache/dalvik-cache/system@app@Email.apk with /system/app/Email.apk?

And does /cache/dalvik-cache/system@app@Email.apk@classes.dex exist?
[Galaxy S II Themes and Apps] rustyx3:
Also try to re-odex it back:

> adb shell
$ su
# dexopt-wrapper /system/app/Email.apk /system/app/Email.odex
[Galaxy S II Themes and Apps] cschmitt:
Odexed the entire ROM, boots fine in dalvik but email still FCs upon switching to ART. I'll try resigning the apk, see if that helps.
[Galaxy S II Themes and Apps] rustyx3:
Pls check logcat during patch application (when the new apk is copied to /system/app) and immediately after during reboot (especially the "optimizing performance" run).
[Galaxy S II Themes and Apps] cschmitt:
I'm using patch-manual, then building a flashable zip and installing in recovery. There are no errors during the patch operation. Zip attached.
[Galaxy S II Themes and Apps] ipprof:
Cschmidt: I've been using your earlier zip file for months with generality great results. How does this differ from that? Would you suggest using this matter zip instead of your earlier one? Thanks.
[Galaxy S II Themes and Apps] cschmitt:
It's from cm11 12.14 nightly, as the filename suggests. ☺
[Galaxy S II Themes and Apps] os2baba:
Anything I can do to find out which file it couldn't find? This is happening while running the jar file on the PC. Is there some debug option I can use?
[Galaxy S II Themes and Apps] ipprof:
Yes I can see that but I was wondering if 4.4 roms can use it since I thought 11 was close to 4.4. No?
[Galaxy S II Themes and Apps] cschmitt:
Should be able to use it, CM11 is 4.4.2.
[Galaxy S II Themes and Apps] roopesh:
I used it on my GPE 4.4 without any issues.
[Galaxy S II Themes and Apps] darkmanlv:
cm-11.0-Email-nosec-20131214-signed - this helped me to fix exchange sync problem on i9505 @ echoe kitkat v2.1 :) now my mail application works perfect!! thanks!
[Galaxy S II Themes and Apps] bubbanc:
No issues on Nexus 7 4.4.2

Using 4.0 on Mac (Mountain Lion). Installed this before adding my corporate Exchange account. I was prompted that I'd need a passcode but never had to set one :)

$ ./apply-patch.sh
Waiting for USB connection...
Waiting for device...
Device connected: 09017264
Checking device...
Model: Nexus 7, build KOT49H, android 4.4.2 (API Level 15)
/system mounted on /dev/block/platform/msm_sdcc.1/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 ...
Building EmailGoogle.patched.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.patched.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 might move to the end of the application list.

Thanks for this :good:
[Galaxy S II Themes and Apps] kwhit:
Just patched my email using version 3.4 all appears ok except that if I try and open the email from the notification pull down it force closes. Any one else have this issue an know how to fix?
[Galaxy S II Themes and Apps] kwhit:
Fixed! Good old factory reset
[Galaxy S II Themes and Apps] cschmitt:
cm-11.0-Email-nosec-20131225.zip

- built from CM source (no smali edits.)

- ART compatible.

- exchange security policy disabled.

- no Email device administrator.

- remote wipe disabled.

Installation: delete exchange account, flash in recovery, reboot and setup exchange account.

Note: Exchange services will prompt to apply security policy (click OK), but no device administrator will be set. Exchange services may FC once or twice following account setup, but after that will run just fine.

Merry Christmas!
[Galaxy S II Themes and Apps] clutrz:
Cheers!!

Hi there,

Just wanted to say a massive thanks for this patch! I had this running on my Xperia Z1 with the older 4.2 firmware which was a breeze. Just upgraded the phone to 4.3 and had to do a lot of learning to get this working (I had to go and learn how to create my own update.zip to be able to place the manually patched files back on to the phone and delete the old .odex files as no write access to /system unless in recovery). Bloody hell what a mission but it's now working flawlessly thank you very much!!!
[Galaxy S II Themes and Apps] phone_:
Samsung galaxy S3 stock room (4.3) rooted version I747

Hello,

I look on the work directory I foud SecExchange.patched.apk and SecEmail_J.patched.apk

So what i did I connect with adb shell I did backup original file to my pc with those command

adb shell

su

# at this point you may need to tap "grant" on your device

mount -o remount,rw /system

adb pull /system/app/SecExchange.apk

adb pull /system/app/SecExchange.odex

adb pull /system/app/SecEmail_J.apk

adb pull /system/app/SecEmail_J.odex

i did delete the folowing file

I did delete the folowing file

rm /system/app/SecExchange.apk

rm /system/app/SecExchange.odex

rm /system/app/SecEmail_J.apk

rm /system/app/SecEmail_J.odex

I copy the .patched file to my sd card and also with fowlowing file SecEmail_J.odex SecExchange.odex

I rename the .patched to original name

I make sure under security check allow install apps from source other than the play store

I copy it to this location /system/app/

cp /storage/extSdCard/SecExchange.apk /system/app/

cp /storage/extSdCard/SecExchange.odex /system/app/

cp /storage/extSdCard/SecEmail_J.apk /system/app/

cp /storage/extSdCard/ SecEmail_J.odex /system/app/

I did change the permission those one

chmod 644 /system/app/SecExchange.apk

chmod 644 /system/app/SecExchange.odex

chmod 644 /system/app/SecEmail_J.odex

chmod 644 /system/app/SecEmail_J.odex

I shutdown the phone and power up again I saw application update at startup

I configure My account and is not working the enforce policy from my exchange are still there

Any one with galaxy S3 android 4.3 have done this modification with succes if yes you could please send you apk file or help me

thanks

seb
[Galaxy S II Themes and Apps] sephstyler:
Hi guys,

OP, long time user of your mod, and thanks for all you've contributed.

I've currently got a Sony Z1. Just updated to 4.3 (stock, rooted and bootloader unlocked, but stock ROM).

V 3.3 of the patch wouldnt work, (i used to use this one), and neither did 4.0, but 3.4 did.
[Galaxy S II Themes and Apps] rmedure:
Patch seemed to not work ...

Phone is a brand new Verizon Galaxy S4, MK2, rooted, +safestrap, stock ROM

Attempted patch with email-policy-patch-4.0

I ran into the same issues as others here with ADB not working at the point where it would push the patched APKs to the phone.

So I manually copied them over out of the work directory (SecEmail_J.patched.apk and SecExchange.patched.apk).

Renamed the old .apk's and .odex's (added .bak to each) and removed the .patched in the new file filenames.

Rebooted.

When I created an exchange account, the mail app still created the admin email user and applied all exchange security policies.

So then I moved old .apk's and .odex's (which had .bak extensions in the filenames) out of the system/app directory, rebooted, and then patch began working properly.

Cheers!
[Galaxy S II Themes and Apps] daniello8:
Hmm .. never failed on me before .. but this time ..

d:\_android\email-policy-patch-4.0>d:\_android\email-policy-patch-4.0\patch-manual.cmd d:\_android\email-policy-patch-4.0\work 16 SecEmail_J.apk SecExchange.apk

No d:\_android\email-policy-patch-4.0\work/init.rc. Using default BOOTCLASSPATH.

Decompiling SecEmail_J.apk ...

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at jpatch.emailPolicy.Run.runIsolated(Run.java:929)

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

at jpatch.emailPolicy.Run.main(Run.java:813)

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0

at java.lang.String.charAt(Unknown Source)

at org.jf.baksmali.main.main(main.java:186)

... 7 more

Debug log written to debug.log ..

No d:\_android\email-policy-patch-4.0\work/init.rc. Using default BOOTCLASSPATH.

SecEmail_J.apk extra libs: com.google.android.maps.jar, touchwiz.jar, sec_feature.jar, sechardware.jar, com.sec.android.app.multiwindow.jar

Decompiling SecEmail_J.apk ...

Running org.jf.baksmali.main : -d d:\_android\email-policy-patch-4.0\work -c -I -x -a16 -o d:\_android\email-policy-patch-4.0\work/out-SecEmail_J.apk/ d:\_android\email-policy-patch-4.0\work/SecEmail_J.apk

Anyone?

edit: I prefer the offline method (pulling the files and patching on the computer) .. this is the one that fails .. the online method with 4.0 ran through without an error.
[Galaxy S II Themes and Apps] rustyx3:
Try version 4.1, it should solve this issue.
[Galaxy S II Themes and Apps] rustyx3:
You should get the patch version 4.1 and:

* either pull /init.rc from the device to the work directory

* or dump device environment to a file called "env". For example like this: "adb shell set >env"

This is needed so that the patch can detect the proper boot class path for decompiling.
[Galaxy S II Themes and Apps] blulite:
Any plans to include the features in this update into the original "[HACK] Removing keyguard and other security policy restrictions from Email apk" patch?
[Galaxy S II Themes and Apps] aldcu:
Latest version (4.1) does not work with Windows??

Latest version (4.1) does not seem to be working on a Win 7 64 bit. this the error I'm getting.

java.io.IOException: Cannot run program "adb" (in directory "work"): CreateProcess error=2, The system cannot find the file specified

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at jpatch.emailPolicy.Run.runCommand(Run.java:93)

at jpatch.emailPolicy.Run.createWorkDir(Run.java:146)

at jpatch.emailPolicy.Run.main(Run.java:675)

Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.<init>(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

... 5 more

Debug log written to debug.log

Press any key to continue . . .

If I run it as Administrator I get the following error:

Error: Unable to access jarfile lib/email-policy-patch.jar

Press any key to continue . . .

I Also tried using version (4.0) and I'm having the timeout errors so I'm AOL at this point.
[Galaxy S II Themes and Apps] greatg:
I'm currently setup on my network with all of the policies in place. Should I do a factory reset before applying this patch?
[Galaxy S II Themes and Apps] rmedure:
Unfortunately, Exchange services has stopped.

Phone is a brand new Verizon Galaxy S4, MK2, rooted, +safestrap, stock ROM

Patched with email-policy-patch-4.0

Exchange account is set to push. Just about everytime a new SMS comes in, the phone freezes up for about 2 seconds and then the warning "Unfortunately, Exchange services has stopped." appears. It's very annoying. Changing the exchange account from push to poll every 5 mins makes it not quite as bad.

Does anybody know if this related to patch or something else? Certainly the stock system doesn't normally do this?

Cheers!
[Galaxy S II Themes and Apps] jsauder2:
No need for that. Just remove the email account if you've set one up and wipe data for the email app and exchange app before applying the patch.

Sent from my Nexus 4
[Galaxy S II Themes and Apps] twosix:
Hi, I'd like to know if this will work on Note 3. Thanks.
[Galaxy S II Themes and Apps] kwhit:
Yes it will. It worked on mine
[Galaxy S II Themes and Apps] chopin_k:
Works on mine too. Luck!
[Galaxy S II Themes and Apps] greatg:
Thanks. I did a factory reset and ran the patch. Says the patch was applied. When I run through the setup it just stops at checking incoming server settings and goes no further?
[Galaxy S II Themes and Apps] rustyx3:
Patch version 4.2 which was just released should solve this issue.
[Galaxy S II Themes and Apps] greatg:
Big THANKS for the work! I'm wondering if anyone has had any success running this patch on an i317M with Ditto Note 3 ROM installed? I tried previous versions of the patch that appeared to complete, but when I went to set up exchange, still had permissions etc...
[Galaxy S II Themes and Apps] os2baba:
rustamabd, do you suppose you could add some context to the "File not found" message? So I could see how to fix this? Thanks.
[Galaxy S II Themes and Apps] rustyx3:
One of these class files must be present in the Email app:

com/android/emailcommon/provider/Policy

com/android/email/SecurityPolicy

com/android/exchange/adapter/ProvisionParser

"File not found" means none of these could be found, so the script quits because there is nothing else it can do.

The LG G2 Email app is probably not using the AOSP policy implementation and as such this patch is incompatible with it.
[Galaxy S II Themes and Apps] os2baba:
I looked at the source code and I think the file it doesn't find is (from the PatchPolicy.java file) is "com/android/emailcommon/provider/Policy.smali"

On the LG, there is no Policy.smali file. I think the equivalent file is the com/lge/email/policy/eas/SecurityPolicy file. I have attached the SecurityPolicy.smali (I had to add an extension of txt to attach it). I have also uploaded the policy directory. If anyone knows what needs to be changed, I'd love to make those changes and try it out.
[Galaxy S II Themes and Apps] cschmitt:
With the AOSP implementation, security policy, device administrator, and remote wipe can all be disabled within the SecurityPolicy alone without modifying any other classes. The following edits will cause AccountSecurity.tryAdvanceSecurity() to fall through during account creation without creating a Device Administrator entry or applying the security policy:

public class SecurityPolicy {
public boolean isActive(Policy policy) {
return true; // always active!
}

public boolean isActiveAdmin() {
return true; // always active!
}

public int getInactiveReasons(Policy policy) {
return 0; // no inactive reasons
}

public void remoteWipe() {
// disable remote wipe
LogUtils.d(Logging.LOG_TAG, "Remote wipe is disabled.");
}

public void setAccountPolicy(long accountId, Policy policy, String securityKey) {
// fixup policy to non-enforced values
policy.mPasswordMode = Policy.PASSWORD_MODE_NONE;
policy.mPasswordMinLength = 0;
policy.mPasswordMaxFails = 0;
policy.mPasswordHistory = 0;
policy.mPasswordExpirationDays = 0;
policy.mPasswordComplexChars = 0;
policy.mMaxScreenLockTime = 0;
policy.mRequireRemoteWipe = false;
policy.mRequireEncryption = false;
policy.mRequireEncryptionExternal = false;
policy.mRequireManualSyncWhenRoaming = false;
policy.mMaxAttachmentSize = 0;
policy.mMaxTextTruncationSize = 0;
policy.mMaxHtmlTruncationSize = 0;
policy.mMaxEmailLookback = 0;
policy.mMaxCalendarLookback = 0;
policy.mPasswordRecoveryEnabled = true;
policy.mDontAllowAttachments = false;
policy.mDontAllowCamera = false;
policy.mDontAllowHtml = false;

Account account = Account.restoreAccountWithId(mContext, accountId);
Policy oldPolicy = null;
if (account.mPolicyKey > 0) {
oldPolicy = Policy.restorePolicyWithId(mContext, account.mPolicyKey);
}
...
}
}

I've tested this on CM11 building from source and it works great. Shouldn't be too difficult to convert this to the equivalent smali edits.
[Galaxy S II Themes and Apps] rustyx3:
Yes that's what the patch does already. But it depends on Android version. On some older versions additional edits are needed, and on even older ones this class doesn't even exist.
[Galaxy S II Themes and Apps] rustyx3:
LG is not supported. com/lge/email/policy/eas/SecurityPolicy looks equivalent but is a custom LG implementation, it is not based on AOSP code.
[Galaxy S II Themes and Apps] os2baba:
Thanks. That gives me a place to start. The smali code is all greek to me. But I'll start with the source code and generate the apk and decompile it to get to the smali. That will be a lot easier. There are a lot more methods in LG's class though. Hopefully, I can figure it out.
[Galaxy S II Themes and Apps] cschmitt:
I only listed the methods that need to be modified in SecurityPolicy, and the code to be added at the beginning of each method.
[Galaxy S II Themes and Apps] nessant:
Samsung galaxy S4 I9505XXUEMK8.

I used script 4.2, here the error message:

Cleaning up ...

Waiting for USB connection...

Checking device...

Model: GT-I9505, build JSS15J.I9505XXUEMK8, android 4.3 (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) ...

Pulling libs ...

Decompiling SecEmail_J.odex ...

java.lang.UnsupportedClassVersionError: org/jf/baksmali/main : Unsupported major.minor version 51.0

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClassCond(Unknown Source)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$000(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at jpatch.emailPolicy.Run.runIsolated(Run.java:921)

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

at jpatch.emailPolicy.Run.main(Run.java:700)

Debug log written to debug.log

it seems this version of email apk is not yet supported.

thanks
[Galaxy S II Themes and Apps] rustyx3:
You need to get Java 7 and make sure it's the default Java on your system.

"java -version" should show "Java 7".
[Galaxy S II Themes and Apps] nessant:
Thank you very much!!! After installation of java 7, tool worked.

Inviato dal mio GT-I9505 utilizzando Tapatalk
[Galaxy S II Themes and Apps] rmedure:
RE: Unfortunately, Exchange services has stopped.

I installed an 3rd party SMS app and this issue went away. Does anybody know why this error occurs with the stock SMS app?
[Galaxy S II Themes and Apps] extremefun:
Works perfectly - HUAWEI P6-U06 with patch version 4.0

Thanks for guide.

worked perfectly...on HUAWEI P6.

Cleaning up ...

Waiting for USB connection...

Waiting for device...

Device connected: [MENTION=522570 [MENTION=1065870 [MENTION=1879310]@@@[/MENTION][/MENTION]@@[/MENTION [MENTION=1065870 [MENTION=1879310]@@@[/MENTION][/MENTION]

Checking device...

Model: HUAWEI P6-U06, build P6-U06V100R001C00B125, android 4.2.2 (API Level 15)

/system mounted on /dev/block/platform/hi_mci.1/by-name/system, 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.patched.apk ...

Decompiling Exchange2.apk ...

Applying patch ...

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

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

Recompiling ...

Building Exchange2.patched.apk ...

Updating device ...

Rebooting device ...

Done.

Press any key to continue . . .