Commit Graph

72 Commits

Author SHA1 Message Date
Benedict Wong
ab765e0ebe Merge changes I2d30b75c,I57ecf4f5
* changes:
  Switch to using list of subIds for policy generation
  Switch to using list-of-subIds for VCN selection of underlying networks
2021-03-31 20:59:00 +00:00
Benedict Wong
85c6ad2363 Switch to using list of subIds for policy generation
Bug: 183174340
Test: atest FrameworksVcnTests
Change-Id: I2d30b75c282cf619d81b0f6dc06638566af61a33
2021-03-30 14:21:49 -07:00
Lucas Lin
0b66568d6a Merge "Remove the usage of hidden API and simplify the design" 2021-03-30 08:01:27 +00:00
Benedict Wong
bda63ebd02 Switch to using list-of-subIds for VCN selection of underlying networks
This change switches from primarily using unwanted(NOT_VCN_MANAGED) to
list-of-subIds. This opens the door for a soft-start, predicated on the
VCN-exposed networks not populating their respective subId fields.

Allowing the potential for soft-start means that the VCN can exit safe
mode without carrier app intervention, when all requested configurations
are active.

Bug: 183174340
Test: atest FrameworksVcnTests
Change-Id: I57ecf4f5f04dc5d15589b17d647661674595b872
2021-03-29 10:45:41 -07:00
lucaslin
36705517ed Remove the usage of hidden API and simplify the design
- ConnectivityManager will be a part of mainline module, so its
hidden API cannot be called by external caller.
- There is no need to listen onNetworkSuspended() and
onNetworkResumed() because if the network is suspended, then
NET_CAPABILITY_NOT_SUSPENDED will be removed and
onCapabilitiesChanged() will be called and the network capabilities
will be different from the previous one. And when the network is
resumed, NET_CAPABILITY_NOT_SUSPENDED will be added back to the
network capabilities. So the current design can be simplified.

Bug: 182963397
Test: atest FrameworksVcnTests
Change-Id: Ib8f8ea1c95503c946b8229670512af2db8be3165
Merged-In: Ib8f8ea1c95503c946b8229670512af2db8be3165
  (cherry-picked from ag/13927656)
2021-03-25 10:29:27 +00:00
Benedict Wong
62f01dfbd5 Trigger re-evaluation of privileged apps upon app install/uninstall
This change registers listeners for package installs and uninstalls,
ensuring that changes to app install statuses are reflected in the VCN

Bug: 183465258
Test: atest FrameworksVcnTests
Change-Id: I8d2afd351208cac12392bf945439845cc521b7ec
2021-03-23 17:42:12 -07:00
Benedict Wong
d68c1f6cb2 Check carrier privilege permissions with package name
This change ensures that carrier privileges for the right packages are
always checked.

Bug: 183465199
Test: atest FrameworksVcnTests
Change-Id: If46c660e54870529868a7b4b1e271c9009b81d45
2021-03-23 17:42:12 -07:00
Cody Kesting
3a51a7d152 Reevaluate VcnGatewayConnections on receiving new configs.
This CL updates Vcn.java to reevaluate its VcnGatewayConnections when it
receives a new VcnConfig. This may result in VcnGatewayConnections being
torn down (if their VcnGatewayConnectionConfig is not in the updated
VcnConfig) or established (if a NetworkRequest matches a new
VcnGatewayConnectionConfig).

Bug: 181815405
Test: atest FrameworksVcnTests CtsVcnTestCases
Change-Id: I7da60f60e972bd968e1ff4fe416fb9a1d3309a18
2021-03-22 11:59:27 -07:00
Roshan Pius
adee4b7b7e TransportInfo: Add a generic redaction mechanism
This replaces the existing mechanism for redacting location sensitive
fields with a more extensible mechanism. Currently supported redactions
are for the following permissions:
i. ACCESS_FINE_LOCATION
ii. LOCAL_MAC_ADDRESS
iii. NETWORK_SETTINGS

Also, removed WifiInfo from ConnectivityServiceTest to reduce cross
dependencies on wifi code.

Bug: 156867433
Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: I2bb980c624667a55c1383f13ab71b9b97ed6eeab
2021-03-19 20:15:21 +00:00
Remi NGUYEN VAN
a89a2ae676 Merge "Move LocationPermissionChecker to libs/net" 2021-03-17 00:13:21 +00:00
Chalard Jean
5c4bb91134 [NS01] Add NetworkScore
As attested by numerous TODOs in the code, a new way of
representing network quality and policy is needed instead
of an int.

An int representing the quality of the network requires
all parties using it to know how all other parties are
using it, and implementation details about the decision
algorithm. For all intents and purposes, the selection
is left to individual network factories who try to
achieve a desired result while piecing together all
possible states of the system.

As the number of such cases and desires increases, this
becomes both intractable and unmaintainable. Indeed, at
this time in the codebase nobody can really predict exactly
how a given change in score will affect selection across
the board, and it is essentially impossible to figure out
the behavior of network selection by inspecting the code
because the moving parts are scattered throughout the
entire codebase.

Having an object encapsulating policy and quality values
will let us centralize the selection and make it again
possible to maintain without knowledge of all behaviors
of all network factories. It will also provide better
guarantees of respecting policy, and allow bugfixes that
were not possible before because they'd touch too many
parts of the code.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Change-Id: I3185a6412b9b659798faf0c6882699e9c63cc115
2021-03-15 09:49:47 +00:00
Cody Kesting
a93e2f9545 Merge "Update Policy Listener API naming." 2021-03-12 21:32:08 +00:00
Cody Kesting
ae3c3593cb Update Policy Listener API naming.
This CL changes the policy listener API to be
VcnNetworkPolicyChangeListener (it was previously
VcnNetworkPolicyListener) per API Council guidance.

This CL also requires permission NETWORK_FACTORY for removing registered
policy listeners.

Bug: 181562364
Test: atest FrameworksVcnTests
Change-Id: I026eaefa62d8f64b9180fc182a7cf0605d83bf97
Merged-In: I026eaefa62d8f64b9180fc182a7cf0605d83bf97
(cherry picked from commit a96ec13821)
2021-03-11 09:48:22 -08:00
Benedict Wong
03c0059bb1 Merge changes Iad296830,I826711bb,Ieb2a9b20,I6b688b00
* changes:
  Declare VCN exposed networks as NOT_VCN_MANAGED
  Allow underlying cell without unwanted NOT_VCN_MANAGED capability
  Override network and use config IKE session
  Remove usage of hidden Connectivity APIs
2021-03-10 21:53:01 +00:00
Benedict Wong
de1f0c3edb Declare VCN exposed networks as NOT_VCN_MANAGED
This change marks VCN-exposed networks as generic use, NOT_VCN_MANAGED
networks. This is the result of changes to the default NetworkCapability
set, where NOT_VCN_MANAGED was removed from the default capabilities.

Bug: 182212201
Test: atest FrameworksVcnTests
Change-Id: Iad296830201d7317537fac6bea53c79d4e41cae3
2021-03-10 10:27:23 -08:00
Benedict Wong
dc1efbb3b2 Allow underlying cell without unwanted NOT_VCN_MANAGED capability
This change updates the UnderlyingNetworkTracker to rely on the
TelephonyNetworkSpecifier for selecting underlying networks. This
ensures that there is always a cellular NetworkRequest filed for
Cellular to bring up an underlying Network.

Bug: 182211364
Test: FrameworksVcnTests
Change-Id: I826711bb671440054c2090793315a5f1d57596c0
2021-03-09 17:58:39 -08:00
Benedict Wong
033a4308ce Override network and use config IKE session
This change ensures the IKE configs are used with the correct network

Bug: 163604823
Test: FrameworksVcnTests
Change-Id: Ieb2a9b202204577f6e6969ef30245baed6382aa6
2021-03-09 15:07:57 -08:00
Cody Kesting
cdc4d4adae Specify exposed capabilities for VCN gateway connection errors.
This CL updates VCN error callbacks to return the exposed capabilities
for a gateway connection for identification purposes. Previously, the
required underlying capabilities were returned (which are not meaningful
to the caller for identification purposes).

Bug: 182281888
Test: atest FrameworksVcnTests
Change-Id: Ic62bd0b524f24f2577d9abc7635112a6419d35ed
2021-03-09 11:22:46 -08:00
Remi NGUYEN VAN
0c4e4a2059 Move LocationPermissionChecker to libs/net
LocationPermissionChecker was written to be used by multiple
connectivity modules, so it belongs in the frameworks/libs/net library.

The file is moved as-is with minor modifications in the test to avoid
usage of the privileged ActivityManager.getCurrentUser API.

Bug: 181837977
Test: atest NetworkStaticLibTests
Change-Id: I63bce35ba87c45138b3aaf6244367e982dfec455
2021-03-09 17:00:39 +09:00
Cody Kesting
df8455eae2 Exit Safe Mode when a VCN gets new configs.
This CL updates VCN instances to exit Safe Mode when they receive a
new VcnConfig. When a VCN exits Safe Mode, they will re-register a
request listener to receive all cached requests and start the
needed VcnGatewayConnections.

Bug: 179429339
Test: atest FrameworksVcnTests
Change-Id: Id1c2dc287e1ec56f37821cf0ae77f066f22d22bb
2021-03-08 11:14:25 -08:00
Cody Kesting
212c06aaa6 Notify VcnStatusCallbacks for VCN start/stop.
This CL updates VcnManagementService to notify VcnStatusCallbacks when a
VCN is started or stopped. VcnStatusCallbacks will also be notified for
config changes that cause a VCN to exit Safe Mode.

Bug: 180659281
Test: atest FrameworksVcnTests
Change-Id: I4168c868185880621333855dfcb51e46cb662741
2021-03-08 11:14:25 -08:00
Cody Kesting
f38b347ca8 Call VcnStatusCallback#onVcnStatusChanged on register.
This CL updates VcnMangementService to notify VcnStatusCallbacks on
registration with the current status of the VCN for the specified
subscription group.

Bug: 180659281
Test: atest FrameworksVcnTests
Change-Id: Id2c74e855fa12d21d292ee94a72ad047f2d56aca
2021-03-03 14:06:55 -08:00
Benedict Wong
e145e06681 Call setUnderlyingNetwork to complete VCN MOBIKE
This change updates the underlying network for the VCN in order to
ensure full MOBIKE switches are handled.

Bug: 169788130
Test: atest FrameworksVcnTests
Change-Id: Ib439bde4217beeb28f425c08ed9f3376dfe0033c
2021-03-02 00:13:28 +00:00
Benedict Wong
6adf88b074 Rename isRunning to isQuitting, and flip all booleans
Per code reviews, this may increase readability

Bug: 179944275
Test: atest FrameworksVcnTests
Change-Id: I5bc0fe946b8da870a8e89f6e07b1d1ade5865710
2021-03-02 00:09:56 +00:00
Benedict Wong
685c909718 Notify Vcn of VcnGatewayConnection quits
This change updates the Vcn when any GatewayConnection StateMachine
quits, removing it from the map of active GatewayConnections, and
triggering a re-evaluation of all existing NetworkRequests. This may (in
the event of a updated policy) result in an immediate restart.

Bug: 179944275
Test: atest FrameworksVcnTests
Change-Id: I72abf1e270a772760a17a03173d5a110e15bd01d
2021-03-01 15:44:52 -08:00
Benedict Wong
75a32b9401 Allow NETWORK_LOST disconnections to retry
This change adds the ability for disconnection requests to specify
whether the full VcnGatewayConnection should be torn down. This is
useful in cases where the cause is an ephemeral failure, and can be
restarted at some later point (eg an underlying network appears, or a
new NetworkRequest is filed that brings the VCN up.)

Bug: 179944275
Test: atest FrameworksVcnTests
Change-Id: Id1813bcbbb80541be97cc383ea9d1fe08554b7ae
2021-03-01 15:36:24 -08:00
Cody Kesting
7458bf88a0 Notify VcnStatusCallback#onVcnStatusChanged for Safe Mode.
This CL updates VcnManagementService to notify callbacks when VCNs enter
Safe Mode via #onVcnStatusChanged. Callbacks were previously notified
via #onEnteredSafeMode - however, VcnStatusCallbacks were changed to
provide more status information by defining onVcnStatusChanged(int) per
API Council feedback.

Bug: 1597023
Test: atest FrameworksVcnTests
Change-Id: I34ef76ec29f4369390449b70b37bc3cf99c09c77
2021-02-22 17:35:29 -08:00
Cody Kesting
a65c2d8ad1 Implement VCN error callback use.
This CL updates VcnGatewayConnection to notify VcnManagementService
(through Vcn) when errors occur with a gateway. VcnManagementService
then notifies registered, permissioned VcnStatusCallbacks via

Bug: 163433613
Test: atest FrameworksVcnTests
Change-Id: I3be3cac4b591b19a0b0075767fde0ba2eb6e12a2
2021-02-17 14:28:34 -08:00
Cody Kesting
f1d78f17c2 Merge changes I3242ad0e,I5daced20,Iefd284ae
* changes:
  Notify status callbacks when a VCN enters Safemode.
  Change all 'safemode' references to use 'safe mode'.
  Define VcnStatusCallback register/unregister.
2021-02-17 18:08:48 +00:00
Cody Kesting
59881b17b4 Notify status callbacks when a VCN enters Safemode.
This CL updates VcnManagementService to notify VcnStatusCallbacks when
the VCN for their specified subscription group enters Safemode. In order
to be notified, the registering app must also have permissions for the
specified permission.

Bug: 163433613
Test: atest FrameworksVcnTests
Change-Id: I3242ad0ee1dc406aef56253f884c2544a994869e
2021-02-16 21:41:03 -08:00
Cody Kesting
a3da6c886e Change all 'safemode' references to use 'safe mode'.
Bug: 163433613
Test: atest FrameworksVcnTests
Change-Id: I5daced209e4e6d8d1b87385b3f64660322908fa0
2021-02-16 21:41:03 -08:00
Cody Kesting
f14145e37a Define VcnStatusCallback register/unregister.
This CL defines VcnStatusCallbacks, which are callbacks used to register
for status updates to a specific subscription group. These Callbacks may
be registered with VcnManager at any time, but will only be invoked for
the specifies subscription group and only if the registering app has
carrier privileges for that subscription.

Bug: 163433613
Test: atest FrameworksVcnTests
Change-Id: Iefd284ae2d09676d195e2a12bf660be3596da59b
2021-02-16 21:33:40 -08:00
Benedict Wong
d301c8544e Merge "Implement ChildSessionCallback#onIpSecTransformsMigrated" 2021-02-17 04:02:40 +00:00
Benedict Wong
d6186bdf3c Implement ChildSessionCallback#onIpSecTransformsMigrated
This change implements the Migrated callback, proxying to
onIpSecTransformCreated

Bug: 180163196
Test: atest FrameworksVcnTests
Change-Id: Ibf07be667882ea35a4d7191b87d1193f38f9db3e
2021-02-16 22:10:42 +00:00
Cody Kesting
a282ea505f Implement Safemode alarm in VcnGatewayConnection.
This CL updates VcnGatewayConnection to use WakeupMessages to support
Safemode detection. Safemode is entered if the VcnGatewayConnection
instance takes more than SAFEMODE_TIMEOUT_SECONDS seconds to a) go from
DisconnectedState to ConnectedState, or b) exit and re-enter
ConnectedState. If this timeout is exceeded, the instance will notify
its managing Vcn via VcnGatewayStatusCallback#onEnteredSafemode.

Bug: 178140973
Test: atest FrameworksVcnTests
Change-Id: Iff40aba639b465c3959ef383f1001be419daba4d
2021-02-16 09:46:07 -08:00
Cody Kesting
57211bc8f5 Use WakeupMesage for delayed events in VcnGatewayConnection.
This CL updates VcnGatewayConnection to use WakeupMessages instead of
sendDelayedMessage() for delayed events. This change allows for
VcnGatewayConnection to guarantee that all its messages are processed
while holding WakeLocks.

Bug: 178140973
Test: atest FrameworksVcnTests
Change-Id: If8182378fe2e9dad08df88a84934b21e22e25752
2021-02-12 16:27:06 -08:00
Cody Kesting
a4bec019a7 Acquire WakeLock while processing Gateway messages.
This CL updates VcnGatewayConnection to acquire a WakeLock when sending
a message to the Handler queue. After every message is processed, the
state will check for additional messages and release the WakeLock if the
queue is empty.

Bug: 178140973
Test: atest FrameworksVcnTests
Change-Id: Ib108c834833cc8feb2c92c9a6c60f218618225ec
2021-02-12 16:01:32 -08:00
Benedict Wong
acf7a30f3e Lazy-create IpSecTunnelInterface
With the Network(int) constructor moving to mainline, we cannot use the
constructor, and should just create the IpSecTunnelInterface lazily, at
first use.

Bug: 165827287
Test: atest FrameworksVcnTests
Change-Id: Ic01858e0f9c80d316676cfbae5edca114655c3fe
2021-02-09 21:22:27 -08:00
Benedict Wong
cebde1ed9a Restrict Carrier Wifi while VCN is configured & privileged
This change removes the NOT_RESTRICTED capability for Carrier Wifi. This
is done even if a VCN is in safe mode, but will ONLY be performed if the
VCN is provisioned, and has the appropriate carrier privileges to run.

This change also fixes a test bug where the NOT_VCN_MANAGED capability
was not present in the query to getUnderlyingNetworkPolicy(), and
therefore was incorrectly passing.

Bug: 163432273
Test: atest FrameworksVcnTests
Change-Id: Iecb827b5341bdeb93ef8692c1d62f0eaf9d416ba
2021-02-09 18:43:21 -08:00
Benedict Wong
36cbdb5391 Implement RetryTimeout state
This change adds support for retries with incrementally increasing
delays.

Bug: 165827287
Test: atest FrameworksVcnTests
Change-Id: I414dce5882540bbe338d0bc1f40481df424821fe
2021-02-05 15:11:39 -08:00
Benedict Wong
2ef953a9a1 Test Network startup in ConnectedState
Add additional tests based on proxy implementations of
ChildSessionCallback and ChildSessionConfiguration

Bug: 165827287
Test: atest FrameworksVcnTests
Change-Id: I165716a0212da7c06b9723656ffe35921cf81854
2021-02-05 15:11:38 -08:00
Cody Kesting
204a2fed4f Support Safemode for VCNs.
This CL updates VcnManagementService to support Safemode for VCN
instances. Specifically, VcnGatewayConnections will notify their Vcn
instance when they enter Safemode. Vcn instances will in-turn notify
VcnManagementService, which notifies all registered
UnderlyingNetworkPolicyListeners to update their policies.

Bug: 178140973
Test: atest FrameworksVcnTests
Change-Id: I3336c150e9406b3eb2330d2e86cae2ed835730bb
2021-02-04 16:22:55 -08:00
Cody Kesting
f5915a7f3a Fix test method naming in VcnManagementServiceTest.
Bug: 175914059
Test: atest FrameworksVcnTests
Change-Id: I03be15d63adfccc357000ee670e373d0359a3c06
2021-02-03 20:28:51 -08:00
Cody Kesting
26409bfe5d Notify PolicyListeners to refresh their policy on VCN changes.
This CL updates VcnManagementService to notify all registered
VcnUnderlyingNetworkPolicyListeners to refresh their
UnderlyingNetworkPolicy when any VCN is added or removed.

Bug: 175914059
Test: atest FrameworksVcnTests
Change-Id: Ie87f4aa3401c6c4ba9f932130a1d475e35f59d4e
2021-02-03 20:28:51 -08:00
Cody Kesting
50e9bf04aa Unit test TelephonySubscriptionSnapshot changes for VCNs.
This CL adds unit testing for TelephonySubscriptionSnapshot updates in
UnderlyingNetworkTracker, Vcn, and VcnManagementService.

Bug: 177364490
Test: atest FrameworksVcnTests
Change-Id: I244744194a1360c7c7dee062a302e04f9b5efc32
2021-02-03 20:28:43 -08:00
Cody Kesting
2b0754517c Notify UnderlyingNetworkTracker for Subscription changes.
This CL updates VcnManagementService to notify active VCNs when it is
notified of subscription changes by TelephonySubscriptionTracker. These
subscription changes are passed down to each VCN's
UnderlyingNetworkTracker, which determines whether it needs to register
or unregister bringup NetworkRequests based on subIds within that VCN's
Subscription Group.

Bug: 177364490
Test: atest FrameworksVcnTests
Change-Id: I15bc9aaf3d5f97046d0ce9fcf1e12c9b1e0e1446
2021-02-03 19:04:01 -08:00
Benedict Wong
539ba24df4 Implement ConnectedState
This change implements the Connected state, ensuring that relevant
capabilities are mirrored from the underlying networks.

Bug: 165827287
Test: atest FrameworksVcnTests
Change-Id: Iedf6d879b4577d7efd40cce41cc1d5fd5021124f
2021-02-03 10:26:36 -08:00
Cody Kesting
07979a07cc Implement Network policy in VcnManagementService.
This CL implements #getUnderlyingNetworkPolicy() for
VcnManagementService. Specifically, it takes the provided
NetworkCapabilities and checks for a corresponding VCN. If one exists,
a VcnUnderlyingNetworkPolicy will be returned with a copy of the
original NetworkCapabilities without the capability NOT_VCN_MANAGED and
with the unwanted capability NOT_VCN_MANAGED.

Any NetworkCapabilities without a corresponding VCN will be returned a
VcnUnderlyingNetworkPolicy with the original NetworkCapabilities intact.

Bug: 175914059
Test: atest FrameworksVcnTests
Change-Id: Icdffc4f586f58a0e5b6290d5c6449e2bbed5cab0
2021-02-01 14:46:58 -08:00
Cody Kesting
f029daa404 Unit test UnderlyingNetworkTracker.
Bug: 177364490
Test: atest FrameworksVcnTests
Change-Id: I681b0bef27cdd1974a574e81b4b435578cd6e9cd
2021-02-01 14:46:57 -08:00
Cody Kesting
a382c9ca0c Register NetworkCallbacks in UnderlyingNetworkTracker.
This CL updates UnderlyingNetworkTracker to register NetworkCallbacks.
UnderlyingNetworkTracker uses two types of NetworkCallbacks:
  - bringup requests
  - selection requests

Bringup requests ensure that VCN-managed Networks are not reaped.
Separate bringup requests are filed for wifi and cell Networks. One cell
request is filed for each subscription ID (subId) in the VCN's
subscription group.

Selection requests are used to allow ConnectivityService to perform
Network selection for the VCN's selected underlying Network (the Network
that VCN traffic will be routed through).

Bug: 177364490
Test: atest FrameworksVcnTests
Change-Id: Ic4dc13a3f7acf08589ddb25b343af2677cd7cf65
2021-02-01 14:46:57 -08:00