TrafficStats具体应用 - 特定的网络接口接口、具体、网络、TrafficStats

由网友(黎铁塔下の那抹阳光)分享简介:我知道我可以使用trafficstats API以下方法来获取发送的字节和针对任何给定应用程序所有的网络接口接收。但是,如何才能获得唯一的移动统计?所以,我可以单独移动和WiFi数据。I know I can use the following methods of trafficstats api to get b...

我知道我可以使用trafficstats API以下方法来获取发送的字节和针对任何给定应用程序所有的网络接口接收。但是,如何才能获得唯一的移动统计?所以,我可以单独移动和WiFi数据。

I know I can use the following methods of trafficstats api to get bytes sent and received for ALL network interfaces for any given app. But how do I get stats for only mobile? So that I can seperate mobile and wifi data.

getUidTxBytes(INT UID)结果  获得通过发送的字节数  网络这个UID。

getUidTxBytes(int uid) Get the number of bytes sent through the network for this UID.

getUidRxBytes(INT UID)结果  获得通过所接收的字节数  网络这个UID。

getUidRxBytes(int uid) Get the number of bytes received through the network for this UID.

好像这样的事情是从API失踪。和其他方式得到它getUidMobileRxBytes(INT UID)

Seems like something like this is missing from API. And other way to get it getUidMobileRxBytes(int uid)

推荐答案

很抱歉,但你只能得到每个接口的统计整个设备,而不是每个UID。

Sorry, but you can only get per-interface stats for the entire device, not per UID.

您可以按接口,每个UID统计所收集的所有接口,每个UID统计和每个接口,整个设备的统计两者,则假定接口为整个设备的比例是估算约,这将是该个体的UID的比率。对短的时间跨度,这很可能是相当准确的,因为设备将只周期性地开关接口

You can estimate per-interface, per-UID stats by collecting both the all-interface, per-UID stats and the per-interface, whole-device stats, then assuming that the ratio of the interfaces for the whole device is approximately the ratio that would be for that individual UID. For short time spans, this is likely to be fairly accurate, as the device will only switch interfaces periodically.

阅读全文

相关推荐

最新文章