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

Commit eb71e821 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [5704859, 5705300, 5704034, 5704195, 5705082, 5704058,...

Merge cherrypicks of [5704859, 5705300, 5704034, 5704195, 5705082, 5704058, 5704059, 5704932, 5705340, 5705341, 5705342, 5705343, 5705344, 5705361, 5705362, 5705363, 5705364, 5704870, 5704196, 5705083, 5701785, 5701786, 5701787, 5704035, 5705261, 5705281, 5704036, 5704037, 5704038, 5704871, 5704933, 5704872, 5705347, 5705262, 5704934] into pi-qpr2-release

Change-Id: Ifb7d048c4deb34b18e69173fd09e91c45980e2d9
parents 18ac0c6f b5dee1ba
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.bluetooth;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.EventLog;


/**
@@ -30,6 +31,8 @@ import android.os.Parcelable;
 */
public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {

    private static final int MAX_DESCRIPTOR_SIZE = 2048;

    private final String mName;
    private final String mDescription;
    private final String mProvider;
@@ -55,6 +58,12 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
        mDescription = description;
        mProvider = provider;
        mSubclass = subclass;

        if (descriptors == null || descriptors.length > MAX_DESCRIPTOR_SIZE) {
            EventLog.writeEvent(0x534e4554, "119819889", -1, "");
            throw new IllegalArgumentException("descriptors must be not null and shorter than "
                    + MAX_DESCRIPTOR_SIZE);
        }
        mDescriptors = descriptors.clone();
    }

+17 −7
Original line number Diff line number Diff line
@@ -776,14 +776,19 @@ public class NetworkStats implements Parcelable {
     * packet needs to be subtracted from the root UID on the base interface both for tx
     * and rx traffic (http://b/12249687, http:/b/33681750).
     *
     * As for eBPF, the per uid stats is collected by different hook, the rx packets on base
     * interface will not be counted. Thus, the adjustment on root uid is only needed in tx
     * direction.
     *
     * <p>This method will behave fine if {@code stackedIfaces} is an non-synchronized but add-only
     * {@code ConcurrentHashMap}
     * @param baseTraffic Traffic on the base interfaces. Will be mutated.
     * @param stackedTraffic Stats with traffic stacked on top of our ifaces. Will also be mutated.
     * @param stackedIfaces Mapping ipv6if -> ipv4if interface where traffic is counted on both.
     * @param useBpfStats True if eBPF is in use.
     */
    public static void apply464xlatAdjustments(NetworkStats baseTraffic,
            NetworkStats stackedTraffic, Map<String, String> stackedIfaces) {
            NetworkStats stackedTraffic, Map<String, String> stackedIfaces, boolean useBpfStats) {
        // Total 464xlat traffic to subtract from uid 0 on all base interfaces.
        // stackedIfaces may grow afterwards, but NetworkStats will just be resized automatically.
        final NetworkStats adjustments = new NetworkStats(0, stackedIfaces.size());
@@ -802,15 +807,20 @@ public class NetworkStats implements Parcelable {
                continue;
            }
            // Subtract any 464lat traffic seen for the root UID on the current base interface.
            // However, for eBPF, the per uid stats is collected by different hook, the rx packets
            // on base interface will not be counted. Thus, the adjustment on root uid is only
            // needed in tx direction.
            adjust.iface = baseIface;
            if (!useBpfStats) {
                adjust.rxBytes = -(entry.rxBytes + entry.rxPackets * IPV4V6_HEADER_DELTA);
            adjust.txBytes = -(entry.txBytes + entry.txPackets * IPV4V6_HEADER_DELTA);
                adjust.rxPackets = -entry.rxPackets;
            }
            adjust.txBytes = -(entry.txBytes + entry.txPackets * IPV4V6_HEADER_DELTA);
            adjust.txPackets = -entry.txPackets;
            adjustments.combineValues(adjust);

            // For 464xlat traffic, xt_qtaguid only counts the bytes of the native IPv4 packet sent
            // on the stacked interface with prefix "v4-" and drops the IPv6 header size after
            // For 464xlat traffic, per uid stats only counts the bytes of the native IPv4 packet
            // sent on the stacked interface with prefix "v4-" and drops the IPv6 header size after
            // unwrapping. To account correctly for on-the-wire traffic, add the 20 additional bytes
            // difference for all packets (http://b/12249687, http:/b/33681750).
            entry.rxBytes += entry.rxPackets * IPV4V6_HEADER_DELTA;
@@ -829,8 +839,8 @@ public class NetworkStats implements Parcelable {
     * base and stacked traffic.
     * @param stackedIfaces Mapping ipv6if -> ipv4if interface where traffic is counted on both.
     */
    public void apply464xlatAdjustments(Map<String, String> stackedIfaces) {
        apply464xlatAdjustments(this, this, stackedIfaces);
    public void apply464xlatAdjustments(Map<String, String> stackedIfaces, boolean useBpfStats) {
        apply464xlatAdjustments(this, this, stackedIfaces, useBpfStats);
    }

    /**
+5 −4
Original line number Diff line number Diff line
@@ -113,11 +113,12 @@ public class NetworkStatsFactory {

    /**
     * Applies 464xlat adjustments with ifaces noted with {@link #noteStackedIface(String, String)}.
     * @see NetworkStats#apply464xlatAdjustments(NetworkStats, NetworkStats, Map)
     * @see NetworkStats#apply464xlatAdjustments(NetworkStats, NetworkStats, Map, boolean)
     */
    public static void apply464xlatAdjustments(NetworkStats baseTraffic,
            NetworkStats stackedTraffic) {
        NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, sStackedIfaces);
            NetworkStats stackedTraffic, boolean useBpfStats) {
        NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, sStackedIfaces,
                useBpfStats);
    }

    @VisibleForTesting
@@ -263,7 +264,7 @@ public class NetworkStatsFactory {

        // No locking here: apply464xlatAdjustments behaves fine with an add-only ConcurrentHashMap.
        // TODO: remove this and only apply adjustments in NetworkStatsService.
        stats.apply464xlatAdjustments(sStackedIfaces);
        stats.apply464xlatAdjustments(sStackedIfaces, mUseBpfStats);

        return stats;
    }
+2 −2
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ static int legacyReadNetworkStatsDetail(std::vector<stats_line>* lines,
            }
        }
        s.tag = rawTag >> 32;
        if (limitTag != -1 && s.tag != limitTag) {
        if (limitTag != -1 && s.tag != static_cast<uint32_t>(limitTag)) {
            //ALOGI("skipping due to tag: %s", buffer);
            continue;
        }
@@ -188,7 +188,7 @@ static int legacyReadNetworkStatsDetail(std::vector<stats_line>* lines,
        if (sscanf(pos, "%u %u %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64,
                &s.uid, &s.set, &s.rxBytes, &s.rxPackets,
                &s.txBytes, &s.txPackets) == 6) {
            if (limitUid != -1 && limitUid != s.uid) {
            if (limitUid != -1 && static_cast<uint32_t>(limitUid) != s.uid) {
                //ALOGI("skipping due to uid: %s", buffer);
                continue;
            }
+8 −0
Original line number Diff line number Diff line
@@ -8768,6 +8768,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public boolean isAppForeground(int uid) {
        int callerUid = Binder.getCallingUid();
        if (UserHandle.isCore(callerUid) || callerUid == uid) {
            return isAppForegroundInternal(uid);
        }
        return false;
    }
    private boolean isAppForegroundInternal(int uid) {
        synchronized (this) {
            UidRecord uidRec = mActiveUids.get(uid);
            if (uidRec == null || uidRec.idle) {
Loading