Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
No-op cleanup
Test: atest ConnectivityServiceTest
Change-Id: Ic07c94785d97bd654ffce960e8bc2652c2dbc3d6

Chalard Jean   commited 2021-07-16 12:02:22 +09:00
6d8f2fbf99
Merge "Remove hidden ArrayUtils usage in test"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-12 02:21:12 +00:00
946da61e70
Remove hidden ArrayUtils usage in test
Internal utils are generally jarjared by connectivity jarjar rules, but
ArrayUtils is not actually statically linked into the tests, so this
makes the ConnectivityCoverageTests fail. FrameworksNetTests has been
fine because it does not use jarjar, but does not exercise updated code
because of that.

Remove usage of the hidden utility, as there are reasonable alternatives
with non-hidden APIs that avoid other breakages long-term.

Bug: 187935317
Test: atest ConnectivityCoverageTests:ConnectivityServiceTest
Change-Id: I8ed85b941c3d1028771a5ac33196b1509a95789d

Remi NGUYEN VAN   commited 2021-07-09 18:52:51 +09:00
61cc1ac9bd
Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
(cherry-pick from ag/14731887)
Merged-In: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

paulhu   commited 2021-07-07 23:06:43 +08:00
aa0743d7c4
Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-07 03:53:17 +00:00
1d2ad89424
Merge "Fix flake in testMobileDataAlwaysOn"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-07 03:52:38 +00:00
02ea3f55c1
Merge "Use Netd new added/removed uid range methods"
Paul Hu   authored and   Gerrit Code Review   commited 2021-07-07 03:07:10 +00:00
51bfbbfb1b
Use Netd new added/removed uid range methods
Replace network[Add|Remove]UidRanges to
network[Add|Remove]UidRangesParcel. The new methods are passing
NativeUidRangeConfig which contains priority value for each uid
range rules.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
(cherry-pick from ag/14911836)
Merged-In: I08bbdbcb8450b08e6208fa730137348550f9e3d2

Change-Id: I08bbdbcb8450b08e6208fa730137348550f9e3d2

paulhu   authored and   Paul Hu   commited 2021-07-07 03:06:32 +00:00
0e79d95332
Fix flake in testMobileDataAlwaysOn
The internal structure backing getAllNetworks is updated after
invoking lost callbacks, so the test needs to wait for the handler
to be idle before calling getAllNetworks.

Also avoid assertions in finally clauses, as it causes confusing
error messages.

Bug: 185081944
Change-Id: I8ad5ab45a3e65b0031672e6f594b1a6d6ad5abcb
Test: atest ConnectivityServiceTest

Remi NGUYEN VAN   commited 2021-07-06 06:09:17 +00:00
e687d5844e
Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported
The test relied on waitForIdle to ensure diagnostics callbacks were called,
but as this may require several iterations in the handler queue, this makes
the test unreliable.

Use mockito timeouts on the verify() calls instead.

Bug: 192651465
Change-Id: Iae1704af7ae3649eae301c6aee223ac753629d55
Test: atest ConnectivityServiceTest

Remi NGUYEN VAN   commited 2021-07-06 06:05:38 +00:00
1f210f792a
Merge "Move BitUtils, RingBuffer test to coretests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-05 05:05:34 +00:00
6be4ebcb0a
Merge "Listen EXTERNAL_APPLICATIONS_AVAILABLE intent"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-02 16:56:12 +00:00
321558ffe8
Listen EXTERNAL_APPLICATIONS_AVAILABLE intent
- Some applications are installed on external storage and they
  are unavailable until exernal storage installed them
  completely. And their permission need update after becoming
  available. Thus, listen EXTERNAL_APPLICATIONS_AVAILABLE intent
  and update those package whose is listed in chaged package
  list.
- Remove user argument on buildPackageInfo() because the uid on
  ApplicationInfo is based uid.

Bug: 145234989
Test: atest FrameworksNetTests
Merged-In: Ia11ca4a7ba6fc1b87c27c0c40e36c91d9cdb322a

Change-Id: Ia11ca4a7ba6fc1b87c27c0c40e36c91d9cdb322a

paulhu   commited 2021-07-02 22:35:26 +08:00
8a4ce40acb
Merge "Allow non-VPNs to have underlying networks."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-02 13:28:01 +00:00
5903d5646c
Allow non-VPNs to have underlying networks.
Certain network types, like the VCN, have underlying
networks for the purpose of data usage, but do not want to
propagate the underlying network capabilities.

Allow these networks to set underlying networks, but continue
not to propagate the capabilities.

Bug: 190620024
Test: new unit test
Change-Id: I53d6080f48707ff3c37fbfbef534284ba77a7432

Lorenzo Colitti   commited 2021-07-02 18:48:25 +09:00
bd079455f1
Move BitUtils, RingBuffer test to coretests
The utilities are part of com.android.internal.util, but were
historically tested as part of the services.net tests. They were then
mistakenly moved to packages/modules/Connectivity with the rest of the
networking code, but actually belong in coretests.

Bug: 187935317
Test: atest FrameworksCoreTests
Change-Id: I74702f6a4d9bed5985d2a830dacd78129a7854a8

Remi NGUYEN VAN   commited 2021-07-02 16:24:01 +09:00
a1b3f57eb8
Merge changes from topic "conn-diags-skipped"
* changes:
  Update ConnDiags CTS test to expect validation result SKIPPED.
  Report result SKIPPED in ConnDiags if the network is not validated.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-07-02 06:26:57 +00:00
05752a5316
Merge "Change to REQUEST from LISTEN for mobile data preferred uids feature"
Paul Hu   authored and   Gerrit Code Review   commited 2021-07-02 01:10:56 +00:00
7079b72fa6
Report result SKIPPED in ConnDiags if the network is not validated.
This CL updates ConnectivityDiagnostics to report
NETWORK_VALIDATION_RESULT_SKIPPED when the platform does not validate
the reported Network. This CL also updates the behavior for
ConnectivityManager#reportNetworkConnectivity, such that it will always
generate a ConnectivityReport on the reported network. If the reported
connectivity does not match the known connectivity of this network, the
network is revalidated and a report is generated. Otherwise,
revalidation is not performed and the cached ConnectivityReport is sent
instead.

This CL also updates ConnDiags behavior for calls to
ConnectivityManager#reportNetworkConnectivity. Specifically, ConnDiags
callbacks are only notified for these calls if:
  a) the call causes the Network to be re-validated, or
  b) the callback registrant was the caller of
     #reportNetworkConnectivity().
For b), the caller is always guaranteed to receive a ConnectivityReport
(a fresh report if the Network is re-validated, else the cached report).

Bug: 162407730
Test: atest FrameworksNetTests ConnectivityDiagnosticsManagerTest
Change-Id: I78b78919d5b0f09348dfdd5fdb37418b8c7f861f

Cody Kesting   commited 2021-07-01 17:38:16 -07:00
f1120be78b
Merge "Make notification icons and autocancel overlayable"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-01 09:49:37 +00:00
2c7e0714c6
Make notification icons and autocancel overlayable
Allow overlays to change the connectivity notification icons, and
whether the notifications are auto-cancelled.

This does not change default behavior, but is necessary to allow vendors
to adapt the notifications to their standards.

Bug: 173171709
Bug: 172048052
Test: atest NetworkNotificationManagerTest
      Added test overlay, verified icon replaced
Change-Id: Ibbb765a5e828b8b870cbfb81e89df2dbd2828be7

Remi NGUYEN VAN   commited 2021-07-01 16:04:09 +09:00
3a8198c3ba
Merge "Simplify the return condition in stop()"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-07-01 01:46:59 +00:00
584ab08627
Simplify the return condition in stop()
Previously, the return condition in stop() will check if the state
is STOPPING and the reason is ERROR_INVALID_NETWORK. The condition
is too restricted so that if another event is happened after binder
died, the exception will be thrown and crash the system.
Since calling stop() twice doesn't make sense, so relax the condition
of return when the state is STOPPING.

Bug: 182586681
Test: atest FrameworksNetTests
Change-Id: I2454c1c080d8954dd3785d4ac6e96fc4131fdb47

lucaslin   commited 2021-07-01 02:29:53 +08:00
40d931c474
Change to REQUEST from LISTEN for mobile data preferred uids feature
- If Mobile data always on is OFF, mobile data preferred uids
  feature does not work.
- We need to request mobile data when MDO list is not empty.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases

Signed-off-by: Ansik <ansik.shin@samsung.com>
Change-Id: Ie9d6b3e39ef16813c4be3979900d226c8f3d656d

Ansik   authored and   paulhu   commited 2021-06-30 14:22:34 +00:00
605e77055c
Fix network callback with the same PendingIntent does not release
Currently, ConnectivityService uses EVENT_REGISTER_NETWORK_LISTENER
to dispatch registering network callback with pending intent, this
is wrong since the code flow will not check if the pending intent
is duplicated. Thus, the registration will be duplicated if the
caller uses the same pending intent and register multiple times.

This change fixes the logic by using
EVENT_REGISTER_NETWORK_LISTENER_WITH_INTENT instead of
EVENT_REGISTER_NETWORK_LISTENER when dispatching register network
callback with pending intent.

Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkRequest_identicalPendingIntents
Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkCallback_identicalPendingIntents
Test: atest ConnectivityServiceTest#testNetworkCallbackMaximum
Test: 1. Use test app to file callback with same PendingIntent
       2. Check dumpsys output
Bug: 189868426
Change-Id: I38bdea3a026a78a6dc34b5200d43a75b3cd1ac0c

WeiZhang   authored and   Junyu Lai   commited 2021-06-30 12:05:43 +00:00
1cc3f17413
Merge "Re-skip connectivity unit tests before S"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-30 07:43:08 +00:00
a9230c1bf7
Merge "Add option to make sign-in notification ongoing"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-30 05:12:09 +00:00
ea395bf6a0
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
Add option to make sign-in notification ongoing
Add an overlay boolean that allows setting the SIGN_IN notification as
an ongoing notification.

This can be useful to make sure users can always easily find the
notification to sign in to a captive portal, as studies have found that
some users have a tendency to dismiss notifications before reading them.
At the same time the notification shade is generally too crowded, which
is what causes such behaviors in the first place, so this option is not
enabled by default and should generally not be enabled without proper
user studies or metrics.

Bug: 173171709
Test: atest NetworkNotificationManagerTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ic187d2a2b7e49ad152ea2aa35bb784864b97473c

Remi NGUYEN VAN   commited 2021-06-30 11:59:11 +09:00
57c0380135
Merge "Revert "Skip connectivity unit tests before S""
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-29 08:14:26 +00:00
b0c9e64d33
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
Merge "Use appId instead of uid"
Paul Hu   authored and   Gerrit Code Review   commited 2021-06-28 03:35:45 +00:00
683c386403
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
Make yield-to-bad-wifi behavior backward compatible with R
Yielding cell wins to exiting wifi (whether good or bad).
It loses to bad wifi that's not exiting.

In R, yielding to bad wifi only affects wifis that are
unvalidated, but a wifi that is exiting should still be
dropped in favor of a cell that yields to bad wifi.

I had misunderstood the policy and implemented it wrong.
Now it's implemented right, and has careful tests.

Test: new tests for this
Bug: 186458024
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ib8637100d491e72a2edb837584ce55b7dda58524
Change-Id: Ib8637100d491e72a2edb837584ce55b7dda58524
  (cherry-picked from ag/14486203)

Chalard Jean   authored and   Junyu Lai   commited 2021-06-24 03:33:05 +00:00
6b2f09272c
Merge "Fix the comments from aosp/1719018"
Luke Huang   authored and   Gerrit Code Review   commited 2021-06-23 03:36:02 +00:00
0c20c4901f
Merge "Provide a way to override the avoid bad wifi configuration"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-06-23 00:48:17 +00:00
38e8c2c94b
Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732

Chiachang Wang   commited 2021-06-22 14:54:02 +08:00
6eac9fb787
Merge "Add connectivity coverage tests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-21 10:55:33 +00:00
cc79d7c0f8
Fix the comments from aosp/1719018
1. Test {start,stop}-service
2. Add waitForIdle

Bug: 181810560
Test: atest NsdServiceTest
Change-Id: I0953887d1d92a644a29a2e80521469c8cc2aa2fc

Luke Huang   commited 2021-06-21 04:54:33 +00:00
05b013c83f
Use appId instead of uid
Multiple user's ares of mApps are not initialized in startMonitoring(),
so mApps.get(uid) of multi-user's app returns null in onPackageAdded().
As the result, permission of system uid is updated to "Network" and
any system application cannot use dedicated apn like IMS.
Using appId avoids this problem.

Bug: 168932048
Test: atest FrameworksNetTests

Signed-off-by: Sangcheol Lee <goodsc.lee@samsung.com>
Change-Id: Ib8ea2185d8056bddb2ca5a8006f83afb3cffc9f4

Sangcheol Lee   commited 2021-06-17 13:35:58 +09:00
1e5d742596
Merge "Make tests compatible with mockito-extended"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-16 13:22:37 +00:00
ad7108ce34
Merge "Remove ConnectivityServiceTest signature perms use"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-16 11:09:05 +00:00
54c7434f0d
Add connectivity coverage tests
The coverage tests will allow measuring code coverage for all
Connectivity+Tethering code.

This is a combination of the current TetheringCoverageTests, and
FrameworksNetTests.

Adding min_sdk_version to the test prevents it from using deprecated
IoUtils utilities. Replace it with the non-deprecated alternative.

Test: atest ConnectivityCoverageTests
Change-Id: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383

Remi NGUYEN VAN   commited 2021-06-16 19:45:20 +09:00
fe20e1317d
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
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
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359

Remi NGUYEN VAN   commited 2021-06-16 16:32:03 +09:00
18a979fa41
Merge changes from topic "per-app-cts"
* changes:
  CTS tests for setOemNetworkPreference
  Update CS so that per-app OEM APIs can be tested

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-16 00:47:06 +00:00
5f78e30839
Merge "Send a proxy broadcast when apps moved from/to a VPN"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-06-15 09:26:21 +00:00
cfc86ef0f6
Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I0ea71b348492aeb4784d487bed4cfd5d387426ba

Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba

paulhu   commited 2021-06-14 15:55:55 +00:00
e99137226e
Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I63f65bffc1b8883ddfd774222e26e629d7ea1f94

Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94

paulhu   commited 2021-06-14 15:53:05 +00:00
01f52e7cce
Merge "Correctly get uids for per-app network preferences"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-14 06:07:56 +00:00
473ddeaebb