Alarm Information Acquisition
Alarm time, Alarm note information
The point at which the alarm causes system changes:
1. Send Notification
2. Play Ring
Alarm information structure
clockinfo{
String Apkname;
String StartTime;
String backup;
Boolean isplayingring;
}
SendNotification
Systemui
Basestatusbar.java
Parse the Expandedview to get the notification that is sent by clock. Because notification is displayed in Basestatusbar, it is not possible to confirm that the ringtone is playing, so isplaying= False. The captured clock information is sent to the server via broadcast.
Alarm information: {
Apkname;
starttime=****;
backup=****;
Isplayingring=false;
}
Play Ring
MediaPlayer
Mediaplayer.java
When clock is generated, the Mediaplayer.start () method is called to play the ringtone. In the call to start () method, create the Clockinfo and send it to the server via broadcast.
Alarm Information {
apkname=**;
starttime=****;
Backup=empty;
Isplayingring=true;
}
Why do I need to create a clockinfo in two places?
1. On-the-clock alarm can be set without sending notification. You can only get to it by calling the Mediaplayer.start () method.
2. Calling the Mediaplayer.start () method does not get the contents of the notification. In order to get the backup information of clock, we need to get clockinfo in StatusBar.
3. On-time alarms and instant alerts will show the next alarm in StatusBar, which is not an alarm event. Therefore, it is necessary to judge the alarm information produced by Mediaplayer.start () at the same time.
Store results
After receiving the broadcast of clock information, the server parses the clock information inside and stores it in the local database.
Media start
Apkname =**, starttime=***,backup=, isplayingring=true;
StatusBar
apkname=**, starttime=***, Backup=****,isplayingring=false;
When storing the clockinfo sent by StatusBar, it is determined that:
Whether there is apkname=** and Backup=empty andisplayingring=true in a certain time interval;
If there is
Update the backup content that already exists.
When storing clockinfo sent by media, it is determined that:
Whether there is apkname=** and backup!=empty andisplayingring=false within a certain time interval;
If there is a setup isplaying=true;