Commit Graph

8946 Commits

Author SHA1 Message Date
Lorenzo Colitti
24398db2b6 Refactor the Nat464Xlat function for simplicity.
This makes the code easier to understand by making state
transitions more explicit. It also makes it easier to address a
TODO to turn the class into a StateMachine.

This should be an exact no-op refactoring. The current cases
covered by the code (all mutually exclusive) are:

1. requiresClat && !isPrefixDiscoveryStarted
   Action: startPrefixDiscovery()
   Equivalent to IDLE && requiresClat, because
   isPrefixDiscoveryStarted returns true for every state except
   IDLE.

2. requiresClat && isPrefixDiscoveryStarted && shouldStartClat
   Action: start()
   Equivalent to DISCOVERING && shouldStartClat,
   because isPrefixDiscoveryStarted is true in DISCOVERING,
   STARTING, and RUNNING, but start() does nothing if mState is
   STARTING or RUNNING.

3. requiresClat && isPrefixDiscoveryStarted && !shouldStartClat
   Action: stop()
   Equivalent to (STARTING or RUNNING) && !shouldStartClat,
   because isPrefixDiscoveryStarted is true in DISCOVERING,
   STARTING, and RUNNING, but stop() does nothing if mState is
   not STARTING or RUNNING.

4. !requiresClat && isStarted
   Action: stop()
   Equivalent to (STARTING or RUNNING) && !requiresClat,
   because isStarted() is only true in STARTING and RUNNING.

5. !requiresClat && !isStarted && isPrefixDiscoveryStarted
   Action: leaveStartedState()
   Equivalent to DISCOVERING && !requiresClat, because
   the only state with isPrefixDiscoveryStarted and !isStarted
   is DISCOVERING.

Also, simplify case #5. In this case, calling leaveStartedState
is superfluous, because in the DISCOVERING state:
- There is no need to call unregisterObserver, since the observer
  is only registered when entering STARTING and is unregistered
  when going back to DISCOVERING or IDLE.
- mIface and mBaseIface don't need to be set to null because they
  are only set to non-null when entering STARTING and nulled out
  when going back to DISCOVERING or IDLE.

Bug: 126113090
Bug: 150648313
Test: covered by existing ConnectivityServiceTest and Nat464XlatTest
Merged-In: Ice536bcb269cc8b040c6e7a72c15d0bc8b5bd235
Change-Id: Ice536bcb269cc8b040c6e7a72c15d0bc8b5bd235
2020-04-06 15:46:38 +00:00
Lorenzo Colitti
6c0cbccf96 Rename the *Nat64Prefix to *Nat64PrefixFromDns.
This just a rename with no functional changes at all. It is
preparation for supporting getting the NAT64 prefix from the
RA.

Bug: 150648313
Test: covered by existing ConnectivityServiceTest and Nat464XlatTest
Merged-In: Ia9a09a708870827b1e4cf068f930fa9542dd116c
Change-Id: Ia9a09a708870827b1e4cf068f930fa9542dd116c
2020-04-06 15:45:14 +00:00
Chalard Jean
417465419b Fix a bug where the legacy extra info is reset on connect. am: 26fc3f31ff
Change-Id: I40f25bc1af74f45bb442baae0a89f96c00f5e8ac
2020-04-06 12:49:11 +00:00
Chalard Jean
26fc3f31ff Fix a bug where the legacy extra info is reset on connect.
Bug: 149459996
Test: NetworkAgentTest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests

Change-Id: I3e437f0fe2eb28f1d621551a8daf164a06af83fc
Merged-In: I3e437f0fe2eb28f1d621551a8daf164a06af83fc
(cherry picked from commit a3fdb94a32eda40e322b7dbdaf3fad9b42bfbbb9, originally aosp/1277602)
2020-04-06 11:14:59 +00:00
Lucas Lin
74c73dc3b2 Merge "Add MatchAllNetworkSpecifierTest" into rvc-dev am: 5123e0509e
Change-Id: Ice0a1fad4a430175b49a047b824e97b1a8df955e
2020-04-06 09:46:21 +00:00
Lucas Lin
5123e0509e Merge "Add MatchAllNetworkSpecifierTest" into rvc-dev 2020-04-06 09:35:27 +00:00
android-build-team Robot
af6b2c47d8 Snap for 6367459 from 9727a0735712c46da133ac5f867b953d1364175e to mainline-release
Change-Id: I1570d936b933bad806034e9a99e07c4a72ac1b8c
2020-04-06 07:03:24 +00:00
Junyu Lai
48d226dd0c Merge changes from topic "am-5ce58db354ac494a84904378ca35c013-rvc-dev" into rvc-dev am: c6b106fbc1
Change-Id: Ie62147dc37f99d05fae4eecccc00f1b15f429220
2020-04-06 04:28:36 +00:00
junyulai
254fddb571 [SP26.2] add a method in NetworkStats that removes empty entries am: 56f59c493b
Change-Id: Ib92c9cff431d5f6f72598550cc7cc869b340c396
2020-04-06 04:28:34 +00:00
Junyu Lai
c6b106fbc1 Merge changes from topic "am-5ce58db354ac494a84904378ca35c013-rvc-dev" into rvc-dev
* changes:
  [SP26] add CTS for NetworkStats
  [SP26.2] add a method in NetworkStats that removes empty entries
2020-04-06 04:15:39 +00:00
Remi NGUYEN VAN
c69180459a Merge "Fix setAdministratorUids tests on Q" into rvc-dev am: 0b4ad3a9d5
Change-Id: Ic59499e070b009dddedcaeb2e6905fb563779841
2020-04-06 02:24:38 +00:00
Remi NGUYEN VAN
0b4ad3a9d5 Merge "Fix setAdministratorUids tests on Q" into rvc-dev 2020-04-06 02:22:37 +00:00
Junyu Lai
b80fe74899 [SP26] add CTS for NetworkStats
Test: atest NetworkStatsApiTest
Test: atest CtsNetTestCasesLatestSdk:NetworkStatsApiTest on Q device
Bug: 150644692
Change-Id: I690704b43cfd16de70c4c83916f6d750cf613f67
Merged-In: I690704b43cfd16de70c4c83916f6d750cf613f67
(cherry picked from commit 5c670a2714f3ed783b6d5245714d0039c8fd1e9c)
2020-04-06 02:21:17 +00:00
junyulai
56f59c493b [SP26.2] add a method in NetworkStats that removes empty entries
In current design, entries with zeros are preserved after
addition/subtraction. These entries are not very useful
and lead to difficulty of verifying the result of
addition/subtraction.

However, change the behavior in the original NetworkStats
is considered risky in current stage.

Thus, this change provide a function that could remove these
empty entries in tests.

Test: atest FrameworksNetTests
Bug: 152827872
Bug: 150644692

Change-Id: I40a76935d55712b8083ee1e17e137a8a4ef5e029
Merged-In: I40a76935d55712b8083ee1e17e137a8a4ef5e029
(cherry picked from commit 6c7bef3064dbe949b7b213036b8e70c125ddd343)
2020-04-06 02:18:50 +00:00
android-build-team Robot
f7d5763121 Snap for 6366237 from 31325cf276fc549dc64a8f4d37184310938b2356 to mainline-release
Change-Id: I25fd39a550778960892f33f25daf646317a3a82e
2020-04-05 07:10:24 +00:00
TreeHugger Robot
1c221a5295 Merge "Only apply VPN isolation if it's fully routed" into rvc-dev am: 147d1574b1
Change-Id: Ibd13db0076a1dcaefd3b006001d24ad3e763409f
2020-04-04 03:48:35 +00:00
TreeHugger Robot
147d1574b1 Merge "Only apply VPN isolation if it's fully routed" into rvc-dev 2020-04-04 03:44:46 +00:00
Remi NGUYEN VAN
24260d5e6d Fix setAdministratorUids tests on Q
setAdministratorUids does not exist on Q, so such tests must be skipped
on Q devices.

Bug: 147903575
Test: atest CtsNetTestCasesLatestSdk on Q and AOSP devices
Merged-In: I1b362660de9733bb9f0ede1ed5cf62279bf1c05e
Change-Id: I1b362660de9733bb9f0ede1ed5cf62279bf1c05e
2020-04-03 09:42:33 +00:00
Remi NGUYEN VAN
03d15b5453 Merge "Make LinkPropertiesTest compatible with Q" into rvc-dev am: d8223ef5fc
Change-Id: I756521af50e0176817cc1502e5a5b2ad15979817
2020-04-03 08:17:06 +00:00
Remi NGUYEN VAN
d8223ef5fc Merge "Make LinkPropertiesTest compatible with Q" into rvc-dev 2020-04-03 07:52:26 +00:00
android-build-team Robot
b40af83157 Snap for 6360643 from 8b88e0f83723c94c8d831c90e2ae585590224cb2 to mainline-release
Change-Id: I151dca5c1b607e35c817f57b22b906818a769a70
2020-04-03 07:23:21 +00:00
Lorenzo Colitti
1dbf63da06 Merge "Added a new capability for temporarily unmetered network." into rvc-dev am: 0edabc5e4e
Change-Id: I2954f582524903c542a65439fba05af6cc37aa0f
2020-04-03 05:07:14 +00:00
Jack Yu
71863e9604 Added a new capability for temporarily unmetered network.
Added a new network capability TEMOPORARILY_NOT_METERED to support
the case that a network can temporarily become unmetered. This
allows carriers to deploy unmetered 5G network. When devices
camp on 5G network, this capability will be dynamically added
to the network and will be removed once leaving 5G coverage.

Bug: 153081494
Test: Manual
Change-Id: I10e26cb0852e67f614e7b9c4e49f95e078602e21
2020-04-02 19:28:41 -07:00
Lorenzo Colitti
adcc974e20 Merge "Add more tests in LinkPropertiesTests.java" into rvc-dev am: 86ae134de8
Change-Id: Icb07eade679f34a7872050ca711aa45ffd11e462
2020-04-02 10:52:46 +00:00
Lorenzo Colitti
7fb7c3e0bf Only apply VPN isolation if it's fully routed
VPN is considered fully routed if both IPv4 and IPv6 have
either a default route or a prohibit route.

Bug: 145332510
Test: atest FrameworksNetTests
Merged-In: I59cf48552bca98092d1212e3d718fd420add5458
Change-Id: I59cf48552bca98092d1212e3d718fd420add5458
2020-04-02 10:36:19 +00:00
Lorenzo Colitti
86ae134de8 Merge "Add more tests in LinkPropertiesTests.java" into rvc-dev 2020-04-02 10:35:49 +00:00
android-build-team Robot
7f1ef2c571 Snap for 6357740 from 4c6e6b9c5a4fb640da0daf20bb42cfa158d961aa to mainline-release
Change-Id: I8e3b3b8da0b0dac54ffc8c632d75ea2261968136
2020-04-02 07:10:37 +00:00
Aaron Huang
ccd5ba288a Make LinkPropertiesTest compatible with Q
CompareResult had been moved from LinkProperties to LinkPropertiesUtils
so this change ignores testCompareResult() on Q and only check
compareAllRoutes() works while android version is at least R.

Bug: 151782584
Test: atest CtsNetTestCasesLatestSdk:LinkPropertiesTest
Merged-In: I38b0d83abf983b3bcc01fc6aea2e5cc307734198
Change-Id: I38b0d83abf983b3bcc01fc6aea2e5cc307734198
2020-04-02 03:30:49 +00:00
Chiachang Wang
3844a61841 Merge "Update constructor of NetworkMonitor" into rvc-dev am: d7df0c13d9
Change-Id: Iea5f995291bdbe3081c8f7ded5bf4f3f50e6c7d1
2020-04-01 09:11:13 +00:00
android-build-team Robot
641cd645f8 Snap for 6353135 from 79b40a2f164a9238f3aa5a30817e8d07c2265cf5 to mainline-release
Change-Id: Idb07acb34245ee84804340740357b081538e2e72
2020-04-01 07:09:35 +00:00
Lucas Lin
6602482f26 Add MatchAllNetworkSpecifierTest
Bug: 139268426
Bug: 135998869
Test: atest CtsNetTestCasesLatestSdk:MatchAllNetworkSpecifierTest

Change-Id: I6c6911041aff1b245e576109a879247cc256093b
Merged-In: Ib593708d5621ff20e6a0c31e5698b2b658f64d45
(cherry picked from commit f46c71b420f4089e0f36a296ed5b59398794f538)
2020-04-01 06:27:43 +00:00
Lucas Lin
d5c455815d Add more tests in LinkPropertiesTests.java
Test getAllInterfaceNames(), hasIpv4DefaultRoute(),
hasIpv4DnsServer() and hasIpv6DnsServer().

Bug: 139268426
Bug: 135998869
Bug: 138306002
Test: atest CtsNetTestCasesLatestSdk:android.net.LinkPropertiesTest

Change-Id: I2bae76dc93e7aa02efe25dca4b6e99692c79135a
Merged-In: Ie77dd7eb5c7ecc763c661e8510f9a308e695e77f
(cherry picked from commit 30a56a5c719c38894b3dfe803d1b58db26cc1c95)
2020-04-01 06:26:59 +00:00
Chiachang Wang
f7d30445c7 Update constructor of NetworkMonitor
Remove redundant parameter.

Bug: 152374582
Test: m -j40 ; atest FrameworksNetIntegrationTests
Merged-In: I3a636f0ea5145ac4435e06a9827bb8e01862542d
Change-Id: I3a636f0ea5145ac4435e06a9827bb8e01862542d
2020-04-01 02:12:32 +00:00
Cody Kesting
5e543c05ed Merge changes I2431a6d2,I9096969a,I748bd9de,Ia5387ca2,I803bdec8, ... into rvc-dev am: bb578182f3
Change-Id: Id83214bd033f56295868f7c54a659a4d4b84fe79
2020-04-01 01:33:46 +00:00
Cody Kesting
f164a670c8 Simplify unregister logic for Connectivity Diagnostics callbacks. am: 5d51a917f5
Change-Id: I6b9541fd562c3e65af65e9b5b754909d96f332fd
2020-04-01 01:33:42 +00:00
Cody Kesting
006ad761b3 Clarify comments for Connectivity Diagnostics reports. am: 7d4ef21010
Change-Id: I9263ddeb7b757e6c147fcf57b5fd9825f2fd3860
2020-04-01 01:33:40 +00:00
Cody Kesting
9b73d9dee0 Sort administrator UIDs for NetworkCapabilities. am: 9c341963ac
Change-Id: I06d79c338f9994988373f43ab67efc1315596e5c
2020-04-01 01:33:36 +00:00
Chalard Jean
4f37a69550 Add combine() and equals() for NetworkCapabilities admin UIDs. am: 0d667c5508
Change-Id: I4b52b619cde3b080bfe58f69dacdb0078a11a7e8
2020-04-01 01:33:30 +00:00
Cody Kesting
184d5e8dd0 Use IBinder as key for ConnectivityDiagnostics storage in CS. am: b65e18e638
Change-Id: I9b75e908b217cf518281e1d8471af66022c65667
2020-04-01 01:33:24 +00:00
Cody Kesting
10e11764d5 Decrement networkRequestPerUid when callbacks are unregistered. am: aebda983d3
Change-Id: I8710a66725a0d09ca652ad8ce6fc7ced0070f647
2020-04-01 01:33:22 +00:00
Cody Kesting
f37380f8cf Invoke onConnectivityReport on registering ConnectivityDiagnostics. am: fe059d8c30
Change-Id: I20430c60e27b9c3b4210ec037b71accac376ca44
2020-04-01 01:33:19 +00:00
Cody Kesting
bb578182f3 Merge changes I2431a6d2,I9096969a,I748bd9de,Ia5387ca2,I803bdec8, ... into rvc-dev
* changes:
  Update CS helper for clearing NetworkCapabilities UIDs.
  Simplify unregister logic for Connectivity Diagnostics callbacks.
  Clarify comments for Connectivity Diagnostics reports.
  Sort administrator UIDs for NetworkCapabilities.
  Add combine() and equals() for NetworkCapabilities admin UIDs.
  Use IBinder as key for ConnectivityDiagnostics storage in CS.
  Decrement networkRequestPerUid when callbacks are unregistered.
  Invoke onConnectivityReport on registering ConnectivityDiagnostics.
2020-04-01 01:13:11 +00:00
Cody Kesting
2a26e7cfa8 Merge "Clean up handling of NetworkCapabilities#administratorUids." into rvc-dev am: c161f59909
Change-Id: I729db9d97d69a088c272a64d270aa05be474ed87
2020-03-31 18:01:30 +00:00
Cody Kesting
c161f59909 Merge "Clean up handling of NetworkCapabilities#administratorUids." into rvc-dev 2020-03-31 17:46:57 +00:00
Benedict Wong
6a0996a110 Merge changes I97ba5903,Icd80b368 into rvc-dev am: d3d72d4452
Change-Id: I5f6ac7365512b16597abae5d9f5306a755bb4879
2020-03-31 17:12:33 +00:00
Benedict Wong
701b0cc046 Merge "Automatically set IPsec tunnel interface as up" into rvc-dev am: c0192c1df6
Change-Id: Ie0ff250e5ff36b317932053a950e49df9eae2e9f
2020-03-31 17:11:16 +00:00
Benedict Wong
d3d72d4452 Merge changes I97ba5903,Icd80b368 into rvc-dev
* changes:
  Make VpnProfile.maxMtu default value match Ikev2VpnProfile
  Add negotiated DNS servers to VPN config
2020-03-31 16:52:04 +00:00
Benedict Wong
c0192c1df6 Merge "Automatically set IPsec tunnel interface as up" into rvc-dev 2020-03-31 16:51:58 +00:00
android-build-team Robot
7187e2f166 Snap for 6349563 from 366b79483cc59e01723e782ce103d94db7feda72 to mainline-release
Change-Id: Ic45dcd2ecb2f15642261f4aeed488e0550f749fb
2020-03-31 07:09:36 +00:00
Benedict Wong
cbb19fcba7 Make VpnProfile.maxMtu default value match Ikev2VpnProfile
This change corrects the VpnProfile's maxMtu defaults to match that of
the Ikev2VpnProfile. 1400 is too high as a default, and Settings will
run into an issue here quite often.

Bug: 152573931
Test: FrameworksNetTests passing
Change-Id: I97ba5903b3cc1ed6a21c706ed3d78bd8ecbeee0c
Merged-In: I97ba5903b3cc1ed6a21c706ed3d78bd8ecbeee0c
(cherry picked from commit d0a44f49df01a1aefa505ee90c9806dee135b4e4)
2020-03-30 22:59:17 -07:00