收不到这个广播,systemUi时间更新。
首先Time_Ticker 这个广播是AlarmManagerService自己创建并发送的。
public void scheduleTimeTickEvent() {
final long currentTime = System.currentTimeMillis();
final long nextTime = 60000 * ((currentTime / 60000) + 1);
// Schedule this event for the amount of time that it would take to get to
// the top of the next minute.
final long tickEventDelay = nextTime - currentTime;
final WorkSource workSource = null; // Let system take blame for time tick events.
setImpl(ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay, 0,
0, mTimeTickSender, null, null, AlarmManager.FLAG_STANDALONE, workSource,
null, Process.myUid(), "android");
// Finally, remember when we set the tick alarm
synchronized (mLock) {
mLastTickSet = currentTime;
}
}
non_wakeup 一分钟一次。并且AlarmManagerService 是系统进程,因此这个广播的Uid 是系统uid 1000.
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
filter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
filter.addDataScheme("package");
另外AlarmManagerService监听了package 清除相关的广播,收到信息会将该uid的alarm清掉。
然后有一些系统应用是shellUid 到system, 因此他们的uid也是1000.
当由于某些原因这些应用被force-stop的时候(在设置里面强行停止, adb shell am force-stop android等),uid 1000的alarm会被清理掉,TIME_TICKER 就停掉了。
以下是google9.0加的一些patch,过滤了相关逻辑的清理。
$git show 12cf0b6921bd4e464f4dbb4a698b078ac3e436fe
commit 12cf0b6921bd4e464f4dbb4a698b078ac3e436fe
Author: Christopher Tate ctate@google.com
Date: Fri Jan 5 18:40:14 2018 -0800
Dump a few more bits of history about TIME_TICK
Bug: 70670726
Test: manual
Change-Id: I7d593da8ec236b505bbdba3ece0a638cc41388c2
commit 1e078def95670527df0672514d0490a81f6e9d9c
Author: Makoto Onuki omakoto@google.com
Date: Wed Jan 10 16:12:39 2018 -0800
Add more WTFs to investigate TIME_TICK issue
Bug: 70670726
Test: Manual test
Change-Id: Id41431be777c69e553e0d51906ec5b48401f7bd3
(cherry picked from commit 5d93b834bb828a01ef6f51b776e897fca243b487)