隨筆-1  評論-68  文章-98  trackbacks-0
          作者:徐建祥(netpirate@gmail.com)
          日期:2010/01/06
          網址:http://www.anymobile.org

          1/ set a alarm clock
          1.1 update alarms.db
          1.2 update com.android.alarmclock_preferences.xml
          1.3 update Settings.System.NEXT_ALARM_FORMATTED for status bar
          1.4 set Kernel RTC alarm or send a message if no driver

          flow:
          com.android.alarmclock.AlarmClock.onCreate() -> SetAlarm.onPreferenceTreeClick() -> SetAlarm.saveAlarm() ->
          Alarm.setAlarm() -> Alarm.setNextAlert() -> Alarm.enableAlert(ALARM_ALERT_ACTION)/saveNextAlarm(Settings.System.NEXT_ALARM_FORMATTED) ->
          android.app.AlarmManager.set() -> AlarmManagerService.set() -> AlarmManagerService.setRepeating -> AlarmManagerService.setLocked() ->
          android.app.IAlarmManager.set() -> RTC.save()// /dev/alarms

          2/ play a clarm clock

          flow:
          RTC (WAKEUP) -> AlarmReceiver.onReceive(ALARM_ALERT_ACTION) -> AlarmAlert.onCreate() ->
          AlarmAlertWakeLock.acquire()/KeyguardManager.newKeyguardLock().disableKeyguard() ->
          AlarmKlaxon.postPlay() ->  AlarmKlaxon.KillerCallback().onKilled() -> AlarmAlert.dismiss() ->
          AlarmAlertWakeLock.release()/KeyguardManager.newKeyguardLock().reenableKeyguard()

          some description:

          /**
           * Days of week coded as single int, convenient for DB storage:
           *
           * 0x00:  no day
           * 0x01:  Monday
           * 0x02:  Tuesday
           * 0x04:  Wednesday
           * 0x08:  Thursday
           * 0x10:  Friday
           * 0x20:  Saturday
           * 0x40:  Sunday
           */

          /**
           * Alarm type
           *
           * ELAPSED_REALTIME            Alarm time in time since boot, including sleep, This alarm does not wake the device up.
           * ELAPSED_REALTIME_WAKEUP    Alarm time in time since boot, including sleep, This alarm will wake up the device when it goes off.
           * RTC            Alarm time in wall clock time in UTC, This alarm does not wake the device up.
           * RTC_WAKEUP    Alarm time in wall clock time in UTC, This alarm will wake up the device when it goes off.
           */

          db example:

          # cat /data/data/com.android.alarmclock/shared_prefs/com.android.alarmclock_preferences.xml
          1 <?xml version='1.0' encoding='utf-8' standalone='yes' ?>
          2 <map>
          3 <string name="label">警報</string>
          4 <boolean name="vibrate" value="true" />
          5 <boolean name="on" value="true" />
          6 </map>

          # sqlite3 /data/data/com.android.alarmclock/databases/alarms.db
          SQLite version 3.5.9
          Enter ".help" for instructions
          sqlite> .tables
          alarms            android_metadata
          sqlite> .schema alarms
          CREATE TABLE alarms (_id INTEGER PRIMARY KEY,hour INTEGER, minutes INTEGER, daysofweek INTEGER, alarmtime INTEGER, enabled INTEGER, vibrate INTEGER, message TEXT, alert TEXT);
          sqlite> select * from alarms;
          1|7|0|127|0|0|1||
          2|8|30|31|1262766600000|1|1|警報|content://media/internal/audio/media/21
          3|9|0|0|0|0|1||
          posted on 2010-01-06 17:27 Xu Jianxiang 閱讀(3938) 評論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 台东县| 水城县| 自治县| 永宁县| 尉犁县| 宁化县| 麻阳| 昔阳县| 延津县| 清水县| 喀喇沁旗| 永川市| 光山县| 麻城市| 柳江县| 岳阳市| 万源市| 湖北省| 凌源市| 娄烦县| 井研县| 铜山县| 吉隆县| 富锦市| 喀喇| 长武县| 壶关县| 大悟县| 平凉市| 乳山市| 剑川县| 天津市| 缙云县| 平罗县| 河北省| 察哈| 绥化市| 柳河县| 土默特右旗| 吴川市| 云浮市|