Simple Analysis of Android alarmclock alarm Application

Source: Internet
Author: User

Author: Xu jianxiang (netpirate@gmail.com)
Date: 2010/01/06
Web: 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/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"> alarm </string>
4 <boolean name = "vibrate" value = "true"/>
5 <boolean name = "on" value = "true"/>
6 </map>

# Sqlite3/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 | alert | content: // media/Internal/Audio/Media/21
3 | 9 | 0 | 0 | 0 | 0 | 1 |

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.