Time_Ticker 广播收不到问题原因

收不到这个广播,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)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值