Commit graph android_packages_modules_Co.../tests/unit/java/android
Message SHA1
Merge "[MS25.2] Remove AppOpsManager.OP_GET_USAGE_STATS dependency"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-01-03 22:41:30 +00:00
90cf8dbd92
Merge "wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key"
Les Lee   authored and   Gerrit Code Review   commited 2022-01-03 12:36:49 +00:00
719ce67677
wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key
1. Used SSID to be a wifi network identity can't separate wifi
data usage when there are two different network with same SSID.
Use a new usage key from in WifiInfo to replace wifi SSID to
solve this issue.

2. To support to query wifi usage per configured Wifi network.
Adding matchWifiNetworkKeys in NetworkTemplate to support querying
multi networkKeys wifi data usage since each configured Wifi
network configuration might be used to connect different Wifi
network.

a. Replaced wording SSID with key of the wifi network
b. Add mock to handle get wifi network key from WifiInfo
c. Add null/empty set unit test to verify matchWifiNetworkKeys

Bug: 197520752
Bug: 126299427
Test: atest -c NetworkTemplateTest
Test: atest -c NetworkStatsServiceTest
Test: atest -c NetworkPolicyManagerServiceTest
Change-Id: Id7d66f6548dd1b4e657db8d7427213293618b406

Les Lee   commited 2022-01-03 15:13:45 +08:00
c728c36ca7
[MS25.2] Remove AppOpsManager.OP_GET_USAGE_STATS dependency
Replaced by public interface.

Test: TH
Bug: 204830222
Change-Id: I1071bcaa74429885165d9dc8d1b02a1c1c48c685

Junyu Lai   commited 2021-12-28 10:00:43 +00:00
9051e66b22
[MS26.2] Remove Process.NETWORK_STACK_UID dependency
Check NetworkStack permission instead.

Test: NetworkStatsAccessTest
Bug: 20483022
Change-Id: Ie345cfa7dec8e001246efec8a27a1dc67a5c989c

Junyu Lai   commited 2021-12-28 10:00:43 +00:00
289db92ba4
Merge "[MS15.2] Move SUBSCRIBER_ID_MATCH_RULE_* constants to static lib"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-12-23 01:35:00 +00:00
78d36d7653
Merge "[DU02]Remove DevicePolicyManagerInternal from NetworkStatsAccess"
Frank Li   authored and   Gerrit Code Review   commited 2021-12-22 14:13:55 +00:00
bacbe802c1
[MS15.2] Move SUBSCRIBER_ID_MATCH_RULE_* constants to static lib
Subscriber Id Match Rules won't be exposed as system Api.
Any caller who references NetworkTemplate#SUBSCRIBER_ID_MATCH_RULE_*
should use the one in NetworkStatsUtils instead.
And remove the need of the constants as soon as possible.

Test: atest NetworkPolicyManagerServiceTest \
      FrameworksNetTests
Bug: 204830222
Change-Id: I363a4440f85f1ca818eaf1125e45b141dd6f0e55

Junyu Lai   commited 2021-12-22 09:41:29 +00:00
07c772cf49
[DU02]Remove DevicePolicyManagerInternal from NetworkStatsAccess
NetworkStatsAccess is using DevicePolicyManagerInternal APIs, which
cannot be accessed after moving into the mainline module. So, replace
and remove those hidden API usages.

Bug: 207100745
Test: atest NetworkStatsAccessTest
Change-Id: I0430ed2c47e5a695206cb660e3971ddab6c467dd

lifr   commited 2021-12-21 23:45:28 +08:00
5f66ddac71
[MS12.2] Add unit test for NetworkTemplate builder
Test: atest NetworkTemplateTest
Bug: 204830222
Change-Id: Ie83cd4322418449980bece7e13d68f2cacbaf1ef

Junyu Lai   commited 2021-12-21 03:26:04 +00:00
00a8897e98
[MS10.2] Move multiplySafeByRational to NetworkStatsUtils
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest
Bug: 204830222
Change-Id: Ib2464bd7607c7ef35fed780fccbc745b565a908c

Junyu Lai   commited 2021-12-20 09:10:50 +00:00
b3e62b8d1d
[MS07.2] Move NetworkStatsCollection/IdentitySet into frameworks
These files are needed for the data migration util system Api
interfaces. Thus, they need to be moved into frameworks folder.

This change also set the @IgnoreUpTo annotation to S, since
these tests are testing purely platform code on S- devices which
is not really necessary for MTS. Also the tests are still covered
by the unit tests, since they are always verifying HEAD.

Test: TH
Bug: 197717846
Change-Id: I93c19b4860864c724be9f9f889ee2173f4605198

Junyu Lai   commited 2021-12-09 08:43:16 +00:00
e9710f0918
Merge "Update NSD tests without AsyncChannel"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-11-22 05:58:15 +00:00
469d941752
Update NSD tests without AsyncChannel
Update the tests to use the newer NsdManager based on Binder interfaces
instead of AsyncChannel.

Bug: 190249673
Test: atest NsdManagerTest NsdServiceTest
Change-Id: I0991b598331e335a0bc211f010da7f034fb2441b

Remi NGUYEN VAN   commited 2021-11-18 18:22:45 +09:00
cd4b4ee973
Merge "Add test case to test normalize"
Les Lee   authored and   Gerrit Code Review   commited 2021-11-06 00:54:14 +00:00
b5ee639fe0
Add test case to test normalize
Bug: 194939211
Test: atest -c NetworkTemplateTest
Change-Id: I2f5790b9217357ddcf3f466cec1b2b1afbb47210

Les Lee   commited 2021-11-05 16:59:10 +08:00
5299a2b307
Move fromStableParcelable to KeepaliveController
TcpKeepaliveController is the only user of
KeepalivePacketDataUtil.fromStableParcelable. Because of
fromStableParcelable, networkstack-client needs to depend on
net-utils-framework-commonm, which pulls a lot of unnecessary classes.
This is particularly problematic considering that networkstack-client
may need to be redistributed as a prebuilt.

Move the method to TcpKeepaliveController, simplifying dependencies.
This also shows that fromStableParcelable could be removed altogether
(or moved to tests) if TcpKeepaliveController built a
TcpKeepalivePacketData class directly.

Test: atest ConnectivityCoverageTests
Change-Id: I554318f6bcd07c73d153598a0231e9fcaf912e90

Remi NGUYEN VAN   commited 2021-11-01 13:23:27 +09:00
5d99aa78f7
Add a test for NetworkIdentity.getMetered()
NetworkIdentity has adapted NET_CAPABILITY_TEMPORARILY_NOT_METERED
network capability so add a test case for it.

Ignore-AOSP-First: The parent of this change contains a CL will
conflict with internal tree so ignore AOSP first.
Bug: 183776809
Test: this
Change-Id: I2ca2a8b4db664b76a5a5ee82fcff451efd87c8ff

Aaron Huang   commited 2021-10-26 12:16:03 +00:00
eaca5b1982
Update callers to use buildTemplateMobileWithRatType with metered
The method buildTemplateMobileWithRatType is updated to take
metered as a parameter so the callers should be updated to
the new version.

Bug: 183776809
Test: atest FrameworksNetTest
Change-Id: I859514b93705f9ee4f9ae4b0bcddcb61005a78ff
Merged-In: I859514b93705f9ee4f9ae4b0bcddcb61005a78ff

Aaron Huang   commited 2021-10-25 15:22:59 +00:00
6359ebd099
Increase timeouts for loopers
In coverage tests this seems to randomly fail, which suggests
some delay. Have a constant for timeout and increase its value
significantly where it makes no functional difference.

Test: FrameworksNetTests
Change-Id: I035d865f01688daf3bce30c5130ce550fa84b885

Chalard Jean   commited 2021-10-04 18:02:17 +09:00
1afb2e33e2
Remove reference when active listener is unregistered
The registered listeners are added into internal ArrayMap as a
reference but are not removed when the listeners are
unregistered. The actions for registration should be done in
pairs.

Test: atest FrameworksNetTests
Change-Id: Id9e674f5104d1471dd81224b6a271a8a92172e34

Chiachang Wang   commited 2021-09-30 10:30:35 +00:00
2de41686e7
Add test for CM#[add|remove]DefaultNetworkActiveListener
Bug: 199753782
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I2520f7f5feef61502479767aa023e281d1335ee4

Chiachang Wang   commited 2021-09-30 18:29:29 +08:00
859218c893
Merge "Modify Nsd{Service,Manager}Test to conform to its change"
Luke Huang   authored and   Gerrit Code Review   commited 2021-09-29 03:35:20 +00:00
38f82199ab
Test a template matches mobile and mobile wildcard
Add two test cases for matchesMobile and matchesMobileWildcard

Bug: 183776809
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I14d31071655204fe6ad36c71f7f521640e01c96e

Aaron Huang   commited 2021-09-14 23:36:04 +08:00
cbb4d498c2
Modify Nsd{Service,Manager}Test to conform to its change
(clean cherry-pick from downstream branch)
Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Merged-In: I3cf658498bef5755dcb01127a94fff913b6e6298

Change-Id: I3cf658498bef5755dcb01127a94fff913b6e6298

Luke Huang   authored and   Remi NGUYEN VAN   commited 2021-09-13 10:18:04 +09:00
df75378ad4
Fix IpSecAlgorithmTest on S
The test may be run on S builds older than itself, in which case the
resource ID may not match. Query the resource ID dynamically instead of
using the constant.

IpSecAlgorithm is not updatable in S, which is why it can use
hidden/unstable platform resources, so the test could also be skipped
altogether on S. But considering that keeping it around is not very
costly yet, this change fixes it for running on S.

Bug: 197489543
Test: atest IpSecAlgorithmTest
Change-Id: I533eede3a360a8db9089e65e017b9d7453b35539

Remi NGUYEN VAN   commited 2021-08-25 18:10:22 +09:00
ae7508f9b5
Merge changes from topic "sdk_int_cp"
* changes:
  Fix testSocketKeepaliveLimitTelephony on R
  Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-19 09:47:21 +00:00
800eff01d0
Fix jarjar-related failures in coverage tests
Instead of jarjaring the whole com.android.internal.util package, apply
the jarjar rules per-class. Jarjaring the whole package causes problems
in tests, as for example ConnectivityServiceTest depends on Vpn that
uses other internal utils as hidden API, and these should not be
jarjared.

Also avoid jarjaring INetdUnsolicitedEventListener which is used by
NetdEventListenerServiceTest, and ensure KeepalivePacketDataUtilTest
expects the right package name in toString.

Generally the problems appear because ConnectivityCoverageTests also
includes tests for classes that are not part of the connectivity module,
and use hidden APIs that refer to classes that should not be jarjared.
Some of the tests could be excluded from the coverage suite instead, but
keeping them is helpful for future modularization efforts.

Test: Build service-connectivity, dexdump classes and verify jarjared
      atest ConnectivityCoverageTests
Change-Id: Id6b7e6833d49fa03d9442d7c1c3e4dc16fb48dfc

Remi NGUYEN VAN   commited 2021-07-14 15:22:56 +09:00
ed8efa75b4
Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411

lucaslin   authored and   Remi NGUYEN VAN   commited 2021-07-08 09:44:39 +09:00
6f77442d76
Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
Replace all FIRST_SDK_INT usage in Connectivity because it has
been renamed to DEVICE_INITIAL_SDK_INT.

Bug: 184735771
Test: m CtsNetTestCases
Merged-In: I2f155592b08cdbf259a00b035cacb37ca9847e72
(clean cherry-pick)

Change-Id: I2f155592b08cdbf259a00b035cacb37ca9847e72

paulhu   authored and   Remi NGUYEN VAN   commited 2021-07-05 14:18:26 +09:00
bee1c6d9cd
Merge "Add tests for in-kernel VPN/VCN dataplane"
Benedict Wong   authored and   Gerrit Code Review   commited 2021-07-02 18:42:15 +00:00
64619cabc1
Add tests for in-kernel VPN/VCN dataplane
This change adds relevant tests for the migrateTun functionality in
NetworkStats.

Bug: 190620024
Test: atest NetworkStatsTest
Change-Id: I33f14f2d0f71013a594fd4c8c3914a590d30ea06

Benedict Wong   commited 2021-07-02 00:39:32 -07:00
1117e853f9
Re-skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

This applies a previous change, this time using DevSdkIgnoreRunner,
as SdkSuppress does not work as expected in branches that have a
codename 2 versions above the SDK version, as is the case in AOSP.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
      atest FrameworksNetTests on S
Change-Id: I5808d34459a4c19238baf8873afa7cf942828460

Remi NGUYEN VAN   commited 2021-06-30 12:00:28 +09:00
154cf1da20
Revert "Skip connectivity unit tests before S"
This reverts commit 05dd1ba540.

Reason for revert: Skips more tests than it should in AOSP
Bug: 192302892

Change-Id: I7c5638d8c1cc626354d240a06af758e1cdd92e94

Remi NGUYEN VAN   commited 2021-06-29 01:08:00 +00:00
284b3c028c
Skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
Change-Id: I10da45ae023e7f1e8cd11ec857b84346892a3fa8

Remi NGUYEN VAN   commited 2021-06-25 10:10:12 +09:00
05dd1ba540
Add more unit tests for ConnectivityManager S APIs
Test: atest android.net.ConnectivityManagerTest
Bug: 188657173
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I33612650eb89486a14fcfc440ba0c357f4bb513c
Change-Id: I33612650eb89486a14fcfc440ba0c357f4bb513c
  (cherry-picked from ag/14640282)

Junyu Lai   commited 2021-06-24 03:20:39 +00:00
92c29c56d7
Move ConnectivityDiagnosticsManagerTest to common
The tests are also useful in CTS to ensure that the
ConnectivityDiagnosticsManager class API is implemented properly
(including behavior of the DataStallReport class for example).

Bug: 187935317
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: I86f39238054f43403f9a1e383dd2a935de84f06f

Remi NGUYEN VAN   commited 2021-06-21 19:33:28 +09:00
7e23f18158
Make tests compatible with mockito-extended
This does not change the mockito library to use mockito-extended in
FrameworksNetTests, but changes the tests so that they would pass if
built against that library.

This is useful to run FrameworksNetTests in a common test suite with
other tests that use mockito-extended, for example a common connectivity
coverage test target.

The change includes increasing the test timeout in
ConnectivityServiceTest, as mockito-extended can have performance impact
(~3 times on hwasan builds). This change does not make tests run slower
in the current FrameworksNetTests suite though.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: I61fa371e8957037075a2617a014647ff062207c6

Remi NGUYEN VAN   commited 2021-06-16 17:53:08 +09:00
c9c745f2f2
Merge "Fix KeepalivePacketDataUtilTest crash on eng build"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-15 07:08:23 +00:00
efdffa82f8
Add unit test when querying TYPE_WIFI + null/empty/non-null subscriberId
Starting with API level 31, the subscriberId is applicable
for the wifi network. Considering applications may use
null or an empty string as subscriberId (for instance, cts),
frameworks create MATCH_WIFI_WILDCARD NetworkTemplate when querying
wifi network with null or an empty string which is the behavior before
API level 31.

Bug: 188915450
Test: atest -c NetworkStatsManagerTest
Change-Id: Id4ae06840e1749997e970b8f1ec391060967bd47

Les Lee   commited 2021-06-15 12:04:23 +08:00
a0592d3e06
Fix KeepalivePacketDataUtilTest crash on eng build
The test causes a Log.wtf to be logged, because it tests a method that
should not be used after R. Mock the terrible failure handler to avoid
crashes on eng builds.

Test: atest KeepalivePacketDataUtilTest

Change-Id: Ic06a0db7fefb4acf38b66feba9b47e21f9927b1c

Remi NGUYEN VAN   commited 2021-06-14 18:13:39 +09:00
b397b5645a
Revert "Use mockito-extended in FrameworksNetTests"
This reverts commit 98b76cc2ec.

Reason for revert: <INSERT REASONING HERE>

b/190622577

Change-Id: Ief39f82875e6fa885829aea62eed00f2f2e6774e

xingdai   commited 2021-06-10 21:41:54 +00:00
892a0ef152
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

Remi NGUYEN VAN   commited 2021-06-08 19:12:09 +09:00
98b76cc2ec
Merge "Improve IKEv2/IPsec VPN by proposing more IPsec algorithms"
Yan Yan   authored and   Gerrit Code Review   commited 2021-05-21 22:00:30 +00:00
70a118d80d
Improve IKEv2/IPsec VPN by proposing more IPsec algorithms
This commit allows IKEv2/IPsec VPN to propose more algorithms that
newly added in IpSecAlgorithm. Those new algorithms have stronger
security guarantees and better performances.

This commit also removes algorithm name validation because all
algorithms are URL encoded to ensure no special characters create
problems due to their use by VpnProfile for list or field delimiting
(e.g. rfc7539esp(chacha20,poly1305))

Bug: 185265778
Test: atest FrameworksNetTests, CtsNetTestCases
Test: All new algorithms are manually verified
Change-Id: I1de322c95aacc8924e95bcdbcfdbd1ec441de99c

Yan Yan   commited 2021-05-21 17:46:54 +00:00
86783c3711
Merge "Add metered filter for API: buildTemplateCarrier"
Les Lee   authored and   Gerrit Code Review   commited 2021-05-18 13:01:38 +00:00
e14af82411
Add metered filter for API: buildTemplateCarrier
This CL modifies NetworkTemplate#buildTemplateCarrier to force on
metered carrier network and rename to buildTemplateCarrierMetered.
This method was introduced recently and has no callers.

This method will be used in Settings and NetworkPolicyManagerService
to display and manage data usage on carrier metered networks.

Settings/NetworkPolicyManagerService will use it instead of the existing
method buildTemplateMobileAll method, which only matches metered networks.
That code will change from matching metered mobile networks to matching
metered carrier networks.

Note: The carrier metered network includes metered mobile network and
metered "merged carrier wifi network" that is a specific cerrier wifi network
which provides the same user experience as mobile.

Bug: 176396812
Test: atest -c NetworkTemplateTest
Change-Id: I7196d62bb60844458a6c4b1d94e2baccb71e15cd

lesl   authored and   Les Lee   commited 2021-05-14 11:04:17 +08:00
70d9ccdc9b
QOS filter matching support based on remote address and port number for connected sockets
This CL adds APIs for telephony to perform filter matching based on
remote address if the socket is connected. Additional checks will be
performed on the state of socket to avoid the future callbacks in a
separate CL.

Bug: 181916576
Test: Manually verified in live T-Mobile network
      atest ConnectivityServiceTest
      atest com.android.internal.telephony.dataconnection.QosCallbackTrackerTest

Change-Id: I6fbd4e84c76bc4acbf4e59f06f8e86e0237bae29

Jayachandran C   commited 2021-05-13 09:50:13 -07:00
b533550b06
Move net unit tests to packages/Connectivity
Move the tests together with packages/Connectivity code, so both can be
moved to packages/modules/Connectivity together.

Also reorganize unit tests in a unit/ directory, as other tests
(integration/, common/ etc.) have been added in tests/net since they
were created. This makes the directory structure consistent.

Test: atest FrameworksNetTests
Bug: 187814163
Merged-In: I254ffd1c08ec058d594b4ea55cbae5505f8497cc

Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc

Remi NGUYEN VAN   commited 2021-05-13 08:30:33 +00:00
5ed250d90a