Commit Graph

23391 Commits

Author SHA1 Message Date
Luke Huang
c9a2bdf2b9 Merge "Modify NsdServiceTest to conform to its new mechanism" 2021-06-13 15:20:52 +00:00
Frank Li
67fe28455d Merge "Add test for ConnectivityService API isPrivateDnsBroken" 2021-06-12 13:02:24 +00:00
Remi NGUYEN VAN
a6c06af0fa Merge "Revert "Use mockito-extended in FrameworksNetTests"" 2021-06-11 01:26:44 +00:00
Remi NGUYEN VAN
d15e52eca9 Merge changes I8d15b626,I993e8da9
* changes:
  Revert "Remove ConnectivityServiceTest signature perms use"
  Revert "Use shell permission to query current user"
2021-06-10 23:39:11 +00:00
xingdai
892a0ef152 Revert "Use mockito-extended in FrameworksNetTests"
This reverts commit 98b76cc2ec.

Reason for revert: <INSERT REASONING HERE>

b/190622577

Change-Id: Ief39f82875e6fa885829aea62eed00f2f2e6774e
2021-06-10 21:41:54 +00:00
lifr
e39741db1c Add test for ConnectivityService API isPrivateDnsBroken
Bug: 189161363
Test: atest android.net.cts.ConnectivityManagerTest
      atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest
Change-Id: Ib45aa439683d48360652a91d7a0609dc82adda33
2021-06-11 05:32:00 +08:00
Remi NGUYEN VAN
3cd164225b Revert "Remove ConnectivityServiceTest signature perms use"
This reverts commit bba8ec0d43.

Reason for revert: Broken tests b/190622577

Change-Id: I8d15b626fcd8da67094ebf461d381b3922f69024
2021-06-10 15:05:47 +00:00
Remi NGUYEN VAN
499219702b Revert "Use shell permission to query current user"
This reverts commit 95bc8d7067.

Reason for revert: Conflict with revert for b/190622577

Change-Id: I993e8da9737634d0cc815cd75b461699170602cc
2021-06-10 15:05:17 +00:00
Treehugger Robot
b9d05685fc Merge "Partial revert of "Remove ConnectivityServiceTest signature perms use"" 2021-06-10 14:35:25 +00:00
Paul Hobbs
cdfeb11719 Partial revert of "Remove ConnectivityServiceTest signature perms use"
This reverts the Android.bp changes in commit
bba8ec0d43.

Reason for revert: This broke ConnectivityServiceTest (https://android-build.googleplex.com/builds/tests/view?invocationId=I90700009364410436&testResultId=TR01525128446370769)

A full revert has a merge conflict in the other file, and is likely
not necessary to fix the failure.

Change-Id: Icc0c2500590a6b936016574be4f234b9f748cb80
2021-06-10 08:43:44 +00:00
Treehugger Robot
28c51a157c Merge "import copy of bpf_net_helpers.h from system/netd/bpf_progs" 2021-06-10 05:50:16 +00:00
Remi NGUYEN VAN
dbb2a23a38 Merge "Use shell permission to query current user" 2021-06-10 05:19:57 +00:00
Maciej Żenczykowski
23f5d805ed import copy of bpf_net_helpers.h from system/netd/bpf_progs
after this:
  diff system/netd/bpf_progs/bpf_net_helpers.h packages/modules/Connectivity/Tethering/bpf_progs/bpf_net_helpers.h
shows no diff, besides a switch to '#pragma once'
as the include guard.

Test: builds, atest, TreeHugger
Bug: 177884581
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib943321d46254ba64ce206fb9e3b3414d15e4d45
2021-06-09 19:53:13 -07:00
Remi NGUYEN VAN
45f922a2ff Merge "Deprecate MANAGE_ACTIVITY_STACKS permission" 2021-06-09 23:45:29 +00:00
Treehugger Robot
3a1a22b82a Merge "Skip CaptivePortalTest for wearables" 2021-06-09 17:59:04 +00:00
Frank Li
99e50a0fc9 Merge "Add CTS test for NetworkAgent/NetworkAgentConfig API" 2021-06-09 12:12:05 +00:00
Treehugger Robot
b80e88d604 Merge "Improve handling of invalid private DNS settings" 2021-06-09 10:52:14 +00:00
Remi NGUYEN VAN
95bc8d7067 Use shell permission to query current user
Use shell permissions to obtain CREATE_USERS to call
ActivityManager.getCurrentUser in ConnectivityServiceTest.

This is necessary to allow the tests to run in coverage tests without
the platform certificate.

Bug: 187935317
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I5a56ffab4820d351dcdb132046698cd0d3b8bdb1
2021-06-09 19:28:16 +09:00
Remi NGUYEN VAN
f900c45afa Deprecate MANAGE_ACTIVITY_STACKS permission
This is a partial cherry-pick of change:
I894ee66e058b1024a731d3be4b33b69626451f08

The permission is actually not used, but this change aligns the manifest
with contents in downstream branches, so it can be modified (including
removing the permission) without conflicts.

Bug: 157876448
Test: atest FrameworksNetTests
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Id50e41a0ea970350eae0a2afab303c022b452bf9
2021-06-09 19:28:10 +09:00
lifr
561547a537 Add CTS test for NetworkAgent/NetworkAgentConfig API
The following is a list of APIs:
1. NetworkAgent.setLegacySubtype
2. NetworkAgentConfig.Builder.setLegacySubType
3. NetworkAgentConfig.Builder.setLegacySubTypeName
4. NetworkAgentConfig.Builder.setLegacyExtraInfo

Bug: 190413710
Test: atest android.net.cts.NetworkAgentTest
      atest CtsNetTestCasesLatestSdk:NetworkAgentTest
Change-Id: Ia67b963b8e18af8440b1b9bd91f53439848bb838
2021-06-09 17:31:23 +08:00
Remi NGUYEN VAN
545f6cf95f Merge "Remove ConnectivityServiceTest signature perms use" 2021-06-09 08:39:33 +00:00
Remi NGUYEN VAN
35e6108119 Merge "Use mockito-extended in FrameworksNetTests" 2021-06-09 08:39:24 +00:00
Junyu Lai
07f97b249c Merge changes from topic "cts-snapshots"
* changes:
  Add CTS for NetworkAgentConfig#setSubscriberId
  Add CTS for getAllNetworkStateSnapshots
  Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots
2021-06-09 08:09:41 +00:00
Lorenzo Colitti
a3f12dd52c Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." 2021-06-09 07:59:25 +00:00
Lorenzo Colitti
f55fa638c8 Merge "Improve test coverage for disconnecting networks with clat." 2021-06-09 07:59:13 +00:00
Treehugger Robot
0103375187 Merge "Fix restorePrivateDnsSetting with null hostnames" 2021-06-09 05:45:24 +00:00
Remi NGUYEN VAN
c2303139ef Improve handling of invalid private DNS settings
When private DNS mode is strict, there should always be a private DNS
specifier with the hostname.

Instead of restoring an invalid strict mode setting when set,
have tests reset private DNS mode to opportunistic and fail.

Bug: 190465704
Test: atest CtsNetTestCases
Change-Id: I45adc527267aa86d52e824f426699c5a7e874f63
2021-06-09 14:42:00 +09:00
Junyu Lai
ed4ef7bb99 Add CTS for NetworkAgentConfig#setSubscriberId
Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkAgentTest
      on R device
Bug: 188140631
Merged-In: I90d47ac9bd0570c0aed19402fa9be4e99e0f8621
Change-Id: I90d47ac9bd0570c0aed19402fa9be4e99e0f8621
  (cherry-picked from ag/14639705)
2021-06-09 01:34:14 +00:00
junyulai
cfefdea403 Add CTS for getAllNetworkStateSnapshots
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testGetAllNetworkStateSnapshots --rerun-until-failure 100
Test: atest
CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest on R
device
Bug: 188140631

Merged-In: I573b009bd05bbc0c855aaa6e20cb8ebde6729936
Change-Id: I573b009bd05bbc0c855aaa6e20cb8ebde6729936
  (cherry-picked from ag/14598438)
2021-06-09 01:34:14 +00:00
junyulai
eaaacb0d47 Check NETWORK_SETTINGS permission for getAllNetworkStateSnapshots
This is declared in the API surface, but the implementation
does not match.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testGetAllNetworkStateSnapshots
Bug: 188140631

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I97aa69651461ebe5c323ec669372f9a61b84e6a6
Change-Id: I97aa69651461ebe5c323ec669372f9a61b84e6a6
  (cherry-picked from ag/14601670)
2021-06-09 01:34:14 +00:00
Remi NGUYEN VAN
de3c20ecb5 Merge changes from topic "conn_test_defaults_cp"
* changes:
  Move connectivity test defaults to tests/common
  Add framework-connectivity-test-defaults
2021-06-09 00:59:17 +00:00
Junyu Lai
5b15e700bb Merge changes from topics "enable-policy-ranking", "sendNetworkScore"
* changes:
  Adjust a test for policy scoring
  Enable policy ranking
  Add CTS to verify NetworkAgent#setLingerDuration
  Allow network providers to set the linger duration.
  Fix nascent timer never get removed
  [NS13] Remove the last usage of the legacy int
  Add documentation
  Use filter from CollectionUtils.
  Fix a bug where updates of offers won't find existing offers
  [NS12] Address comments on NS09
  [NS11] Fix yieldToBadWifi over the policy scoring
  Add doc for NetworkScore#getLegacyInt
  Expose sendNetworkScore that takes a NetworkScore
2021-06-08 22:34:44 +00:00
Yan Yan
77f2e95515 Merge changes I00d1aa47,Icffbe67f
* changes:
  Add CTS for AES-CMAC
  Add tests for new IPsec algorithms in IpSecManagerTest
2021-06-08 22:30:16 +00:00
Frank Li
3103a318bf Merge "Add CTS test for API setLegacyExtraInfo" 2021-06-08 11:15:06 +00:00
Remi NGUYEN VAN
679a8e0a72 Move connectivity test defaults to tests/common
The build file currently holds a single build rule in test/. Move it to
the existing build file in tests/common/Android.bp.

(clean cherry-pick of history in downstream branch)

Test: m
Bug: 186628461
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ifa32681c0cdd2f6a70cb83a81cd7fec0f91824d1
2021-06-08 19:54:35 +09:00
Remi NGUYEN VAN
3912c80e99 Add framework-connectivity-test-defaults
The defaults follow the same pattern as framework-wifi-test-defaults to
allow unit tests to build against hidden API in Connectivity.

(clean cherry-pick of history in downstream branch)

Bug: 171540887
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ia8531f672820fcc8968f98494903e486c4e42652
2021-06-08 19:54:27 +09:00
Remi NGUYEN VAN
908b002ed2 Fix restorePrivateDnsSetting with null hostnames
When private DNS setting was set to opportunistic (mode) and null
(hostname), CtsNetUtils would not restore it.

Make sure that private DNS settings are restored after every test. Also
fail if restore is called without having saved any setting beforehand.

Bug: 190465704
Test: atest CtsNetTestCases
Change-Id: Ic5d8d8b729469e0eef89a0b53f166e604264c1ee
2021-06-08 19:29:08 +09:00
Remi NGUYEN VAN
bba8ec0d43 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I80c5cae5fcd3d40be55d1a79a93d614e665fbbf4
2021-06-08 19:12:13 +09:00
Remi NGUYEN VAN
98b76cc2ec Use mockito-extended in FrameworksNetTests
This is necessary to mock classes like BatteryStatsManager, which cannot
be used without signature permissions, and to merge the test with other
test suites that use mockito extended.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: I5dba65d806c5d06b3ff8f633846edb911a7a44ec
2021-06-08 19:12:09 +09:00
Mark Chien
7648833bd4 Merge changes Ib8fe719f,Ia8c05780
* changes:
  Suppress IpServer message logs
  Remove *Locked wording
2021-06-08 10:02:44 +00:00
Remi NGUYEN VAN
674ce27fee Merge changes from topic "framework-conn-stub-cp"
* changes:
  Reference framework-connectivity stubs explicitly
  Merge framework-connectivity impl and stub targets
2021-06-08 09:15:15 +00:00
Remi NGUYEN VAN
12474fdab5 Merge "Add min_sdk_version to connectivity targets" 2021-06-08 08:44:21 +00:00
markchien
21021efbe1 Suppress IpServer message logs
To avoid log flooding, suppress CMD_IPV6_TETHER_UPDATE and
CMD_NEIGHBOR_EVENT message log because they appear frequentlg and
don't have any content which means they are ueseless for debugging.
Also remove logMessage from BaseServingState to fix duplicated
message because all the message already log in TetheredState
and LocalHotspotState which inherit BaseServingState.

Bug: 162920185
Bug: 185649441
Test: atest TetheringCoverageTests
      atest MtsTetheringTestLatestSdk
      atest CtsTetheringTest
Change-Id: Ib8fe719f3c1c4a65e6b5152df5e5adf33aba2079
2021-06-08 15:57:04 +08:00
markchien
dc5903ae56 Remove *Locked wording
Since tethering run in single thread without any synchronized lock,
remove "Locked" wording from the methods which the use lock before.

Bug: 162920185
Test: atest TetheringCoverageTest
Change-Id: Ia8c057800cab30cdcbacae4db2d706b6427e9861
2021-06-08 15:56:14 +08:00
Paul Hu
7cba5f4163 Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting" 2021-06-08 07:23:39 +00:00
Lorenzo Colitti
b4bf015b57 Don't send onLinkPropertiesChanged after onLost for 464xlat.
Currently, when a network that uses 464xlat is torn down,
NetworkCallbacks will receive onLinkPropertiesChanged after
onLost. This is confusing and incorrect.

The incorrect callback is sent because handleLinkProperties
checks that the netId of the agent still exists, not that the
NetworkAgent is still registered. This is normally correct,
because the NetworkAgent is removed from mNetworkAgentInfos and
the netId are removed from mNetworkForNetId by the same method,
disconnectAndDestroyNetwork.

In this specific case it's not correct, because the call to
handleUpdateLinkProperties is from disconnectAndDestroyNetwork
itself via nai.clatd.update and calls Nat464Xlat#stop.

No other callers of handleUpdateLinkProperties are affected
because:

- EVENT_NETWORK_PROPERTIES_CHANGED is called only by
  maybeHandleNetworkAgentMessage, which first checks that the
  NetworkAgent is registered.
- handlePrivateDnsSettingsChanged only looks at registered
  NetworkAgents (it loops over mNetworkAgentInfos).
- handlePrivateDnsValidationUpdate, handleNat64PrefixEvent and
  handleCapportApiDataUpdate call getNetworkAgentInfoForNetId,
  which will correctly determine that the agent is no longer
  registered, since they run on the handler thread and thus
  cannot run at the same time as disconnectAndDestroyNetwork.

The existing code contains a check for the netId being current.
This is intended to ensure that an update from a NetworkAgent
cannot affect another agent with the same Network. This extra
check is not necessary, because code running on the handler
thread can never observe a NetworkAgent in mNetworkAgentInfos
unless mNetworkForNetId maps that NetworkAgent's Network to that
NetworkAgent. This is because mNetworkForNetId is updated by the
same methods as mNetworkAgentInfos, and those updates occur on
the handler thread. So all code on the handler thread will see
those two as consistent.

Bug: 176496580
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Change-Id: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
2021-06-08 15:48:57 +09:00
Lorenzo Colitti
284ca22f0c Improve test coverage for disconnecting networks with clat.
Ensure that NetworkCallbacks and netd operations are accounted
for. Also add a test for the spurious onLinkPropertiesChanged
callback that is currently send out after onLost.

Bug: 176496580
Test: atest ConnectivityServiceTest
Change-Id: I69cf58bc87dfe55ea359a2cd76167d03fe2c953d
2021-06-08 15:43:17 +09:00
Remi NGUYEN VAN
f20103940e Reference framework-connectivity stubs explicitly
To merge the framework-connectivity and framework-connectivity.impl
targets, framework-connectivity stubs need to be referenced explicitly
in java_sdk_libraries, otherwise the build system will currently see
dependency cycles.

Bug: 183600168
Test: m
Merged-In: I556747f9ba934f8b44b6ea9a518adbccc84ac2a9
Change-Id: I0ff10dcb553115d349e287c9f648d77579158f9d
2021-06-08 15:24:05 +09:00
Remi NGUYEN VAN
e70cd84601 Merge framework-connectivity impl and stub targets
Instead of using api_only: true, use a single java_sdk_library to
generate both framework-connectivity stubs and
framework-connectivity.impl.

Original change (project moved):
I76d7cf1ba31a3f38ae6b9facbf1b668860c8c165

Bug: 183600168
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I07d8c4c92c91939b8e8890fdb5db517b75faee2c
2021-06-08 15:24:05 +09:00
Remi NGUYEN VAN
da43ef0b68 Add min_sdk_version to connectivity targets
All targets need min_sdk_version 30 to be included in the tethering
APEX. They will actually never be used on SDK 30 and are only loaded on
31, but this is necessary to be included in com.android.tethering.

Original change (project moved):
I190fd1f3c9fabff057d0a2bd7f45b63a4fe447b3

This also includes changes to the lint baseline to make it match actual
filenames.

Bug: 171540887
Test: m
Test: m lint-check
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I24198565bc98d85d0c036be02e3a6c311b5bb2a3
2021-06-08 15:23:40 +09:00