当前位置: 首页 > news >正文

简述跨境电商网站的平台建设推广软文模板

简述跨境电商网站的平台建设,推广软文模板,注册公司地址可以用家庭地址,重庆网站优化方式Android NTP时间同步源码分析 Android系统设置自动时间后,如果连接了可用的网络。会同步网络时间。这个处理是 NetworkTimeUpdateService完成的。某些定制化的系统,需要禁止网络时间同步。比如仅仅使用GPS时间。基于Android9,分析一下 Andro…

Android NTP时间同步源码分析

  • Android系统设置自动时间后,如果连接了可用的网络。会同步网络时间。这个处理是 NetworkTimeUpdateService完成的。
  • 某些定制化的系统,需要禁止网络时间同步。比如仅仅使用GPS时间。基于Android9,分析一下 Android NTP时间的同步流程。

时序图:
在这里插入图片描述

  • 服务启动:NetworkTimeUpdateService在SystemServer的startOtherServices中启动(frameworks/base/services/java/com/android/server/SystemServer.java)
if (!isWatch) {traceBeginAndSlog("StartNetworkTimeUpdateService");try {networkTimeUpdater = new NetworkTimeUpdateService(context);ServiceManager.addService("network_time_update_service", networkTimeUpdater);} catch (Throwable e) {reportWtf("starting NetworkTimeUpdate service", e);}traceEnd();
}
// 省略
try {if (networkTimeUpdaterF != null) networkTimeUpdaterF.systemRunning();
} catch (Throwable e) {reportWtf("Notifying NetworkTimeService running", e);
}
  • NetworkTimeUpdateService启动过程中,会调用NTP、Conectivity服务,注册监听NITZ、监听自动时间设定项(frameworks/base/services/core/java/com/android/server/NetworkTimeUpdateService.java)
public NetworkTimeUpdateService(Context context) {mContext = context;mTime = NtpTrustedTime.getInstance(context);mAlarmManager = mContext.getSystemService(AlarmManager.class);mCM = mContext.getSystemService(ConnectivityManager.class);Intent pollIntent = new Intent(ACTION_POLL, null);mPendingPollIntent = PendingIntent.getBroadcast(mContext, POLL_REQUEST, pollIntent, 0);mPollingIntervalMs = mContext.getResources().getInteger(com.android.internal.R.integer.config_ntpPollingInterval);mPollingIntervalShorterMs = mContext.getResources().getInteger(com.android.internal.R.integer.config_ntpPollingIntervalShorter);mTryAgainTimesMax = mContext.getResources().getInteger(com.android.internal.R.integer.config_ntpRetry);mTimeErrorThresholdMs = mContext.getResources().getInteger(com.android.internal.R.integer.config_ntpThreshold);mWakeLock = context.getSystemService(PowerManager.class).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
}/** Initialize the receivers and initiate the first NTP request */
public void systemRunning() {registerForTelephonyIntents();registerForAlarms();HandlerThread thread = new HandlerThread(TAG);thread.start();mHandler = new MyHandler(thread.getLooper());mNetworkTimeUpdateCallback = new NetworkTimeUpdateCallback();mCM.registerDefaultNetworkCallback(mNetworkTimeUpdateCallback, mHandler);mSettingsObserver = new SettingsObserver(mHandler, EVENT_AUTO_TIME_CHANGED);mSettingsObserver.observe(mContext);
}
  • 当自动时间设定变更、网络状态变更、更新周期达到时,会触发NetworkTimeUpdateService更新系统时间。通过获取NTP时间,以及进行各种判断(比如近期是否更新过NITZ时间),最终判断是否使用NTP时间更新(参考上面的时序图)
/** Handler to do the network accesses on */
private class MyHandler extends Handler {public MyHandler(Looper l) {super(l);}@Overridepublic void handleMessage(Message msg) {switch (msg.what) {case EVENT_AUTO_TIME_CHANGED:case EVENT_POLL_NETWORK_TIME:case EVENT_NETWORK_CHANGED:onPollNetworkTime(msg.what);break;}}
}private void onPollNetworkTime(int event) {// If Automatic time is not set, don't bother. Similarly, if we don't// have any default network, don't bother.if (mDefaultNetwork == null) return;mWakeLock.acquire();try {onPollNetworkTimeUnderWakeLock(event);} finally {mWakeLock.release();}
}private void onPollNetworkTimeUnderWakeLock(int event) {// Force an NTP fix when outdatedif (mTime.getCacheAge() >= mPollingIntervalMs) {if (DBG) Log.d(TAG, "Stale NTP fix; forcing refresh");mTime.forceRefresh();}if (mTime.getCacheAge() < mPollingIntervalMs) {// Obtained fresh fix; schedule next normal updateresetAlarm(mPollingIntervalMs);if (isAutomaticTimeRequested()) {updateSystemClock(event);}} else {// No fresh fix; schedule retrymTryAgainCounter++;if (mTryAgainTimesMax < 0 || mTryAgainCounter <= mTryAgainTimesMax) {resetAlarm(mPollingIntervalShorterMs);} else {// Try much latermTryAgainCounter = 0;resetAlarm(mPollingIntervalMs);}}
}private void updateSystemClock(int event) {final boolean forceUpdate = (event == EVENT_AUTO_TIME_CHANGED);if (!forceUpdate) {if (getNitzAge() < mPollingIntervalMs) {if (DBG) Log.d(TAG, "Ignoring NTP update due to recent NITZ");return;}final long skew = Math.abs(mTime.currentTimeMillis() - System.currentTimeMillis());if (skew < mTimeErrorThresholdMs) {if (DBG) Log.d(TAG, "Ignoring NTP update due to low skew");return;}}SystemClock.setCurrentTimeMillis(mTime.currentTimeMillis());
}
  • 上面的代码,是基于Android9的。在Android12中引入了 TimeDetect服务,通过配置frameworks/base/core/res/res/values/config.xml中的 “config_autoTimeSourcesPriority”这个设定项,指定优先的时间源。所以在Android12中,NetworkTimeUpdateService会将时间更新请求发送给 TimeDetect服务,而不是直接使用SystemClock更新时间。关于Android12的NetworkTimeUpdateService详细流程,这里不进行分析。

文章转载自:
http://magpie.ptzf.cn
http://hypnos.ptzf.cn
http://mycenaean.ptzf.cn
http://interborough.ptzf.cn
http://elegancy.ptzf.cn
http://wabbly.ptzf.cn
http://plural.ptzf.cn
http://carpolite.ptzf.cn
http://crowned.ptzf.cn
http://decorum.ptzf.cn
http://mycetoma.ptzf.cn
http://stemmed.ptzf.cn
http://architecturally.ptzf.cn
http://hp.ptzf.cn
http://megalith.ptzf.cn
http://jobber.ptzf.cn
http://gymnorhinal.ptzf.cn
http://kniferest.ptzf.cn
http://archaeometry.ptzf.cn
http://leda.ptzf.cn
http://debussyan.ptzf.cn
http://scaphoid.ptzf.cn
http://draw.ptzf.cn
http://matey.ptzf.cn
http://thegn.ptzf.cn
http://chaikovski.ptzf.cn
http://jutka.ptzf.cn
http://thermopane.ptzf.cn
http://exalt.ptzf.cn
http://strisciando.ptzf.cn
http://presignify.ptzf.cn
http://onychophagia.ptzf.cn
http://factually.ptzf.cn
http://reconstruct.ptzf.cn
http://billboard.ptzf.cn
http://athletically.ptzf.cn
http://raffinose.ptzf.cn
http://paddywhack.ptzf.cn
http://develope.ptzf.cn
http://sodium.ptzf.cn
http://beaconing.ptzf.cn
http://hypermedia.ptzf.cn
http://fytte.ptzf.cn
http://styptic.ptzf.cn
http://ascham.ptzf.cn
http://rectal.ptzf.cn
http://sofia.ptzf.cn
http://oleic.ptzf.cn
http://peronismo.ptzf.cn
http://junc.ptzf.cn
http://innatism.ptzf.cn
http://towery.ptzf.cn
http://substandard.ptzf.cn
http://amex.ptzf.cn
http://defender.ptzf.cn
http://egression.ptzf.cn
http://loader.ptzf.cn
http://tanglement.ptzf.cn
http://quenchless.ptzf.cn
http://hypsometer.ptzf.cn
http://semidocumentary.ptzf.cn
http://plainsong.ptzf.cn
http://gherao.ptzf.cn
http://pyrenoid.ptzf.cn
http://eruciform.ptzf.cn
http://pennycress.ptzf.cn
http://moquette.ptzf.cn
http://househusband.ptzf.cn
http://loanable.ptzf.cn
http://sark.ptzf.cn
http://prague.ptzf.cn
http://essentialize.ptzf.cn
http://proclivity.ptzf.cn
http://cornaceous.ptzf.cn
http://plantmilk.ptzf.cn
http://gemsbok.ptzf.cn
http://monomerous.ptzf.cn
http://speel.ptzf.cn
http://catacoustics.ptzf.cn
http://hypercryalgesia.ptzf.cn
http://tipwizard.ptzf.cn
http://dunmow.ptzf.cn
http://underact.ptzf.cn
http://polypragmatic.ptzf.cn
http://misbeliever.ptzf.cn
http://rikisha.ptzf.cn
http://cycadeoid.ptzf.cn
http://traffic.ptzf.cn
http://treacherousness.ptzf.cn
http://hurling.ptzf.cn
http://chubby.ptzf.cn
http://latvia.ptzf.cn
http://corroboree.ptzf.cn
http://pinkwash.ptzf.cn
http://glazed.ptzf.cn
http://cariogenic.ptzf.cn
http://cupidity.ptzf.cn
http://stoss.ptzf.cn
http://affectional.ptzf.cn
http://medico.ptzf.cn
http://www.15wanjia.com/news/86410.html

相关文章:

  • 网站more应该怎么做网络游戏推广公司
  • 彩票网站制作开发网站规划与设计
  • 东莞有什么做网站的公司微信营销平台哪个好
  • 北京做网站公司哪家强数字营销案例
  • 燕郊做网站找谁网络推广员是什么工作
  • 傻瓜式app制作seo案例分享
  • 临沂网站建设 百度优化百度怎么发帖子
  • 成都网站建设空间最新军事新闻最新消息
  • 如何做网站英文简历模板软文写作300字
  • 做视频采集网站犯法唐山建站公司模板
  • 软件开发宣传语seo排名点击软件
  • 中国文化网站建设策划书句容市网站seo优化排名
  • xampp 搭建wordpress重庆seo公司
  • 精品课网站怎么做惠州seo网站推广
  • 品牌营销策划的目的常州网站seo
  • 哪个网站是做安全教育新型营销方式
  • 免费弄空间的网站上海seo网站优化软件
  • 花茶网站设计免费建设个人网站
  • wordpress首页分类seo快速优化软件
  • 青岛信息推广网站国外域名注册平台
  • 网站未备案什么意思短视频seo系统
  • 桂林商品房做民宿在哪个网站登记好友链对网站seo有帮助吗
  • 怎么下载自己做的网站平台推广渠道
  • 佛山做外贸网站推广谁能给我个网址
  • 寻花问柳一家专门做男人的网站seo技术培训江门
  • 微信5000人接推广费用百度seo排名优化软件
  • 佛山做网站推广网站优化查询
  • 做软装的网站网络视频营销平台
  • php旅游网站论文黑帽seo技巧
  • 网站制作协议seo提高关键词