Commit Graph

153 Commits

Author SHA1 Message Date
Treehugger Robot
c8a42f6a39 Merge "Disable the remaining VPN CTS tests on watches." into main 2023-10-03 16:39:31 +00:00
abdelrahmani
5bcbbc1ce9 Disable the remaining VPN CTS tests on watches.
- Watches don't support VPN apps.
- The HostsideVpnTests CTS tests are already skipped on watches.
- The tests for VpnManager VPNs do run on watches, but there isn't
  actually a way to start a VpnManager VPN on a watch because there is
  no way to display the consent dialog to the user.
- The VpnService CTS tests verify the VpnService API on watches
  bypassing the consent dialogs.
- Because there is no way to start a VPN app on a watch, there's no
  point requiring the VPN CTS tests to pass.

This CL disables the remaining VPN CTS tests on watches. This allows
watches to disable the VPN service, reducing startup time and memory
usage.

Bug: 286240194
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Idb7110232ae7e45cafc265cd4f955c2a6b22361c
2023-10-02 06:29:46 +00:00
Junyu Lai
35c69c7986 Address review followup comments for NetworkStats
This change includes:
1. Mark groupedBy*() deprecated and throw after android U.
2. Modify map() to mapKeysNotNull().
3. rename clearInterfaces to withoutInterfaces and refactoring.
4. Modify tests accordingly.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Fix: 296149902
Fix: 296150018
Change-Id: I5d97422ba957a212c0c5fbc1eee3f8b174343348
2023-09-04 18:01:14 +08:00
Motomu Utsumi
5324475f6e Add some tests back which were removed for fixing kotlin nullable errors
Followup CL for aosp/2700076

Bug: 296972712
Test: build with aosp/2688146
Change-Id: I617b330c42a99e4c839adac2ea614756b5955ce9
2023-08-24 11:25:21 +09:00
Colin Cross
4e5a061f26 Fix kotlin nullable errors in Connectivity tests
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: Id49e4a2ee0b7b463d99bce6eb22919b84c21443a
2023-08-09 10:57:35 -07:00
Junyu Lai
23d89c0bbf Deduplicate items after clear interface in NetworkStats
Follow-up from commit Ie60829a65d0d9b5b63ad353695a820c0586e3665,
the interface field was cleared before returning the result to
the caller. However, this can cause problems in the
NetworkStats#subtract method. If the interface field is cleared,
the findIndexHinted method can match to a wrong entry.
This is because the keys of multiple entries will now be the
same. This can cause the subtract result to be unexpectedly
large and the return value of getUidStatsForTransport to be
mismatched with the values retrieved from other APIs.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Bug: 290728278
Change-Id: I891ab29b8a2902663febc7c32b04417caf510926
2023-08-01 13:38:26 +08:00
Paul Hu
f51a0139a2 Merge "Move NsdServiceInfoTest to common tests" 2023-07-03 06:24:43 +00:00
Steven Moreland
f85847c137 Remove toString test.
This is not a stable format.

Bug: 285376559
Bug: 265470635
Test: N/A
Change-Id: I15b58ff7a50f9f1acc3d5e8f86f9272855183870
2023-06-01 21:34:50 +00:00
Remi NGUYEN VAN
bee2ee14f3 Move ConnectivityResources to service-connectivity
The ConnectivityResources class is only usable with QUERY_ALL_PACKAGES
permission, so it is not generally usable in framework-connectivity. It
is also backed by the ServiceConnectivityResources APK, which is
intended as resources for service-connectivity.

Move the class to service-connectivity and update callers. CTS needs a
way to determine the supported keepalive count as it used the
resources from KeepaliveUtils as @hide API, so provide a
ConnectivityManager @hide API for testing.

Bug: 279108992
Test: atest
Change-Id: I3c9a77c580b5ab87c922c32778bce15dc33b4d1d
2023-04-28 19:18:39 +09:00
Junyu Lai
9d25241337 Merge changes from topic "statsaccess"
* changes:
  Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
  Move checkAnyPermissionOf to PermissionUtils
2023-04-14 09:54:49 +00:00
Junyu Lai
e68c42b888 Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
Follow up from aosp/1933093. The test failed because certain
devices use a flattened apex that lacks the NETWORK_STACK
permission for sharing with the GTS apk.
Additionally, the NetworkStatsAccess does not recognize the
GTS apk, which holds the MAINLINE_NETWORK_STACK permission.

Test: TH
Bug: 275532605
Change-Id: Icce80a3d3dbea4a84fbd369d9b5fbe0029ab463e
2023-04-11 14:56:15 +08:00
Junyu Lai
2c12f922de Do not crash when passing null into buildTemplateMobileAll
Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkTemplateTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkTemplateTest
Bug: 273963543
Change-Id: I0a8f94df124147e92d35cf474b3d69d1dee6902c
2023-03-30 13:59:02 +08:00
Paul Hu
62503cfef1 Merge "Add a CompatChange flag to enable platform backend" 2023-03-17 13:14:19 +00:00
Paul Hu
2e0a88c0fa Add a CompatChange flag to enable platform backend
Apps targeting sdk < U are considered to use a legacy native
daemon as NsdManager backend, but other apps use a
platform-integration mDNS implementation as backend. So add a
CompatChange flag to enable platform backend for non-legacy
apps.

Bug: 270306772
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I7ba58f8a5186fb49ad5f8aeacc8b8234bef1eabe
2023-03-17 09:10:46 +08:00
Paul Hu
839b81e22f Move NsdServiceInfoTest to common tests
- NsdServiceInfoTest can be the unit and cts test because
  NsdServiceInfo is a Parcelable class. Thus, move
  NsdServiceInfoTest class to common tests directory.
- Also add ConnectivityModuleTest annotation because the tests
  are using some connectivity APIs which need to run with the
  latest module.
- Fix some coding style errors.
- Remove unnecessary ThreadPolicy code which may affect other
  tests.

Bug: 266839012
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Idc4251ef7a1efa294c8a692eb09129440691a22e
2023-03-08 01:43:11 +00:00
Aaron Huang
8ac1143594 Remove requireNonNull check from matchesWifiNetworkKey
matchesWifiNetworkKey expects a non-null value of the
wifiNetworkKey, however, it might be null in practice
and the null wifiNetworkKey will be stored into disk.
And then when the matchesWifiNetworkKey is called, the
requireNonNull will crash the system. Thus, remove the
requireNonNull from matchesWifiNetworkKey to avoid
system crash and handle if the wifiNetworkKey is null
then it should not match a template with non-empty
mMatchWifiNetworkKeys.

Check if WifiInfo contains a null network key then skip it
to prevent adding the identity to the network identity set.
Also, add a Log.wtf when setWifiNetworkKey(info.getNetworkKey()),
this might be useful to catch why the wifiNetworkKey is
null.

Bug: 267815242
Bug: 266598304
Test: FrmeworksNetTests
Change-Id: I9c21f7e3dca9482133c7e331741cf808105414e9
2023-03-07 18:16:55 +08:00
Kangping Dong
7dc4459d33 Merge "add TRANSPORT_THREAD to NetworkCapabilities" 2023-02-28 07:16:16 +00:00
chiachangwang
015b68b192 Add unit tests for new VpnProfile fields
Add and update tests for automaticNattKeepaliveTimerEnabled
and automaticIpVersionSelectionEnabled fields.

Test: atest Ikev2VpnProfileTest VpnProfileTest
Change-Id: I4e424abd2197d9099a2efe0bd8c4b9120bfcfe3a
2023-02-15 15:01:28 +00:00
Aaron Huang
2a69e41772 Merge "Tempates with different subscriber ID should be not equal" 2023-02-10 08:06:07 +00:00
Aaron Huang
c9371d05fe Tempates with different subscriber ID should be not equal
mSubscriberId was removed from NetworkTemplate and equals/hashCode
does not check the mMatchSubscriberIds. This will cause tempates
with different subscriber ID matching that are equal now. Thus
adding the check for mMatchSubscriberIds to fix it.

Bug: 267968247
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I2956bf4c8cf2c4d73ebe102d53e755fbcc5d7642
2023-02-10 08:04:53 +00:00
Yuyang Huang
90a2cbdd8d Moves all compatibility flags to ConnectivityCompatChanges.java
ConnectivityCompatChanges.java becomes the centralized place for all the
CompatChanges used in the Connectivity module. By putting all the
CompatChanges here, we are able to manage them under a single
platform_compat_config.

Bug: 268440216
Test: atest FrameworksNetTests
Change-Id: I3e17af545718073d7d1c96e27298e7790563fd33
2023-02-09 19:51:37 +09:00
Paul Hu
18aecccc9d New API to listen service update
Currently, the resolution is a one shot query, it only notifies
the first finding service information. There is no way to listen
the service update. Thus, add a new API that can register a
callback to listen to the service updates continuously.

Bug: 245369943
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I0e9d92b9028375feb3e344ab6c4acb515c5b2be9
2023-01-19 20:16:03 +09:00
Aaron Huang
2500069488 Merge "Remove *_WILDCARD constants from NetworkTemplate" 2023-01-16 07:56:09 +00:00
Aaron Huang
99348b1664 Merge "Remove mSubscriberId from NetworkTemplate" 2023-01-16 07:55:26 +00:00
Kangping Dong
707a996c9b add TRANSPORT_THREAD to NetworkCapabilities
This commit also updates to use V11 dnsresolver APIs which was V9.

Bug: 262683651
Test: unit tests
Change-Id: Ifbd71157012dc66ec0f377beef9fa59d1c8620b8
2023-01-16 10:51:56 +08:00
Yan Yan
81c2160a63 Expose APIs to migrate IpSecTransform
This commit exposes APIs to migrate a tunnel mode transform to
new source/destination addresses, as required by MOBIKE.

By calling the exposed API, the caller only caches the new
address in the transform. To complete the migration, caller
MUST apply the tranform to the appropriate tunnel.

This API design is mainly based on the kernel interface and use
cases. The Linux kernel requires Android to provide both the
IpSecTransform and the IpSecTunnelInterface to perform the
migration. And in most cases those two instances are managed
by different entities: IpSecTranform is managed by the key
exchange protocol (e.g. IKE) and IpSecTunnelInterface is managed by
the security tunnel provider (e.g. VPN, VCN, and IWLAN). Thus the
migration process has been designed to have two steps where the
key exchange protocol negotiates and caches the new address,
passes out the updated transform, and the security tunnel
provider applies the transform to a tunnel.

Another benefit of this API is it can also apply to the case
where the network peer does not support MOBIKE and thus cannot
update the existing transforms. In this case, the key exchange
protocol can create a new transform and give it to the security
tunnel provider, and the tunnel provider can still call "apply"
to perform migration without needing to know the details of the
transform update process.

Bug: 169171001
Test: atest FrameworksNetTests, IpSecManagerTunnelTest
Change-Id: I0658cdb09fb31f7e0fb9d0b07f37c2b72b6e705f
2023-01-10 19:09:05 +00:00
Aaron Huang
ece181997c Remove *_WILDCARD constants from NetworkTemplate
NetworkTemplate was moved into mainline module and
provide Builder for external users to build template.
MATCH_MOBILE_WILDCARD and MATCH_WIFI_WILDCARD are not
exposed so currently the usage of these two constants
only in module. This change is to remove the constants.

After removing the constants, two methods matchesWifi
and matchesMobile are changed to adapt the original
matches[Wifi|Mobile]Wildcard behavior.

Bug: 238843364
Test: FrameworksNetTests
Change-Id: I9e156b504ce4eb903b39279e443fad27bc921186
2022-12-28 18:49:37 +08:00
Aaron Huang
ee23c03121 Remove mSubscriberId from NetworkTemplate
Currently NetworkTemplate provides Builder for users to build a
template and it supports multiple subscriber ids. The mSubscriberId
is a local variable in current design so it can be removed from
NetworkTemplate and also can be removed from the parameter of a
constructor as long as the constructor is not annotated with
@UnsupportedAppUsage.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic6a695e1c1719111bf26ba905a38673952a24736
2022-12-28 12:09:21 +08:00
Aaron Huang
4854d055bb Remove mSubscriberIdMatchRule from NetworkTemplate
Currently, mSubscriberIdMatchRule is only used in NetworkTemplate
and it depends on if mMatchSubscriberIds is empty or not. Thus,
remove it since is not really necessary and replace it with
checking matchSubscriberIds if needed.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic66d2ff2826846778b004bb15a4718a62fa1f470
2022-12-28 12:09:09 +08:00
Yan Yan
e114b38f07 Support IPsec transform migration
This commit adds methods to support migrating tunnel mode
IpSecTransform to new source/destination addresses.

Bug: 169171001
Test: atest FrameworksNetTests (new tests added)
Change-Id: Ic177015fba5b62d3f73009633118109d3631086f
2022-12-21 23:12:35 +00:00
Mark Chien
82eb31b346 Increased the timeout from 5 to 30 seconds
Increase the timeout to deal with the flaky test.

Bug: 260073439
Test: TH

Change-Id: I653d80cfa97256e139f8cf989a085b1133732092
2022-12-06 06:51:03 +00:00
Treehugger Robot
841b1f33d5 Merge "Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage" 2022-12-02 11:27:27 +00:00
Aaron Huang
c5a05d1d8f Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage
Currently, NET_CAPABILITY_TEMPORARILY_NOT_METERED traffic is
counted as unmetered data usage, and "mobile data usage"
settings screen shows metered data usage which means it doesn't
include TEMPORARILY_NOT_METERED traffic. However, some carriers
show TEMPORARILY_NOT_METERED data usage in customer's bill which
would be confusing if the data usage in the device shows different
results. Thus, revert the change to avoid confusing.

Bug: 183776809
Test: FrameworksNetTests
Change-Id: I4ef25095462adf30b1ecf82134996739f167930d
2022-12-02 16:04:55 +08:00
Aaron Huang
859884a48f Make mMatchSubscriberIds as a NonNull variable
In current design, mMatchSubscriberIds can be null which has the
same meaning with empty set, and is not easy to maintain since it
need more checks for this variable when mSubscriberId is null.
Thus make mMatchSubscriberIds NonNull for the maintenance.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I6cfc529b5f4a39ded8598283ff968f2f4d1bc89f
2022-11-30 16:38:24 +00:00
Aaron Huang
a8a6da0db9 Remove unused methods from NetworkTemplate
NetworkTemplate.Builder was introduced in Android T and the callers
outside of Connectivity module should use this Builder to build a
template instead. Thus remove the buildTemplate* methods from
NetworkTemplate class. Also, deprecate the methods which are
annotated with @UnsupportedAppUsage and also use Builder to build
the template.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I3190325f6663e4771edf5c7a19bf5ecc7780bf12
2022-11-30 16:38:19 +00:00
Chiachang Wang
dfea18945c Merge "Move VpnTransportInfoTest to common test" 2022-11-18 05:44:20 +00:00
chiachangwang
91bac1953c Move VpnTransportInfoTest to common test
Move VpnTransportInfoTest to common test to add the cts
coverage.

Annotate @ConnectivityModuleTest so that the test will
not fail with module that is not up-to-date, and use
assertParcelingIsLossless to prevent similar order module
in device case.

Bug: 256775913
Test: atest CtsNetTestCases:android.net.VpnTransportInfoTest
Change-Id: I1c40a4fc42468748d71c3df5c18b2ceb5b3769e1
2022-11-18 02:17:33 +00:00
Chiachang Wang
89d4bda742 Merge "Expose vpn bypassability in VpnTransportInfo" 2022-11-15 05:35:08 +00:00
Aaron Huang
ac28a04c6e Merge "Enhance NetworkTemplate test" 2022-11-14 09:38:27 +00:00
chiachangwang
d12d2011cb Expose vpn bypassability in VpnTransportInfo
Bug: 256775913
Test: m framework-connectivity.stubs.source.system-update-current-api
Test: m lint-check
Test: atest FrameworksNetTests
Change-Id: I6aaad7b4372aa4f91df4bed89caea674031a6367
2022-11-11 08:38:17 +00:00
Maciej Żenczykowski
5d78c63662 ipsec - use ro.vendor.api_level instead of ro.product.first_api_level
Bug: 254143771
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9f91fc250e0fa40c9dc9ee3e7a2f7bc3cf2ebc75
2022-11-09 00:47:13 +00:00
Aaron Huang
fc4236b945 Enhance NetworkTemplate test
This change addresses comment from aosp/1784390 to improve test

Bug: 200454911
Test: FrameworksNetTests:NetworkTemplateTest#testMobileWildcardMatches
Change-Id: Ia0ac9e44d12e7c9e26cf46adaa26a2e2771947d0
2022-11-02 10:41:08 +00:00
Aaron Huang
0c8d808117 Merge "Make constants static import" 2022-10-17 04:25:25 +00:00
Aaron Huang
4c3159d3a7 Add test for NetworkStats.clearInterfaces
Test: FrameworksNetTests:NetworkStatsTest
Change-Id: Ic8ff1c3213e53a043ebbd3d7ddfeb295a198675d
2022-10-12 18:57:43 +00:00
Chalard Jean
43aae65caf Move MultinetworkPolicyTracker to services, where it belongs.
This is necessary so that MultinetworkPolicyTracker can see
DeviceConfig. It will also allow removing reflection from
this file to address a long-standing TODO.

Test: build
Change-Id: I968bf67e0e0189b01515242371599c02bc9e2ca2
2022-09-27 14:10:41 +09:00
Chalard Jean
020b93ac63 Introduce an overlay for actively preferring bad wifi.
This correctly updates when the mcc/mnc change.

Test: MultinetworkPolicyTrackerTest
Change-Id: I11c7ea7074a15975fb68d39eb3c728778d84a516
2022-09-22 16:58:49 +09:00
Chalard Jean
f11ed8c699 Start listening to telephony changes in #start()
Starting to listen on the handler races with the rest of
the constructor. The class already has a #start() method
meant to start listening, so implement better practices
by leveraging this method.

Test: CtsNetTestCases
      FrameworksNetIntegrationTests
      FrameworksNetTests
Change-Id: I772f761d3ca5f9711b9d988e6330b0878814f491
2022-09-21 18:07:13 +09:00
chiachangwang
4e953f63dd Verify converting to Vpnprofile with IkeTunnelConnectionParams set
Add test to verify converting Ikev2VpnProfile to Vpnprofile with
IkeTunnelConnectionParams set. Some fields like server should
not be set since the information should contain in the assigned
IkeTunnelConnectionParams.

Bug: 243718982
Test: atest FrameworksNetTests
Change-Id: Ie019ea98932a6d079f213e3bff45f21b44d3fa4e
2022-09-14 02:38:26 +00:00
Aaron Huang
f4fbf8ed52 Make constants static import
Bug: 238843364
Test: FrameworksNetTests
Change-Id: Id88bcc175db0a599dd3205812b1bce78012e2216
2022-09-12 06:51:57 +00:00
Chiachang Wang
ebab250383 Merge "Add test to verify null ProxyInfo in Ikev2VpnProfile" 2022-09-02 12:15:09 +00:00