replace CookieTagMapKey with S64
(mostly autogenerated, with minor tweaks to make it build) Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I2065c3fc6d4d37663a0a52281deb7624fd5c801d
This commit is contained in:
parent
84ac5ae4e7
commit
9ef3916ba4
8 changed files with 47 additions and 80 deletions
|
|
@ -33,8 +33,8 @@ import android.system.Os;
|
|||
import android.util.Pair;
|
||||
|
||||
import com.android.net.module.util.BpfDump;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
|
|
@ -56,11 +56,11 @@ public class SkDestroyListenerTest {
|
|||
private static final String LINE_DELIMITER = "\\n";
|
||||
private static final String DUMP_COMMAND = "dumpsys netstats --bpfRawMap --cookieTagMap";
|
||||
|
||||
private Map<CookieTagMapKey, CookieTagMapValue> parseBpfRawMap(final String dump) {
|
||||
final Map<CookieTagMapKey, CookieTagMapValue> map = new HashMap<>();
|
||||
private Map<S64, CookieTagMapValue> parseBpfRawMap(final String dump) {
|
||||
final Map<S64, CookieTagMapValue> map = new HashMap<>();
|
||||
for (final String line: dump.split(LINE_DELIMITER)) {
|
||||
final Pair<CookieTagMapKey, CookieTagMapValue> keyValue =
|
||||
BpfDump.fromBase64EncodedString(CookieTagMapKey.class,
|
||||
final Pair<S64, CookieTagMapValue> keyValue =
|
||||
BpfDump.fromBase64EncodedString(S64.class,
|
||||
CookieTagMapValue.class, line.trim());
|
||||
map.put(keyValue.first, keyValue.second);
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class SkDestroyListenerTest {
|
|||
|
||||
private int countTaggedSocket() {
|
||||
final String dump = runShellCommandOrThrow(DUMP_COMMAND);
|
||||
final Map<CookieTagMapKey, CookieTagMapValue> cookieTagMap = parseBpfRawMap(dump);
|
||||
final Map<S64, CookieTagMapValue> cookieTagMap = parseBpfRawMap(dump);
|
||||
int count = 0;
|
||||
for (final CookieTagMapValue value: cookieTagMap.values()) {
|
||||
if (value.tag == COOKIE_TAG && value.uid == Process.myUid()) {
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.net.module.util.bpf;
|
||||
|
||||
import com.android.net.module.util.Struct;
|
||||
import com.android.net.module.util.Struct.Field;
|
||||
import com.android.net.module.util.Struct.Type;
|
||||
|
||||
/**
|
||||
* Key for cookie tag map.
|
||||
*/
|
||||
public class CookieTagMapKey extends Struct {
|
||||
@Field(order = 0, type = Type.S64)
|
||||
public final long socketCookie;
|
||||
|
||||
public CookieTagMapKey(final long socketCookie) {
|
||||
this.socketCookie = socketCookie;
|
||||
}
|
||||
}
|
||||
|
|
@ -186,8 +186,8 @@ import com.android.net.module.util.SharedLog;
|
|||
import com.android.net.module.util.SkDestroyListener;
|
||||
import com.android.net.module.util.Struct;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.Struct.U8;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.netlink.InetDiagMessage;
|
||||
import com.android.net.module.util.netlink.StructInetDiagSockId;
|
||||
|
|
@ -455,7 +455,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||
*/
|
||||
private SparseIntArray mActiveUidCounterSet = new SparseIntArray();
|
||||
private final IBpfMap<S32, U8> mUidCounterSetMap;
|
||||
private final IBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap;
|
||||
private final IBpfMap<S64, CookieTagMapValue> mCookieTagMap;
|
||||
private final IBpfMap<StatsMapKey, StatsMapValue> mStatsMapA;
|
||||
private final IBpfMap<StatsMapKey, StatsMapValue> mStatsMapB;
|
||||
private final IBpfMap<S32, StatsMapValue> mAppUidStatsMap;
|
||||
|
|
@ -736,7 +736,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||
mSkDestroyListener = mDeps.makeSkDestroyListener((message) -> {
|
||||
final StructInetDiagSockId sockId = message.inetDiagMsg.id;
|
||||
try {
|
||||
mCookieTagMap.deleteEntry(new CookieTagMapKey(sockId.cookie));
|
||||
mCookieTagMap.deleteEntry(new S64(sockId.cookie));
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "Failed to delete CookieTagMap entry for " + sockId.cookie + ": " + e);
|
||||
}
|
||||
|
|
@ -906,10 +906,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||
}
|
||||
|
||||
/** Gets the cookie tag map */
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getCookieTagMap() {
|
||||
try {
|
||||
return new BpfMap<>(COOKIE_TAG_MAP_PATH,
|
||||
CookieTagMapKey.class, CookieTagMapValue.class);
|
||||
S64.class, CookieTagMapValue.class);
|
||||
} catch (ErrnoException e) {
|
||||
Log.wtf(TAG, "Cannot open cookie tag map: " + e);
|
||||
return null;
|
||||
|
|
@ -3327,7 +3327,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||
return;
|
||||
}
|
||||
BpfDump.dumpMap(mCookieTagMap, pw, "mCookieTagMap",
|
||||
(key, value) -> "cookie=" + key.socketCookie
|
||||
(key, value) -> "cookie=" + key.val
|
||||
+ " tag=0x" + Long.toHexString(value.tag)
|
||||
+ " uid=" + value.uid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ import com.android.net.module.util.SingleWriterBpfMap;
|
|||
import com.android.net.module.util.Struct;
|
||||
import com.android.net.module.util.Struct.Bool;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.Struct.U32;
|
||||
import com.android.net.module.util.Struct.U8;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.bpf.IngressDiscardKey;
|
||||
import com.android.net.module.util.bpf.IngressDiscardValue;
|
||||
|
|
@ -134,7 +134,7 @@ public class BpfNetMaps {
|
|||
// BpfMap for UID_OWNER_MAP_PATH. This map is not accessed by others.
|
||||
private static IBpfMap<S32, UidOwnerValue> sUidOwnerMap = null;
|
||||
private static IBpfMap<S32, U8> sUidPermissionMap = null;
|
||||
private static IBpfMap<CookieTagMapKey, CookieTagMapValue> sCookieTagMap = null;
|
||||
private static IBpfMap<S64, CookieTagMapValue> sCookieTagMap = null;
|
||||
// TODO: Add BOOL class and replace U8?
|
||||
private static IBpfMap<S32, U8> sDataSaverEnabledMap = null;
|
||||
private static IBpfMap<IngressDiscardKey, IngressDiscardValue> sIngressDiscardMap = null;
|
||||
|
|
@ -177,7 +177,7 @@ public class BpfNetMaps {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
public static void setCookieTagMapForTest(
|
||||
IBpfMap<CookieTagMapKey, CookieTagMapValue> cookieTagMap) {
|
||||
IBpfMap<S64, CookieTagMapValue> cookieTagMap) {
|
||||
sCookieTagMap = cookieTagMap;
|
||||
}
|
||||
|
||||
|
|
@ -248,11 +248,11 @@ public class BpfNetMaps {
|
|||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
private static IBpfMap<CookieTagMapKey, CookieTagMapValue> getCookieTagMap() {
|
||||
private static IBpfMap<S64, CookieTagMapValue> getCookieTagMap() {
|
||||
try {
|
||||
// Cannot use SingleWriterBpfMap because it's written by ClatCoordinator as well.
|
||||
return new BpfMap<>(COOKIE_TAG_MAP_PATH,
|
||||
CookieTagMapKey.class, CookieTagMapValue.class);
|
||||
S64.class, CookieTagMapValue.class);
|
||||
} catch (ErrnoException e) {
|
||||
throw new IllegalStateException("Cannot open cookie tag map", e);
|
||||
}
|
||||
|
|
@ -1308,7 +1308,7 @@ public class BpfNetMaps {
|
|||
// to dump CookieTagMap. But the TagSocketTest in CTS depends on this dump so the tests
|
||||
// need to be updated before remove the dump from BpfNetMaps.
|
||||
BpfDump.dumpMap(sCookieTagMap, pw, "sCookieTagMap",
|
||||
(key, value) -> "cookie=" + key.socketCookie
|
||||
(key, value) -> "cookie=" + key.val
|
||||
+ " tag=0x" + Long.toHexString(value.tag)
|
||||
+ " uid=" + value.uid);
|
||||
BpfDump.dumpMap(sUidOwnerMap, pw, "sUidOwnerMap",
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ import com.android.net.module.util.BpfDump;
|
|||
import com.android.net.module.util.BpfMap;
|
||||
import com.android.net.module.util.IBpfMap;
|
||||
import com.android.net.module.util.InterfaceParams;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.TcUtils;
|
||||
import com.android.net.module.util.bpf.ClatEgress4Key;
|
||||
import com.android.net.module.util.bpf.ClatEgress4Value;
|
||||
import com.android.net.module.util.bpf.ClatIngress6Key;
|
||||
import com.android.net.module.util.bpf.ClatIngress6Value;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
|
|
@ -134,7 +134,7 @@ public class ClatCoordinator {
|
|||
@Nullable
|
||||
private final IBpfMap<ClatEgress4Key, ClatEgress4Value> mEgressMap;
|
||||
@Nullable
|
||||
private final IBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap;
|
||||
private final IBpfMap<S64, CookieTagMapValue> mCookieTagMap;
|
||||
@Nullable
|
||||
private ClatdTracker mClatdTracker = null;
|
||||
|
||||
|
|
@ -280,11 +280,11 @@ public class ClatCoordinator {
|
|||
|
||||
/** Get cookie tag map */
|
||||
@Nullable
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
try {
|
||||
// also read and written from other locations
|
||||
return new BpfMap<>(COOKIE_TAG_MAP_PATH,
|
||||
CookieTagMapKey.class, CookieTagMapValue.class);
|
||||
S64.class, CookieTagMapValue.class);
|
||||
} catch (ErrnoException e) {
|
||||
Log.wtf(TAG, "Cannot open cookie tag map: " + e);
|
||||
return null;
|
||||
|
|
@ -536,7 +536,7 @@ public class ClatCoordinator {
|
|||
// Tag raw socket with uid AID_CLAT and set tag as zero because tag is unused in bpf
|
||||
// program for counting data usage in netd.c. Tagging socket is used to avoid counting
|
||||
// duplicated clat traffic in bpf stat.
|
||||
final CookieTagMapKey key = new CookieTagMapKey(cookie);
|
||||
final S64 key = new S64(cookie);
|
||||
final CookieTagMapValue value = new CookieTagMapValue(AID_CLAT, 0 /* tag, unused */);
|
||||
try {
|
||||
mCookieTagMap.insertEntry(key, value);
|
||||
|
|
@ -556,7 +556,7 @@ public class ClatCoordinator {
|
|||
// destroy listener only monitors on group INET_TCP, INET_UDP, INET6_TCP, INET6_UDP.
|
||||
// The other socket types, ex: raw, are not able to be removed automatically by the
|
||||
// listener. See TrafficController::makeSkDestroyListener.
|
||||
final CookieTagMapKey key = new CookieTagMapKey(cookie);
|
||||
final S64 key = new S64(cookie);
|
||||
try {
|
||||
mCookieTagMap.deleteEntry(key);
|
||||
} catch (ErrnoException | IllegalStateException e) {
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ import com.android.modules.utils.build.SdkLevel;
|
|||
import com.android.net.module.util.IBpfMap;
|
||||
import com.android.net.module.util.Struct.Bool;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.Struct.U32;
|
||||
import com.android.net.module.util.Struct.U8;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.bpf.IngressDiscardKey;
|
||||
import com.android.net.module.util.bpf.IngressDiscardValue;
|
||||
|
|
@ -181,8 +181,8 @@ public final class BpfNetMapsTest {
|
|||
new TestBpfMap<>(U32.class, Bool.class);
|
||||
private final IBpfMap<LocalNetAccessKey, Bool> mLocalNetAccessMap =
|
||||
new TestBpfMap<>(LocalNetAccessKey.class, Bool.class);
|
||||
private final IBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap =
|
||||
spy(new TestBpfMap<>(CookieTagMapKey.class, CookieTagMapValue.class));
|
||||
private final IBpfMap<S64, CookieTagMapValue> mCookieTagMap =
|
||||
spy(new TestBpfMap<>(S64.class, CookieTagMapValue.class));
|
||||
private final IBpfMap<S32, U8> mDataSaverEnabledMap = new TestBpfMap<>(S32.class, U8.class);
|
||||
private final IBpfMap<IngressDiscardKey, IngressDiscardValue> mIngressDiscardMap =
|
||||
new TestBpfMap<>(IngressDiscardKey.class, IngressDiscardValue.class);
|
||||
|
|
@ -1132,7 +1132,7 @@ public final class BpfNetMapsTest {
|
|||
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||
public void testPullBpfMapInfo() throws Exception {
|
||||
// mCookieTagMap has 1 entry
|
||||
mCookieTagMap.updateEntry(new CookieTagMapKey(0), new CookieTagMapValue(0, 0));
|
||||
mCookieTagMap.updateEntry(new S64(0), new CookieTagMapValue(0, 0));
|
||||
|
||||
// mUidOwnerMap has 2 entries
|
||||
mUidOwnerMap.updateEntry(new S32(0), new UidOwnerValue(0, 0));
|
||||
|
|
@ -1299,7 +1299,7 @@ public final class BpfNetMapsTest {
|
|||
@Test
|
||||
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||
public void testDumpCookieTagMap() throws Exception {
|
||||
mCookieTagMap.updateEntry(new CookieTagMapKey(123), new CookieTagMapValue(456, 0x789));
|
||||
mCookieTagMap.updateEntry(new S64(123), new CookieTagMapValue(456, 0x789));
|
||||
assertDumpContains(getDump(), "cookie=123 tag=0x789 uid=456");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ import com.android.net.module.util.bpf.ClatEgress4Key;
|
|||
import com.android.net.module.util.bpf.ClatEgress4Value;
|
||||
import com.android.net.module.util.bpf.ClatIngress6Key;
|
||||
import com.android.net.module.util.bpf.ClatIngress6Value;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
import com.android.testutils.TestBpfMap;
|
||||
|
|
@ -131,7 +131,7 @@ public class ClatCoordinatorTest {
|
|||
INET6_PFX96, INET6_LOCAL6);
|
||||
private static final ClatIngress6Value INGRESS_VALUE = new ClatIngress6Value(STACKED_IFINDEX,
|
||||
INET4_LOCAL4);
|
||||
private static final CookieTagMapKey COOKIE_TAG_KEY = new CookieTagMapKey(RAW_SOCK_COOKIE);
|
||||
private static final S64 COOKIE_TAG_KEY = new S64(RAW_SOCK_COOKIE);
|
||||
private static final CookieTagMapValue COOKIE_TAG_VALUE = new CookieTagMapValue(AID_CLAT,
|
||||
0 /* tag, unused */);
|
||||
|
||||
|
|
@ -139,8 +139,8 @@ public class ClatCoordinatorTest {
|
|||
spy(new TestBpfMap<>(ClatIngress6Key.class, ClatIngress6Value.class));
|
||||
private final TestBpfMap<ClatEgress4Key, ClatEgress4Value> mEgressMap =
|
||||
spy(new TestBpfMap<>(ClatEgress4Key.class, ClatEgress4Value.class));
|
||||
private final TestBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap =
|
||||
spy(new TestBpfMap<>(CookieTagMapKey.class, CookieTagMapValue.class));
|
||||
private final TestBpfMap<S64, CookieTagMapValue> mCookieTagMap =
|
||||
spy(new TestBpfMap<>(S64.class, CookieTagMapValue.class));
|
||||
|
||||
@Mock private INetd mNetd;
|
||||
@Spy private TestDependencies mDeps = new TestDependencies();
|
||||
|
|
@ -341,7 +341,7 @@ public class ClatCoordinatorTest {
|
|||
|
||||
/** Get cookie tag map */
|
||||
@Override
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
return mCookieTagMap;
|
||||
}
|
||||
|
||||
|
|
@ -632,7 +632,7 @@ public class ClatCoordinatorTest {
|
|||
throw new IOException();
|
||||
}
|
||||
@Override
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
return mock(IBpfMap.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -650,7 +650,7 @@ public class ClatCoordinatorTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
return mock(IBpfMap.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -739,7 +739,7 @@ public class ClatCoordinatorTest {
|
|||
public void testNotStartClatWithNullCookieTagMap() throws Exception {
|
||||
class FailureDependencies extends TestDependencies {
|
||||
@Override
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ import com.android.net.module.util.LocationPermissionChecker;
|
|||
import com.android.net.module.util.SkDestroyListener;
|
||||
import com.android.net.module.util.Struct;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.Struct.U8;
|
||||
import com.android.net.module.util.bpf.CookieTagMapKey;
|
||||
import com.android.net.module.util.bpf.CookieTagMapValue;
|
||||
import com.android.net.module.util.netlink.InetDiagMessage;
|
||||
import com.android.server.connectivity.ConnectivityResources;
|
||||
|
|
@ -291,8 +291,8 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||
@Mock
|
||||
private SkDestroyListener mSkDestroyListener;
|
||||
|
||||
private TestBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap = new TestBpfMap<>(
|
||||
CookieTagMapKey.class, CookieTagMapValue.class);
|
||||
private TestBpfMap<S64, CookieTagMapValue> mCookieTagMap = new TestBpfMap<>(
|
||||
S64.class, CookieTagMapValue.class);
|
||||
private TestBpfMap<StatsMapKey, StatsMapValue> mStatsMapA = new TestBpfMap<>(StatsMapKey.class,
|
||||
StatsMapValue.class);
|
||||
private TestBpfMap<StatsMapKey, StatsMapValue> mStatsMapB = new TestBpfMap<>(StatsMapKey.class,
|
||||
|
|
@ -579,7 +579,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getCookieTagMap() {
|
||||
public IBpfMap<S64, CookieTagMapValue> getCookieTagMap() {
|
||||
return mCookieTagMap;
|
||||
}
|
||||
|
||||
|
|
@ -3017,8 +3017,8 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||
|
||||
private void initBpfMapsWithTagData(int uid) throws ErrnoException {
|
||||
// key needs to be unique, use some offset from uid.
|
||||
mCookieTagMap.insertEntry(new CookieTagMapKey(1000 + uid), new CookieTagMapValue(uid, 1));
|
||||
mCookieTagMap.insertEntry(new CookieTagMapKey(2000 + uid), new CookieTagMapValue(uid, 2));
|
||||
mCookieTagMap.insertEntry(new S64(1000 + uid), new CookieTagMapValue(uid, 1));
|
||||
mCookieTagMap.insertEntry(new S64(2000 + uid), new CookieTagMapValue(uid, 2));
|
||||
|
||||
mStatsMapA.insertEntry(new StatsMapKey(uid, 1, 0, 10), new StatsMapValue(5, 5000, 3, 3000));
|
||||
mStatsMapA.insertEntry(new StatsMapKey(uid, 2, 0, 10), new StatsMapValue(5, 5000, 3, 3000));
|
||||
|
|
@ -3101,14 +3101,14 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||
initBpfMapsWithTagData(UID_BLUE);
|
||||
|
||||
final String dump = getDump(new String[]{DUMPSYS_BPF_RAW_MAP, DUMPSYS_COOKIE_TAG_MAP});
|
||||
Map<CookieTagMapKey, CookieTagMapValue> cookieTagMap = parseBpfRawMap(
|
||||
CookieTagMapKey.class, CookieTagMapValue.class, dump);
|
||||
Map<S64, CookieTagMapValue> cookieTagMap = parseBpfRawMap(
|
||||
S64.class, CookieTagMapValue.class, dump);
|
||||
|
||||
final CookieTagMapValue val1 = cookieTagMap.get(new CookieTagMapKey(2002));
|
||||
final CookieTagMapValue val1 = cookieTagMap.get(new S64(2002));
|
||||
assertEquals(1, val1.tag);
|
||||
assertEquals(1002, val1.uid);
|
||||
|
||||
final CookieTagMapValue val2 = cookieTagMap.get(new CookieTagMapKey(3002));
|
||||
final CookieTagMapValue val2 = cookieTagMap.get(new S64(3002));
|
||||
assertEquals(2, val2.tag);
|
||||
assertEquals(1002, val2.uid);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue