[Galaxy S II Themes and Apps] mcfisch:
Working with new Lollipop Gmail 5.0 and AOSP Exchange 5.0 (on Xperia Z)

I got it working today with the new Lollipop Gmail 5.0 and AOSP Exchange 5.0.

I have the very first Lollipop non-Nexus ROM on my Xperia Z and after getting root the first thing I tried was this hack which I can't live without - I wanna decide on my own how complex my device should be locked.

However, the the patch in version 4.3 works flawlessly if one knows where to find the APKs.

Note: I've tested this just on my Xperia Z. I assume it will work on other Lollipop systems as well, but no promises...

So here is the content from my console window when patching the files. Please also note that I just did the "remote patch", could not get it working with the files copied locally and the patch applied manually.

AOSP Email 5.0

The trick is to submit the (relative) sub-directory paths where the single system APKs are located, e.g. /system/app/Email/Email.apk.

C:\Users\mcfisch\Android\email-policy-patch-4.3> apply-patch.cmd
Cleaning up ...
Found adb on PATH.
Waiting for USB connection...
Checking device...
Model: Full Android on C6603, build full_c6603-userdebug 5.0 LRX21M eng.thomas.20141109.175337 test-keys, android 5.0 (API Level 15)
/system mounted on /dev/block/platform/msm_sdcc.1/by-name/system, mode ro
checking root access. root uid: 0, secure: no, busybox: yes
Can't detect boot class path. Using defaults...
Pulling app(s) ...
Can't find Email app. Enter the name of your Email apk or press <Enter> to exit: Email/Email.apk
Can't find Exchange app. Enter the name of your Exchange apk or press <Enter> to continue: Exchange2/Exchange2.apk
Pulling libs ...
Decompiling Email/Email.apk ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Recompiling ...
Building Email/Email.patched.apk ...
Decompiling Exchange2/Exchange2.apk ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z
Recompiling ...
Building Exchange2/Exchange2.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 icon will move towards the end of the application list.

Drücken Sie eine beliebige Taste . . .

Gmail 5.0 + GmailExchange 5.0

With Gmail 5.0 Google introduced the ability to handle Microsoft Exchange accounts within the Gmail app. Therefore they deliver an additional Exchange connector for Gmail, which is separated from the AOSP Exchange2 service. Here we additionally now need to know the name of these new APKs, find them e.g. by typing ls -l /system/app in an ADB shell.

PrebuiltGmail/PrebuiltGmail.apk

PrebuiltExchange3Google/PrebuiltExchange3Google.apk

C:\Users\mcfisch\Android\email-policy-patch-4.3> apply-patch.cmd
Cleaning up ...
Found adb on PATH.
Waiting for USB connection...
Checking device...
Model: Full Android on C6603, build full_c6603-userdebug 5.0 LRX21M eng.thomas.20141109.175337 test-keys, android 5.0 (API Level 15)
/system mounted on /dev/block/platform/msm_sdcc.1/by-name/system, mode ro
checking root access. root uid: 0, secure: no, busybox: yes
Can't detect boot class path. Using defaults...
Pulling app(s) ...
Can't find Email app. Enter the name of your Email apk or press <Enter> to exit: PrebuiltGmail/PrebuiltGmail.apk
Can't find Exchange app. Enter the name of your Exchange apk or press <Enter> to continue: PrebuiltExchange3Google/PrebuiltExchange3Google.apk
Pulling libs ...
Decompiling PrebuiltGmail/PrebuiltGmail.apk ...
Applying patch ...
Unable to apply patch. Code to patch not found.
Decompiling PrebuiltExchange3Google/PrebuiltExchange3Google.apk ...
Applying patch ...
Patching com/android/emailcommon/provider/Policy.normalize()V
Patching com/android/exchange/adapter/ProvisionParser.hasSupportablePolicySet()Z
Recompiling ...
Building PrebuiltExchange3Google/PrebuiltExchange3Google.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 icon will move towards the end of the application list.

Drücken Sie eine beliebige Taste . . .

Ignore the warning about not being able to patch Gmail itself - it isn't necessary. Just the patch needs it when remotely applied.

I've set up both patched applications with my company related Exchange account for testing and both are working flawlessly. :D

I'll stick with the Gmail app for now just to see how it goes, but may recreate the account in the AOSP Email app later if not satisfying.

Many thanks to the OP for making this possible! :)