Commit Graph

8097 Commits

Author SHA1 Message Date
Rubin Xu
ab8cf306ea 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
Change-Id: I59cf48552bca98092d1212e3d718fd420add5458
2020-04-01 09:36:29 +01:00
Chiachang Wang
3402ee64ed Merge "Update constructor of NetworkMonitor" 2020-03-30 08:40:45 +00:00
Chiachang Wang
0ab5158418 Update constructor of NetworkMonitor
Remove redundant parameter.

Bug: 152374582
Test: m -j40 ; atest FrameworksNetIntegrationTests
Change-Id: I3a636f0ea5145ac4435e06a9827bb8e01862542d
2020-03-30 07:52:02 +00:00
Lucas Lin
b1bf1f2d36 Merge "Fix NetworkCapabilitiesTest fail on Q device" 2020-03-30 07:41:01 +00:00
Aaron Huang
9d66de5d5e Merge "Make LinkPropertiesTest compatible with Q" 2020-03-30 06:06:32 +00:00
lucaslin
be8bbacfa2 Fix NetworkCapabilitiesTest fail on Q device
The getSSID() has changed to getSsid() in Android R, adding
isAtLeastR() to prevent NetworkCapabilitiesTest fail on Android
Q.

Bug: 151322799
Test: Run "atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest"
      on Android Q & R device.
Change-Id: I602ae32dae1ad29fe3293c541fa6d2cef01b81d3
Merged-In: I602ae32dae1ad29fe3293c541fa6d2cef01b81d3
2020-03-30 03:47:00 +00:00
Lucas Lin
28ff516ba7 Merge "Add MatchAllNetworkSpecifierTest" 2020-03-30 03:08:48 +00:00
Lucas Lin
246821b7b4 Merge "Add more tests in LinkPropertiesTests.java" 2020-03-30 03:08:40 +00:00
Remi NGUYEN VAN
e3aade0a30 Merge "Create a builder for NetworkCapabilities." 2020-03-30 02:58:45 +00:00
Mark Chien
0b3d643758 Merge "Unbreak testStartUsingNetworkFeature_enableHipri failure" 2020-03-27 15:28:09 +00:00
markchien
9eb9399321 Unbreak testStartUsingNetworkFeature_enableHipri failure
aosp/1261619 break legacy API that only supported for SDK which is
smaller than android M, caller need to have network stack permission
to request network with legacy type. Fix failure by whitelist permission
check for the caller who built with oder SDK(< M).

Bug: 152229492
Test: atest CtsTetheringTest
      atest ConnectivityManagerLegacyTest# \
      testStartUsingNetworkFeature_enableHipri

Change-Id: I367dff0429f26f266282300edc38637b55eece38
2020-03-27 14:15:13 +00:00
Daulet Zhanguzin
053fb7317e Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull" 2020-03-27 11:53:39 +00:00
Aaron Huang
7988471ec9 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
Change-Id: I38b0d83abf983b3bcc01fc6aea2e5cc307734198
2020-03-27 16:41:21 +08:00
Aaron Huang
a09a992749 Merge "API review: access field by method" 2020-03-27 07:03:25 +00:00
Daulet Zhanguzin
ee67425c05 Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull

Bug: 126528330
Bug: 149348618

Test: Treehugger
Change-Id: Idb1b6ba41af3b52f3376b1157259af3c30328c4e
Merged-In: Idb1b6ba41af3b52f3376b1157259af3c30328c4e
2020-03-26 12:44:56 +00:00
lucaslin
55c6a844fc 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: Ie77dd7eb5c7ecc763c661e8510f9a308e695e77f
2020-03-26 19:15:55 +08:00
lucaslin
5bf0d2de9d Add MatchAllNetworkSpecifierTest
Bug: 139268426
Bug: 135998869
Test: atest CtsNetTestCasesLatestSdk:MatchAllNetworkSpecifierTest
Change-Id: Ib593708d5621ff20e6a0c31e5698b2b658f64d45
2020-03-26 18:58:08 +08:00
Xiao Ma
854b55854b Merge "Add CTS tests for ApfCapabilities static APIs." 2020-03-26 01:22:05 +00:00
Chalard Jean
a982d12943 Merge "Allow MANAGE_TEST_NETWORKS to register limited agents" 2020-03-25 09:47:03 +00:00
Chalard Jean
5b63976366 Allow MANAGE_TEST_NETWORKS to register limited agents
This puts in force some restrictions against test networks,
and in exchange relaxes the restrictions around registering
a network agent that provides a test network.
Test networks can only ever have transport TEST, and have
only a few capabilities available to them.

This is useful in particular to test CTS. See aosp/1253423
for first, basic usage of this capability.

Test: IpSecManagerTunnelTest
Test: new CTS aosp/1253423
Bug: 139268426
Change-Id: I47600e6097e8519e50ae771daa13bb6bb7640451
2020-03-25 16:28:50 +09:00
Chalard Jean
542e60001a Create a builder for NetworkCapabilities.
Bug: 151322799
Test: FrameworksWifiTests
Change-Id: I69c00c9e3963950e55d7105d8825f7d3a3ec9b2f
Merged-In: I06eb97e50d5583579b3c26d1365d2dbaec8bfc99
(cherry picked from commit 9771f34dae9cdeb857636cac2b3c2d473713914e)
2020-03-25 13:27:04 +09:00
Benedict Wong
bc74233e8a Merge "Automatically set IPsec tunnel interface as up" 2020-03-25 04:18:50 +00:00
Chalard Jean
461f81faac Merge "Expose netId by adding getter API" 2020-03-25 02:23:03 +00:00
Aaron Huang
005f9d10ae API review: access field by method
- InvalidPacketException, public field should be a method so
  add getter to get error code.
- KeepalivePacketData, public fields should be methods so
   add getter for fields.

Bug: 151322799
Test: atest FrameworksNetTests
      atest FrameworksWifiTests
      atest FrameworksTelephonyTests: some failure in CarrierAppUtilsTest
Copy from ag/10731108
Change-Id: Id01e6135193716cc21bba11da529bf1507a954f7
Merged-In: Id01e6135193716cc21bba11da529bf1507a954f7
2020-03-24 10:55:18 +00:00
Xiao Ma
2772ddd5bd Add CTS tests for ApfCapabilities static APIs.
Add tests for getApfEtherTypeBlackList and getApfDrop8023Frames APIs.

Bug: 150640397
Test: atest CtsNetTestCasesLatestSdk:android.net.apf.ApfCapabilitiesTest
      on both of Q and R devices.
Change-Id: I06c5d84d7025420a1e45a953c8c7a5cc3c452e24
2020-03-24 19:38:21 +09:00
markchien
9d26f92289 Expose netId by adding getter API
Bug: 151156820
Test: m
      atest TetetheringTests

Clean CP from ag/10747732

Change-Id: Ieb1483c146aa2f7d8f251157e6e81d71c44ae899
Merged-In: Ieb1483c146aa2f7d8f251157e6e81d71c44ae899
2020-03-24 09:19:26 +00:00
Treehugger Robot
56d39d3251 Merge "Fix addRoute replace default route unexpectedly" 2020-03-24 05:51:30 +00:00
junyulai
a1493a52d0 Fix addRoute replace default route unexpectedly
In aosp/1203789, if two routes are with the same destination,
it will be replaced instead of added when calling addRoute.
This breaks scenarios which rely on the ability to add multiple
default routes, such as multiple IPv6 default routes learned
via address autoconfiguration.

This change treats the route is an update if the destination
and nexthop are the same, but different in other properties.

Test: atest OffloadControllerTest#testSetUpstreamLinkPropertiesWorking
Test: atest LinkPropertiesUtilsTest#testLinkPropertiesIdenticalEqual
Test: atest ConnectivityServiceTest#testStackedLinkProperties
Test: atest ConnectivityServiceTest#testRouteAddDeleteUpdate
  (only directly related tests are listed)
Fix: 152170074
Fix: 151911339
Bug: 142892223

Change-Id: I7153ec9866f14a109ba8155c905e5d9e4f85eb64
2020-03-24 10:27:01 +08:00
Tobias Thierer
f06634ae70 Merge "Refactor Network's use of mUrlConnectionFactory." 2020-03-23 11:34:43 +00:00
Tobias Thierer
47c0d852da Refactor Network's use of mUrlConnectionFactory.
1.) Replace maybeInitUrlConnectionFactory() with a static method
    createUrlConnectionFactory(Dns) and move the logic to acquire
    the lock and initialize mUrlConnectionFactory out into
    openConnection. This makes it a bit clearer that the lock
    is acquired during openConnection().
2.) Use @GuardedBy("mLock") rather than a human readable comment
    on mUrlConnectionFactory.
3.) Make mUrlConnectionFactory non-volatile (since it's guarded by
    mLock), as recommended by Narayan on the review thread for
    http://r.android.com/370652
    Alternatively, the field could have remained volatile
    and we could have used double-checked locking to avoid
    acquiring the lock in the common case.
    The lock is only acquired during getSocketFactory() and
    openConnection(), so it shouldn't usually be contended.

This CL is a pure refactoring that shouldn't have any observable
behavior change.

Bug: 38311512
Test: Treehugger
Exempt-From-Owner-Approval: refactoring only, owner didn't respond in time
Change-Id: I1cf6075dc7cd994657b11d6a82de3ec63235fb1e
2020-03-23 11:34:32 +00:00
Remi NGUYEN VAN
10adc9a7b9 Merge changes from topic "netstack_constant_cherrypick"
* changes:
  Remove usage of Context.NETWORK_STACK_SERVICE
  Remove NETWORK_STACK_SERVICE constant
2020-03-23 03:33:58 +00:00
Remi NGUYEN VAN
fbb0836bc6 Remove usage of Context.NETWORK_STACK_SERVICE
The NetworkStack.getService() API should be used instead.

Bug: 151243982
Test: atest FrameworksNetTests TetheringTests
      Manual tethering test
Merged-In: I7855090bffbe895c8349ad4903b8f2eb55515f0b
(clean cherry-pick from internal branch)

Change-Id: If4af2846a82605e828287a9a4680d5547b76b802
2020-03-23 11:29:06 +09:00
Cody Kesting
1a78f835eb Merge "Change NetworkCapabilties administrator UIDs to be stored as int[]." 2020-03-19 18:09:26 +00:00
Mark Chien
bc91f858e6 Merge "TetheringManager API clean up" 2020-03-19 16:09:21 +00:00
Treehugger Robot
f0da719ed1 Merge "Move NetworkCallback to last parameter for new exposed requestNetwork" 2020-03-19 15:51:32 +00:00
markchien
fac84a2be1 Move NetworkCallback to last parameter for new exposed requestNetwork
Bug: 151243698
Test: atest TetheringTests
Change-Id: I87ef1d451eefa6998b9793c4eacabae978376d24
Merged-In: I87ef1d451eefa6998b9793c4eacabae978376d24
2020-03-19 11:36:07 +00:00
markchien
f47d83448c TetheringManager API clean up
Per API review:
- @IntDef defined on the type integer parameter
- have getters on each parameter that is set in the
  TetheringRequest.Builder
- new added API should not be deprecated
Below APIs is moved from system-current to module-lib-current that only
plafrom code(e.g. ConnectivityManager and Settings) can use them.
TetheringRequest.
onTetherableInterfaceRegexpsChanged, TetheringInterfaceRegexps:
Only platform code can use them because interfaces by regular
expressions are a mechanism which is planning to be deprecated.

Also rename some constants for easier to understand.

Bug: 149858697
Bug: 151243337
Test: m doc-comment-check-docs
      atest TetheringTests
Change-Id: I45cb21d5bc919f6d32c42650326597d5173ea028
Merged-In: Idd041f0fbeca411ea23e49786a50dd7feb77ef45
2020-03-19 19:32:50 +08:00
Lorenzo Colitti
cabe5e5615 Merge "Make Ethernet interfaces more testable." 2020-03-19 11:12:09 +00:00
junyulai
b767c0b024 [SM08] Add NetworkTemplate unit test for fetching mobile data usage
Test: atest NetworkTemplateTest
Bug: 129082217

Change-Id: I7eaca623adf93f9b8d53c2e5857ecae90ea572ab
Merged-In: I7eaca623adf93f9b8d53c2e5857ecae90ea572ab
(cherry picked from commit 4670baace6c8dafe3a30330596c333d6b2389e4d)
2020-03-19 10:10:07 +08:00
junyulai
678befa63c [SM07] Make combine subtype configurable from Settings
Note that enabling/disabling would not take effect until device
reboot. This will be addressed in follow-up patch.

Test: 1. atest NetworkStatsServieTest SettingsBackupTest
      2. adb shell settings put global netstats_combine_subtype_enabled 1|0
Bug: 146415925

Change-Id: Ic94da540afa479ed18f1b6fbda4ae3216c37476b
Merged-In: Ic94da540afa479ed18f1b6fbda4ae3216c37476b
(cherry picked from commit c4f77ac90bf2e48a655ad19b162fe74a23bf3fb0 and
 fix merge conflict in SettingsBackupTest)
2020-03-19 10:10:07 +08:00
junyulai
2632681cf0 [SM05] Enable record mobile network stats by collapsed rat type
Switch on the recording in device side. Metrics will be
collected in follow-up patches which can be independently
enabled/disabled.

This change also fix the fail in NetworkStatsCollectionTest
which caused by enabling this feature, where the rounding
problem happened when records are distributed into smaller
buckets and categorized into more NetworkIdentity.

Test: atest FrameworksNetTests
Bug: 129082217
Change-Id: If330e85330a4ff713dd420c98d42fa741eabd90a
Merged-In: If330e85330a4ff713dd420c98d42fa741eabd90a
(cherry picked from commit 2d4fa2c0fae8c2d79a25093d9f732a33c2f91dd4)
2020-03-19 10:10:07 +08:00
Paul Hu
57b993bfb5 Merge "Kill ConnectivityManager.CONNECTIVITY_ACTION_SUPL" 2020-03-19 01:10:55 +00:00
Lorenzo Colitti
965434afab Make Ethernet interfaces more testable.
This CL adds a setIncludeTestInterfaces method to EthernetManager
that, when called, causes the Ethernet service to recognize and
manage test interfaces created by TestNetworkManager.

Bug: 150644681
Test: Tested by EthernetTetheringTest in same topic
Change-Id: I86eef7a93267f800dbfc8eafd307effa76a344ca
2020-03-19 09:46:37 +09:00
Cody Kesting
5ab1f55d1f Change NetworkCapabilties administrator UIDs to be stored as int[].
NetworkCapabilities#mAdministratorUids is used to track the UIDs that
are administrators of the given Network. This value was previously
stored as List<Integer>. However, general Android API Council guidelines
recommend using Arrays for primitive values. In order to be consistent
with the guidelines, updating the field to use an Array.

Bug: 147903575
Test: atest FrameworksNetTests
Change-Id: I2652a5b0f276b8944454af5cb4b1383a3e054cfa
Merged-In: I2652a5b0f276b8944454af5cb4b1383a3e054cfa
2020-03-18 15:18:47 -07:00
Cody Kesting
4074c2d181 Merge "Restrict VPN Diagnostics callbacks to underlying networks." 2020-03-18 20:07:52 +00:00
Junyu Lai
cc227f1df5 Merge "Fix flaky ConnectivityServiceTest#testNetworkFactoryUnregister" 2020-03-18 08:41:08 +00:00
junyulai
80bf34b2af Fix flaky ConnectivityServiceTest#testNetworkFactoryUnregister
Test: atest ConnectivityServiceTest#testNetworkFactoryUnregister \
      --geneate-new-metrics 100
Bug: 151792032
Change-Id: Iece9e8ad5c51170cd404ac995d0005392d37fe0c
2020-03-18 15:22:54 +08:00
Lorenzo Colitti
9839a4311a Merge "mtu: Add MTU parameter to Routes" 2020-03-18 07:20:01 +00:00
Lucas Lin
30faad6d0f Merge "Add version check to prevent test fail on Android Q" 2020-03-18 03:56:37 +00:00
Junyu Lai
52ee59fb03 Merge "[SP25] Rename functions that add Entry conditionally" 2020-03-18 03:16:41 +00:00