Commit Graph

66162 Commits

Author SHA1 Message Date
Chalard Jean
d20e94e4e5 Validate NetworkCapabilities on unparceling
(and also on parceling, which is not really essential, but
still feels better)
This will avoid issues with NC objects unparceled by processes
when the sender was malicious.

Test: FrameworksNetTests
Bug: 246542132
Bug: 246542330
Change-Id: I8b40eb0c11e39b98bce23dc4e3df037c04639000
2022-09-29 18:31:48 +09:00
Zhi Dou
8344c8bcee Merge "Enable R8 shrinking of standalone system server jar service-connectivity" 2022-09-27 11:15:31 +00:00
Patrick Rohr
b47364dfd3 Merge "ethernet: unregister NetworkAgent before stopping IpClient" 2022-09-27 08:01:42 +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
zhidou
b33a2638db Enable R8 shrinking of standalone system server jar service-connectivity
This change enables R8 shrinking, and R8 full mode of standalone system
server jar service-connectivity. Keep rules are specified based on the entries in
frameworks/base/services/java/com/android/server/SystemServer.java. Keep rules of classes extending SystemServer is inherited from "standalone-system-server-module-optimize-defaults", https://cs.android.com/android/platform/superproject/+/master:packages/modules/common/proguard/Android.bp, which is a set of common rules for standalone system server jar. Keep rules of proto is inherited from "proguard_basic_keeps", https://cs.android.com/android/platform/superproject/+/master:build/make/core/proguard_basic_keeps.flags, which is the common set of keep rules for all dex target.

The
size of service-connectivity will be reduced by 31% from 2094301B to 1426485B.

Test: Presubmit and MTS. Run MTS locally with command `mts-tradefed run` with `mts-tethering`, `mts-network`, `mts-cellbroadcast` on  Pixel 4 with sunfish-userdebug image.
Bug: 233746531
Change-Id: I291c9d880a1ffc7dc87f932f9d27ce3740b9dc36
2022-09-27 04:03:13 +00:00
Patrick Rohr
88a8565697 Merge "ethernet: delete testListenEthernetStateChange" 2022-09-27 03:55:44 +00:00
Patrick Rohr
64b7696994 ethernet: unregister NetworkAgent before stopping IpClient
When NetworkAgent unregisters, it invokes destroyNativeNetwork() which
deletes all routes. This process is not synchronized with IpClient. So
on an IpClient restart, it can happen that destroyNativeNetwork()
executes after the IpClient has restarted, which causes the new routes
to be deleted.

Moving NetworkAgent#unregister() to before stopping IpClient hopefully
improves this situation.

Test: atest EthernetManagerTest
Bug: 240323229
Change-Id: I68f5b35ba48d5892db0e03fa34b1884b4612485a
2022-09-26 20:54:08 -07:00
Lucas Lin
4904cde167 Merge "Clean up VpnTest" 2022-09-26 13:51:19 +00:00
Hungming Chen
0090e969af ClatCoordinator: only dump information when clat is started
ClatCoordinator should not rely on the caller Nat464Xlat to
avoid dumping when clat is not started. It is safer to dump
information after ClatCoordinator has checked its status.
Only dumping ClatCoordinator with clatd started reduces the null
pointer check of dumped elements as well.

Test: atest ClatCoordinatorTest
Change-Id: Ia0be9a593cd75fd34f647230d642b0dcf84aaf3b
2022-09-26 10:32:42 +00:00
Treehugger Robot
23196b6ccb Merge "Cleanup test (fix comment + make a helper easier to use)" 2022-09-26 08:50:11 +00:00
Jean Chalard
435ac367b8 Merge changes I5b93af75,Idb05b6a6,I5bc42afb,I6694db49,Ib7aba464
* changes:
  Add unit tests for preferring bad wifi
  Add the notification for actively prefer bad wifi
  Clear notif upon bad wifi off + tests for bad wifi notif
  Detect captive portals as they are tested, not upon notifying
  Implement the "actively prefer bad wifi" feature
2022-09-26 04:46:56 +00:00
Chalard Jean
565d679dc0 Cleanup test (fix comment + make a helper easier to use)
Test: ConnectivityServiceTest
Change-Id: Ia3e30d863cf860ee44fa5ea961b5aa0d0b8e44bb
2022-09-26 02:57:30 +00:00
Patrick Rohr
10b848d95b ethernet: delete testListenEthernetStateChange
This test has been broken for a while. It tested:
- adding a listener triggers an interface state changed callback and an
  ethernet state changed callback.
- setEthernetEnabled calls back the correct listeners and removes / adds
  the interface.

Interface state listeners are already well covered in
EthernetManagerTest. I am currently working on adding tests for
setEthernetEnabled (there is partial coverage in setUp and tearDown of
EthernetManagerTest).

Bug: 242671512
Test: atest EthernetTrackerTest
Change-Id: Id1325a9056384444affb5c096cbc19d200ae0c4e
2022-09-25 17:04:33 -07:00
Treehugger Robot
d748bf6b6b Merge "Import translations. DO NOT MERGE ANYWHERE" 2022-09-25 03:53:01 +00:00
Chalard Jean
4203229ac9 Add unit tests for preferring bad wifi
This tests both the behavior of preferring bad wifi and
the notification.

Test: this
Change-Id: I5b93af756e898998f769015004c3286cd2ac5222
2022-09-24 11:35:15 +09:00
Chalard Jean
e9332c4bdf Add the notification for actively prefer bad wifi
With this patch and "config_activelyPreferBadWifi=1"
(or SDK level >= U) and bad wifi avoidance turned off,
when the device connects to a bad wifi, after 20
seconds of the wifi not validating the device will
pop up a head-up notification with text
"<SSID> has no internet access".

When tapped, the notification will bring up the existing
Settings dialog :
*Wifi not connected to the internet*
You can switch to mobile whenever Wi-Fi is bad
 □ Never show again
 <Stay on Wi-Fi> <Switch to Mobile>

If the wifi validates and loses access again, the same
notification/dialog are shown if Settings.Global.
NETWORK_AVOID_BAD_WIFI=PROMPT ; if IGNORE, the device
stays stuck on wifi.
If AVOID, then bad wifi avoidance is turned on in the
first place, so none of this happens.

Behavior in other cases :
- If config_activelyPreferBadWifi=0, then upon connecting
  to a wifi without internet, the behavior is unchanged :
  the device stays on mobile and after 8 seconds a
  notification pops up asking whether to stay connected.
  If the network validates, then loses access, the behavior
  depends on a few things :
  - If config_networkAvoidBadWifi is 0 and Settings.Global.
    NETWORK_AVOID_BAD_WIFI = IGNORE, then the device stays
    on wifi and says nothing.
  - If config_networkAvoidBadWifi is 0 and Settings.Global.
    NETWORK_AVOID_BAD_WIFI = PROMPT, then
    notification pops up asking whether to switch to mobile.
  - If config_networkAvoidBadWifi is 1 (regardless of the
    value of Settings.Global.NETWORK_AVOID_BAD_WIFI), or if
    Settings.Global.NETWORK_AVOID_BAD_WIFI = AVOID, then
    the device switches back to mobile.

- If Mobile is not connected, all the above applies. This
  is not great for the messages including "switch to mobile"
  but this patch doesn't change it.

Test: manual
Change-Id: Idb05b6a6e5c085f5ef72435d462e14bfd1341f87
2022-09-24 11:11:51 +09:00
Chalard Jean
1325a631cc Clear notif upon bad wifi off + tests for bad wifi notif
If a notification is up and the avoid bad wifi setting
is turned off, the notification should disappear.

This patch also adds some general tests for the bad wifi
notifications.

Test: new tests in this patch
Change-Id: I5bc42afbe0efd93cfb59a759bf0aaba49a4bfc9f
2022-09-24 11:11:51 +09:00
Chalard Jean
8a9061f0b5 Detect captive portals as they are tested, not upon notifying
In the previous code, ConnectivityService would mark a network
a captive portal when NetworkMonitor sends it a message to notify
the user for it. Theoretically, this is incorrect ; instead, the
marking should be done upon receiving the message that the network
was tested to be a captive portal.

In practice this hasn't been a problem so far. The captive portal
capability is observable in the app-received callbacks, but for
these purposes the old code and the new code behave the same, in
that in the callbacks, the network used to not have the portal
capability, then later it acquires it.

However, this is only not a problem as long as the captive portal
bit isn't used by network selection, which an upcoming change has
to implement for the "prefer bad wifi" feature. When that is the
case, network selection prefers the wrong result between the time
the network is marked as having been evaluated and the time the
network has been marked a captive portal. It should be marked as
both at the same time to avoid this discrepancy. This is what
this patch is accomplishing.

To do this correctly, this patch also has to disconnect the network
immediately upon it being tested as a captive portal if the old
CAPTIVE_PORTAL_MODE setting is set to CAPTIVE_PORTAL_MODE_AVOID,
instead of keeping it until NM sends the message to notify about
it.

Unfortunately because of the relative timing of the events this
patch has observable impact on what callbacks are sent because of
b/245893397 (the DoubleValidated bug). Before this patch, there
would be an extra useless callback when a captive portal validates
where the capabilities contain both VALIDATED and CAPTIVE_PORTAL,
then a second callback removing CAPTIVE_PORTAL. This patch fixes
this, but unfortunately introduces a symmetrical extra useless
callback when a captive portal network starts matching a callback,
where onCapabilitiesChanged is fired a second time after the
onAvailable sequence with the same capabilities. Fixing this is
very complex ; the best (and simplest) solution is really to
address b/245893397 decisively.

In the mean time, the behavior implemented by this patch is better
than the old one, because there no longer is an observable state
where the network is supposed to be a closed captive portal AND
validated, but instead there is a useless, but correct, caps
callback that mirrors exactly the one from b/245893397. When
b/245893397 is addressed this behavior goes away at the same time,
so this is probably the better behavior.

Test: FrameworksNetTests CtsNetTestCases
Change-Id: I6694db498507860e1d711e2aa0c591dfbfa90be2
2022-09-24 11:11:49 +09:00
Bill Yi
11f459f7b9 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: I475151b25c98424460d655afca232204832e1734
2022-09-23 12:10:08 -07:00
Bill Yi
5f0a5bd8a7 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: I36f586feb4dcdcca5fd61141c224b7a8d8eda050
2022-09-23 12:09:08 -07:00
Jean Chalard
778c9c9f52 Merge changes I7414c278,I11c7ea70
* changes:
  Only wait for 8 seconds when T && !activelyPreferBadWifi
  Introduce an overlay for actively preferring bad wifi.
2022-09-23 07:24:36 +00:00
Xinyi Zhou
b630dfc3a9 [CTS] Fix CTS failure in mainline train 2/2 am: b0b4fa9c10
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2225582

Change-Id: I51e7089aacf21d3b319aba57e274e999452e4d8a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-22 16:59:35 +00:00
Chalard Jean
9708f7239c Implement the "actively prefer bad wifi" feature
Test: in progress
Change-Id: Ib7aba464a2f32642d434418842306dfcf90b8319
2022-09-22 16:59:30 +09:00
Chalard Jean
e63c42f543 Only wait for 8 seconds when T && !activelyPreferBadWifi
Also addressing a cleanup comment from aosp/2210758

Test: FrameworksNetTests
Change-Id: I7414c27840ec84e5ad0aef6d76a7aa7bc39c51fc
2022-09-22 16:59:17 +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
Patrick Rohr
1b8cac56b9 Merge "ethernet: reenable testUpdateConfiguration_forOnlyCapabilities" 2022-09-22 03:45:33 +00:00
Junyu Lai
3e7778805b Merge "Revert^2 "[ST02.2] Use the getters of DnsHeader"" 2022-09-22 02:39:42 +00:00
Xinyi Zhou
b0b4fa9c10 [CTS] Fix CTS failure in mainline train 2/2
- Use reasonable key value in DataElementTest

Test: -m CtsNearbyFastPairTestCases
Bug: 244133414
Change-Id: Ice0307205bba5a0220ac68bb0ec8bb756f531b5f
2022-09-21 16:31:41 -07:00
Patrick Rohr
51827dfbfc ethernet: reenable testUpdateConfiguration_forOnlyCapabilities
Reenabling the test since b/240323229 has been fixed.

Test: TH
Bug: 240323229
Change-Id: I061d961c66084ada24e12a78dc9b973e075c1286
2022-09-21 14:45:08 -07:00
Xinyi Zhou
b1391d5d15 Merge "[CTS] Fix CTS failure in mainline train" into android13-tests-dev am: 2d3df1b225
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2222423

Change-Id: I3b27262819528d048be3352407a1759ce0526ce1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-21 21:34:10 +00:00
Patrick Rohr
1c40837525 [automerger skipped] Merge changes from topic "dscp-cts13-r2" into android13-tests-dev am: 68e3c3c634 -s ours
am skip reason: Merged-In I1d2bfd52e05c334f9808e60455c346b4dca18cf7 with SHA-1 1bba92f1bc is already in history

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

Change-Id: I2533d44b3239192df5e033b986d242137d2bc003
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-21 21:33:50 +00:00
Patrick Rohr
62916eb8ce [automerger skipped] DscpPolicy: remove v6 default route as it is added by the RA am: e0196ea540 -s ours
am skip reason: Merged-In I1d2bfd52e05c334f9808e60455c346b4dca18cf7 with SHA-1 1bba92f1bc is already in history

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

Change-Id: I2f5da0bbbf8011726b50420348d415cc2e9cf489
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-21 21:33:44 +00:00
Patrick Rohr
d837becc15 Merge changes I29f7d2b4,Ie2aa7529
* changes:
  Revert "Add SkipPresubmit to EthernetManagerTest"
  ethernet: reenable IPv6 provisioning delays
2022-09-21 21:30:00 +00:00
Patrick Rohr
0a822f8f41 Merge changes I0b88bc8b,I60d884db,I436858e7,Iaaace0e6,Ie7ee84c3, ...
* changes:
  ethernet: cleanup updateConfiguration tests
  ethernet: fix callbacks for running interfaces
  ethernet: test callbacks when adding running interface
  ethernet: ensure EthernetOutcomeReceiver receives only one result
  ethernet: fix enable/disableInterface result
  ethernet: remove enable/disable interface unit test
2022-09-21 19:08:02 +00:00
Patrick Rohr
68897055cd ethernet: cleanup updateConfiguration tests
Unfortunately, TestableNetworkCallback.expectCapabilitiesWith cannot be
used as it expects to be passed a HasNetwork object.

Test: atest EthernetManagerTest
Change-Id: I0b88bc8b51711db4464608a5075dec32a1fc8ef7
2022-09-21 12:03:15 -07:00
Patrick Rohr
cc2bf28207 ethernet: fix callbacks for running interfaces
updateInterfaceState(true) changes the interface state and triggers an
interface state callback. In addition, maybeTrackInterface() always
sends out a callback (which is correct, as for an interface that is
being added, maybeTrackInterface() would send the initial DOWN
callback). setTetheringInterfaceMode() (the other caller of
addInterface) also already sends its own callback.

Test: atest EthernetManagerTest
Change-Id: I60d884db5e788639b035cad1dd0d6c316e5836f7
2022-09-21 12:03:15 -07:00
Patrick Rohr
270211ddbf ethernet: test callbacks when adding running interface
Test: atest EthernetManagerTest
Change-Id: I436858e7aaa4d709df9115c1f8cdeb3e7c1c75e9
2022-09-21 12:03:15 -07:00
Patrick Rohr
bb320db199 ethernet: ensure EthernetOutcomeReceiver receives only one result
Sending multiple callbacks to one receiver is an easy trap to fall into.
Asserting that the future has not completed in EthernetOutcomeReceiver
should catch this mistake.

Test: atest EthernetManagerTest
Change-Id: Iaaace0e6604558bfc2fc1ae58c2744185e0b13ca
2022-09-21 12:03:15 -07:00
Patrick Rohr
d337299e66 ethernet: fix enable/disableInterface result
Calling enableInterface() / disableInterface() for an interface already
in the correct state used to return an error which is incorrect
according to the API specification in EthernetManager. onError() is now
only returned for untracked and server mode interfaces.

This change also fixes the updateInterfaceState() function signature.

Test: atest EthernetManagerTest
Change-Id: Ie7ee84c3756a8a0c489a38548214fd524352c8da
2022-09-21 12:03:15 -07:00
Patrick Rohr
faebf303a6 ethernet: remove enable/disable interface unit test
This unit test is not particularly useful and there is already coverage
in EthernetManagerTest.

Test: test only change.
Change-Id: I6f9d19d9603229553f44d562ff0276567cb0e26d
2022-09-21 12:03:11 -07:00
Maciej Żenczykowski
c502646e5c Move prohr@'s temp EthernetManagerTest.kt ownership so it will work.
(or at least try to)

Test: N/A
Change-Id: I33855ed29806c269dac0a6c5002c3f72d47ebd2c
2022-09-21 19:01:02 +00:00
Patrick Rohr
a3e6cc423b Merge "owners: grant prohr temporary owners for EthernetManagerTest" 2022-09-21 18:46:41 +00:00
Xinyi Zhou
2d3df1b225 Merge "[CTS] Fix CTS failure in mainline train" into android13-tests-dev 2022-09-21 18:32:05 +00:00
Xinyi Zhou
5500b3cda0 [CTS] Fix CTS failure in mainline train
- Delete test case from CTS. This would be moved to unit test
- Use reasonable key value in DataElementTest

Test: -m CtsNearbyFastPairTestCases
Bug: 244133414
Change-Id: Ia476c64ad5ebedd8eb007f7e0cb5b30a1d12dee5
2022-09-21 18:20:30 +00:00
Sorin Basca
f04e85aafc Merge "Fix errorprone 2.15.0 errors" 2022-09-21 14:42:58 +00:00
Chiachang Wang
90798f9a5a Merge "Update VpnTest to handle teardown-on-network-lost" 2022-09-21 14:22:33 +00:00
Sorin Basca
14343732c3 Fix errorprone 2.15.0 errors
Bug: 246761518
Test: RUN_ERROR_PRONE=true m javac-check lint-check dist
Change-Id: I4b81ef161fab5ee80a1713de87b89500a88e625e
2022-09-21 13:29:19 +01:00
Treehugger Robot
dd2dd2baa2 Merge "Start listening to telephony changes in #start()" 2022-09-21 12:24:28 +00:00
lucaslin
4b842678b1 Update VpnTest to handle teardown-on-network-lost
- Fix the wrong MOBIKE value set in
  testStartPlatformVpnHandlesNetworkLoss_mobikeEnabled.
- Verify the networkAgent is unregistered when the default
  network is lost

Bug: 231749077
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idc6ebd42090eff1135dc5f96af4bc2fb268dd340
2022-09-21 11:30:49 +00:00
Chiachang Wang
3dca00e965 Merge "Update test on calling getAppExclusionList with restricted user" 2022-09-21 09:41:45 +00:00