diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-11-26 18:42:25 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-11-26 18:42:25 +0000 |
commit | d62ebc451beaa7e53810250724e775399de30502 (patch) | |
tree | f15092f99dcdd1abdabbe409605773a257813db7 | |
parent | 9a6381bcb488dae3e3ecf93939d180b520df999d (diff) | |
parent | 294484563c94eedd70f8dd53d134d701a1d6e9cb (diff) | |
download | base-d62ebc451beaa7e53810250724e775399de30502.tar.gz |
Snap for 5140444 from 294484563c94eedd70f8dd53d134d701a1d6e9cb to pi-qpr2-release
Change-Id: Iae8b94ce89b79e0e3fd9f0e2daf7d186660f2df9
8 files changed, 41 insertions, 94 deletions
diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 4bcc2453689d..edf9bc1c6b39 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -776,19 +776,14 @@ 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, boolean useBpfStats) { + NetworkStats stackedTraffic, Map<String, String> stackedIfaces) { // 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()); @@ -807,20 +802,15 @@ 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.rxPackets = -entry.rxPackets; - } + adjust.rxBytes = -(entry.rxBytes + entry.rxPackets * IPV4V6_HEADER_DELTA); adjust.txBytes = -(entry.txBytes + entry.txPackets * IPV4V6_HEADER_DELTA); + adjust.rxPackets = -entry.rxPackets; adjust.txPackets = -entry.txPackets; adjustments.combineValues(adjust); - // 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 + // 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 // 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; @@ -839,8 +829,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, boolean useBpfStats) { - apply464xlatAdjustments(this, this, stackedIfaces, useBpfStats); + public void apply464xlatAdjustments(Map<String, String> stackedIfaces) { + apply464xlatAdjustments(this, this, stackedIfaces); } /** diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index f86a6f6ce7d2..de25fd214d48 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -227,6 +227,8 @@ public class Build { * increase when the hardware manufacturer provides an OTA update. * <p> * Possible values are defined in {@link Build.VERSION_CODES}. + * + * @see #FIRST_SDK_INT */ public static final int SDK_INT = SystemProperties.getInt( "ro.build.version.sdk", 0); diff --git a/core/java/com/android/internal/net/NetworkStatsFactory.java b/core/java/com/android/internal/net/NetworkStatsFactory.java index b3cf389c1bb9..c4d08c7dc5d6 100644 --- a/core/java/com/android/internal/net/NetworkStatsFactory.java +++ b/core/java/com/android/internal/net/NetworkStatsFactory.java @@ -113,12 +113,11 @@ public class NetworkStatsFactory { /** * Applies 464xlat adjustments with ifaces noted with {@link #noteStackedIface(String, String)}. - * @see NetworkStats#apply464xlatAdjustments(NetworkStats, NetworkStats, Map, boolean) + * @see NetworkStats#apply464xlatAdjustments(NetworkStats, NetworkStats, Map) */ public static void apply464xlatAdjustments(NetworkStats baseTraffic, - NetworkStats stackedTraffic, boolean useBpfStats) { - NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, sStackedIfaces, - useBpfStats); + NetworkStats stackedTraffic) { + NetworkStats.apply464xlatAdjustments(baseTraffic, stackedTraffic, sStackedIfaces); } @VisibleForTesting @@ -264,7 +263,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, mUseBpfStats); + stats.apply464xlatAdjustments(sStackedIfaces); return stats; } diff --git a/core/jni/com_android_internal_net_NetworkStatsFactory.cpp b/core/jni/com_android_internal_net_NetworkStatsFactory.cpp index de3a78a61a7e..c15b7ee4fe04 100644 --- a/core/jni/com_android_internal_net_NetworkStatsFactory.cpp +++ b/core/jni/com_android_internal_net_NetworkStatsFactory.cpp @@ -175,7 +175,7 @@ static int legacyReadNetworkStatsDetail(std::vector<stats_line>* lines, } } s.tag = rawTag >> 32; - if (limitTag != -1 && s.tag != static_cast<uint32_t>(limitTag)) { + if (limitTag != -1 && s.tag != 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 && static_cast<uint32_t>(limitUid) != s.uid) { + if (limitUid != -1 && limitUid != s.uid) { //ALOGI("skipping due to uid: %s", buffer); continue; } diff --git a/media/java/android/media/audiofx/AudioEffect.java b/media/java/android/media/audiofx/AudioEffect.java index 5a1a1fca4320..24c595f5594e 100644 --- a/media/java/android/media/audiofx/AudioEffect.java +++ b/media/java/android/media/audiofx/AudioEffect.java @@ -982,7 +982,7 @@ public class AudioEffect { // -------------------- /** * The OnEnableStatusChangeListener interface defines a method called by the AudioEffect - * when the enabled state of the effect engine was changed by the controlling application. + * when a the enabled state of the effect engine was changed by the controlling application. */ public interface OnEnableStatusChangeListener { /** @@ -996,7 +996,7 @@ public class AudioEffect { /** * The OnControlStatusChangeListener interface defines a method called by the AudioEffect - * when control of the effect engine is gained or lost by the application + * when a the control of the effect engine is gained or lost by the application */ public interface OnControlStatusChangeListener { /** diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index a1d42c091334..10707b255c29 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8768,14 +8768,6 @@ 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) { diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java index 17ab29d74790..9bf3874088d7 100644 --- a/services/core/java/com/android/server/net/NetworkStatsService.java +++ b/services/core/java/com/android/server/net/NetworkStatsService.java @@ -1622,8 +1622,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // fold tethering stats and operations into uid snapshot final NetworkStats tetherSnapshot = getNetworkStatsTethering(STATS_PER_UID); tetherSnapshot.filter(UID_ALL, ifaces, TAG_ALL); - NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, tetherSnapshot, - mUseBpfTrafficStats); + NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, tetherSnapshot); uidSnapshot.combineAllValues(tetherSnapshot); final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService( @@ -1633,8 +1632,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { final NetworkStats vtStats = telephonyManager.getVtDataUsage(STATS_PER_UID); if (vtStats != null) { vtStats.filter(UID_ALL, ifaces, TAG_ALL); - NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, vtStats, - mUseBpfTrafficStats); + NetworkStatsFactory.apply464xlatAdjustments(uidSnapshot, vtStats); uidSnapshot.combineAllValues(vtStats); } diff --git a/tests/net/java/android/net/NetworkStatsTest.java b/tests/net/java/android/net/NetworkStatsTest.java index d6dbf5aaa9d8..8f18d072a0bb 100644 --- a/tests/net/java/android/net/NetworkStatsTest.java +++ b/tests/net/java/android/net/NetworkStatsTest.java @@ -39,7 +39,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import android.net.NetworkStats.Entry; import android.os.Process; import android.support.test.runner.AndroidJUnit4; import android.support.test.filters.SmallTest; @@ -786,38 +785,7 @@ public class NetworkStatsTest { ArrayMap<String, String> stackedIface = new ArrayMap<>(); stackedIface.put(v4Iface, baseIface); - // Ipv4 traffic sent/received by an app on stacked interface. - final NetworkStats.Entry appEntry = new NetworkStats.Entry( - v4Iface, appUid, SET_DEFAULT, TAG_NONE, - 30501490 /* rxBytes */, - 22401 /* rxPackets */, - 876235 /* txBytes */, - 13805 /* txPackets */, - 0 /* operations */); - - // Traffic measured for the root uid on the base interface if eBPF is in use. - // Incorrectly includes appEntry's bytes and packets, plus IPv4-IPv6 translation - // overhead (20 bytes per packet), only for TX traffic. - final NetworkStats.Entry ebpfRootUidEntry = new NetworkStats.Entry( - baseIface, rootUid, SET_DEFAULT, TAG_NONE, - 163577 /* rxBytes */, - 187 /* rxPackets */, - 1169942 /* txBytes */, - 13902 /* txPackets */, - 0 /* operations */); - - // Traffic measured for the root uid on the base interface if xt_qtaguid is in use. - // Incorrectly includes appEntry's bytes and packets, plus IPv4-IPv6 translation - // overhead (20 bytes per packet), in both directions. - final NetworkStats.Entry xtRootUidEntry = new NetworkStats.Entry( - baseIface, rootUid, SET_DEFAULT, TAG_NONE, - 31113087 /* rxBytes */, - 22588 /* rxPackets */, - 1169942 /* txBytes */, - 13902 /* txPackets */, - 0 /* operations */); - - final NetworkStats.Entry otherEntry = new NetworkStats.Entry( + NetworkStats.Entry otherEntry = new NetworkStats.Entry( otherIface, appUid, SET_DEFAULT, TAG_NONE, 2600 /* rxBytes */, 2 /* rxPackets */, @@ -825,41 +793,39 @@ public class NetworkStatsTest { 3 /* txPackets */, 0 /* operations */); - final NetworkStats statsXt = new NetworkStats(TEST_START, 3) - .addValues(appEntry) - .addValues(xtRootUidEntry) - .addValues(otherEntry); - - final NetworkStats statsEbpf = new NetworkStats(TEST_START, 3) - .addValues(appEntry) - .addValues(ebpfRootUidEntry) + NetworkStats stats = new NetworkStats(TEST_START, 3) + .addValues(v4Iface, appUid, SET_DEFAULT, TAG_NONE, + 30501490 /* rxBytes */, + 22401 /* rxPackets */, + 876235 /* txBytes */, + 13805 /* txPackets */, + 0 /* operations */) + .addValues(baseIface, rootUid, SET_DEFAULT, TAG_NONE, + 31113087, + 22588, + 1169942, + 13902, + 0) .addValues(otherEntry); - statsXt.apply464xlatAdjustments(stackedIface, false); - statsEbpf.apply464xlatAdjustments(stackedIface, true); + stats.apply464xlatAdjustments(stackedIface); - assertEquals(3, statsXt.size()); - assertEquals(3, statsEbpf.size()); - final NetworkStats.Entry expectedAppUid = new NetworkStats.Entry( - v4Iface, appUid, SET_DEFAULT, TAG_NONE, + assertEquals(3, stats.size()); + assertValues(stats, 0, v4Iface, appUid, SET_DEFAULT, TAG_NONE, + METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 30949510, 22401, 1152335, 13805, 0); - final NetworkStats.Entry expectedRootUid = new NetworkStats.Entry( - baseIface, 0, SET_DEFAULT, TAG_NONE, + assertValues(stats, 1, baseIface, 0, SET_DEFAULT, TAG_NONE, + METERED_NO, ROAMING_NO, DEFAULT_NETWORK_NO, 163577, 187, 17607, 97, 0); - assertEquals(expectedAppUid, statsXt.getValues(0, null)); - assertEquals(expectedRootUid, statsXt.getValues(1, null)); - assertEquals(otherEntry, statsXt.getValues(2, null)); - assertEquals(expectedAppUid, statsEbpf.getValues(0, null)); - assertEquals(expectedRootUid, statsEbpf.getValues(1, null)); - assertEquals(otherEntry, statsEbpf.getValues(2, null)); + assertEquals(otherEntry, stats.getValues(2, null)); } @Test @@ -884,7 +850,7 @@ public class NetworkStatsTest { .addValues(secondEntry); // Empty map: no adjustment - stats.apply464xlatAdjustments(new ArrayMap<>(), false); + stats.apply464xlatAdjustments(new ArrayMap<>()); assertEquals(2, stats.size()); assertEquals(firstEntry, stats.getValues(0, null)); |