Android擷取第三方鬧鐘的鬧鈴資訊

來源:互聯網
上載者:User


鬧鈴資訊採集

鬧鈴時間,鬧鈴備忘資訊

鬧鈴引起系統變化的點:

1. Send Notification

2. Play Ring

鬧鈴資訊結構體

ClockInfo{

String apkName;

String startTime;

String backup;

boolean isPlayingRing;

}

SendNotification

SystemUI

BaseStatusBar.java

解析ExpandedView,擷取Clock發送的Notification.因為在BaseStatusBar裡顯示Notification時,不能夠確認是否在播放鈴聲,所以isPlaying=false.將擷取的Clock information 通過廣播發送到服務端.

鬧鈴資訊:{

apkName;

startTime=****;

backup=****;

isPlayingRing=false;

}

Play Ring

MediaPlayer

MediaPlayer.java

當產生Clock時,會調用MediaPlayer.start()方法播放鈴聲。在調用start()方法裡,建立ClockInfo,然後通過廣播發送到服務端。

鬧鈴資訊{

apkName=**;

startTime=****;

backup=Empty;

isPlayingRing=true;

}

為什麼需要在兩個地方建立ClockInfo?

1.正點鬧鐘可以設定不發送Notification。這時只能擷取到它調用MediaPlayer.start()方法。

2.調用MediaPlayer.start()方法不能擷取到Notification的內容。為了盡量擷取到Clock的backUp資訊,需要同時在StatusBar裡擷取ClockInfo。

3.正點鬧鐘和即時提醒會在StatusBar中顯示下一個鬧鐘,此時並不是鬧鈴事件。所以需要同時根據MediaPlayer.start()產生的鬧鈴資訊判斷。

儲存結果

服務端接收到收集Clock information的廣播後,解析裡面的clock information,並儲存到Local database.

Media start

apkName =**, startTime=***,backup= ,isPlayingRing=true;

StatusBar

apkName=**, startTime=***, backup=****,isPlayingRing=false;

當儲存StatusBar發送的ClockInfo時,會判斷:

一定時間間隔內是否存在 apkName=** and backup=Empty andisPlayingRing=true;

如果存在

更新已經存在的backup內容。

當儲存Media發送的ClockInfo時,會判斷:

一定時間間隔內是否存在apkName=** and backup !=Empty andisPlayingRing=false;

如果存在設定isPlaying=true;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.