Android has the Gmail push features, which means the new message arrives in the mailbox without checking or refreshing the mailbox.
As I understand, the sync processes are like these:
1) User turns on the sync
2) There will be a alert msg and the sync flag in the Gmail DB of this device will be True
3) When a new email reach the Gmail Server, it will check if the device sync value, if it's True then send the email
OK, here, I don't quite understand how exactly does it work,
For a WiFi and cell signal connection, does the phone has a TCP socket open keep listening to the Gmail Server, or when a new email arrives the Server send a SMS alert to the phone, and then it will open the data channel to fetch the email? Are the two ways of connections have different approaches?
And second question is which method is the priority one? Say when you are in the middle of receiving data(emails), and suddenly the phone connect to a wireless network, will the data socket be closed and then reopened for the WiFi one? What's the behavior for the case when carrier's data channel and WiFi flips?
I have also downloaded the source code, anyone knows which part should I be looking into in order to solves my questions? I found a folder called "email" inside the folder "package", should I be looking at its code?
I know I asked quite some questions here, I'd appreciate if you know the answer for any of them, thanks very much!