why Android add an alarm driver?
来源:互联网 发布:curl post请求 json 编辑:程序博客网 时间:2024/05/20 05:09
Android has a new rtc driver implemented in "drivers/rtc/alarm.c". Why bother adding such a driver?
Android alarm driver provides a monotonic timebase that runs while the device is asleep. It enables an Android application to be run at some point in the future even device is in sleep mode.
According to Android developer document http://developer.android.com/reference/android/os/SystemClock.html, "three different clocks are available, and they should not be confused:"
System.currentTimeMillis()
is the standard "wall" clock (time and date) expressing milliseconds since the epoch. The wall clock can be set by the user or the phone network (seesetCurrentTimeMillis(long)
), so the time may jump backwards or forwards unpredictably. This clock should only be used when correspondence with real-world dates and times is important, such as in a calendar or alarm clock application. Interval or elapsed time measurements should use a different clock. If you are using System.currentTimeMillis(), consider listening to theACTION_TIME_TICK
,ACTION_TIME_CHANGED
andACTION_TIMEZONE_CHANGED
Intent
broadcasts to find out when the time changes.uptimeMillis()
is counted in milliseconds since the system was booted. This clock stops when the system enters deep sleep (CPU off, display dark, device waiting for external input), but is not affected by clock scaling, idle, or other power saving mechanisms. This is the basis for most interval timing such asThread.sleep(millls)
,Object.wait(millis)
, andSystem.nanoTime()
. This clock is guaranteed to be monotonic, and is the recommended basis for the general purpose interval timing of user interface events, performance measurements, and anything else that does not need to measure elapsed time during device sleep. Most methods that accept a timestamp value expect theuptimeMillis()
clock.elapsedRealtime()
is counted in milliseconds since the system was booted, including deep sleep. This clock should be used when measuring time intervals that may span periods of system sleep.
Below these clocks APIs are Linux driver supporting.
- System.currentTimeMillis() is implemented in Dalvik runtime "dalvik/vm/native/java_lang_System.c". It invokes gettimeofday() finally.
*) System.nanoTime() is another related API. It inovkes dvmGetRelativeTimeNsec(), which implemented with clock_gettime().
- uptimeMillis() and elapsedRealtime() are implemented in "framework/base/libs/utils/SystemClock.cpp".
- uptimeMillis() finally reach clock_gettime() on Android phone.
- elapsedRealtime() finally open "/dev/alarm", which is implemented in Android added alarm.c.
int64_t elapsedRealtime()
- why Android add an alarm driver?
- Android学习之Alarm driver
- android alarm driver &framework 关键流程
- MTK Android Driver :add a new key
- MTK Android Driver :add a new key
- MTK Android Driver :add a new key
- MTK Android Driver :add a new key
- MTK Android Driver :add a new key
- android alarm
- Android Alarm
- Add a Border to an Android Layout
- msm8660 add lcd driver
- 【Alarm】Android中alarm的使用
- android 闹钟 Alarm
- android Alarm 闹钟
- Android--Alarm,定时闹钟
- Android alarm解析
- android alarm类型
- 5月21号起的未来几个月计划
- 软件项目需求分析总结
- flex中的属性
- 如何在VisualC++中检测和隔离内存泄漏
- windows集群简单介绍
- why Android add an alarm driver?
- java webservice
- java远程调试参数
- Bring back Visual SourceSafe 2005 menu in VB6.0 environment
- 每天看一遍,会有收获
- CGAL编译安装笔记
- 蛮 实 在 的 话丶【推荐】
- Java解惑3-34被奇数击倒了
- 删除归档日志小记