这个是

private void setLocked(int type, long when) {

if (mNativeData != 0) {
            // The kernel never triggers alarms with negative wakeup times
            // so we ensure they are positive.
            long alarmSeconds, alarmNanoseconds;
            if (when < 0) {
                alarmSeconds = 0;
                alarmNanoseconds = 0;
            } else {
                alarmSeconds = when / 1000;
                alarmNanoseconds = (when % 1000) * 1000 * 1000;
            }
            
            set(mNativeData, type, alarmSeconds, alarmNanoseconds);
        } else {
            Message msg = Message.obtain();
            msg.what = ALARM_EVENT;
            
            mHandler.removeMessages(ALARM_EVENT);
            mHandler.sendMessageAtTime(msg, when);
        }

}

setLocked()内部会调用native函数set():

[java] view plain copy
  1. private native void set(int fd, int type, long seconds, long nanoseconds);

重新设置“实体闹钟”的激发时间。这个函数内部会调用ioctl()和底层打交道。具体代码可参考frameworks/base/services/jni/com_android_server_AlarmManagerService.cpp文件:

[java] view plain copy
  1. static void android_server_AlarmManagerService_set(JNIEnv* env, jobject obj, jint fd,
  2. jint type, jlong seconds, jlong nanoseconds)
  3. {
  4. struct timespec ts;
  5. ts.tv_sec = seconds;
  6. ts.tv_nsec = nanoseconds;
  7. int result = ioctl(fd, ANDROID_ALARM_SET(type), &ts);
  8. if (result < )
  9. {
  10. ALOGE("Unable to set alarm to %lld.%09lld: %s\n", seconds, nanoseconds, strerror(errno));
  11. }
  12. }

rtc关机闹钟6 AlarmManagerService研究的更多相关文章

  1. rtc关机闹钟5 AlarmManager研究

    AlarmManager研究 侯 亮 转自 http://blog.csdn.net/codefly/article/details/17058425 1.概述 在Android系统中,闹钟和唤醒功能 ...

  2. rtc关机闹钟4 AlarmManagerService.java

    vim base/services/core/java/com/android/server/AlarmManagerService.java AlarmManager 调用 IAlarmManage ...

  3. rtc关机闹钟3 IAlarmManager

    vim framework/base/core/java/android/app/IAlarmManager.aidl import android.app.AlarmManager;import a ...

  4. rtc 关机闹钟1 app层

    private static void enableAlertPowerOn(Context context, final Alarm alarm, final long atTimeInMillis ...

  5. rtc关机闹钟7 jni层 com_android_server_AlarmManagerService

    frameworks/base/services/core/jni/com_android_server_AlarmManagerService.cpp int AlarmImplAlarmDrive ...

  6. rtc关机闹钟2 Alarm manager

    public void set(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingInten ...

  7. C语言中时钟编程

    目录 C语言中时钟编程 1. 文章目的 2.基本概念 2.1 UTC时间 2.2 UNIX纪元时间 2.3 格林威治时间 (GMT) 3.时间转换 3.1 asctime函数 3.2 ctime函数 ...

  8. 【原创】STM32低功耗模式及中断唤醒(基于BMI160及RTC)的研究

    预研目标 六轴静止时,终端进入低功耗模式:六轴震动时,终端正常工作模式,从而极大减少非工作时的电流消耗. 解决方案 机器静止时,依据六轴算法,CPU进入休眠(停止)模式:机器工作时,触发六轴中断唤醒C ...

  9. S3C2440上RTC时钟驱动开发实例讲解(转载)

    嵌入式Linux之我行,主要讲述和总结了本人在学习嵌入式linux中的每个步骤.一为总结经验,二希望能给想入门嵌入式Linux的朋友提供方便.如有错误之处,谢请指正. 共享资源,欢迎转载:http:/ ...

随机推荐

  1. 清除UIWebView的缓存

    //清除cookies NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCook ...

  2. javascript 作用域

    作用域:可以理解为在一定范围内对数据进行读.写操作 域:空间.范围.区域... 作用:读.写 浏览器内部,可以暂时把专门用来读取JS的那部分叫做“js解析器”, “js解析器”工作流程: “js解析器 ...

  3. H2的MVStore

    翻译自http://www.h2database.com/html/mvstore.html 转载请著名出处,及译者信息. 第一次翻译,诸多不妥请谅解,谢谢. 概述 MVStore是一个持久化的.日志 ...

  4. spring 怎样将枚举项注入到bean的数组字段中

    在配置文件的xmlns中引入util的scheam xmlns:util=http://www.springframework.org/schema/util 在配置文件的xmlns:util=&qu ...

  5. Lintcode: Kth Smallest Number in Sorted Matrix

    Find the kth smallest number in at row and column sorted matrix. Example Given k = 4 and a matrix: [ ...

  6. JAVA-面向对象-继承

    继承   (关键字extends   ) (关键字 final 表示终态,在父类前加 final 则父类无法被继承,加在方法前则方法不能被重写或者覆盖,加在变量前则变量只能被赋值一次) 1.权限修饰符 ...

  7. [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  8. nginx、fastCGI、php-fpm关系梳理(转载 http://blog.sina.com.cn/s/blog_6df9fbe30102v57y.html)

        前言: Linux下搭建nginx+php+memached(LPMN)的时候,nginx.conf中配需要配置fastCGI,php需要安装 php-fpm扩展并启动php-fpm守护进程, ...

  9. Java -verbose:gc 命令

    Java -verbose:gc 中参数-verbose:gc 表示输出虚拟机中GC的详细情况. [Full GC 168K->97K(1984K), 0.0253873 secs]   解读如 ...

  10. scan cell

    scan cell有两种不同的input: 1)data input:由电路的combinational logic驱动: 2)scan input:由另一个scan cell驱动,从而形成scan  ...