yashsingh1/xdaforums huggingface dataset:
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Yes, a standard behavior of the Email app. I could bypass that too if you need. It's a shame that both Calendar and Email period of sync cannot be setup properly (whatever the user might desire)
[HD2 Android Q&A, Help & Troubleshooting and Genera] gpietron:
Great news, thank you very much!!!

Will definitely test this evening :D.

Yes, ability to sync all mail would be nice, too, if it's not a problem for you :-).
[HD2 Android Q&A, Help & Troubleshooting and Genera] kot7k:
This is great, good job.

I experimented the same issue and noone seemed to believe me. Well done.

EDIT: btw im a galaxy s cyanogen mod user, maybe you could post this in a more general forum
[HD2 Android Q&A, Help & Troubleshooting and Genera] rhainman:
I'm not knowledgeable about these things, but how would someone go about getting this fix implemented into CM7? I'm also a Galaxy S CM7 user who has suffered from this issue and I've had to resort to using Moxier Mail as a remedy. If I install this fixed .apk, will it just get overwritten once I flash the next CM7 nightly? It would be great if it could be integrated into CM7.
[HD2 Android Q&A, Help & Troubleshooting and Genera] kasper_h:
Works very well on Samsung GalaxyS-CM7, thanks a lot!

One question though, the maximum sync period is one month, whereas in the CM7 client it can be set to unlimited (for email at least).

I also made a zip-file to flash this new email.apk. Made for galaxy S CM7, but I guess it should work on any CM7...
[HD2 Android Q&A, Help & Troubleshooting and Genera] gpietron:
3h ago exchanged Email.apk and so far good. Switching to Flight produces 2mA drain. Synchronizing corporate mail and Contacts/Calendar works normally with no issues so far :D.
[HD2 Android Q&A, Help & Troubleshooting and Genera] Katana1234:
niiiiiceeeeee!!!!

but is there any way to get the app skaled when changing the devices-density???

it's been workin' with this one:

http://xdaforums.com/showthread.php?t=775007

but your version keeps beein small while changin :(

thx in advance...
[HD2 Android Q&A, Help & Troubleshooting and Genera] kobik77:
Hi jakubklos,

I'm using airplain mode every night when I go to sleep and being aware of this annoying bug I usually kills the EMail app and stops all it syncs.

From now I can go to sleep knowing I won't be losing 10% or more of my battery while sleeping.

You're great man!

BTW, Beats me what takes Google so much time to fix it themselves.
[HD2 Android Q&A, Help & Troubleshooting and Genera] frumpy:
genius, thanks jakubklos
[HD2 Android Q&A, Help & Troubleshooting and Genera] tobiascrystal:
Is this the same email app for sense roms or is it only ASOP that is effected by this issue?

Also, Way to go on showing google up!
[HD2 Android Q&A, Help & Troubleshooting and Genera] mootmetal:
cant use it ..i get force close all the time !!!!!
[HD2 Android Q&A, Help & Troubleshooting and Genera] rhainman:
I got that too after installing it, but then I fixed the permissions using Rom Manager and rebooted and it worked.
[HD2 Android Q&A, Help & Troubleshooting and Genera] Revhead:
If I am using the Gmail app, can't I just uninstall the system app and not worry about installing the new one?
[HD2 Android Q&A, Help & Troubleshooting and Genera] kobik77:
Yes, you can do that.

Just to update, left the phone over night on flight mode and there was no battery drain.

Great work!
[HD2 Android Q&A, Help & Troubleshooting and Genera] syl0n:
Thanks a lot for this!
[HD2 Android Q&A, Help & Troubleshooting and Genera] reidar.ostrem:
Any chance of patching til version to disable security features? :-)
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Submitted a ticket to CM7

Originally I thought the only way for the fix to get to CM7 was from Google but you convinced me. I have submitted a new ticket with the link to this topic and also the google ticket.

http://code.google.com/p/cyanogenmod/issues/detail?id=4281

Hope they will incorporate the fix soon and we can all enjoy our beloved CM7.
[HD2 Android Q&A, Help & Troubleshooting and Genera] Denkov:
What security features you want to be disabled?
[HD2 Android Q&A, Help & Troubleshooting and Genera] banesi:
Bypassing MS Exchange lock feature, something already done HERE but unfortunately using old Email.apk.
[HD2 Android Q&A, Help & Troubleshooting and Genera] kot7k:
Unfortunately the bug is set as invalid now, they answered you this:

Comment 1 by project member psychoi3oy, Today (2 hours ago)

see 'howto use gerrit' on the cm wiki for how to submit patches to CM
[HD2 Android Q&A, Help & Troubleshooting and Genera] Denkov:
This is big risk!
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Yes, I have noticed. I have to go through the Gerrit process. Working on it but it will take some time.
[HD2 Android Q&A, Help & Troubleshooting and Genera] toddmworth:
Jakub, I really appreciate the efforts you have made, fighting annoying red tape processes and seemingly uncaring google staff for the benefit of us all.... So I feel a little selfish to ask this of you, but... Would you mind making an apk which allows us to sync all email, not with the one month limit? Perhaps I should pay a bounty, if you'd like to name your price.
[HD2 Android Q&A, Help & Troubleshooting and Genera] BigsyBiggins:
Please can someone patch the security on this? I'd be very grateful.
[HD2 Android Q&A, Help & Troubleshooting and Genera] kot7k:
Once he posts his patch on the git, i guess everyone could see it and implement it for any mods for email, so be patient and you will be happy
[HD2 Android Q&A, Help & Troubleshooting and Genera] Denkov:
What is your problem with the security? I have no problem.:)
[HD2 Android Q&A, Help & Troubleshooting and Genera] vviskari:
Thank you Jakub!

Finally the serious battery drain issue with Exchange sync is fixed. At last I can go to bed without worrying the phone dies and won't wake me up in the morning. I've been using this patched email app for a few days now with zero problems!

ZTE Blade and Android 2.3.4.

Installation:

-Rooted phone.

-Removed email app with TI backup

-Reboot.

-Installed the new email app normally from filemanager.
[HD2 Android Q&A, Help & Troubleshooting and Genera] BigsyBiggins:
I don't want my company to have the ability to wipe my phone at their will...that and the in forced pin code is a pain in the arse, I like my pattern unlock.
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
I'm hesitant to patch in the code change after the following response from Google's Marc Blank:

Firstly, can you post the code change you made? Then let's figure out what needs to be placed in the done() method as Marc Blank specified. Here is what I think should be placed in there:

EasSyncService.java

if (sServiceThread != Thread.currentThread())
return;
[HD2 Android Q&A, Help & Troubleshooting and Genera] gpietron:
Hm, I exchanged my email.apk with this one on Thursday and since then no side effects - also no drain while data disabled (at night) or in flight mode.

very happy now :D

but this is just to add more info, I am no specialist ...
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
I patched my Email app with my interpretation of the code change and haven't had any issues either. But I haven't patched it in officially and released it yet in my app because I want to collaborate with jakubklos to see how he changed the code and make sure that's the best change to make for the problem. Plus, the comment that Marc made is technically valid and needs to be addressed or what will happen is the following:

Thread 1: sync starts on a folder

Thread 2: sync starts on a folder

Thread 1: failure syncing, call SyncManager.done(this). It's possible it could kill the SyncManager thread started by Thread 2 rather than Thread 1 since we're not checking Thread ids. This would cause a looping behavior in the event of a failure in the sync process
[HD2 Android Q&A, Help & Troubleshooting and Genera] gpietron:
thanked you for taking effort to explain, sounds very reasonable.

BTW, was testing your app looking for a solution to this issue, very nice indeed - but was no remedy for me :-)

and I did not like Touchdown, worked but too complicated - sorry for off topic ...
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
If by remedy you mean fixed the wake lock issue then ya I have the same bug that all AOSP Android email clients have since my app is based on that open source code. But with this revelation in this thread I'm looking forward to patching my app so it no longer has the wake lock bug as well.

By the way, to the XDA member who created this thread. Even though my app is a paid app I still continue to contribute code that I add in my app to the open source community. So I give back stuff that I know people no where could possibly figure out. My email app I released with no exchange security along with the source code for it. Or the full source code I released with HTML for Exchange 2003 implemented.
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Finally, I managed to install Git and configure Gerrit and all. I have uploaded the change to Gerrit a few seconds ago.

http://review.cyanogenmod.com/#change,7905

Lets wait

---------- Post added at 08:33 AM ---------- Previous post was at 08:29 AM ----------

Sorry I did not get back to you shafty. I thought you and Marc figured this out. Initially, I made this change

http://review.cyanogenmod.com/#change,7905

and tested it and it worked fine. Then Marc told me about the SyncManager.done() and that's the one I have been using since and also the email.apk I published here. Marc then contacted me and told me about possible misbehavior.

So I decided to put back the original fix which basically just releases the wake lock as it was originally acquired. So I am sure it does not have any other side effects and that's also why I uploaded this fix to Gerrit.

You can contact me by email if you want.
[HD2 Android Q&A, Help & Troubleshooting and Genera] kasper_h:
Great to see you put this up on git!

So If I understand correctly, the only thing done to solve this problem was to add

SyncManager.runAsleep(mMailboxId, 0);

to

EasSyncService.java

Another question, in your opening post, you also mention the time limits for Syncing. In which files do you set these time limits for synchronizing calendar/email (default 1 month, I like to set it to sync all)?
[HD2 Android Q&A, Help & Troubleshooting and Genera] reidar.ostrem:
Shafty023,

I am pleased to hear that the changes will be incorporated into your app. As i understand this is a fix for the wakelock that appears when the email apps don't have connectivity. There are also the problem that causes a wakelock every time the calendar is updated/synced.. This happens if you update the calendar, go from mobile data to wifi and vice versa.

Will this fix also correct this failure ?
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
Yes the calendar is considered a mailbox/folder and falls under this part of the sync process which obtains/releases the wakelocks

---------- Post added at 08:53 AM ---------- Previous post was at 08:46 AM ----------

Ya I haven't heard back from Marc yet but I talk with him off/on so I'm sure he's busy. Thanks for the patch submission. I agree it seems pretty harmless on the surface to do and I don't see that it could cause any issues. I'll ping you on email if I see any changes that need to be made. Thanks man!
[HD2 Android Q&A, Help & Troubleshooting and Genera] claimui:
I can't seem to find the option to set a background color when reading emails. In my stock app, I could display emails with a black background. Is that option still in this version? Thanks very much for the bug fix.

EDIT: Sorry, I think that option was specific to the Samsung version of Email.apk, so it wouldn't be here. Thanks though.
[HD2 Android Q&A, Help & Troubleshooting and Genera] kot7k:
I dont get this, it seems like a "world conspiracy" to dont get this bug fixed, now your code change has a "-1" code review:

Diogo Ferreira	-1	I would prefer that you didn't submit this

I really dont get the menssage though, hope its an standard menssage associated to the "-1" cause if not, it doesnt have any sense.

EDIT: ah, ok he made a comment then explaining a little more, but i guess he could have made it before reviewing a -1. If its true what you explained after his comment, then the -1 doesnt make sense now.
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
Make sure you reboot your phone as there could be some sync processes from the old version lost in thread-land.
[HD2 Android Q&A, Help & Troubleshooting and Genera] tytnguy:
Is this update applicable only for specific ROM or any phone/ROM with gingerbread?

I have samsung s2 and have following ROM. I have a similar issue so can I apply this email update?

My ROM http://xdaforums.com/showthread.php?t=1095274

Thanks
[HD2 Android Q&A, Help & Troubleshooting and Genera] pillmonkey:
help, i might be being a bit thick but i've followed the instructions and all i get is application not installed. I'm not sure i've removed the old email.apk correctly?

I've copied email.apk file in system\app then saved it in sdroot as oldemail.apk ( too keep a copy) deleted orginal in system\app copied the new email.apk to root of sd card, rebooted phone then ran new email.apk to get "application not installed"

Any ideas?? I take it i've not removed the old version correctly?
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Seems we are finally getting somewhere. They approved the bug and will be merged.

http://review.cyanogenmod.com/#change,7905

Btw. I reported this bug to Shafty about 3 months ago and I even paid for the app :). Maybe he remembers. The bug was not analyzed or researched though (just the symptoms).

Anyway, now I could go back to EE when it has this fixed too.

---------- Post added at 02:51 PM ---------- Previous post was at 02:46 PM ----------

Yes, exactly.

As for the other change. It is the same file actually. I was thinking about adding a new option in settings for Calendar history but wanted to see the CM7 Gerrit process really works first.

Anyway, just look for

} else if (className.equals("Calendar")) {

// TODO Force all for calendar until we can set this!

s.data(Tags.SYNC_FILTER_TYPE, Eas.FILTER_

and replace with

} else if (className.equals("Calendar")) {

// TODO Force all for calendar until we can set this!

s.data(Tags.SYNC_FILTER_TYPE, Eas.FILTER_ALL);

}

I was thinking of using the

private String getEmailFilter()

so it would be actually controlled by the Email history setting but I could see someone might not like it. Even though I would prefer the same setting for both Email and Calendar.

Thoughts?
[HD2 Android Q&A, Help & Troubleshooting and Genera] toddmworth:
So close..........
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
Ya for the past 7 months actually I've been working two jobs (EE and my full time job) so it was impossible to tackle these large scale issues given I was working almost 80+ hours a week. BUT, EE is now my full time job so I have all the time in the world :)

Oh, and EE has the fix in the latest market version so get it while its hot!

---------- Post added at 10:10 AM ---------- Previous post was at 10:05 AM ----------

You can't do that. The Email sync window and the calendar sync window do not share the same "allowed" values. For instance, if you tried using an email sync window of 3 days and use that same value for calendar sync window the sync process would fail. There are specific values that an Exchange server allows for the calendar sync window and they are not 1:1 with the email sync window values. Just fyi

Here is what I use for calendar sync window: all, 2 weeks, 1 month, 3 months, 6 months. These have to translate to numbers when you actually do the sync with an Exchange server. The actual numbers are: 0, 4, 5, 6, 7
[HD2 Android Q&A, Help & Troubleshooting and Genera] kot7k:
Like i said, it seems like a conspiracy cause if you look in dependicies the patch doesnt have anything there xD

EDIT: Yay, aproved finally, this time for sure :)
[HD2 Android Q&A, Help & Troubleshooting and Genera] toddmworth:
Sold. Wish I had come across your app when I was looking at k9,droidmail,etc... I didn't like any of them and stayed with stock. I'm looking forward to stock++ ;)
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Finally! :)

I have checked and the change is included in the official Git for CyanogenMod now.

For some reason the CM7 nightlies are not build anymore (8/31 or 9/1 are the last for any device I have checked). Have to wait then.

Btw. Shafty is right about the Calendar EAS filter values. The main reason I wanted to fix the EAS (Exchange ActiveSync protocol) issue was that the company I work for (IceWarp) has their own EAS implementation and a GroupWare sever. I would be greatful if Shafty could mention it in the app description on the market (where he mentions Zimbra...).

http://www.icewarp.com/ (IceWarp Server)

I was the one to write the GroupWare part (not the EAS itself)

I also hope Shafty realizes that EAS needs to be licensed from Microsoft (we at IceWarp have to pay a license fee for each user who uses any EAS device to connect to our IceWarp server). All Android vendors do so to and it is big money (in fact MS makes more from the licensing fees than from their WindowsPhone). I would not deal with this unless MS comes to you though. You can always increase the price then and pay them their fees.
[HD2 Android Q&A, Help & Troubleshooting and Genera] tytnguy:
Anyone going to answer me please..?
[HD2 Android Q&A, Help & Troubleshooting and Genera] reidar.ostrem:
:) Well, the phone has been rebooted every night since this post ...
[HD2 Android Q&A, Help & Troubleshooting and Genera] toddmworth:
That's because kernel.org is down due to hacking. The git repo is being moved and rumour has it that nightlies will be back soon. (Tonight?)

FYI Shafty, it also works with Novell GroupWise.
[HD2 Android Q&A, Help & Troubleshooting and Genera] shafty023:
So are you saying my app works with IceWarp server via the Activesync protocol? If so then I'll definitely add it to my description :)
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
Any I would say

---------- Post added at 05:21 AM ---------- Previous post was at 05:20 AM ----------

Yes, absolutely. Thank you for that

---------- Post added at 05:24 AM ---------- Previous post was at 05:21 AM ----------

Yes, I knew about that and it gave me some problems downloading the source for that reason. Lets hope for them to put it back on. It has been down for more than 2 weeks now.
[HD2 Android Q&A, Help & Troubleshooting and Genera] geenyous:
I have a question regarding compatibility mode in CM7.

I use screen density of 202 and your email.apk displays in a smaller window. The official email.apk did not show this behaviour. I have enabled and disabled compatibility mode but to no avail.

Any changes you made that might give such a behaviour?
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
No changes there but I originally did not use CM7 sources for the Email package but the Android ones. That must be the reason.

Anyway, it was officially merged to CM7 GitHub and any nighlty has the fix included now. I am just waiting for the usual guy to release the CM7 nightly build for my device...
[HD2 Android Q&A, Help & Troubleshooting and Genera] cyberx85:
Is it possible that somebody make detail instructions how to remove Email app since i'm a tottaly newby, and i use gmail app so i don't need it. And also please how to make backup. Is the Email.apk same as Mail.apk, because that is what i have found, but it tell me Mail.apk, can't be deleted.. I'm using HD2 T-mobile, with magdlr 1.13, hspl 2.08, and installed this android: http://xdaforums.com/showthread.php?t=893620.

Thanks in advance
[HD2 Android Q&A, Help & Troubleshooting and Genera] geenyous:
Nevermind my issue anyway, after a night of charging the email.apk now displays propperly.

Thx!
[HD2 Android Q&A, Help & Troubleshooting and Genera] ppk.net:
thank guy, now i'll can use my phone through day
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
I would recommend these steps:

1. Make sure your phone is rooted (you have the superuser app)

2. Download Root Explorer from the market, start it and Allow the superuser access

3. Browse to /system/app and mount as R/W

4. Delete the Email.apk

5. Reboot your phone

6. Install the Email.apk (either from your sdcard or via adb)

I am not sure if Mail.apk is the same as Email.apk but I think it is not the same. Mail.apk might be from HTC (depends on your ROM) - in such case you do not need to remove it.

Another way would be to replace the Email.apk in /system/app using Root Explorer. Anytime you make a change to system you need to reboot though
[HD2 Android Q&A, Help & Troubleshooting and Genera] gdsbalaji:
jakubklos - could you tell me from which nightly version your email.apk is merged?
[HD2 Android Q&A, Help & Troubleshooting and Genera] cyberx85:
Sorry but what it means "Mount as R/W, i have downloaded File explorer it says superuser granted accses or something similar , but when i delete it i have rebooted and it is still there.......
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
CM7 202

http://cm-nightlies.appspot.com/?device=bravo

---------- Post added at 05:24 AM ---------- Previous post was at 05:23 AM ----------

You need Root Explorer not just some File Explorer. When in system storage it will offer mounting the storage as read/write. You will notice it at the top of the screen
[HD2 Android Q&A, Help & Troubleshooting and Genera] execute_method:
I don't imagine this has the security "fix" does it? If not any chance of getting my hands on one that has been modified?
[HD2 Android Q&A, Help & Troubleshooting and Genera] abreede:
I'm also keen on the version without this "security enforcement feature"
[HD2 Android Q&A, Help & Troubleshooting and Genera] jakubklos:
I did not do this and will not do it. Try Shafty and his EE app on the market or just a new CM7 nightly
[HD2 Android Q&A, Help & Troubleshooting and Genera] Raziel2k6:
Greetings,

Is there any possibility to to modify the original email.apk from the Samsung Galaxy S II for it to behave like the modified email app from this thread, in other words not draining the battery when set to push on exchange accounts?

I have been using this app for the last two weeks, and I can confirm the fix works and my battery usage is much greater now, however I would really like if I could use the original Samsung email app, as I like its UI better.

Regards,
[HD2 Android Q&A, Help & Troubleshooting and Genera] KwiHa:
mem usage?

Hi,

I've just got a mem. usage after a day, 53MB, ~18hrs up-time (see the screensht.).

Has anybody else seen it?
[HD2 Android Q&A, Help & Troubleshooting and Genera] goodhank:
Awesome! this really helped!
[HD2 Android Q&A, Help & Troubleshooting and Genera] Hd2RuL3z:
I confirm that the fixed apk is working!
[HD2 Android Q&A, Help & Troubleshooting and Genera] tCC:
Bump, anyone ?
[HD2 Android Q&A, Help & Troubleshooting and Genera] toddmworth:
You can't do that, unless you can find the source code?
[HD2 Android Q&A, Help & Troubleshooting and Genera] tCC:
I guess you're right. Anyway, replaced the Samsung app with the attached email.apk and my drain is gone :D

Thanks!
[HD2 Android Q&A, Help & Troubleshooting and Genera] nikzDHD:
Thanks mate works a treat, for anyone wanting the security policy removed version head over to the SGS2 themes & apps for it. I will see if I can try & fix the SGS2 version!
[HD2 Android Q&A, Help & Troubleshooting and Genera] _DX_:
Just to double check (English is not my native language), are you saying that the version om the latest CM7 nightly's has both your batterydrain fix

and

the no-security hack?
[HD2 Android Q&A, Help & Troubleshooting and Genera] ngh55:
Hi, I just want to know if the 30 day limit for email sync has been removed.

And if not I will do a humble request to add an option for All Mail Sync.

Thank you in advance.