Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73d7775f authored by Junyu Lai's avatar Junyu Lai Committed by Android (Google) Code Review
Browse files

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

parents e9fbacf6 592c6055
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -4886,8 +4886,6 @@ message MobileBytesTransfer {
    optional int64 tx_bytes = 4;

    optional int64 tx_packets = 5;

    optional int32 rat_type = 6;
}

/**
@@ -4910,8 +4908,6 @@ message MobileBytesTransferByFgBg {
    optional int64 tx_bytes = 5;

    optional int64 tx_packets = 6;

    optional int32 rat_type = 7;
}

/**
+16 −25
Original line number Diff line number Diff line
@@ -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.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
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.Process.getUidForPid;
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) {
        final NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
        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 */);
        return StatsManager.PULL_SUCCESS;
    }
        return StatsManager.PULL_SKIP;
    }

    private int pullMobileBytesTransfer(
            int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) {
        int ret = StatsManager.PULL_SKIP;
        for (final int ratType : getAllCollapsedRatTypes()) {
        final NetworkTemplate template =
                    NetworkTemplate.buildTemplateMobileWithRatType(null, ratType);
                NetworkTemplate.buildTemplateMobileWithRatType(null, NETWORK_TYPE_ALL);
        final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg);
            if (stats != null) {
                addNetworkStats(atomTag, pulledData, stats, withFgbg, ratType);
                ret = StatsManager.PULL_SUCCESS; // If any of them is not null, then success.
            }
        }
        // If there is no data return PULL_SKIP to avoid wasting performance adding empty stats.
        return ret;

        // Return with PULL_SKIP to indicate there is an error.
        if (stats == null) return StatsManager.PULL_SKIP;

        addNetworkStats(atomTag, pulledData, stats, withFgbg, NETWORK_TYPE_ALL);
        return StatsManager.PULL_SUCCESS;
    }

    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.txBytes);
            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());
        }
    }