Commit Graph

335 Commits

Author SHA1 Message Date
Treehugger Robot
e41baf1752 Merge "Add logging on UnfinishedStubbingException" am: f2ddb4151c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1805818

Change-Id: Id8aa8e2c460891500b2926b0585edd0bfd972fa9
2021-09-13 02:46:35 +00:00
Treehugger Robot
f2ddb4151c Merge "Add logging on UnfinishedStubbingException" 2021-09-13 02:34:27 +00:00
Junyu Lai
6f988d4042 Merge "Include suspended network when getAllNetworkStateSnapshots" am: 48426bb2a4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1797867

Change-Id: I700e16334e0f8aeea862555e8ecf784cf36fd315
2021-09-09 09:40:15 +00:00
Junyu Lai
48426bb2a4 Merge "Include suspended network when getAllNetworkStateSnapshots" 2021-09-09 09:24:04 +00:00
Junyu Lai
ddecb66246 Include suspended network when getAllNetworkStateSnapshots
Suspended network should be considered as temporary shortage of
connectivity of a connected network. Thus, it should not be
excluded from network state snapshots and causes data usage to
stop accounting or iptables rules to be removed on the interface
of the suspended network.

This change also address the naming confusion of default networks
parameter of expectNotifyNetworkStatus.

Test: atest ConnectivityServiceTest#testGetAllNetworkStateSnapshots
Bug: 196079981
Change-Id: I8096356f9a472fb1c1246fbdf3fd5f981387fb1c
2021-09-08 06:02:28 +00:00
Paul Hu
9477c7b5ca Merge changes Id2ffb056,I2a4e298b am: 420fa2baef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772667

Change-Id: I84acbefcaf5cb95cc208d27caf8a89c0717db94e
2021-09-07 06:13:41 +00:00
Paul Hu
420fa2baef Merge changes Id2ffb056,I2a4e298b
* changes:
  Adjust some behaviors on PermissionMonitorTest
  Use common code
2021-09-07 06:01:54 +00:00
Chalard Jean
3fe1865b96 Merge "Remove a forgotten log" am: 3d872e662e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1803417

Change-Id: I5714b36c6f0f71887848aa8aa41697fca6c409aa
2021-09-07 04:51:49 +00:00
Chalard Jean
3d872e662e Merge "Remove a forgotten log" 2021-09-07 04:37:23 +00:00
paulhu
941fa70744 Adjust some behaviors on PermissionMonitorTest
- This is a test only change.
- Remove calling startMonitoring() in setup() because this method
  should be called only once, so each test needs to call
  startMonitoring() if the testing function is running on it.
- Return empty list instead of null when getting installed
  pacakges in setup(). This can help test to have default user
  MOCK_USER1 when they call startMonitoring().

Bug: 192431153
Test: atests FrameworksNetTests
Change-Id: Id2ffb056b378873c3ba6a8bb31b7dedb56ad6d46
2021-09-07 09:46:23 +08:00
Paul Hu
2fe543353b Merge "Correct uid to app id for netd traffic permission methods" am: 9fe8c8fc76
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1767733

Change-Id: I11d1e21c7510c5f2d07198d8930134c6a9976708
2021-09-07 01:26:18 +00:00
paulhu
b7dd7a3f4b Use common code
- Some code are used many times, it's better to make them as
  common code for reducing inconsist behavior.
- Also stop using Boolean to represent network permissions and
  replace them with int value. Because using Boolean for
  permission comparison is really complicated and bizarre.
- Use PERMISSION_* for netd network permission directly.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I2a4e298b9a01f4b2874ae68e9d9539a0ab4aff4c
2021-09-07 09:25:31 +08:00
Paul Hu
9fe8c8fc76 Merge "Correct uid to app id for netd traffic permission methods" 2021-09-07 01:13:56 +00:00
Paul Hu
f74a08823e Merge "Reduce duplicated code" am: 1d04d8362f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1767727

Change-Id: I7612eb48c780c94b47f4741eb85b91b3cdf0a44f
2021-09-06 16:33:38 +00:00
Paul Hu
1d04d8362f Merge "Reduce duplicated code" 2021-09-06 16:17:45 +00:00
Remi NGUYEN VAN
f68905683f Add logging on UnfinishedStubbingException
The test flakes with UnfinishedStubbingException, but the root cause
could not be identified. Add some logging to try to get more information
when that happens.

Bug: 195626111
Test: atest ConnectivityServiceTest

Change-Id: If12c1ea809789148ca9251386e5ee6ca6d74ff74
2021-09-06 15:13:09 +09:00
paulhu
1d4ec79020 Correct uid to app id for netd traffic permission methods
Some uids should be app ids, correct them for avoiding confusion
and incorrect use.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I4a5930e5dc63b4d901e1567f8935ad7203866c89
2021-09-06 00:12:23 +08:00
paulhu
7a29739f2f Reduce duplicated code
- This is a test only change.
- Some methods are very similar and duplicated. So merge them to
  improve readability and reduce code complexity.
- Stop spying PermissionMonitor.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I8ec17bd2d396c4d49dd8b64be85d89d0145f4c3c
2021-09-03 15:58:15 +08:00
Orion Hodson
89213602ee Merge "Fix IpSecAlgorithmTest on S" am: 0084591e94
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1806806

Change-Id: I152aaf741e474f9cf6d39a86be9ff4800a83b1b4
2021-08-26 07:59:21 +00:00
Remi NGUYEN VAN
ae7508f9b5 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
2021-08-25 18:10:22 +09:00
Chalard Jean
1347844336 Remove a forgotten log
Test: ConnectivityServiceTest
Change-Id: Idc3b91422263bf5d062ee1682f41fc28616376b6
2021-08-25 13:19:04 +09:00
Chalard Jean
72ed43d6dc Merge "Fix an infinite loop with network offers" am: 77992bbfbb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1800007

Change-Id: I1fe463232308fbc73753dc8d19f269142f6f8776
2021-08-20 06:39:30 +00:00
Chalard Jean
bb902a5fee Fix an infinite loop with network offers
When the avoidBadWifi configuration is false and not overridden,
a WiFi network that was validated in the past but becomes
unvalidated needs to outscore a cell network that is validated.
This is happening correctly when the stack compares two networks.
However, when the stack compares an existing network to an offer
for a cellular network, the offer was automatically considered
not to yield. This would mean the stack would be requesting cell
out of the telephony factory, only for that network to lose to
WiFi and be discarded immediately, then recreated again etc.

When there is some other reason cell should be up (such as the
"mobile always on" setting being active), this would not be
visible because the cell network would have another reason not
to be torn down.

Have offers correctly account for the current value of the
configuration and setting. This has the ranking of the offer
lose against WiFi like the actual network loses, meaning the
offer is not needed.

This also requires updating the offers whenever the value of
the setting changes.

Test: new test for this, also ConnectivityServiceTest
Bug: 195441367
Change-Id: I4fe5de98bc15bcf9bbbe25c6c7c8a7ba382f8db7
2021-08-19 22:53:41 +09:00
Xin Li
e534ce4c55 Merge "Merge sc-dev-plus-aosp-without-vendor@7634622" into stage-aosp-master 2021-08-17 18:15:09 +00:00
Treehugger Robot
b8178678df Merge "Add a unit test for a bug in registerDefaultNetworkCallback." 2021-08-17 01:32:39 +00:00
Lorenzo Colitti
bbadec37d2 Add a unit test for a bug in registerDefaultNetworkCallback.
Currently, when a VPN app calls registerDefaultNetworkCallback,
it will always get its own VPN, even if the VPN app called
VpnService.Builder#addDisallowedApplication to take itself out
of the VPN's UID ranges.

Add a test for the current incorrect behaviour.

Also fix an indentation error elsewhere.

Bug: 195265065
Test: test-only change
Change-Id: Id9648ea71fc7ae10855aa311beeb7975569d17f2
2021-08-17 01:36:54 +09:00
Treehugger Robot
1ac3e27399 Merge "Fix a flake in ConnectivityDiagnostics" 2021-08-16 09:01:58 +00:00
Chalard Jean
4da146bd2f Fix a flake in ConnectivityDiagnostics
Bug: none
Test: ConnectivityServiceTest
Change-Id: I9242226be976e7c346addcbaf7e2b0154a3829f7
2021-08-16 16:05:06 +09:00
Xin Li
3ec4468fb7 Merge sc-dev-plus-aosp-without-vendor@7634622
Merged-In: I5a33f959c8ae5a34584f57508f392038e44062e7
Change-Id: Ib4e5e75ee8bbe19806bdc2f69590d164fb75774b
2021-08-14 06:31:05 +00:00
Benedict Wong
5805d3cfd2 Merge "Prevent NPEs when registering/unregistering ConnDiags CBs." 2021-08-12 20:35:39 +00:00
Chiachang Wang
8787b2ab68 Remove the @Ignore annotation on testAvoidBadWifi am: 73745baa38 am: 3bac051c7a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1773885

Change-Id: Ibec81bed964cab7f9bc18cf7cabf0b52d0eeb824
2021-08-10 05:41:23 +00:00
Chiachang Wang
73745baa38 Remove the @Ignore annotation on testAvoidBadWifi
testAvoidBadWifi could pass without issue. The refactor should
also be done. The test does not need to be ignored now. Remove
the annotation to bring the test coverage back.

Bug: 178071397
Test: atest ConnectivityServiceTest
Change-Id: I5652fa817f16b8c241f1e2066a0b04ad2156a3b7
2021-08-10 05:17:29 +00:00
Lucas Lin
9e2ffd6a23 Merge "Add test for [stop|start]VpnProfile()" into sc-dev am: 2900ffbb5f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15359731

Change-Id: Ieb3774e45cacb9c9e2e3ebea1ba55c757d2679e8
2021-08-10 02:38:50 +00:00
Lucas Lin
2900ffbb5f Merge "Add test for [stop|start]VpnProfile()" into sc-dev 2021-08-10 02:28:24 +00:00
TreeHugger Robot
4e257a92ca Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." into sc-dev 2021-08-06 18:35:45 +00:00
Luke Huang
2bb20e6637 Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." am: d4c0d59179 am: 29b6cb0288
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1789012

Change-Id: I601a0046b5ae33cee9d267c7a4bdc1ead949ae22
2021-08-06 17:46:22 +00:00
Luke Huang
d4c0d59179 Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." 2021-08-06 17:10:36 +00:00
Remi NGUYEN VAN
0ccf3fb461 Use dns resolver v9 in connectivity and set resolverOptions to null.
The resolverOptions member of the ResolverParamsParcel has never
been set by AOSP code but was only used by OEMs modifying
DnsManager. Now that DnsManager is mainline code, this is no
longer possible. So the DNS resolver introduces a new
setResolverOptions IPC to allow OEMs to set the options and makes
the resolverOptions nullable.

Make DnsManager set resolverOptions to null, to ensure that when
DnsManager calls setResolverConfiguration, it does not overwrite
any options set by the OEM.

Bug: 194048056
Test: Device boots and has connectivity
Change-Id: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
Merged-In: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
2021-08-06 22:21:51 +09:00
Remi NGUYEN VAN
30bebea049 Use dns resolver v9 in connectivity and set resolverOptions to null.
The resolverOptions member of the ResolverParamsParcel has never
been set by AOSP code but was only used by OEMs modifying
DnsManager. Now that DnsManager is mainline code, this is no
longer possible. So the DNS resolver introduces a new
setResolverOptions IPC to allow OEMs to set the options and makes
the resolverOptions nullable.

Make DnsManager set resolverOptions to null, to ensure that when
DnsManager calls setResolverConfiguration, it does not overwrite
any options set by the OEM.

Bug: 194048056
Test: Device boots and has connectivity
Change-Id: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
2021-08-06 21:19:38 +09:00
Remi NGUYEN VAN
6c1e049e29 Merge changes Ic33d8976,Ib5bd74d8 into sc-dev
* changes:
  Mock connectivity resources in integration tests
  Add overlay options for no internet notifications
2021-08-05 07:17:31 +00:00
Chalard Jean
5234f3acc6 Fix a crash when changing preferences
The crash occurs when some app has more than half its limit
in requests that will need to be moved to some other default
network upon changing the preferences.
This will send the requests for this app over the limit
temporarily when creating new requests for the reevaluated
ones.

While ConnectivityService has a provision for making a
transaction-like addition/removal of requests that is meant
to avoid exactly this kind of crash with the transact()
method on PerUidCounter, the code only transacts on
mSystemNetworkRequestCounter. But these requests are counted
in the mNetworkRequestCounters, which is not part of the
transaction, causing the crash anyway.

To avoid the problem, this patch allows the request counters
to go over the max if and only if the system server is
updating the request counts for a UID other than its own.
This should allow only the case where ConnectivityService is
moving the requests over to the new per-uid default, while
keeping the exception when registering from an app (then the
calling UID is not the system server), or when the system
server registers its own requests (then the UID inside the
request is that of the system server).

A much better solution than this patch would be to completely
eliminate the transact() method by somehow unregistering the
old ones before creating the new ones.
However this would be a much bigger and difficult patch than
this, and much more dangerous, because callers depend on the
list of requests to find out the old requests to remove, so
they have to be created first.

Another possible clean solution would be to count the
requests not in the NRI constructor, but later. This would be
more error-prone though because it would be very easy to
create an NRI without counting it.

Bug: 192470012
Test: ConnectivityServiceTest. Improve tests so they catch
      this case.

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1781202

Merged-In: Ia482e6fbf2bf300ce6cbaca72810d394ed201b98
Change-Id: I6744d2f60d6bd664f048b532a58461c110a5b7fe
(cherry picked from commit 916aeb7b0d)
2021-08-05 10:33:12 +09:00
Chalard Jean
faa5bad6c3 Merge "Fix a crash when changing preferences" am: aeb051b962 am: 916aeb7b0d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1781202

Change-Id: I39a8e756c73c675fc0eb74f3d570d128f6ecf390
2021-08-04 12:48:02 +00:00
Chalard Jean
aeb051b962 Merge "Fix a crash when changing preferences" 2021-08-04 12:23:52 +00:00
Remi NGUYEN VAN
893494289b Add overlay options for no internet notifications
Add an option to display the no internet dialog directly instead of
showing a notification when the notification would have been high
priority (typically when the network was explicitly selected). This is
disabled by default, but allows device manufacturers to use a slightly
more disruptive UX to ensure that the user is aware that the network has
no connectivity, and can take action.

Also add an option to show the same notification as "no internet"
instead of the "partial connectivity" notification. This is also
disabled by default, but allows device manufacturers to use the "no
internet" text if they feel that "partial connectivity" text is hard
to understand for the user.

Bug: 193847396
Test: atest NetworkNotificationManagerTest
Original-Change: https://android-review.googlesource.com/1782433
Merged-In: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
Change-Id: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
2021-08-04 08:20:24 +00:00
Remi NGUYEN VAN
f51a0ded84 Merge "Add overlay options for no internet notifications" am: 4f39cacbc3 am: aca228c07a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1782433

Change-Id: I87238b54c517a4efb11bca6e23cc2484b66f217e
2021-08-04 08:08:20 +00:00
Remi NGUYEN VAN
5dc6ca0318 Add overlay options for no internet notifications
Add an option to display the no internet dialog directly instead of
showing a notification when the notification would have been high
priority (typically when the network was explicitly selected). This is
disabled by default, but allows device manufacturers to use a slightly
more disruptive UX to ensure that the user is aware that the network has
no connectivity, and can take action.

Also add an option to show the same notification as "no internet"
instead of the "partial connectivity" notification. This is also
disabled by default, but allows device manufacturers to use the "no
internet" text if they feel that "partial connectivity" text is hard
to understand for the user.

Bug: 193847396
Test: atest NetworkNotificationManagerTest
Change-Id: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
2021-08-04 11:23:03 +09:00
Treehugger Robot
d266885202 Merge "Add a small comment to a test" am: 8ba4b12dff am: 9529651ecb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779754

Change-Id: Iff5cd49863772e5ed1d7e0cbc2f3161fc9d3b753
2021-08-03 15:44:23 +00:00
Treehugger Robot
8ba4b12dff Merge "Add a small comment to a test" 2021-08-03 15:00:26 +00:00
Treehugger Robot
b1263d0363 Merge "Mock DisplayMetrics in NotificationManagerTest" 2021-08-03 05:09:14 +00:00
Treehugger Robot
e89c417ce3 Merge "Merge NetdServiceMonitor into NetdMonitor." am: 44021f4a17 am: 7a1dfa1238
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1767648

Change-Id: Ia6d652a9aa23ade3f9d24fef9f05676549fb1d89
2021-08-02 16:37:56 +00:00