Commit Graph

13132 Commits

Author SHA1 Message Date
Junyu Lai
4d9ef0fc1e Merge "[VCN06] Support request background network" am: 2141aec60a am: 336c5d93a7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553866

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8c41f6e2eda3b0b690cf6715c58f3bb98de8b1c1
2021-01-29 23:21:03 +00:00
Junyu Lai
d53184a4de Merge "[FUI16] Expose setSubscriberId in NetworkAgentConfig as system API" am: bc1a11fdb2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556552

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4d3eb542b1c3a9aabf51c58b8d83ad3e669f2077
2021-01-29 23:04:04 +00:00
Junyu Lai
ba245e077f Merge "[FUI04] Refactor VpnInfo" am: 149add890e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1537211

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I59054bfe1761e28cdfb8e8e6d67e4aabda399adc
2021-01-29 22:55:54 +00:00
Junyu Lai
336c5d93a7 Merge "[VCN06] Support request background network" am: 2141aec60a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553866

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic959a453489767781ebb8fb71effb2c14e0f69d8
2021-01-29 22:46:27 +00:00
Junyu Lai
bc1a11fdb2 Merge "[FUI16] Expose setSubscriberId in NetworkAgentConfig as system API" 2021-01-29 17:15:28 +00:00
junyulai
6e74469a64 [FUI16] Expose setSubscriberId in NetworkAgentConfig as system API
The wifi (mainline module) need to set the subscriberId for specific
wifi network.

Bug: 176396812
Test: TreeHugger
Change-Id: Ib568ce0c2d1b629e1c20e7ac8d8b78579cf4825c
2021-01-29 22:09:10 +08:00
Junyu Lai
149add890e Merge "[FUI04] Refactor VpnInfo" 2021-01-29 13:54:53 +00:00
Junyu Lai
2141aec60a Merge "[VCN06] Support request background network" 2021-01-29 11:02:02 +00:00
junyulai
62d35f7e59 [FUI04] Refactor VpnInfo
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
  1. Change raw arrays into lists according to API guidelines.
  2. Write test.
  3. Rename class to UnderlyingNetworkInfo.
  4. Rename vpnIface to iface.
  5. Make underlyingIfaces @NonNull in order to adapt new
     unparceling code.
  6. implement equals and hashCode for testing.

Test: atest android.net.UnderlyingNetworkInfoTest
Bug: 174123988

Change-Id: I405c21e57c4af8a12a9dd0a1749b9e6690f87045
2021-01-29 17:44:32 +08:00
Junyu Lai
23568a4f04 [VCN06] Support request background network
This will be mainly used by VCN management service which will
need to hold the networks but preserve the backgrounded-ness
of the networks.

Test: android.net.ConnectivityManagerTest#testRequestType
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork /
      --rerun-until-failure 100
Test: ConnectivityServiceTest#testBackgroundNetworks
Test: m -j doc-comment-check-docs
Bug: 175662146

Change-Id: I463c7a3139a286e50ea71e674060975ce228caa9
2021-01-29 14:42:32 +08:00
Lorenzo Colitti
8eef233b19 Fix legacy APIs when VPN switches to suspended underlying network.
Currently, when the VPN underlying network changes from a
network that is not suspended to one that is suspended (or vice
versa), some of the legacy APIs return incorrect results.

This is because the VPN's NetworkInfo can get into SUSPENDED
state even though the capabilities have the NOT_SUSPENDED
capability. This happens because the code in updateCapabilities
that checks for changes in NOT_SUSPENDED and NOT_ROAMING (which
are the capabilities that can affect the NetworkInfo state) is
only run when the capabilities change in a certain way.

Fix this by always checking for changes in these capabilities,
regardless of what else has changed.

This results in sending a lot more SUSPENDED and RESUMED
callbacks than the code sent previously. This should hopefully
not impact apps because those callback methods have never been
public API, though because they're just callbacks, it's possible
that apps found out via code inspection that the callbacks
existed and implemented them.

Bug: 172870110
Test: changes to existing tests in ConnectivityServiceTest
Change-Id: I6ec246a6a4e61f634956a165797fbb80296efd6a
Merged-In: I6ec246a6a4e61f634956a165797fbb80296efd6a
2021-01-29 01:23:32 +00:00
Lorenzo Colitti
0f33369a43 Backport test coverage from aosp/1547496.
This test coverage is necessary to fix an upcoming bug in R.
Backport it from the change that added it. The non-test portion
of that change is not necessary in R because it fixes a
bug that was introduced in S.

Bug: 172870110
Test: accompanying unit test shows lots of bugs removed
Change-Id: If7eb8857474d8b4f774f5fa5db2a3112e85c9cae
Merged-In: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
2021-01-29 01:23:06 +00:00
Lorenzo Colitti
cd44e43d15 Backport some helpers in ConnectivityServiceTest.
These were added in aosp/1527378, which is impractical to
backport.

Bug: 172870110
Test: test-only change
Change-Id: Id3d12b23034b284c8f7dffb5167244e1e43987e2
Merged-In: I827543751dbf5e626a24ec02cd6f50b423f5f761
2021-01-29 01:22:44 +00:00
Lorenzo Colitti
973da4644d Test for bugs with suspended VPN underlying networks.
Bug: 172870110
Test: atest --rerun-until-failure 100 ConnectivityServiceTest#testVpnSwitchFromSuspendedToNonSuspended
Change-Id: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
Merged-In: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
2021-01-29 01:22:22 +00:00
Lorenzo Colitti
8f35ad5871 Add a test for getDefaultNetworkCapabilitiesForUser.
Bug: 172870110
Test: test-only change
Test: new test passes 100 times in a row
Change-Id: I210284578e38cd25b8b95235d3390d5bd66a5a70
Merged-In: I210284578e38cd25b8b95235d3390d5bd66a5a70
2021-01-29 01:21:59 +00:00
Lorenzo Colitti
07fc61c954 Improve testing of CONNECTIVITY_ACTION broadcasts.
We currently test CONNECTIVITY_ACTION broadcasts by directly
registering BroadcastReceivers with BroadcastInterceptingContext,
and making the receivers unregister themselves when all the
broadcasts they expect have been received.

This works for current test cases, but does not work if anything
registers another receiver for CONNECTIVITY_ACTION. In that case,
when we unregister the receiver in the receiver's onReceive
method, BroadcastInterceptingContext will throw a
ConcurrentModificationException because the list of receivers is
being modified during iteration.

Fix this by adding an ExpectedBroadcast class that stores the
receiver and unregisters the receiver only when the test checks
that the broadcast was received, which happens after the receiver
runs. This is easier to use and also guarantees that the receiver
is unregistered even if the test is expecting that the broadcast
is never fired. Accordingly, remove mRegisteredReceivers and the
code that uses it; it's no longer necessary now that
ExpectedBroadcast always unregisters its receivers.

Also add a convenience expectConnectivityAction method to expect
a CONNECTIVITY_ACTION broadcast with specific contents. This
makes the test easier to read and more detailed. Convert some
existing tests to this method.

While I'm at it, fix a test that was using "mCellNetworkAgent" to
represent a wifi network.

R backport notes: added import for NetworkInfo.DetailedState.
That was added in aosp/1527378, which is impractical to backport.

Bug: 172870110
Test: test-only change
Change-Id: Ibada8b4215625e1016d9fd170526206920af76f5
Merged-In: Ibada8b4215625e1016d9fd170526206920af76f5
2021-01-29 01:21:29 +00:00
Lorenzo Colitti
e2d336afcc Test passing an underlying network array with null network in it.
Current code treats these nulls as if they weren't there.

Bug: 172870110
Test: test-only change
Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
Merged-In: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
2021-01-29 01:21:00 +00:00
Lorenzo Colitti
834f32089f Make testVpnNetworkActive more deterministic.
This test is a bit brittle because it sets the underlying
networks while the VPN is undergoing validation by
NetworkMonitor. The test does attempt to disable validation,
but that's not actually possible - the only thing that's possible
is to tell NetworkMonitor to validate immediately without sending
any probes. So the underlying network change races with the
validation. I'm not sure why the test isn't flaky. It might be
because both the network change and the validation result in a
capabilities change, and the test expects "a capabilities change"
without expressing what change that should be.

Make this a bit more predictable by ensuring that the network
validates before the underlying networks are set.

This is useful because an upcoming CL will change the way
underlying network capabilities are propagated. With this test
CL, both the old and the new code pass.

Bug: 172870110
Test: test-only change
Change-Id: I319858228e8d097c0b60a107029f296385f91269
Merged-In: I319858228e8d097c0b60a107029f296385f91269
2021-01-29 01:20:33 +00:00
Lorenzo Colitti
6d8b1d2846 Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 172870110
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378
Merged-In: I749ff325bc13ac96f512270b86d1f67686eec378
2021-01-29 01:20:04 +00:00
Lorenzo Colitti
4525be8bfd Increase test coverage for VPN info sent to NetworkStatsService.
Bug: 172870110
Test: test-only change
Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
Merged-In: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7
2021-01-29 01:19:40 +00:00
Lorenzo Colitti
bc3211dd81 Simplify MockVpn.
This CL removes four methods in MockVpn by slightly changing the
test code to leverage the actual methods implemented by the
(production) Vpn superclass.

This works because setting mInterface results in
isRunningLocked() returning true, which makes a number of methods
behave as if the VPN is connected (which is what the test
expects).

The more realistic behaviour exposes a minor bug in the treatment
of underlying networks. Add a TODO to fix it.

Bug: 172870110
Test: test-only change
Change-Id: I49421183538ba61ca790af71e309ece36b653bf9
Merged-In: I49421183538ba61ca790af71e309ece36b653bf9
2021-01-29 01:19:11 +00:00
Lorenzo Colitti
ca7cebc1f6 Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 172870110
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
Merged-In: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
2021-01-29 01:18:29 +00:00
Junyu Lai
8d06e8aba8 Merge "[VCN01] Add NOT_VCN_MANAGED capability" am: 00caf89795 am: 227fc5d23d am: f76c711734
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1549897

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ide501fcf659637c0ec175d3f6f5926c2482734e0
2021-01-28 14:58:38 +00:00
Junyu Lai
f76c711734 Merge "[VCN01] Add NOT_VCN_MANAGED capability" am: 00caf89795 am: 227fc5d23d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1549897

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia78c1366c0f843bfeadcb16f857a0fc13e2b72cd
2021-01-28 14:15:04 +00:00
Junyu Lai
227fc5d23d Merge "[VCN01] Add NOT_VCN_MANAGED capability" am: 00caf89795
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1549897

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I30b0cc54c340150884bebfd289824f1e562eea88
2021-01-28 13:25:50 +00:00
Junyu Lai
00caf89795 Merge "[VCN01] Add NOT_VCN_MANAGED capability" 2021-01-28 13:04:59 +00:00
Treehugger Robot
0658f3f717 [automerger skipped] Merge "Note network interfaces based on transport" am: a7656b2d7e am: 73a7e5b4e9 am: a4f689e36d -s ours
am skip reason: Change-Id I4e928fac8a57a9b1fc758a44af2a5719b8c871b8 with SHA-1 4768f6316e is in history

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1562876

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie00f6cdf0545b325d43e8b5491ee182bc6b4035b
2021-01-28 09:57:25 +00:00
Treehugger Robot
a4f689e36d Merge "Note network interfaces based on transport" am: a7656b2d7e am: 73a7e5b4e9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1562876

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I444343c7230c0f947a666334fb895736fa4bc153
2021-01-28 09:02:21 +00:00
Treehugger Robot
73a7e5b4e9 Merge "Note network interfaces based on transport" am: a7656b2d7e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1562876

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iae2ae51e3819b37cf2c85ce12715978d6ba68c55
2021-01-28 08:32:23 +00:00
Lorenzo Colitti
29e36cb8c8 Merge "Fix legacy APIs when VPN switches to suspended underlying network." am: 83563fd735 am: d892e45c9b am: edd29a2f23
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1547497

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I21c1c7913987a2bb4d486e6ce8da24a76ddf2dc6
2021-01-28 08:06:46 +00:00
Chiachang Wang
fb61f467cf Merge "Replace hidden getFileDescriptor$()" am: f13926d8dc am: 6d0e73ed67 am: 72f68cc2f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553966

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iebc2b32fa7ed14b5326ec7649831fbc8e08b1e9d
2021-01-28 08:06:05 +00:00
Treehugger Robot
b7ac698f9d Merge "[Mainline] Migrate TextUtils#emptyIfNull" am: a4520fd260 am: 59452b2ad4 am: ac4ababa1b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1550514

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I14cc8f1f44b09c82ed9d897b904513d3ea49d558
2021-01-28 08:05:36 +00:00
Daulet Zhanguzin
8ef2001b7f Update frameworks to use unbundled version of BouncyCastle.
Previously BouncyCastle methods were exposed as libcore APIs (@CorePlatformApi), which no longer possible when ART is updatable module (and can't guarantee BouncyCastle API stability)

Bug: 154796679
Test: Treehugger

Change-Id: I908681841a6766de88761767c77c4e2d4b5f56d5
2021-01-28 07:51:22 +00:00
Treehugger Robot
a7656b2d7e Merge "Note network interfaces based on transport" 2021-01-28 07:45:20 +00:00
Lorenzo Colitti
edd29a2f23 Merge "Fix legacy APIs when VPN switches to suspended underlying network." am: 83563fd735 am: d892e45c9b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1547497

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I174ab03efc5291c58aa2842831ba2cd62381cf43
2021-01-28 07:42:30 +00:00
Chiachang Wang
72f68cc2f7 Merge "Replace hidden getFileDescriptor$()" am: f13926d8dc am: 6d0e73ed67
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553966

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id15d49eb46923d3d5c0433babeceea9fec21386c
2021-01-28 07:32:11 +00:00
Treehugger Robot
ac4ababa1b Merge "[Mainline] Migrate TextUtils#emptyIfNull" am: a4520fd260 am: 59452b2ad4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1550514

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie90c6d0245703243f66a9bc2e4d0bf512b3e6339
2021-01-28 07:31:49 +00:00
Lorenzo Colitti
d892e45c9b Merge "Fix legacy APIs when VPN switches to suspended underlying network." am: 83563fd735
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1547497

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I385f93ef5fc3a627fcc2ae827c72e0785c464d8f
2021-01-28 07:22:25 +00:00
Chiachang Wang
6d0e73ed67 Merge "Replace hidden getFileDescriptor$()" am: f13926d8dc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553966

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib6f87447485fd0a4ee008bcabea80b4827fdd99b
2021-01-28 07:15:15 +00:00
Lorenzo Colitti
83563fd735 Merge "Fix legacy APIs when VPN switches to suspended underlying network." 2021-01-28 07:07:37 +00:00
Treehugger Robot
59452b2ad4 Merge "[Mainline] Migrate TextUtils#emptyIfNull" am: a4520fd260
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1550514

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9ae1d067d23fb87d97f326f6da29ddf3a022a821
2021-01-28 07:04:48 +00:00
Chiachang Wang
f13926d8dc Merge "Replace hidden getFileDescriptor$()" 2021-01-28 06:36:11 +00:00
Remi NGUYEN VAN
afd7560b29 Note network interfaces based on transport
Instead of classifying interfaces by network type in BatteryStats,
classify them based on the transports array provided by the
NetworkAgent.

Network types are deprecated and transports should be used instead. This
change allows BatteryStats to stop depending on unstable APIs such as
isNetworkTypeMobile.

This change also updates nullability annotations in ConnectivityService
and NetworkAgentInfo to show that the NetworkCapabilities are non-null
(as provided by the network agent) when calling
noteNetworkInterfaceTransports.

Bug: 174436414
Test: atest
  atest ConnectivityServiceTest#testBatteryStatsNetworkType \
      --rerun-until-failure 40

Merged-In: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8

Change-Id: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8
2021-01-28 15:10:54 +09:00
Treehugger Robot
a4520fd260 Merge "[Mainline] Migrate TextUtils#emptyIfNull" 2021-01-28 06:05:08 +00:00
TreeHugger Robot
359e963945 Merge "Revert "Revert "Note network interfaces based on transport""" into sc-dev 2021-01-28 05:55:23 +00:00
Lucas Lin
6225d58df6 Merge "Use createStringArray instead of readStringArray" am: d1a04ba095 am: a9090b57cf am: da20373654
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559093

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I743f07815b4d2d112d0f8bbeb9d313f6f3d3a8e0
2021-01-28 05:33:07 +00:00
Lucas Lin
19a324e9bd Merge "Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier" am: d15fcc3048 am: b96b07febe am: 0c2e799c80
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556546

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1f7bafc63926c7c68c7c3cdd13069234487888fa
2021-01-28 05:32:36 +00:00
Lucas Lin
da20373654 Merge "Use createStringArray instead of readStringArray" am: d1a04ba095 am: a9090b57cf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559093

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1631856cb2324f5295f834ce8ff2f6276d15a759
2021-01-28 05:01:27 +00:00
Lucas Lin
0c2e799c80 Merge "Check if NetworkSpecifier is an instance of MatchAllNetworkSpecifier" am: d15fcc3048 am: b96b07febe
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556546

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I061c38c83eedf9235d85c4353e88b72117d93b86
2021-01-28 05:01:00 +00:00
Lucas Lin
a9090b57cf Merge "Use createStringArray instead of readStringArray" am: d1a04ba095
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559093

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I38445a56180675c48055fc4256ea238c2b86fabe
2021-01-28 04:31:18 +00:00