Commit Graph

1781 Commits

Author SHA1 Message Date
Paul Hu
bad6fe9835 Report sent query count
Report the sent query count when the discovery is stopped.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I47b91c0c530eee2f00920ee5ea99e8d7b6e2e9ee
2023-08-22 17:26:27 +08:00
Paul Hu
ddce5919af Report service info callback metrics data
Bug: 287546772
Test: atest FrameworksNetTestCases
Change-Id: I630c0e4921f7acf42bf29812d9790ee5a894d60b
2023-08-22 15:25:37 +08:00
Paul Hu
6014905672 Report resolution stop
Report the nsd metrics event of resolution stop.

Bug: 287546772
Test: atest FrameworksNetTestCases
Change-Id: I2e6de22c946d58a3410f16b2f2689fd3ffc635a4
2023-08-18 11:59:06 +08:00
Paul Hu
a6bc463155 Report resolution metrics data
Collect information on resolution success and failure events,
then use this data to build metrics and report them.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I373ce91fea9d5a278f53fc0c505be90dd39b2d5b
2023-08-16 15:53:06 +08:00
Paul Hu
812e9217b9 Report discovery metrics data
Collect information on discovery start, failure, and stop events,
then use this data to build metrics and report them.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I2f6a718024870f9658cfeabe8995624a3ad81f05
2023-08-16 15:09:17 +08:00
Paul Hu
d45bf5499f Merge "Fix NullPointerException on NsdService" into main 2023-08-10 09:03:41 +00:00
Paul Hu
101dbf5262 Fix NullPointerException on NsdService
The NsdService will throw a NPE if a new client is registered
with a null INsdManagerCallback object. To avoid this, perform
a null check before registering a new client and throw an
IllegalArgumentException if the callback is null.

Bug: 293285797
Test: atest FrameworksNetTests
Change-Id: Id61e27873591031c3fe383879aee0d40eebc08b3
2023-08-10 14:19:01 +08:00
Junyu Lai
ef0afdef0e Merge "Fix flaky test: testDataMigration_differentFromFallback" into main 2023-08-09 08:53:46 +00:00
Treehugger Robot
b15f7d1e68 Merge "Allow VPN lockdown UID ranges to stack properly" into main 2023-08-09 08:05:20 +00:00
Junyu Lai
353ec97c64 Fix flaky test: testDataMigration_differentFromFallback
Test main thread mocked settings object but use that on the handler
thread as well, which is not thread-safe.
Create a real object instead of mocking it instead.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#testDataMigration_differentFromFallback \
      --rerun-until-failure 500
Fix: 289705810
Change-Id: Ibfb722818467fdf2b69a4b8fa87b4ac04a713573
2023-08-09 14:44:23 +08:00
Treehugger Robot
b7d3f3fd77 Merge "Use destroyLiveTcpSocketsByOwnerUids for frozen apps" into main 2023-08-09 05:17:14 +00:00
Chiachang Wang
f574524c0b Merge "Add VpnTest back to presubmut" into main 2023-08-08 08:39:21 +00:00
chiachangwang
1a72396be6 Add VpnTest back to presubmut
These tests were disabled from presubmit because of flaky test.
It's no longer flaky now, so add these tests back to presubmit.

Bug: 293233390
Test: atest FrameworksNetTests
Change-Id: I7f1f36385d2ca6ed210e1d9b7399b6509fd26519
2023-08-07 08:47:34 +00:00
Treehugger Robot
8ba50ae30f Merge "Fix flake : testVpnSetUnderlyingNetworks" into main 2023-08-07 05:22:20 +00:00
Chalard Jean
9033477aa7 Fix flake : testVpnSetUnderlyingNetworks
When the device is very slow to run this test, cell might end
its lingering period in the middle of the test while wifi is
the default. VPN will then ignore it as an underlying network,
causing the test to fail.

Test: testVpnSetUnderlyingNetworks
      Added sleep in a strategic place to make sure the problem
      was correctly identified, and observed the test failing.
      After the fix, the test passes with the sleep.
Fixes: 280627836
Fixes: 293844384
Change-Id: Iaf56de963eb17845c1d76a0310b55f7f9321f7e4
2023-08-07 14:20:13 +09:00
Yuyang Huang
7ddf2935f9 Replace usage of android.util.Log to SharedLog
Bug: 294326360
Test: atest FrameworksNetTests
Change-Id: I9a3a84f907362260bdcf6be19e2c4d5345788d2e
2023-08-06 17:34:50 +09:00
Yuyang Huang
33fa4d268c Add callbacks for service offload
Components that can provide offload like IpClient (packet
filter offloading) can use the API to register a callback to be notified
when offload is necessary.

Bug: 269240366
Test: atest CtsNetTestCases
Change-Id: I8080702f5b530001b88e79e504f4722ac01bc576
2023-08-04 19:22:15 +09:00
Chiachang Wang
89b25779e3 Merge "Add version control for packet address translation design" into main 2023-08-03 06:58:28 +00:00
chiachangwang
144dd51761 Add version control for packet address translation design
This commit adds the version control for keepalive packet address
translation design to prevent device crash if the network stack
is not updated to a newer version. This commit also adds a
DeviceConfig to control the design in newer module version.

Bug: 291870956
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Id4efbf51dae9154d2bc3a1ee405e2139d5c91e36
2023-08-02 12:16:31 +00:00
Treehugger Robot
865bfacab7 Merge "Deduplicate items after clear interface in NetworkStats" into main 2023-08-01 07:40:57 +00:00
Motomu Utsumi
dc9cb1da23 Merge "Revert isDefaultNetworkActive behavior when there is no default network" into main 2023-08-01 05:49:47 +00: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
Motomu Utsumi
51e7a60359 Revert isDefaultNetworkActive behavior when there is no default network
aosp/2605757 updated isDefaultNetworkActive returns false when there is
no default network.
But this change was not merged to U release branch and this change was
not well tested by dogfooding.
So this CL reverts the isDefaultNetworkActivity behavior change.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: Id88662faea9eeaba93d59ab2729f6204a3631ab1
2023-08-01 12:50:00 +09:00
Motomu Utsumi
3f35bb2fce Merge "Revert onNetworkActive callback behavior on U+" into main 2023-07-31 10:34:41 +00:00
Motomu Utsumi
1e51a64988 Revert onNetworkActive callback behavior on U+
aosp/2605757 changed onNetworkActive callback behavior on U+ but this
change was not merged to U release branch.
This CL reverts the behavior change and keep the current behavior on U+.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: I91ccc7ee93f0827986401f316997b4a2df11318f
2023-07-31 19:33:24 +09:00
Chiachang Wang
52f3e8f29e Merge "Deflake doTestPlatformVpnWithException related tests" into main 2023-07-31 08:54:14 +00:00
chiachangwang
9f9a4dc69c Deflake doTestPlatformVpnWithException related tests
This commit updates test to
- Execute IkeSessionCallback inside executor. The callback should
  be called from executor in production code but test trigger the
  callback from test main thread which will result in unexpected
  code interaction.
- Verify the timer directly. The origin design verifies
  interactions with Captor with uncertain interaction. Test
  should be able to verify the schedule() calls with the expected
  timeout value. Also, in lower performance device, device may
  still process previous interaction. Add longer timeout to reduce
  flakes.

Bug: 293233390
Test: atest FrameworksNetTests
Test: atest VpnTest#testStartPlatformVpnFailedWithRecoverableError
      --rerun-until-failure 100
Change-Id: Ie42a2597a382800d6484a086b6d808490dfbdd32
2023-07-31 04:59:58 +00:00
Hansen Kurli
ebdda22240 Merge changes Ia5fc3e53,Ie1ab6013,I1cd5acb3 into main
* changes:
  Unregister BroadcastReceiver and OnSubscriptionsChangedListener.
  Disable KeepaliveStatsTracker before T.
  Disable KeepaliveStatsTracker instead of throwing.
2023-07-28 11:20:21 +00:00
Junyu Lai
a6be6cd48a Merge changes from topic "hostsidevpntestflaky" into main
* changes:
  Skip presubmit for flaky tests in FrameworksNetTests due to Out of SLO
  Skip presubmit for flaky tests in HostsideVpnTests due to Out of SLO
2023-07-28 02:06:17 +00:00
Chiachang Wang
32a8cbce6f Merge "Increase timeout to deflake tests" into main 2023-07-28 00:37:42 +00:00
chiachangwang
595fac0840 Increase timeout to deflake tests
In failed log, VPN still process the migration which does not
send the network capabilities update to network agent.
In low performance devices like cuttlefish, it may sometimes
cause flaky. Specify a longer timeout to deflake the test.

Bug: 293233390
Test: atest FrameworksNetTests
Change-Id: I4e6c80c03e19efb448ee2806c5a250425b0e068f
2023-07-27 09:17:00 +00:00
Junyu Lai
b8fc755259 Skip presubmit for flaky tests in FrameworksNetTests due to Out of SLO
Test: TH
Bug: 293233390
Change-Id: Ic1d0d86b3f8dfc8e8122c6b05973fab8b57e52b4
2023-07-26 16:31:46 +08:00
Paul Hu
6be7db441c Merge "Report registration metrics data" into main 2023-07-26 00:45:34 +00:00
Treehugger Robot
9a9852d782 Merge "Add polling and logging when launcher is settings" into main 2023-07-25 08:12:30 +00:00
Treehugger Robot
4525688b2d Merge "Move QueryTaskConfig to a standalone class" into main 2023-07-25 04:51:55 +00:00
Yuyang Huang
54125ef545 Merge "Ensure the ServiceTypeClient Executor threads can be shutdown" into main 2023-07-25 03:05:08 +00:00
Yuyang Huang
bbd573b92f Move QueryTaskConfig to a standalone class
Bug: 292470176
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Iff15e7b59277444bbaa92b98318bb4f910eea070
2023-07-24 18:34:09 +09:00
Yuyang Huang
66cd57f2d8 Ensure the ServiceTypeClient Executor threads can be shutdown
When ServiceTypeClient is not used, the Executor threads should be
shutdown as well.

Bug: 287013457
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I9dae01e7b6c2bcd395a98f4362f0c36f1535b2a6
2023-07-24 16:14:19 +09:00
Paul Hu
777ed05c73 Report registration metrics data
Collect information about registration successes, failures, and
unregistrations, then build metrics data from this information
and report it.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I6324279b479da2e61b7519d96df5ad24a432e54a
2023-07-24 14:50:48 +08:00
Paul Hu
2048dd2ad3 Address leftover comments
- Rename QuerySentResult to QuerySentArguments
- Add constants INVALID_TRANSACTION_ID
- Remove useSessionIdToScheduleMdnsTask check
- Update subtype in MdnsServiceTypeClientTests

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I5e544d505c645262c213d40cdd94a79088ac4886
2023-07-20 05:34:57 +00:00
Remi NGUYEN VAN
6c3f4160df Add polling and logging when launcher is settings
getLauncherPackageName sometimes returns "com.android.settings", causing
the test to fail.

Add polling for the launcher to not return settings, and logging to
try to understand why this happens, especially if polling does not solve
the issue.

Bug: 286550950
Test: atest

Change-Id: I90963d5db326732dfc82db07f36676190ffdcce9
2023-07-19 18:49:59 +09:00
Paul Hu
e85479a1eb Move MdnsResponseDecoder.Clock to MdnsUtils
This is a no-op change. The Clock class is a wrapper that is
used for testing. So move it from MdnsResponseDecoder to
MdnsUtils for subsequence metrics changes.

Bug: 287546772
Test: m
Change-Id: If4c8c0061c76ae26fc78a5ff463a31d57470fba0
2023-07-17 11:35:27 +08:00
Hansen Kurli
1363cf4e43 Unregister BroadcastReceiver and OnSubscriptionsChangedListener.
1. Unregister BroadcastReceiver of default subscription id.
2. Use a CompletableFuture to store and unregister the
   OnSubscriptionsChangedListener. Note this has to be done since the
   listener cannot be constructed in the handler thread.

Bug: 288059409
Test: atest FrameworksNetTests
Change-Id: Ia5fc3e53305a99c32ad2f6d5b1b6a367dc20c1d7
2023-07-14 07:47:04 +00:00
Hansen Kurli
21eae05622 Disable KeepaliveStatsTracker instead of throwing.
Avoid throwing errors when something unexpected occurs with the
keepalive state since metrics should not cause a crash. Instead, disable
the tracker and skip writing the metrics.

Bug: 288059409
Test: atest FrameworksNetTests
Change-Id: I1cd5acb32eb062ccdf7d1ac3e25a21309ad011c2
2023-07-13 09:56:20 +00:00
Chiachang Wang
c21ccc8399 Merge "Use utility method to execute things on the handler" into main 2023-07-13 03:24:29 +00:00
chiachangwang
26bd4adfc2 Use utility method to execute things on the handler
Replace Handler.post() with visibleOnHandlerTread().

Test: atest FrameworksNetTests
Change-Id: I3a2f166d939db8ed6ac7fbb1cb9306256ae22189
2023-07-12 11:33:51 +00:00
Paul Hu
9f353f9cc6 Merge "Deal with responses on MdnsServiceCache" into main 2023-07-12 10:54:00 +00:00
Paul Hu
cd57c783f5 Merge "Remove synchronized lock in MdnsServiceTypeClient" into main 2023-07-12 09:48:48 +00:00
Paul Hu
639e3c70bb Deal with responses on MdnsServiceCache
To cache services and respond quickly, the MdnsServiceTypeClient
should add all services to the MdnsServiceCache and remove any
services from there as well.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: If0a9e6b563a0992ac25b8cde7f3beb00700f1c11
2023-07-12 08:12:54 +00:00
Paul Hu
2118d33da8 Remove synchronized lock in MdnsServiceTypeClient
Now that all access to MdnsServiceTypeClient parameters is
running on the handler thread, the synchronized lock is no
longer necessary. Therefore, the synchronized lock can be
safely removed from MdnsServiceTypeClient.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I5cd28aa738ea3c199b75097f4583e98be86a6ee7
2023-07-12 08:10:22 +00:00