Commit graph android_packages_modules_Co.../tests/net/java
Message SHA1
Revert "[RFPM04] Adjust hasRestrictedNetworkPermission method"
This reverts commit de5b46c10b.

Reason for revert: Regression in SW.  Bug:162499840

Change-Id: I96bf28ffc9f2d8f3838cb6d2dac16f89a70177ed

Paul Hu   authored and   Remi NGUYEN VAN   commited 2020-08-20 06:23:00 +00:00
b275ee6f41
Revert "[RFPM05] Add UidNetdPermissionInfo class"
This reverts commit 1daf973605.

Reason for revert: Regression in SW.  Bug:162499840

Change-Id: I0e846efcc4fc06b53d97b2007e0d8e8f97c6ac10

Paul Hu   commited 2020-08-20 03:10:08 +00:00
dfb26833f0
[RFPM05] Add UidNetdPermissionInfo class
Add UidNetdPermissionInfo class to store netd permission info of
each uid. Use the bit mask for combining all netd permission into
one value which can update and get the uid permission easily.
Moreover, aosp/1340042 add carryover package info into this class
which centralizes all netd permissions relevant data.

Bug: 132784544
Test: atest FrameworksNetTests
Change-Id: I3b81ea2a5017e8f4d0d603144a33c9b08640d7ba

paulhu   commited 2020-08-12 10:33:18 +08:00
1daf973605
Merge "[RFPM04] Adjust hasRestrictedNetworkPermission method"
Paul Hu   authored and   Gerrit Code Review   commited 2020-08-03 10:37:52 +00:00
2933a04749
Merge "[Telephony Mainline] Rename getActiveAndHiddenSubscriptionIdList and guard with permission"
Peter Wang   authored and   Gerrit Code Review   commited 2020-07-31 08:43:44 +00:00
c80aabbd2e
Move utils from network stack to libs.
This package is using some common utilities from
a library that used to live in the network stack.
A better home for these utilities is frameworks/libs,
so this topic moves the files ther and also changes
the package of some utilities.

See aosp/1350222 and aosp/1350182 for a detailed
description of the specific files that moved.

Test: checkbuild
Change-Id: I76a9b7790f3997e3e6b3c2f75ba6308286457cde

Chalard Jean   commited 2020-07-29 21:15:48 +09:00
3b7591e1f5
[RFPM04] Adjust hasRestrictedNetworkPermission method
There are two parts in hasRestrictedNetworkPermission method.
One is carryover package check and one is uid permission
check. Seperate carryover package check part to another method
to be clearer the usage of hasRestrictedNetworkPermission method.

Bug: 132784544
Test: atest FrameworksNetTests
Change-Id: Iab0609fcaa52acb0dfcb31ca957f22bfe8d62392

paulhu   commited 2020-07-29 14:14:27 +08:00
de5b46c10b
Merge "[RFPM03] Check permission by uid."
Paul Hu   authored and   Gerrit Code Review   commited 2020-07-29 05:41:32 +00:00
563de5b8c7
Merge "Gracefully handle integer overflows."
Junyu Lai   authored and   Gerrit Code Review   commited 2020-07-29 01:19:07 +00:00
cdb1f03144
Merge "Update language to comply with Android's inclusive language guidance"
Chiachang Wang   authored and   Gerrit Code Review   commited 2020-07-28 10:51:53 +00:00
f702025bdf
[RFPM03] Check permission by uid.
PermissionMonitor check permission by each package name but only
update the uid permission to netd. It's better to check
permission by uid directly. Thus, use
ActivityManager#checkUidPermission to check permissions for each
uid.

Bug: 132784544
Test: atest FrameworksNetTests
Change-Id: I057d34383b4dc408b2773e4c6b146774ba0c5eb2

paulhu   commited 2020-07-28 18:23:38 +08:00
8adb39a688
Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code
for reference.

Bug: 161896447
Test: m
Change-Id: I6c3c03c0c2d1302af6d5245486823c13a3432900

Chiachang Wang   commited 2020-07-28 15:36:30 +08:00
3b9549f408
Gracefully handle integer overflows.
Avoid recording negative data by doing integer-based
math as much as possible, but switch to double-based
math if we detect that we'd end up causing an overflow.

Test :

    - Builds, Boots
    - High data throughput scenarios
    - NetworkStatsHistoryTest, NetworkStatsCollectionTest,
      NetworkStatsTest

Bug: 119527458
Change-Id: I55d4aa649bea3ae201ad513074ff2b71cb918dad

Pavan Kumar M   commited 2020-07-28 11:36:49 +05:30
e55ab87e5d
Attribute data usage to virtual RAT type for 5G non-standalone mode
Test: atest NetworkStatsSubscriptionsMonitorTest#test5g
Bug: 160727498
Change-Id: I8753e68140c0993773017c9a49bd8a666a364071
Merged-In: I8753e68140c0993773017c9a49bd8a666a364071
(cherry-picked from ag/12167624)

junyulai   commited 2020-07-16 18:22:09 +08:00
c3e3a1d0ef
[Telephony Mainline] Rename getActiveAndHiddenSubscriptionIdList and
guard with permission

Bug: 150878235
Fix: 150878235
Test: Build
Change-Id: I7f3b1f5170e032336d9b39b322c49e2b92573586
Merged-In: I7f3b1f5170e032336d9b39b322c49e2b92573586

Peter Wang   commited 2020-07-16 02:01:06 -07:00
1041764067
Revert "Attribute data usage to 5G for 5G non-standalone mode"
This reverts commit dc31686c31.

Reason for revert: Revert and wait for the design is settled down.

Change-Id: I10fdfc37d6456678de1886698cd6ad08bf8aa810

Junyu Lai   commited 2020-07-10 03:43:19 +00:00
43b3142dc3
Attribute data usage to 5G for 5G non-standalone mode
Test: atest NetworkStatsSubscriptionsMonitorTest#test5g
Bug: 160727498

Change-Id: I563df14500caeb3602b381479afaf5163ad8e6a1

junyulai   commited 2020-07-09 16:56:54 +08:00
dc31686c31
[RFPM02] Add Dependencies class for injection in tests.
Add Dependencies class in PermissionMonitor for injection
in tests easily.

Bug: 132784544
Test: atests FrameworksNetTests
Change-Id: Ibb84d548908f7a955fa0ff206794486733259978

paulhu   commited 2020-07-08 15:30:42 +08:00
a1a8814b82
Revert "Test IPv6ProvisioningLossParcelable in the NetworkAttrib..."
Revert "Add new network quirk parcelable in the NetworkAttributes."

Revert submission 1323251-ipv6_prov_loss_quirk_parcelable

Reason for revert: Breaks CtsStrictJavaPackagesTestCases
Reverted Changes:
I18e05c09f:Add new network quirk parcelable in the NetworkAtt...
I8dbff2377:Test IPv6ProvisioningLossParcelable in the Network...

Change-Id: Ie906919b344131cd768fbed787248d3caac2f74d

Chalard Jean   commited 2020-07-01 01:46:26 +00:00
f90e5bcc2a
Test IPv6ProvisioningLossParcelable in the NetworkAttributes.
Bug: 157534516
Test: atest FrameworksNetTests
Change-Id: I8dbff2377457bb8fd0f447be0a3cda9af952f2a2

Xiao Ma   commited 2020-06-29 11:57:32 +00:00
0c140bf1ec
Merge "[RFPM01] Merge package added/removed methods"
Paul Hu   authored and   Gerrit Code Review   commited 2020-06-29 11:50:57 +00:00
6287112701
Disable sockets and DNS if process lacks INTERNET permission.
This is a Client-only solution.
  - Add to NetdClient a per-process std::atomic_boolean
    similar to netIdForProcess and netIdForResolv.
  - The boolean says whether the process should be
    allowed Internet connectivity.
  - Add an @hide method to NetUtils.java to set the boolean;
    call it from the initialization code of the new
    process just after forking from zygote.
  - Make netdClientSocket and dnsOpenProxy check the
    boolean. If the boolean is false, return EPERM from
    socket calls.

Bug: 150028556
Test: atest NetworkUtilsTest
Test: atest CtsAppSecurityHostTestCases:UseProcessTest
(cherry-pick from internal branch, ag/11881939)
Merged-In: If002280fbad493dfc2db3d9d505c0257d49a9056
Change-Id: If002280fbad493dfc2db3d9d505c0257d49a9056

Luke Huang   commited 2020-06-24 11:58:57 +00:00
caaee1d0ec
[RFPM01] Merge package added/removed methods
There are two methods to handle package added/removed from
two differnt listeners. It can use one of listener to handle the
changes. Thus, keep PackageManagerInternal#PackageListObserver
but remove the listening from ConnectivityService.

Bug: 132784544
Test: atests FrameworksNetTests
Change-Id: Ib2db85e4108f9fda731bf6667d0af0610fc79fea

paulhu   commited 2020-06-23 16:10:03 +08:00
aa4620914e
Update DnsManagerTest for AIDL interface change
Check one more parameter enforceDnsUid in ResolverOptionsParcel in
DnsManagerTest.

Bug: 159587277
Test: atest
com.android.server.connectivity.DnsManagerTest#testSendDnsConfiguration

Change-Id: Ic53f42b968626294c851dac252a70769846ba427
Merged-In: Ic53f42b968626294c851dac252a70769846ba427

Ken Chen   authored and   Lorenzo Colitti   commited 2020-06-22 15:10:12 +00:00
fc7dd4c35e
Support DNS-over-TLS probes in NetworkDiagnostics
Probe DNS servers to see they support DNS-over-TLS. Use system
CAs to verify whether the certificates sent by DNS servers are
trusted or not. An error is thrown to cause the probe failed if
DNS servers send untrusted certificates.

Unlike the DnsResolver which doesn't verify the certificates
in opportunistic mode, all of the DoT probes from NetworkDiagnostics
check certificates.

DoT probes apply to the DNS servers gotten from LinkProperties
and the DoT servers gotten from PrivateDnsConfig whatever private
DNS mode is.

A common example in DNS strict mode:
.  DNS TLS dst{8.8.8.8} hostname{dns.google} src{192.168.43.2:48436} qtype{1} qname{815149-android-ds.metric.gstatic.com}: SUCCEEDED: 1/1 NOERROR (432ms)
F  DNS TLS dst{192.168.43.144} hostname{}: FAILED: java.net.ConnectException: failed to connect to /192.168.43.144 (port 853) from /192.168.43.2 (port 41770) after 2500ms: isConnected failed: ECONNREFUSED (Connection refused) (172ms)
.  DNS TLS dst{8.8.4.4} hostname{dns.google} src{192.168.43.2:37598} qtype{1} qname{759312-android-ds.metric.gstatic.com}: SUCCEEDED: 1/1 NOERROR (427ms)

An example when the CA is not trusted:
F  DNS TLS dst{8.8.8.8} hostname{dns.google}: FAILED: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. (16ms)

An example when TCP/TLS handshake timeout:
F  DNS TLS dst{8.8.8.8} hostname{dns.google}: FAILED: java.net.SocketTimeoutException: failed to connect to /8.8.8.8 (port 853) from /192.168.2.108 (port 45680) after 2500ms (2514ms)

Bug: 132925257
Bug: 118369977
Test: atest FrameworksNetTests
Change-Id: I1b54abed0e931ca4b8a97149459cde54da1c3d6f

Mike Yu   commited 2020-06-20 16:22:35 +08:00
6cad4b10db
Address comments from aosp/1298476
This patch addresses the followings,
- Pass Looper to NetworkStatsSubscriptionsMonitor constructor
- Replace Looper with TestLooper in unit test
- Assert fail if result of condition check is not expected.

Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsServiceTest
      atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
Change-Id: Ibcaba2b38af80cc0ec9a4e428a3b3a1538bc4325

Aaron Huang   commited 2020-06-18 15:05:19 +08:00
69bfb5afea
Merge "Dynamically enable/disable watch for RAT type changes"
Aaron Huang   authored and   Gerrit Code Review   commited 2020-06-18 03:51:51 +00:00
3fdad73a32
Merge "Add unit test for NetworkStatsSubscriptionsMonitor"
Aaron Huang   authored and   Gerrit Code Review   commited 2020-06-17 08:52:20 +00:00
0543f2328d
Dynamically enable/disable watch for RAT type changes
Add ContentObserver to observe the status of
NETSTATS_COMBINE_SUBTYPE_ENABLED to determine that
NetworkStatsSubscriptionsMonitor start or stop
monitoring data usage per RAT type changes.

Bug: 154080515
Test: atest NetworkStatsServiceTest#testDynamicWatchForNetworkRatTypeChanges
Change-Id: I272d589633c9186b45753228b05aa0b40b7c7b89

Aaron Huang   authored and   Chalard Jean   commited 2020-06-17 17:09:10 +09:00
7558938ce9
Add unit test for NetworkStatsSubscriptionsMonitor
Bug: 154080205
Test: atest FrameworksNetTests:com.android.server.net.NetworkStatsSubscriptionsMonitorTest
(copy from ag/11788484 but getActiveAndHiddenSubscriptionIdList() since it's renamed
in internal)
Change-Id: Ia162f36efe96d90b2f6f70190d9fa855bba34484
Merged-In: I4ef3f1ab2e5ea1322133edd80db3ccd0022e9c91

Aaron Huang   commited 2020-06-15 07:05:19 +00:00
b0e7dca43e
Test extra info sent to NetworkMonitor
Test extra info sent to NetworkMonitor correctly if network
agent is created through new NetworkAgent constructor without
legacy network info taken as parameter.

Bug: 156173829
Test: atest FrameworkNetTests
Change-Id: I4f827664c528bea30cc957a0a617dd37693f4460

Chiachang Wang   commited 2020-06-12 18:13:00 +08:00
301bc7b40a
Merge "Add RequiresFeature annotations for IKEv2 VPN profiles"
Benedict Wong   authored and   Gerrit Code Review   commited 2020-05-29 01:55:08 +00:00
de684cfa06
Merge changes I289d935f,I0121a4ac
* changes:
  NetworkStats: apply464xlatAdjustments - don't remove CLAT_UID
  NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.

Treehugger Robot   authored and   Gerrit Code Review   commited 2020-05-28 10:34:01 +00:00
84af34369d
Merge changes Ie73ba058,I4393afcb,Ifebd946e,Ib12ee882,Ia171b779
* changes:
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting100MBDownload
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting
  fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccountingSimple
  fix android.net.NetworkStatsTest#testApply464xlatAdjustments
  NetworkStats - no need for xt_qtaguid clat bw fixups

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2020-05-28 09:04:42 +00:00
9fb791c62d
NetworkStats: apply464xlatAdjustments - remove useBpfStats parameter.
Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0121a4ac7ee824adc5930bab786d550b2f00b05b

Maciej Żenczykowski   commited 2020-05-28 01:33:25 -07:00
4bfcfc5f02
fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting100MBDownload
No clat app uid 0 rx stats on base iface due to ip6tables raw prerouting drop

(so just copy over the rx stats from the before file)

Test: atest NetworkStatsTest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie73ba0586dafde67bc2726db26e07f7268c18be3

Maciej Żenczykowski   commited 2020-05-28 00:26:18 -07:00
b053a337e3
fix com.android.server.net.NetworkStatsFactoryTest#testDoubleClatAccounting
No clat app uid 0 rx stats on base iface due to ip6tables raw prerouting drop

Test: atest NetworkStatsFactoryTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4393afcbe8e1bb886ecf4f5c1573f6ac8a0e29f5

Maciej Żenczykowski   commited 2020-05-28 00:26:18 -07:00
2cc6ec11d7
fix android.net.NetworkStatsTest#testApply464xlatAdjustments
Test: atest NetworkStatsTest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib12ee88295eb502f6da13d212b4fd6298dea380f

Maciej Żenczykowski   commited 2020-05-28 00:26:18 -07:00
f24ada13aa
Merge "Adjust tests for renaming groupHint to cluster."
Chalard Jean   authored and   Gerrit Code Review   commited 2020-05-28 04:20:26 +00:00
f1b1600637
Add RequiresFeature annotations for IKEv2 VPN profiles
This change adds the @RequiresFeature annotation to Ikev2VpnProfile
Builder methods, and checks before provisioning VPN profiles.

Bug: 156681625
Test: New tests added, passing.
Change-Id: I125d8fbe5d67fb877ad7d0636c007cb3e1a9f59b

Benedict Wong   commited 2020-05-27 02:05:49 -07:00
d196714698
Merge "Inform the DNS resolver when it needs to do DNS64 synthesis."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-05-26 09:26:46 +00:00
c0ba5bf41d
Merge "Test that if an RA sets the same prefix as DNS, nothing happens."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2020-05-24 10:59:40 +00:00
eafdd034f8
Inform the DNS resolver when it needs to do DNS64 synthesis.
This is only necessary when learning the NAT64 prefix from the
RA, because if the NAT64 prefix is learned from DNS, the DNS
resolver already knows the prefix and automatically enables
DNS64 synthesis.

The DNS resolver needs to be informed of the prefix any time
clat is running on a prefix learned from an RA. This is simple to
implement: just set the prefix when starting clat if prefix
discovery is not running, and clear the prefix when stopping clat
if prefix discovery was not running. This ensures that the prefix
is cleared iff it was set.

Bug: 156914456
Test: new unit test coverage
Change-Id: If8ad2d30712a6df3e207c8d3e8a129705242191e

Lorenzo Colitti   commited 2020-05-21 23:32:57 +09:00
b432bc75e5
Test that if an RA sets the same prefix as DNS, nothing happens.
This is not particularly likely to happen unless the pref64 RA is
sent by a different router than the main RA. But more tests are
always good, and this additional coverage will be more useful
in an upcoming change.

Bug: 150648313
Test: test-only change
Change-Id: I3316d49d42100800740afadc4edf0a13a4d8377c

Lorenzo Colitti   commited 2020-05-21 17:26:00 +09:00
16b28e2b22
Merge "Suppress deprecation warnings in LegacyTypeTrackerTest."
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-05-21 07:47:45 +00:00
8d55b55f60
Suppress deprecation warnings in LegacyTypeTrackerTest.
This saves dozens of warnings every time FrameworkNetTests is
compiled. There is nothing we can do about those warnings because
LegacyTypeTracker's reason for existence is to power deprecated
APIs.

Test: m FrameworksNetTests
Change-Id: I4d65b0aade493e12b56a94247efbf9d1ad7bb4b9

Lorenzo Colitti   commited 2020-05-20 20:53:16 +09:00
84f1909fb1
Adjust tests for renaming groupHint to cluster.
Bug: 146460486
Test: atest android.net.IpMemoryStoreTest
Test: atest com.android.server.connectivity.ipmemorystore.IpMemoryStoreServiceTest
Change-Id: I69f7a2971cc5985d0f0078aecc39d4d6a6130033

Chalard Jean   commited 2020-05-20 14:37:17 +09:00
3cd880b4bb
Merge "Address nit from aosp/1301317"
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-05-15 06:43:42 +00:00
1894a79964
Merge "Add methods for IKEv2/IPsec test mode profiles"
Benedict Wong   authored and   Gerrit Code Review   commited 2020-05-15 02:18:02 +00:00
56b98b0206
Add methods for IKEv2/IPsec test mode profiles
This change adds the ability for IKEv2/IPsec VPN profiles to run on Test
Networks. If enabled, the IKEv2/IPsec VPN profiles will request ONLY
test networks.

Bug: 148582947
Test: FrameworksNetTests passing
Test: Added for testing
Change-Id: I2511b39b27a1e29ae97907cdb12728d13fb1628f

Benedict Wong   commited 2020-05-12 22:55:55 -07:00
0d7bed76cb