您的当前位置:首页不插卡待机电流分析

不插卡待机电流分析

2024-12-14 来源:哗拓教育

和你一起终身学习,这里是程序员 Android

本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:

一、确保飞行模式低电流正常
二、不插卡手机会与基站通讯
三、确认是否存在异常休眠唤醒源
四、根据 RTC alarm 唤醒寻找对应的app和alarm

一、确保飞行模式低电流正常

如下查看飞行模式电流异常问题,请查看如下文章:

二、不插卡手机会与基站通讯

不插卡手机会与基站通讯,并且会有paging,此时需要留意paging的周期和脉冲高度。
最干净的待机电流应该只有Paging,以下两点需要注意:

  1. 每个paging 的间隔,不同的网络不一样,有可能是 256ms,512ms,124s,2.48s。
  2. 每个paging 起来的burst 可能不止一个,单独的一个是PICH,起来两个的是PICH + PCH ,但是,良好的网络中PCH出现的次数不能占比太高。
  3. 如果周期过小,或者高度多大都会导致功耗增加,抬高整体电流,可以尝试换一个地方看看网络小区是否存在问题。
周期过小,或者高度多大都会导致功耗增加,抬高整体电流

三、确认是否存在异常休眠唤醒源

1. 查看波形图是否有异常唤醒

通过电流波形图,查看波形图的异常唤醒位置以及时间。

2.根据波形图确认的时间点,推断log中的大致时间点

连上手机,打开 Powermonitor ,手机开机,在Home Screen 界面,点击 Powermonitor 的 Run , 然后马上按powerkey 休眠,这样就能积累系统按powerkey 的时间。
尽量保证点击Run 和按Powerkey 时间间隔足够短,这样波形从0处 就是log中 powerkey 的时间。

注意
kernel log使用的是 UTC 硬件时间,Android 时间一般为UTC 时间+ 时区(比如中国时区需要+8小时)

3. 查看异常时间点的log打印情况

  • 有log打印

如果确认异常的时间点附近有打印log,可以查看对应唤醒原因,可以看下面步骤 4查找唤醒源log。

  • 无log 打印

如果这个时间点附近没有log打印,那说明 AP 侧没有唤醒,可能是其他模块的唤醒行为,比如:Modem 、WCN。这个需要接串口线打印log确认。

4. 查找唤醒源 log

查找唤醒log 分为一下两个步骤:

    1. 搜索关键字: [WDT] suspend
      这个是判断系统是否进入睡眠的标志,如果有,请继续看第二步。
    1. 然后继续搜索关键字: wake up by
      通过搜索 wake up by 就知道唤醒源,比如以下的唤醒源EINT。

//1. 搜索关键字:  [WDT] suspend 
<7>[199145.576777] -(0)[2029:system_server][name:mtk_wdt&][WDT] suspend
<4>[199145.576777] -(0)[2029:system_server][SPM] md_settle = 99, settle = 99
<4>[199145.576777] -(0)[2029:system_server][SPM] sec = 900, wakesrc = 0xe00c5e4 (1)(1)

//2. 搜索关键字:  wake up by 
<4>[199145.576777] -(0)[2029:system_server][SPM] wake up byEINT, timer_out = 2046093, r13 = 0x40000, debug_flag = 0x9f
<4>[199145.576777] -(0)[2029:system_server][SPM] r12 = 0x20, raw_sta = 0x20, idle_sta = 0x9fa, event_reg = 0x90100000, isr = 0x0
<4>[199145.576777] -(0)[2029:system_server][SPM] suspend dormant state = 0, md32_flag = 0x0, md32_flag2 = 0
<4>[199145.576777] -(0)[2029:system_server][SPM] log_wakesta_index = 8301
<5>[199145.576777] -(0)[2029:system_server]EINT_STA:
<5>[199145.576777] -(0)[2029:system_server]EINT Module - index:192,EINT_STA = 0x4000

5. 确认唤醒源是否是波形图上对应的异常大电流

通过步骤二推测出波形图上的大致时间,然后跟log中的打印的唤醒源时间对比看看是否一致。

6.常见的唤醒源

MT6765/MT6762平台的EINT 一般对应的是PMIC。PMIC 有两个原因可能出发EINT 唤醒系统。

  • 1.PMIC 有两个原因可能出发EINT 唤醒系统

PMIC 有两个原因可能出发EINT 唤醒系统如下:

  1. RTC alarm
  2. Powerkey
    1. 确认 PMIC 的种类 关键字: PMIC_INT

可以通过搜索关键字: PMIC_INT

  C:\Users\Administrator\mobilelog\APLog_2020_0202_104403__1\kernel_log_6__2020_0202_111218 (19 hits)
    Line 1049: <3>[199093.023388]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c8]=0x40
    Line 1908: <3>[199104.153376]  (2)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x1
    Line 1918: <3>[199104.413338]  (2)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x4
    Line 2717: <3>[199145.583307]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 2867: <3>[199145.943239]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 3040: <3>[199146.753179]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 3443: <3>[199155.073249]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x1
    Line 3452: <3>[199155.263268]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x4
    Line 3625: <3>[199156.593122]  (1)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 3818: <3>[199157.253059]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 3960: <3>[199157.593005]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4110: <3>[199157.942942]  (2)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4262: <3>[199158.292882]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4420: <3>[199158.642820]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4571: <3>[199158.992750]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4714: <3>[199159.332717]  (0)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 4880: <3>[199159.692647]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 5085: <3>[199160.062558]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x1
    Line 5116: <3>[199160.236813]  (1)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x4
    1. 确认PMIC EINT 的真正handler 关键字: pmic_thread

通过搜索关键字: pmic_thread 确认是RTC Alarm 还是 powerkey 。

1. RTC 唤醒 log 如下

    Line 2867: <3>[199145.943239]  (3)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x200
    Line 2868: <5>[199145.943263]  (3)[53:pmic_thread]mtk_rtc_common: rtc_tasklet_handler start
    Line 2869: <5>[199145.943378]  (3)[53:pmic_thread]mtk_rtc_hal: pdn1 = 0x   0
    Line 2870: <5>[199145.943406]  (3)[53:pmic_thread]mtk_rtc_common: alarm time is up
    Line 2871: <4>[199145.943443]  (3)[53:pmic_thread][PWRAP] clear EINT flag mt_pmic_wrap_eint_status=0x0

备注:
如何通过 RTC alarm 唤醒源,查找对应的app,请看下面的步骤四

2. Power可以 唤醒log 如下

    Line 1908: <3>[199104.153376]  (2)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x1
    Line 1909: <3>[199104.153413]  (2)[53:pmic_thread]kpd: Power Key generate, pressed=1
    Line 1910: <3>[199104.153472]  (2)[53:pmic_thread]kpd: kpd: (pressed) HW keycode =116 using PMIC
    Line 1911: <4>[199104.153504]  (2)[53:pmic_thread][PWRAP] clear EINT flag mt_pmic_wrap_eint_status=0x0
    Line 1917: <7>[199104.397600]  (2)[53:pmic_thread][name:perf_ioctl&]PERF_IOCTLenable UI boost, frame update, is_render_aware_boost:1
    Line 1918: <3>[199104.413338]  (2)[53:pmic_thread][PMIC] [PMIC_INT] addr[0x2c4]=0x4
    Line 1919: <3>[199104.413361]  (2)[53:pmic_thread]kpd: Power Key generate, pressed=0
    Line 1920: <3>[199104.413397]  (2)[53:pmic_thread]kpd: kpd: (released) HW keycode =116 using PMIC
    Line 1921: <4>[199104.413427]  (2)[53:pmic_thread][PWRAP] clear EINT flag mt_pmic_wrap_eint_status=0x0

四、根据 RTC alarm 唤醒寻找对应的app和alarm

通过以上定位到的 RTC alarm 可以在Android log中寻找对应的唤醒源。
在 main log或者 sys log中搜索一下关键字 type 0type 2sending alarm

通过唤醒源时间点,以及对应log中 apk 的包名,可以推测出异常唤醒源的app 。

1.type 0 log 举例如下:

search "type 0" (12 hits in 1 file)
  C:\Users\Administrator\mobilelog\APLog_2020_0202_104403__1\sys_log_4__2020_0202_111218 (12 hits)
    Line 10719: 02-02 10:47:08.360163  1850  2254 V AlarmManager: sending alarm Alarm{a8a2ce9 type 0 when 1580611596872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10721: 02-02 10:47:08.364560  1850  2254 V AlarmManager: sending alarm Alarm{bba4d6e type 0 when 1580611624510 com.baidu.searchbox,statsTag:*walarm*:com.baidu.action.SOFIRE.VIEW}
    Line 10739: 02-02 10:49:37.359524  1850  2254 V AlarmManager: sending alarm Alarm{a044b34 type 0 when 1580611776872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10846: 02-02 10:53:32.370952  1850  2254 V AlarmManager: sending alarm Alarm{51c59ec type 0 when 1580611919505 com.tencent.mm,statsTag:*walarm*:com.tencent.mm/.booter.MMReceivers$AlarmReceiver}
    Line 10848: 02-02 10:53:32.372220  1850  2254 V AlarmManager: sending alarm Alarm{9ecf04a type 0 when 1580611956872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10883: 02-02 10:57:07.360059  1850  2254 V AlarmManager: sending alarm Alarm{9e0161c type 0 when 1580612136872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10903: 02-02 10:58:38.366169  1850  2254 V AlarmManager: sending alarm Alarm{9e3bba1 type 0 when 1580612316872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10918: 02-02 11:01:38.363097  1850  2254 V AlarmManager: sending alarm Alarm{6f0cb4 type 0 when 1580612496872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10946: 02-02 11:05:09.356889  1850  2254 V AlarmManager: sending alarm Alarm{94a4020 type 0 when 1580612676872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 10978: 02-02 11:09:50.362327  1850  2254 V AlarmManager: sending alarm Alarm{92bf338 type 0 when 1580612819505 com.tencent.mm,statsTag:*walarm*:com.tencent.mm/.booter.MMReceivers$AlarmReceiver}
    Line 10980: 02-02 11:09:50.369473  1850  2254 V AlarmManager: sending alarm Alarm{c0c3e77 type 0 when 1580612856872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}
    Line 11000: 02-02 11:10:38.358771  1850  2254 V AlarmManager: sending alarm Alarm{5b9705 type 0 when 1580613036872 com.baidu.searchbox,statsTag:*walarm*:com.baidu.searchbox/com.baidu.android.pushservice.PushService}


2. type 2 log 举例如下:

Search "type 2" (10 hits in 1 file)
  C:\Users\Administrator\mobilelog\APLog_2020_0202_104403__1\sys_log_4__2020_0202_111218 (10 hits)
    Line 9849: 02-02 10:39:28.517732  1850  2254 V AlarmManager: sending alarm Alarm{9b24a40 type 2 when 521624705 com.google.android.gms,statsTag:*walarm*:com.google.android.intent.action.GCM_RECONNECT}
    Line 10695: 02-02 10:45:55.354595  1850  2254 V AlarmManager: sending alarm Alarm{f468eed type 2 when 522010342 com.google.android.gms,statsTag:*walarm*:CONTEXT_MANAGER_ALARM_WAKEUP_521863480}
    Line 10718: 02-02 10:47:08.359414  1850  2254 V AlarmManager: sending alarm Alarm{e964170 type 2 when 522010547 com.google.android.gms,statsTag:*walarm*:com.google.android.gms.gcm.ACTION_CHECK_QUEUE}
    Line 10845: 02-02 10:53:32.370625  1850  2254 V AlarmManager: sending alarm Alarm{1202e3e type 2 when 522413966 android,statsTag:*walarm*:*job.delay*}
    Line 10850: 02-02 10:53:32.377243  1850  2254 V AlarmManager: sending alarm Alarm{e550bbb type 2 when 522467687 com.tencent.mm,statsTag:*walarm*:ALARM_ACTION(6420)}
    Line 10882: 02-02 10:57:07.359654  1850  2254 V AlarmManager: sending alarm Alarm{868138f type 2 when 522542841 android,statsTag:*walarm*:DeviceIdleController.light}
    Line 10945: 02-02 11:05:09.356626  1850  2254 V AlarmManager: sending alarm Alarm{6c05323 type 2 when 522983549 android,statsTag:*walarm*:DeviceIdleController.light}
    Line 10948: 02-02 11:05:09.358532  1850  2254 V AlarmManager: sending alarm Alarm{ce73dd9 type 2 when 523164752 com.google.android.gms,statsTag:*walarm*:CONTEXT_MANAGER_ALARM_WAKEUP_436764323}
    Line 10974: 02-02 11:09:50.359979  1850  2254 V AlarmManager: sending alarm Alarm{ae33e4c type 2 when 522713966 android,statsTag:*walarm*:*job.deadline*}
    Line 10976: 02-02 11:09:50.361470  1850  2254 V AlarmManager: sending alarm Alarm{2a25baa type 2 when 522545819 com.autonavi.minimap,statsTag:*walarm*:com.autonavi.minimap.intent.action.COCKROACH}

至此,本篇已结束,如有不对的地方,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!

显示全文