Merge "[SM17] Remove ratType field in MobileBytesTransfer(ByFgBg)" into rvc-dev

This commit is contained in:
Junyu Lai
2020-05-05 03:06:49 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 29 deletions

View File

@@ -4886,8 +4886,6 @@ message MobileBytesTransfer {
optional int64 tx_bytes = 4; optional int64 tx_bytes = 4;
optional int64 tx_packets = 5; optional int64 tx_packets = 5;
optional int32 rat_type = 6;
} }
/** /**
@@ -4910,8 +4908,6 @@ message MobileBytesTransferByFgBg {
optional int64 tx_bytes = 5; optional int64 tx_bytes = 5;
optional int64 tx_packets = 6; optional int64 tx_packets = 6;
optional int32 rat_type = 7;
} }
/** /**

View File

@@ -21,7 +21,7 @@ import static android.app.AppOpsManager.OP_FLAG_TRUSTED_PROXY;
import static android.app.usage.NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN; import static android.app.usage.NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN;
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED; import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS; import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS;
import static android.net.NetworkTemplate.getAllCollapsedRatTypes; import static android.net.NetworkTemplate.NETWORK_TYPE_ALL;
import static android.os.Debug.getIonHeapsSizeKb; import static android.os.Debug.getIonHeapsSizeKb;
import static android.os.Process.getUidForPid; import static android.os.Process.getUidForPid;
import static android.os.storage.VolumeInfo.TYPE_PRIVATE; import static android.os.storage.VolumeInfo.TYPE_PRIVATE;
@@ -726,27 +726,25 @@ public class StatsPullAtomService extends SystemService {
int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) { int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) {
final NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard(); final NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg); final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg);
if (stats != null) {
// Return with PULL_SKIP to indicate there is an error.
if (stats == null) return StatsManager.PULL_SKIP;
addNetworkStats(atomTag, pulledData, stats, withFgbg, 0 /* ratType */); addNetworkStats(atomTag, pulledData, stats, withFgbg, 0 /* ratType */);
return StatsManager.PULL_SUCCESS; return StatsManager.PULL_SUCCESS;
} }
return StatsManager.PULL_SKIP;
}
private int pullMobileBytesTransfer( private int pullMobileBytesTransfer(
int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) { int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) {
int ret = StatsManager.PULL_SKIP;
for (final int ratType : getAllCollapsedRatTypes()) {
final NetworkTemplate template = final NetworkTemplate template =
NetworkTemplate.buildTemplateMobileWithRatType(null, ratType); NetworkTemplate.buildTemplateMobileWithRatType(null, NETWORK_TYPE_ALL);
final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg); final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg);
if (stats != null) {
addNetworkStats(atomTag, pulledData, stats, withFgbg, ratType); // Return with PULL_SKIP to indicate there is an error.
ret = StatsManager.PULL_SUCCESS; // If any of them is not null, then success. if (stats == null) return StatsManager.PULL_SKIP;
}
} addNetworkStats(atomTag, pulledData, stats, withFgbg, NETWORK_TYPE_ALL);
// If there is no data return PULL_SKIP to avoid wasting performance adding empty stats. return StatsManager.PULL_SUCCESS;
return ret;
} }
private void addNetworkStats(int atomTag, @NonNull List<StatsEvent> ret, private void addNetworkStats(int atomTag, @NonNull List<StatsEvent> ret,
@@ -766,13 +764,6 @@ public class StatsPullAtomService extends SystemService {
e.writeLong(entry.rxPackets); e.writeLong(entry.rxPackets);
e.writeLong(entry.txBytes); e.writeLong(entry.txBytes);
e.writeLong(entry.txPackets); e.writeLong(entry.txPackets);
switch (atomTag) {
case FrameworkStatsLog.MOBILE_BYTES_TRANSFER:
case FrameworkStatsLog.MOBILE_BYTES_TRANSFER_BY_FG_BG:
e.writeInt(ratType);
break;
default:
}
ret.add(e.build()); ret.add(e.build());
} }
} }