Commit Graph

1486 Commits

Author SHA1 Message Date
Lorenzo Colitti
02e6ba7210 Merge "Improve getConnectionOwnerUid tests." am: bd2f639a30 am: aa7644c9f9 am: 42f099f5c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1572980

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie69cc409c24468aaebb4a0267009bdc4f9b7a622
2021-02-04 10:11:21 +00:00
Lorenzo Colitti
dbcd5d632a Improve getConnectionOwnerUid tests.
Currently, the tests only check whether the method throws a
SecurityException or not. Also check the return value of the
call, by mocking out InetDiagMessage.getConnectionOwnerUid.

This is required to test an upcoming change that will never
throw SecurityException but always return INVALID_UID if the
caller lacks permissions.

Bug: 173331190
Test: test-only change
Change-Id: I63f42a2f098fcf8796c9b4525a3a7b8320c0a139
2021-02-04 04:19:28 +00:00
Lorenzo Colitti
b1014ac0e4 Merge changes Ifa2aa335,I09366a7f am: 7fed667205 am: 1700ac64d3 am: 61074fe878
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1565201

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2ac2a510eb5837acd77b2d7884da0af14cca502f
2021-02-03 16:33:10 +00:00
Chalard Jean
a02d3f4256 Merge "[NS] Tests : don't expect a score in NF#acceptRequest" am: c6bf15898a am: 8b1998bfb2 am: 66ab10ca12
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556098

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie9e2883453e20f09a269b99ccf8e3ec86b66964b
2021-02-03 10:25:02 +00:00
Lorenzo Colitti
94d03aecfc Allow passing the underlying network to startLegacyVpn.
This will be used by a future change that makes the legacy
lockdown VPN pass the underlying network.

Bug: 173331190
Test: tests in subsequent CLs in stack
Change-Id: I09366a7f872ef3d4538962a75b0114a2ecb536e6
2021-02-03 19:03:53 +09:00
Chalard Jean
c6bf15898a Merge "[NS] Tests : don't expect a score in NF#acceptRequest" 2021-02-03 08:10:19 +00:00
James Mattis
959f869760 Merge "Adding support for multiple "default" networks" am: ca0ab687be am: 24bc30f408 am: b68cb3106c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532548

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ibcb06ea4004e988190ac8ae0dfaa2498d79777fb
2021-02-03 06:44:30 +00:00
James Mattis
8af2d60519 Adding support for multiple "default" networks
Updating ConnectivityService foundational support for multiple default
networks by extending mDefaultRequest and mDefaultNetworkNai from single
instances to a HashMap to support more than a single default network.

Bug: 176027457
Bug: 172347841
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I2f5fa96c2d21ab883499e82afa74e73f3ca606cd
2021-02-02 16:14:36 -08:00
Lorenzo Colitti
89ef449561 Merge changes I4f38a539,Id4f6c7f4 am: 7b49264237 am: 6964d11672 am: 79f031dadc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1565198

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I49cd86725c481827b4278e05afd4847c3a06e8d7
2021-02-02 11:49:08 +00:00
Lorenzo Colitti
786947b4ac Improve testing for network blocking.
This simplifies the uidNetworkingBlocked method and makes it more
realistic by supporting more combinations of rules than just the
four used by this test.

Also support RULE_ALLOW_METERED, and add test coverage for it.

Test: test-only change
Change-Id: Id4f6c7f41429f3ae7841d3214b3e5e95ec591f85
2021-02-02 16:17:22 +09:00
Chalard Jean
efb8409f66 [NS] Tests : don't expect a score in NF#acceptRequest
The score argument is going away, so there no longer
is a need to test it. It's never been used by anybody
and is actually a problem going forward.

Since removing the argument requires a small re-arch
of the testing tool anyway, rebuild expecting requests
on top of TrackRecord. This simplifies the test a
great deal, as well as (as observed in running the
tests) makes the test faster.

Test: this
Change-Id: If03b9e64f14ac8ffa5398b964939a9a45a74b28d
2021-02-01 23:06:49 +09:00
Lorenzo Colitti
ec960a86ce Merge changes Idcc9e32c,I58769bb7 am: e73a36ba21 am: 203c72f86c am: 910fb03907
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552503

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3d15c00910467d51531a25c025efb491b446b6a4
2021-02-01 12:41:24 +00:00
Lorenzo Colitti
e73a36ba21 Merge changes Idcc9e32c,I58769bb7
* changes:
  Remove getFilteredNetworkState and add @NonNull in NetworkState.
  Add test coverage for get*NetworkInfo on metered networks.
2021-02-01 10:56:19 +00:00
Lorenzo Colitti
0e920055dc Add test coverage for get*NetworkInfo on metered networks.
Test: test-only change
Change-Id: I58769bb768978d0acff1da6d32c2f6942c43508b
2021-02-01 15:58:12 +09:00
Junyu Lai
680e2d4f64 Merge "[FUI04] Refactor VpnInfo" am: 149add890e am: ba245e077f am: 55c1a77fea
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1537211

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Icfa9918e41fc3f952a23956108df4db449741364
2021-01-29 23:38:06 +00:00
Junyu Lai
3c48d0cf6f Merge "[VCN06] Support request background network" am: 2141aec60a am: 336c5d93a7 am: 4d9ef0fc1e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553866

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I50867bc7cb21eb134f20af9ef55c44c2bd8962e9
2021-01-29 23:36:41 +00: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
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
00caf89795 Merge "[VCN01] Add NOT_VCN_MANAGED capability" 2021-01-28 13:04:59 +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
Treehugger Robot
a7656b2d7e Merge "Note network interfaces based on transport" 2021-01-28 07:45:20 +00:00
Lorenzo Colitti
83563fd735 Merge "Fix legacy APIs when VPN switches to suspended underlying network." 2021-01-28 07:07:37 +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
359e963945 Merge "Revert "Revert "Note network interfaces based on transport""" into sc-dev 2021-01-28 05:55:23 +00:00
Treehugger Robot
524489652e Merge "[FUI03] No-op refactoring of VpnInfo" am: c1140f2a33 am: 2b6868d243 am: 85c56d4826
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1547637

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I05e6b14fca44919610317831c147413b0a431224
2021-01-27 14:16:00 +00:00
Remi NGUYEN VAN
4768f6316e Revert "Revert "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.

This is rolling forward a previously reverted change. The new change
also fixes MobileRadioPowerCalculatorTest that was broken when
submitting the previous change.

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

Merged-In: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8

Change-Id: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8
(cherry picked from commit 2d17d202bc709c205506c03149d847f00f92d78d)
2021-01-27 09:02:22 +00:00
Junyu Lai
120e49e971 [VCN01] Add NOT_VCN_MANAGED capability
Add new capability to indicate whether a network is
managed by Virtual Carrier Network (VCN). This is needed
to identify networks between VCN managed network and
others. And this capability will be:
  1. mutable
  2. requestable
  3. set by default for network agents and requests
  4. allowed for test networks

Note that this commit is identical to aosp/1529959 except the
capability remains hidden to address the javadoc problem first.
And this CL also needs to be bound with the counter part change
to prevent build breakage.

Test: 1. atest FrameworksNetTests CtsNetTestCases
      2. adb shell dumpsys connectivity
      3. atest ConnectivityServiceTest#testLoseMutableAndRequestableCaps
Bug: 175662146

Change-Id: I37a6f492c2aba72836e36851b50b67398f8bdd36
2021-01-27 16:13:01 +08:00
Treehugger Robot
6d457c9156 Merge changes I713bc2ec,Ib9ab07c9 am: c5a7a59483 am: efeaa56ba6 am: 8b8a8fc5de
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1537264

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4b291a4e82b89d3808e9bcd980d5b2aa4d2b1b71
2021-01-27 07:53:30 +00:00
junyulai
bd7f3cd75b [FUI03] No-op refactoring of VpnInfo
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
  1. Move VpnInfo to android.net
  2. Add nullability annotations
  3. Make members final

Bug: 174123988
Test: TH
Change-Id: I1530bb45d0e84c28c6deac33596bc686058afc0d
2021-01-27 15:03:06 +08:00
Remi NGUYEN VAN
f4ae885dbd Merge "Revert "Note network interfaces based on transport"" 2021-01-26 04:25:56 +00:00
Remi NGUYEN VAN
f9054ed6bd Revert "Note network interfaces based on transport"
This reverts commit 6e1b16c9fe.

Reason for revert: Broke build of tests: b/178441996

Change-Id: Idaf35fa02f76852fa8134b0d505467007f6d0f60
2021-01-26 04:22:54 +00:00
Remi NGUYEN VAN
5e420d9ef4 Merge "Note network interfaces based on transport" 2021-01-26 03:20:21 +00:00
junyulai
cb95247c1e [FUI05] Remove wimax data usage unit test
In follow-up patches, the network type will be derived from
transport types, which officially doesn't support wimax.
Thus, remove the test which rely on it first since it is
not needed and will not be needed.

Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: I713bc2ec39e3a4fa19ed13d2e9ff9ae35477d726
2021-01-22 23:58:14 +08:00
junyulai
de493c006a [FUI14] Get SSID from NetworkCapabilities
This allows subsequent patches to remove the need of exposing
SSID in NetworkState.

Test: atest NetworkStatsServiceTest
Bug: 174123988
Change-Id: Ib9ab07c9610954c9a5de035a3aefbf6d0bb0b53b
2021-01-22 23:58:14 +08:00
Chalard Jean
04ba35dc06 Merge "Add Qos Callback support" am: 29f0f6d47f am: b97f23ae96 am: f14671c09a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1386623

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If0a123f16951c88cc5881fba8865fae822ba92f0
2021-01-22 14:52:58 +00:00
Daniel Bright
60f02ed76b Add Qos Callback support
* Provide App Developers Qos related info associated to
  a bound socket through ConnectivityManager
* Qos sessions are generated and filtered by Network Agents
  and sent back through the Connectivity Service to the
  API consumer.
* The structure of the code within com.android.server
  is designed to support different types of filters in the
  the future.
* The first type of Qos Attributes are related to EPS
  Bearers in order support RCS.

Bug: 155176305
Test: Added to cts/NetworkAgentTest
Test: Added to ConnectivityServiceTest
Change-Id: I145dd065d9deeee449eb9695ab3f6c8556ee7c09
2021-01-21 20:14:52 -08:00
Remi NGUYEN VAN
6e1b16c9fe 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

Change-Id: Icc912473d97a42eef73eb953607c9161fdbeb794
2021-01-20 15:53:54 +09:00
Lorenzo Colitti
246d176689 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
2021-01-20 11:32:51 +09:00
Junyu Lai
12703ee175 Merge "Revert "[VCN06] Support request background network"" am: 2fa034c812 am: b7b3064394 am: dd7029fd30
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553864

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I896c2008e29163527b03f031623e1c70d16e1da4
2021-01-19 12:39:27 +00:00
Junyu Lai
2fa034c812 Merge "Revert "[VCN06] Support request background network"" 2021-01-19 10:24:47 +00:00
Junyu Lai
34263da2c9 Revert "[VCN06] Support request background network"
Revert submission 1545847-vcn06

Reason for revert: b/177876289 presubmit failure
Reverted Changes:
I8042ce197:[VCN06.1] Add CTS for request background network
If9aaa87b7:[VCN06] Support request background network

Change-Id: I9270b02a2d6d1ffcdd83b4f41becaf09a2b91e0a
2021-01-19 09:06:00 +00:00
Treehugger Robot
b19d0ca85d Merge changes I475502fd,Ibf376a6f,Ia52f9caf am: 4fcb0e54a1 am: ed9f5d54a5 am: 0cc2e20cc9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1553958

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic7c2c6289bcc469f43f0293ca4bfd7d6b15ce80a
2021-01-19 05:46:03 +00:00
Treehugger Robot
4fcb0e54a1 Merge changes I475502fd,Ibf376a6f,Ia52f9caf
* changes:
  Address comments on aosp/1539753, aosp/1542487 and aosp/1547496.
  Fix propagating underlying caps when a network disconnects.
  Test for bugs with suspended VPN underlying networks.
2021-01-19 04:19:56 +00:00
Junyu Lai
635c79aeff Merge "[VCN06] Support request background network" am: 95f0791724 am: bf098917d8 am: d57038a8b0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1545847

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I12d2cbe4a5fc10a7ec7abf8038c088fe13b02d59
2021-01-19 01:50:31 +00:00
Lorenzo Colitti
34007bd8de Address comments on aosp/1539753, aosp/1542487 and aosp/1547496.
Bug: 173331190
Test: test-only change
Change-Id: I475502fde55d24e7ae3f7fe9f43c54740c57a9cf
2021-01-19 10:35:43 +09:00
Junyu Lai
95f0791724 Merge "[VCN06] Support request background network" 2021-01-19 01:04:20 +00:00
Lorenzo Colitti
c284b4b8dd Fix propagating underlying caps when a network disconnects.
aosp/1513052, which generalized support for underlying networks,
broke default network switching when the network underlying a VPN
disconnects.

This is because it calls propagateUnderlyingNetworkCapabilities
in the middle of the bookkeeping operations needed when a
network is disconnected (specifically, after all satisified
requests are removed from the disconnecting network, but before
mDefaultNetworkNai is updated). This is completely incorrect
because propagateUnderlyingNetworkCapabilities can trigger a
network rematch, and running a rematch when the request data
structures are inconsistent is obviously wrong. See the test
changes in this CL for an example of the damage.

Fix this by moving propagateUnderlyingNetworkCapabilities to
before the bookeeping operations begin. It must be before
mDefaultNetworkNai is updated, because otherwise it will not know
that the default network is disconnecting, and it will not be
able to propagate capabilities to VPNs that set underlying
networks to null (i.e., to the default network). It must be
after the nai is removed from mNetworkForNetId because
otherwise it will think that the underlying network is still
connected.

Bug: 173331190
Test: accompanying unit test shows lots of bugs removed
Change-Id: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
2021-01-19 09:40:53 +09:00