Alarm information collection
Alert time and alert remarks
System changes caused by an alarm:
1. Send Notification
2. Play Ring
Alert Message structure
ClockInfo {
String apkName;
String startTime;
String backup;
Boolean isPlayingRing;
}
SendNotification
SystemUI
BaseStatusBar. java
Parse ExpandedView to get the Notification sent by Clock. Because the Notification is not displayed in BaseStatusBar, isPlaying = false. The retrieved Clock information is broadcast to the server.
Alert Message :{
ApkName;
StartTime = ****;
Backup = ****;
IsPlayingRing = false;
}
Play Ring
MediaPlayer
MediaPlayer. java
When a Clock is generated, the MediaPlayer. start () method is called to play the ringtone. In the start () method, create ClockInfo and send it to the server through broadcast.
Alert Message {
ApkName = **;
StartTime = ****;
Backup = Empty;
IsPlayingRing = true;
}
Why do we need to create ClockInfo in two places?
1. You can set the Enable alarm to not send notifications. At this time, you can only obtain it and call the MediaPlayer. start () method.
2. The content of Notification cannot be obtained by calling the MediaPlayer. start () method. In order to obtain Clock backUp information as much as possible, you need to get ClockInfo in StatusBar at the same time.
3. The next alarm is displayed in the StatusBar when the alarm is triggered. Therefore, you must determine the alert information generated by MediaPlayer. start.
Storage results
After receiving the broadcast that collects Clock information, the server parses the clock information and stores it in the Local database.
Media start
ApkName = **, startTime = ***, backup =, isPlayingRing = true;
StatusBar
ApkName = **, startTime = ***, backup = ***, isPlayingRing = false;
When the ClockInfo message sent by StatusBar is stored, it determines:
Whether apkName = ** and backup = Empty andisPlayingRing = true exists in a certain interval;
If yes
Update existing backup content.
When the ClockInfo sent by Media is stored, it determines:
Whether apkName = ** and backup exists in a certain interval! = Empty andisPlayingRing = false;
If isPlaying = true exists;