SP91的待机功耗大到42mA(com.android.deskclock.ON_QUARTER_HOUR)

2024-02-06 17:40

本文主要是介绍SP91的待机功耗大到42mA(com.android.deskclock.ON_QUARTER_HOUR),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

CPU 休眠偶尔平均电流 42 mA

  • 现象如下
    这里写图片描述

  • 发生时刻:PC时间 11:06 ,PowerMonitor 1026~1032秒

  • MtkLog 时间点
11-28 11:05:45.118827   950  1112 E ActivityManager: Sending non-protected broadcast com.android.deskclock.ON_QUARTER_HOUR from system uid 1000 pkg com.android.deskclock
11-28 11:05:45.118827   950  1112 E ActivityManager: java.lang.Throwable
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:19338)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:19942)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.ActivityManagerService.broadcastIntentInPackage(ActivityManagerService.java:20130)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:325)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.PendingIntentRecord.sendWithResult(PendingIntentRecord.java:222)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.am.ActivityManagerService.sendIntentSender(ActivityManagerService.java:8169)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at android.app.PendingIntent.send(PendingIntent.java:836)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.AlarmManagerService$DeliveryTracker.deliverLocked(AlarmManagerService.java:3565)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.AlarmManagerService.deliverAlarmsLocked(AlarmManagerService.java:2938)
11-28 11:05:45.118827   950  1112 E ActivityManager:    at com.android.server.AlarmManagerService$AlarmThread.run(AlarmManagerService.java:3086)
11-28 11:05:45.129578   950   978 D AppOps  : startOperation: allowing code 40 uid 1000 package android
11-28 11:05:45.130176   950  1112 D AES     : onEndOfErrorDumpThread: system_server_wtf Process: system_server
11-28 11:05:45.130176   950  1112 D AES     : Subject: ActivityManager
11-28 11:05:45.130176   950  1112 D AES     : Build: LAVA/Z91/Z91:7.1.1/N6F26Q/1514365452:user/release-keys
11-28 11:05:45.130176   950  1112 D AES     : 
11-28 11:05:45.130176   950  1112 D AES     : android.util.Log$TerribleFailure: Sending non-protected broadcast com.android.deskclock.ON_QUARTER_HOUR from system uid 1000 pkg com.android.deskclock
11-28 11:05:45.130176   950  1112 D AES     :   at android.util.Log.wtf(Log.java:295)
11-28 11:05:45.130176   950  1112 D AES     :   at android.util.Log.wtf(Log.java:290)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:19335)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:19942)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.ActivityManagerService.broadcastIntentInPackage(ActivityManagerService.java:20130)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:325)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.PendingIntentRecord.sendWithResult(PendingIntentRecord.java:222)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.ActivityManagerService.sendIntentSender(ActivityManagerService.java:8169)
11-28 11:05:45.130176   950  1112 D AES     :   at android.app.PendingIntent.send(PendingIntent.java:836)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.AlarmManagerService$DeliveryTracker.deliverLocked(AlarmManagerService.java:3565)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.AlarmManagerService.deliverAlarmsLocked(AlarmManagerService.java:2938)
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.AlarmManagerService$AlarmThread.run(AlarmManagerService.java:3086)
11-28 11:05:45.130176   950  1112 D AES     : Caused by: java.lang.Throwable
11-28 11:05:45.130176   950  1112 D AES     :   at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:19338)
11-28 11:05:45.130176   950  1112 D AES     :   ... 9 more
11-28 11:05:45.130176   950  1112 D AES     :  950
11-28 11:05:45.130366   950  1112 W AES     : Exception Log handling...
11-28 11:05:45.130829   950  1169 D AppOps  : startOperation: allowing code 40 uid 1000 package android
11-28 11:05:45.137684  1223  1223 D KeyguardUpdateMonitor: received broadcast android.intent.action.TIME_TICK
11-28 11:05:45.138396  1223  1223 D KeyguardUpdateMonitor: handleTimeUpdate
11-28 11:05:45.272902  1223  1223 V Clock   : onReceive: Intent { act=android.intent.action.TIME_TICK flg=0x50000014 (has extras) }
11-28 11:05:45.293306   950  1472 D AES     : AEEIOCTL_GET/SET_SF_STATE IOCTL,cmd= 1074294797, lParam=0. 
11-28 11:05:45.294011   950  1472 D AES     : AEEIOCTL_RT_MON_Kick IOCTL,cmd= 2147774474, lParam=300. 
11-28 11:05:45.294107  1223  1223 V Clock   : onReceive: Intent { act=android.intent.action.TIME_TICK flg=0x50000014 (has extras) }

分析

首先查看系统唤醒
如果是 RTC 唤醒,要找上层的 alarm 也很简单,在 main log 或者 sys log 里面搜索下面的关键字即可
关键字 AlarmManager: sending alarm Alarm

查询结果如下:

11-28 11:05:45.134589   950  1112 V AlarmManager: sending alarm Alarm{b982fb4 type 1 when 1480302001000 com.android.deskclock} success具体细节:
4,381: 11-28 11:05:45.134589   950  1112 V AlarmManager: sending alarm Alarm{b982fb4 type 1 when 1480302001000 com.android.deskclock} success 
4,399: 11-28 11:05:45.389511   950  1783 V AlarmManager: APP set(PendingIntent{9e1ef52: PendingIntentRecord{78a1223 com.android.deskclock broadcastIntent}}) : type=1 triggerAtTime=1480302901000 win=0 tElapsed=4190256 maxElapsed=4190256 interval=0 flags=0x9 由于该AlarmManager.RTC 没有实际唤醒CPU,故kenalLog不显示
11-28 11:05:45.426971     0     0 I [ 1084.519376]-(1)[0:swapper/1]: [SPM] wake up by  R12_APXGPT1_EVENT_B, timer_out = 375, r13 = 0xe860200, debug_flag = 0x200110ff 0x0, r12 = 0x10, r12_ext = 0x100, raw_sta = 0x0, idle_sta = 0xfb, req_sta =  0x1800, event_reg = 0x90100000, isr = 0x0, raw_ext_sta = 0x4402a3aa, wake_misc = 0x0, pcm_flag = 0x180 0x0, req = 0x0

上述确定 com.android.deskclock 设置定时进行广播com.android.deskclock.ON_QUARTER_HOUR唤醒 type 1 表示AlarmManager.RTC

AlarmManager.RTC,硬件闹钟,不唤醒手机(也可能是其它设备)休眠;当手机休眠时不发射闹钟。

xref: /frameworks/base/core/java/android/app/AlarmManager.java
83public class AlarmManager {92    /**
93     * Alarm time in {@link System#currentTimeMillis System.currentTimeMillis()}
94     * (wall clock time in UTC).  This alarm does not wake the
95     * device up; if it goes off while the device is asleep, it will not be
96     * delivered until the next time the device wakes up.
97     */
98    public static final int RTC = 1;

分析结果

com.android.deskclock 休眠下执行的com.android.deskclock.ON_QUARTER_HOUR导致平均电流被拉高

查看 com.android.deskclock 相关源码

AndroidManifest.xml

        <!-- #endif --><!--  add start by  for MultiClock Widget  --><receiver android:name="com.android.alarmclock.MultiColckWidgetProvider" android:label="@string/multi_gadget"android:icon="@drawable/ic_launcher_alarmclock"><intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /><action android:name="com.android.deskclock.ON_QUARTER_HOUR" /><action android:name="android.intent.action.DATE_CHANGED" /><action android:name="android.intent.action.TIMEZONE_CHANGED" /><action android:name="android.intent.action.TIME_SET" /><action android:name="android.intent.action.LOCALE_CHANGED" /><action android:name="com.android.deskclock.worldclock.update" /><action android:name="android.intent.action.DATE_FORMAT_CHANGED" /></intent-filter><meta-data android:name="android.appwidget.provider" android:resource="@xml/multiclock_appwidget" /></receiver><!-- #endif -->
package com.android.alarmclock;public class MultiColckWidgetProvider extends AppWidgetProvider {/*** Intent to be used for checking if a world clock's date has changed. Must be every fifteen* minutes because not all time zones are hour-locked.**/public static final String ACTION_ON_QUARTER_HOUR = "com.android.deskclock.ON_QUARTER_HOUR";@Overridepublic void onReceive(Context context, Intent intent) {String action = intent.getAction();Log.d(TAG, "onReceive: " + action);super.onReceive(context, intent);if (ACTION_ON_QUARTER_HOUR.equals(action)|| Intent.ACTION_DATE_CHANGED.equals(action)|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)|| Intent.ACTION_TIME_CHANGED.equals(action)|| Intent.ACTION_LOCALE_CHANGED.equals(action)|| Cities.WORLDCLOCK_UPDATE_INTENT.equals(action)) {AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);if (appWidgetManager != null) {int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));for (int appWidgetId : appWidgetIds) {updateClock(context, appWidgetManager, appWidgetId);}if(!ACTION_ON_QUARTER_HOUR.equals(action)) {cancelAlarmOnQuarterHour(context);}startAlarmOnQuarterHour(context);}}}/*** Start an alarm that fires on the next quarter hour to update the world clock city* day when the local time or the world city crosses midnight.** @param context The context in which the PendingIntent should perform the broadcast.*/private void startAlarmOnQuarterHour(Context context) {if (context != null) {final long onQuarterHour = Utils.getAlarmOnQuarterHour();final PendingIntent quarterlyIntent = getOnQuarterHourPendingIntent(context);final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);am.setExact(AlarmManager.RTC, onQuarterHour, quarterlyIntent);Log.v(TAG, "startAlarmOnQuarterHour " + context.toString());}}

上述确认无误了

写一个Demo 验证

定时器进行AlarmManager.RTC休眠下唤醒
代码如下

调用
===============================================================================
package com.android.wakeupdemo;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;public class MainActivity extends Activity {private Intent mIntent;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mIntent = new Intent(this, MyBroadcast.class);mIntent.setAction(MyBroadcast.ACITON);AlarmTaskUtil.starRepeatAlarmTaskBroadcast(this, 5 * 1000 /* 5秒钟 */, mIntent);Log.d("suhuazhi", "starRepeatAlarmTaskBroadcast " + MyBroadcast.ACITON);}@Overrideprotected void onDestroy() {super.onDestroy();AlarmTaskUtil.stopAlarmTaskByBroadcast(this, mIntent);Log.d("suhuazhi", "onDestroy");}
}
定时器
===============================================================================
package com.android.wakeupdemo;import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;public class AlarmTaskUtil {public static void starRepeatAlarmTaskBroadcast(Context context, long intervalMillis, Intent intent) {AlarmManager mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);PendingIntent operation = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);mAlarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), intervalMillis, operation);}public static void stopAlarmTaskByBroadcast(Context context, Intent intent) {AlarmManager mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);PendingIntent operation = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);mAlarmManager.cancel(operation);}
}
广播
===============================================================================
package com.android.wakeupdemo;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;public class MyBroadcast extends BroadcastReceiver {public final static String ACITON = "com.su.wakeupdemo.ON_QUARTER_HOUR";@Overridepublic void onReceive(Context context, Intent intent) {if (ACITON.equals(intent.getAction())) {Log.d("suhuazhi", "I am here " + ACITON);}}}

捕获台阶电流

这里写图片描述

Log关键字
sending alarm Alarm

3,687: 11-28 15:46:40.163016   920  1090 V AlarmManager: sending alarm Alarm{92ddf3e type 1 when 1511855198951 com.android.wakeupdemo} success 
3,681: 11-28 15:46:40.122116   920  1090 V AlarmManager: sending alarm Alarm{e4b4fd type 1 when 1511854898951 com.android.wakeupdemo} success 

解决方案

本测试是在飞行模式下测试,要求平均待机电流在 4mA 下,该广播的主要作用是刷新时间控件,解决思路,没有联网的情况下,不进行定时设置或者延迟更新时间,不要太频繁。如果影响不大,甚至可以去除自定义广播

这篇关于SP91的待机功耗大到42mA(com.android.deskclock.ON_QUARTER_HOUR)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/685065

相关文章

Android实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

Android平台播放RTSP流的几种方案探究(VLC VS ExoPlayer VS SmartPlayer)

技术背景 好多开发者需要遴选Android平台RTSP直播播放器的时候,不知道如何选的好,本文针对常用的方案,做个大概的说明: 1. 使用VLC for Android VLC Media Player(VLC多媒体播放器),最初命名为VideoLAN客户端,是VideoLAN品牌产品,是VideoLAN计划的多媒体播放器。它支持众多音频与视频解码器及文件格式,并支持DVD影音光盘,VCD影

android-opencv-jni

//------------------start opencv--------------------@Override public void onResume(){ super.onResume(); //通过OpenCV引擎服务加载并初始化OpenCV类库,所谓OpenCV引擎服务即是 //OpenCV_2.4.3.2_Manager_2.4_*.apk程序包,存

从状态管理到性能优化:全面解析 Android Compose

文章目录 引言一、Android Compose基本概念1.1 什么是Android Compose?1.2 Compose的优势1.3 如何在项目中使用Compose 二、Compose中的状态管理2.1 状态管理的重要性2.2 Compose中的状态和数据流2.3 使用State和MutableState处理状态2.4 通过ViewModel进行状态管理 三、Compose中的列表和滚动

Android 10.0 mtk平板camera2横屏预览旋转90度横屏拍照图片旋转90度功能实现

1.前言 在10.0的系统rom定制化开发中,在进行一些平板等默认横屏的设备开发的过程中,需要在进入camera2的 时候,默认预览图像也是需要横屏显示的,在上一篇已经实现了横屏预览功能,然后发现横屏预览后,拍照保存的图片 依然是竖屏的,所以说同样需要将图片也保存为横屏图标了,所以就需要看下mtk的camera2的相关横屏保存图片功能, 如何实现实现横屏保存图片功能 如图所示: 2.mtk

android应用中res目录说明

Android应用的res目录是一个特殊的项目,该项目里存放了Android应用所用的全部资源,包括图片、字符串、颜色、尺寸、样式等,类似于web开发中的public目录,js、css、image、style。。。。 Android按照约定,将不同的资源放在不同的文件夹中,这样可以方便的让AAPT(即Android Asset Packaging Tool , 在SDK的build-tools目

Android fill_parent、match_parent、wrap_content三者的作用及区别

这三个属性都是用来适应视图的水平或者垂直大小,以视图的内容或尺寸为基础的布局,比精确的指定视图的范围更加方便。 1、fill_parent 设置一个视图的布局为fill_parent将强制性的使视图扩展至它父元素的大小 2、match_parent 和fill_parent一样,从字面上的意思match_parent更贴切一些,于是从2.2开始,两个属性都可以使用,但2.3版本以后的建议使

Android Environment 获取的路径问题

1. 以获取 /System 路径为例 /*** Return root of the "system" partition holding the core Android OS.* Always present and mounted read-only.*/public static @NonNull File getRootDirectory() {return DIR_ANDR

消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法

消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法   消除安卓SDK更新时的“https://dl-ssl.google.com refused”异常的方法 [转载]原地址:http://blog.csdn.net/x605940745/article/details/17911115 消除SDK更新时的“

Android逆向(反调,脱壳,过ssl证书脚本)

文章目录 总结 基础Android基础工具 定位关键代码页面activity定位数据包参数定位堆栈追踪 编写反调脱壳好用的脚本过ssl证书校验抓包反调的脚本打印堆栈bilibili反调的脚本 总结 暑假做了两个月的Android逆向,记录一下自己学到的东西。对于app渗透有了一些思路。 这两个月主要做的是代码分析,对于分析完后的持久化等没有学习。主要是如何反编译源码,如何找到