BugReport中的App Processor wakeup字段意义

news/2024/10/5 8:00:29/

一、功耗字段意义:

App processor wakeup:Netd基于xt_idletimer 待机下监视网络设备的收发工作状态,即当设备发生联网从休眠态变成为唤醒态时,会记录打醒者的uid(uid大于0)和网络类型(wifi或数据类型)、时间戳

实际日志:我们在BugReport主要也是在设备待机休眠中,alarm+联网心跳的应用会触发AppProcessorWakeup事件。即只要能在设备休眠时,发生网络事件使系统的休眠状态被打破,就会被Netd标记上报给battery stats. 除了待机的长链接心跳联网包外,微信给灭屏待机的手机发消息或三方push联网也会触发该事件

二、相关源码

2.1 代码流程图

0

2.2 联网事件

xt_idletimer 的 uevent 消息与 IdlertimerController 有关,主要用来监视网络设备的收发工作状态。当对应设备工作或空闲时间超过设置的监控时间后【wifi网络默认15秒,数据网络默认15秒超时监测】, Kernel将会发送携带其状态(idle或active)的UEvent消息。

android/qssi/system/netd/server/NetlinkHandler.cpp

void NetlinkHandler::onEvent(NetlinkEvent *evt) {    const char *subsys = evt->getSubsystem();    if (!subsys) {        ALOGW("No subsystem found in netlink event");        return;    }         //处理对应 NETLINK_KOBJECT_UEVENT和 NETLINK_ROUTE 的消息    if (!strcmp(subsys, "net")) {        int action = evt->getAction();        const char *iface = evt->findParam("INTERFACE");//查找消息中携带的网络设备名         if (action == evt->NlActionAdd) {            notifyInterfaceAdded(iface); //添加NIC(Network Interface Card)的消息        } else if (action == evt->NlActionRemove) {            notifyInterfaceRemoved(iface);        //NIC被移除的消息        } else if (action == evt->NlActionChange) {            evt->dump();            notifyInterfaceChanged("nana", true); //NIC变化消息        } else if (action == evt->NlActionLinkUp) { //下面两个消息来自 NETLINK_ROUTE            notifyInterfaceLinkChanged(iface, true);        //链路启用(类此插网线)        } else if (action == evt->NlActionLinkDown) {            notifyInterfaceLinkChanged(iface, false);        //链路断开(类似拔网线)        } else if (action == evt->NlActionAddressUpdated ||                   action == evt->NlActionAddressRemoved) {            const char *address = evt->findParam("ADDRESS");            const char *flags = evt->findParam("FLAGS");            const char *scope = evt->findParam("SCOPE");            if (action == evt->NlActionAddressRemoved && iface && address) {                int resetMask = strchr(address, ':') ? RESET_IPV6_ADDRESSES : RESET_IPV4_ADDRESSES;                resetMask |= RESET_IGNORE_INTERFACE_ADDRESS;                if (int ret = ifc_reset_connections(iface, resetMask)) {                    ALOGE("ifc_reset_connections failed on iface %s for address %s (%s)", iface,                          address, strerror(ret));                }            }            if (iface && flags && scope) {                notifyAddressChanged(action, address, iface, flags, scope);            }        } else if (action == evt->NlActionRdnss) {            const char *lifetime = evt->findParam("LIFETIME");            const char *servers = evt->findParam("SERVERS");            if (lifetime && servers) {                notifyInterfaceDnsServers(iface, lifetime, servers);            }        } else if (action == evt->NlActionRouteUpdated ||                   action == evt->NlActionRouteRemoved) {            const char *route = evt->findParam("ROUTE");            const char *gateway = evt->findParam("GATEWAY");            const char *iface = evt->findParam("INTERFACE");            if (route && (gateway || iface)) {                notifyRouteChange(action, route, gateway, iface);            }        }     } else if (!strcmp(subsys, "qlog")) {        //对应 NETLINK_NFLOG        const char *alertName = evt->findParam("ALERT_NAME");        const char *iface = evt->findParam("INTERFACE");        notifyQuotaLimitReached(alertName, iface);                //当数据量超过预警值,则会收到该通知    //idletimer:用于跟踪某个 NIC[网络接口]的工作状态,即idle或active,检测时间按秒计算    } else if (!strcmp(subsys, "xt_idletimer")) {        const char *label = evt->findParam("INTERFACE");        const char *state = evt->findParam("STATE");        const char *timestamp = evt->findParam("TIME_NS");        if (state)            notifyInterfaceClassActivity(label, !strcmp("active", state), timestamp); #if !LOG_NDEBUG    } else if (strcmp(subsys, "platform") && strcmp(subsys, "backlight")) {        /* It is not a VSYNC or a backlight event */        ALOGV("unexpected event from subsystem %s", subsys);#endif    }}

2.3 BatteryStats统计

AppProcessorWakeup特征:联网时,存在休眠态-> 唤醒态时才统计

void NetlinkHandler::onEvent(NetlinkEvent *evt) {    const char *subsys = evt->getSubsystem();    if (!subsys) {        ALOGW("No subsystem found in netlink event");        return;    }         //处理对应 NETLINK_KOBJECT_UEVENT和 NETLINK_ROUTE 的消息    if (!strcmp(subsys, "net")) {        int action = evt->getAction();        const char *iface = evt->findParam("INTERFACE");//查找消息中携带的网络设备名         if (action == evt->NlActionAdd) {            notifyInterfaceAdded(iface); //添加NIC(Network Interface Card)的消息        } else if (action == evt->NlActionRemove) {            notifyInterfaceRemoved(iface);        //NIC被移除的消息        } else if (action == evt->NlActionChange) {            evt->dump();            notifyInterfaceChanged("nana", true); //NIC变化消息        } else if (action == evt->NlActionLinkUp) { //下面两个消息来自 NETLINK_ROUTE            notifyInterfaceLinkChanged(iface, true);        //链路启用(类此插网线)        } else if (action == evt->NlActionLinkDown) {            notifyInterfaceLinkChanged(iface, false);        //链路断开(类似拔网线)        } else if (action == evt->NlActionAddressUpdated ||                   action == evt->NlActionAddressRemoved) {            const char *address = evt->findParam("ADDRESS");            const char *flags = evt->findParam("FLAGS");            const char *scope = evt->findParam("SCOPE");            if (action == evt->NlActionAddressRemoved && iface && address) {                int resetMask = strchr(address, ':') ? RESET_IPV6_ADDRESSES : RESET_IPV4_ADDRESSES;                resetMask |= RESET_IGNORE_INTERFACE_ADDRESS;                if (int ret = ifc_reset_connections(iface, resetMask)) {                    ALOGE("ifc_reset_connections failed on iface %s for address %s (%s)", iface,                          address, strerror(ret));                }            }            if (iface && flags && scope) {                notifyAddressChanged(action, address, iface, flags, scope);            }        } else if (action == evt->NlActionRdnss) {            const char *lifetime = evt->findParam("LIFETIME");            const char *servers = evt->findParam("SERVERS");            if (lifetime && servers) {                notifyInterfaceDnsServers(iface, lifetime, servers);            }        } else if (action == evt->NlActionRouteUpdated ||                   action == evt->NlActionRouteRemoved) {            const char *route = evt->findParam("ROUTE");            const char *gateway = evt->findParam("GATEWAY");            const char *iface = evt->findParam("INTERFACE");            if (route && (gateway || iface)) {                notifyRouteChange(action, route, gateway, iface);            }        }     } else if (!strcmp(subsys, "qlog")) {        //对应 NETLINK_NFLOG        const char *alertName = evt->findParam("ALERT_NAME");        const char *iface = evt->findParam("INTERFACE");        notifyQuotaLimitReached(alertName, iface);                //当数据量超过预警值,则会收到该通知    //idletimer:用于跟踪某个 NIC[网络接口]的工作状态,即idle或active,检测时间按秒计算    } else if (!strcmp(subsys, "xt_idletimer")) {        const char *label = evt->findParam("INTERFACE");        const char *state = evt->findParam("STATE");        const char *timestamp = evt->findParam("TIME_NS");        if (state)            notifyInterfaceClassActivity(label, !strcmp("active", state), timestamp); #if !LOG_NDEBUG    } else if (strcmp(subsys, "platform") && strcmp(subsys, "backlight")) {        /* It is not a VSYNC or a backlight event */        ALOGV("unexpected event from subsystem %s", subsys);#endif    }}

三、相关日志

0

0

0

四、文档参考

Android系统中iptables的应用(五)IdlertimerController_idletimer iptables-CSDN博客 Android系统中iptables的应用(五)IdlertimerController

Netd工作流程_does drops in forward by default-CSDN博客 Netd工作流程


http://www.ppmy.cn/news/1534840.html

相关文章

基于MATLAB的安全帽检测系统

课题名称 课题介绍 众所周知,在一些施工工地,必须明确佩戴安全帽。可以对生命安全起到保障作用。该课题为常见的安全帽的识别,主要分为红色,蓝色,黄色三类安全帽。而安全帽的主要是红色,蓝色&…

UFS 3.1架构简介

整个UFS协议栈可以分为三层:应用层(UFS Application Layer(UAP)),传输层(UFS Transport Layer(UTP)),链路层(UIC InterConnect Layer(UIC))。应用层发出SCSI命令(UFS没有自己的命令使用的是简化的SCSI命令),在传输层将SCSI分装为UPIU,再经过链路层将命令发送给Devices。下…

高通芯片手机查看空口消息工具:QCAT

关于QCAT的作用,之前一直理解的不够,最近查看了GSM网络协议,有进一步理解,记录如下:结论:QCAT是查看空口消息的工具。 一:背景知识。 1. 在GSM 网络协议中,手机设备(MS:mobile stati…

做数据抓取工作要如何选择ip池

选择合适的IP池对于数据抓取工作至关重要。一个优质的IP池可以提高抓取的效率和成功率,同时减少被目标网站封禁的风险。以下是选择IP池时需要考虑的一些关键因素: 1. IP类型 住宅IP:住宅IP通常来自真实用户,难以被识别为代理。它…

pytorch张量基础

好的,为了编写一篇全面且详细的指南,涵盖 PyTorch 中张量的所有知识,并为学习机器学习和深度学习打好基础,我将会提供一个结构化的内容,包括基础知识、进阶知识、实际应用和一些优化技巧。这个文档大纲如下&#xff1a…

从零开始:SpringBoot实现古典舞在线交流平台

第二章 相关技术介绍 2.1Java技术 Java是一种非常常用的编程语言,在全球编程语言排行版上总是前三。在方兴未艾的计算机技术发展历程中,Java的身影无处不在,并且拥有旺盛的生命力。Java的跨平台能力十分强大,只需一次编译&#xf…

CNN模型对CIFAR-10中的图像进行分类

代码功能 这段代码展示了如何使用 Keras 和 TensorFlow 构建一个卷积神经网络(CNN)模型,用于对 CIFAR-10 数据集中的图像进行分类。主要功能包括: 加载数据:从 CIFAR-10 数据集加载训练和测试图像。 数据预处理&#…

鸿蒙HarmonyOS之选择相册文件(照片/视频)方法

一、新建文件工具类FileUtil.ets 包含:选择照片方法、获取文件类型方法、去除后缀、获取后缀方法 import { BusinessError, request } from kit.BasicServicesKit; import photoAccessHelper from ohos.file.photoAccessHelper; import bundleManager from ohos.b…