下载事件统计,添加该游戏已安装数
This commit is contained in:
@ -26,14 +26,12 @@ public class TrafficUtils {
|
||||
synchronized (TrafficUtils.class) {
|
||||
if (instance == null) {
|
||||
instance = new TrafficUtils(context);
|
||||
if (update)
|
||||
instance.update();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (update)
|
||||
if (update) {
|
||||
instance.update();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -47,9 +45,7 @@ public class TrafficUtils {
|
||||
// 获取所有的安装在手机上的应用软件的信息,并且获取这些软件里面的权限信息
|
||||
PackageManager pm = context.getPackageManager();// 获取系统应用包管理
|
||||
// 获取每个包内的androidmanifest.xml信息,它的权限等等
|
||||
List<PackageInfo> pinfos = pm
|
||||
.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES
|
||||
| PackageManager.GET_PERMISSIONS);
|
||||
List<PackageInfo> pinfos = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
|
||||
// 遍历每个应用包信息
|
||||
for (PackageInfo info : pinfos) {
|
||||
// 请求每个程序包对应的androidManifest.xml里面的权限
|
||||
@ -64,9 +60,7 @@ public class TrafficUtils {
|
||||
long rx = TrafficStats.getUidRxBytes(uId);
|
||||
// 如果返回-1,代表不支持使用该方法,注意必须是2.2以上的
|
||||
long tx = TrafficStats.getUidTxBytes(uId);
|
||||
if (rx < 0 || tx < 0) {
|
||||
continue;
|
||||
} else {
|
||||
if (rx >= 0 && tx >= 0) {
|
||||
db.update(info.packageName, rx + tx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user