I am an engineer currently working with the Android P's system time setting/synchronization.
When we build Android and load it for the very first time we can see an initial time has already been set(whether it is correct time or not). I have no idea where to look at for getting the initial time setting without any time source activated(wifi, GPS, etc.). Rough guess is that maybe this time reference can be obtained from the linux time info, but as I said it is a just a guess and I do not know how I can prove/check the code for this also.
Can someone give me an enlightenment? Thanks.
As an electronics engineer, I will try to answer this question in more realistic way.
There is a special part in main board (called RTC) which is designed just to keep track of time. As @Lie Ryan stated, it has its own battery and relatively larger capacitor. In addition there is a special chip, which basically functions as a counter. You can initialize it, load new data, etc. That chip is powered by the special battery (usually very small). The chip can get input from a crystal and CPU. Once the system is assembled and the battery is placed, even the main system has no battery, it starts counting. The value stored in it keeps increasing. It takes crystal frequency as a reference frequency, makes it a clock signal, and uses it as its reference clock. The value of the counter increases at each fixed number of crystal oscillations (clock signal). When you power on the system, assuming the system is set to read the real time from RTC, it reads the value stored in that chip and decodes it in a format the system was set.
If the value you get is wrong, after the time is set from internet or manually, you load new data, and the chip continues counting from that new reference. Because of the imperfections of the real world system (crystal oscillation frequency is given with percentage error), if you don't set the time for long enough period, the time of your system might not be synchronized with real time (as you might have practiced). Or if you wait long enough, the battery gets out of power and the system does not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With