Android Network Time Synchronization Summary

Source: Internet
Author: User

I recently read the network time synchronization and summarized it.

Overall description:

Android Network Time Synchronization uses the network identity and Time Zone (nitz) operator to select Services.

The RIL layer actively reports the notify message. The notification (notify Y) is sent to the notify and gsmservicestatetracker. The notify obtains the network synchronization time and determines whether to synchronize and send the notifications Based on the automatic synchronization settings in datetimesetting (action_network_set_time) broadcast.

 

Where

/** If time between nitz updates is less than mnitzupdatespacing the update may be ignored .*/

Private Static final int nitz_update_spacing_default = 1000*60*10;
Private int mnitzupdatespacing = systemproperties. getint ("Ro. nitz_update_spacing ",
Nitz_update_spacing_default );

Determines the synchronization interval. If the Active Reporting interval is less than this interval, the message is ignored.

 

/** If mnitzupdatespacing hasn't been exceeded but update is> mnitzupdate do the update */
Private Static final int nitz_update_diff_default = 2000;
Private int mnitzupdatediff = systemproperties. getint ("Ro. nitz_update_diff ",
Nitz_update_diff_default );

The default interval between the reported nitz synchronization time and the current processing time. If the actual interval is greater than this interval, this time is synchronized.

 

Synchronous judgment Condition

If (msavedattime = 0) | (timesincelastupdate> nitzupdatespacing)
| (Math. Abs (gained)> nitzupdatediff )){
Log. I (log_tag, "nitz: auto updating time of day to" + C. gettime ()
+ "Nitz receive delay =" + millissincenitzreceived
+ "Ms gained =" + gained + "MS from" + nitz );

Setandbroadcastnetworksettime (C. gettimeinmillis ());

} Else {
Log. I (log_tag, "nitz: Ignore, a previous update was"
+ Timesincelastupdate + "Ms ago and gained =" + gained + "Ms ");
Return;
}

 

In the upper-layer setting app, if datetimesetting sets autotime to true, then the cdmaservicestatetracker and gsmservicestatetracker listen based on the current

If (msavedtimezone! = NULL & msavedtime! = 0 & msavedattime! = 0 ){
Setandbroadcastnetworksettimezone (msavedtimezone );
Setandbroadcastnetworksettime (msavedtime
+ (Systemclock. elapsedrealtime ()-msavedattime ));
}

Broadcast time and time zone

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.