Commit Graph

1827 Commits

Author SHA1 Message Date
Chalard Jean
5b2817f17e Merge changes Ic4500dc8,I32477db5 into sc-dev
* changes:
  [NS12] Address comments on NS09
  [NS11] Fix yieldToBadWifi over the policy scoring
2021-04-12 12:41:17 +00:00
Chalard Jean
1fc552984a [NS11] Fix yieldToBadWifi over the policy scoring
This doesn't reactivate the test because it's not yet fixed over int
scoring.

Bug: 184834350
Test: Remove @Ignore and run testAvoidBadWifi
Change-Id: I32477db52eb50faabc499fa68e24ba07577782aa
2021-04-12 10:19:57 +00:00
James Mattis
2066a2dc84 Merge "Adding log history for setOemNetworkPreference()" am: 7fe91d40f1 am: 98b7cc58c6 am: 3842f94fe3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1666340

Change-Id: I123342002b462567174960aa30d1bc4727a8cec7
2021-04-09 17:54:44 +00:00
Remi NGUYEN VAN
43cc2bbfd7 Merge "Add option to make sign-in notification ongoing" into sc-dev 2021-04-09 06:17:17 +00:00
James Mattis
6e4405f926 Adding log history for setOemNetworkPreference()
Adding historical logging for the setOemNetworkPreference() calls. This
will last across reboots.

Bug: 177257940
Bug: 176494815
Test: atest FrameworksNetTests
Change-Id: I4fc35fd58ff741830aa292adc1c559b4279ad8f9
2021-04-08 17:40:06 -07:00
Remi NGUYEN VAN
f672f1b055 Add option to make sign-in notification ongoing
Add an overlay boolean that allows setting the SIGN_IN notification as
an ongoing notification.

This can be useful to make sure users can always easily find the
notification to sign in to a captive portal, as studies have found that
some users have a tendency to dismiss notifications before reading them.
At the same time the notification shade is generally too crowded, which
is what causes such behaviors in the first place, so this option is not
enabled by default and should generally not be enabled without proper
user studies or metrics.

Bug: 173171709
Test: atest NetworkNotificationManagerTest
Change-Id: Ic187d2a2b7e49ad152ea2aa35bb784864b97473c
2021-04-08 14:42:48 +09:00
Chiachang Wang
ec27c044d3 Merge "Assign the bit calculation as long to prevent overflow" am: d125112aa2 am: 7f5c1bc46c am: 67bdf0e830
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1664307

Change-Id: Ia3a1974227ebfd0069b288203df3551a561556eb
2021-04-07 06:06:50 +00:00
Chiachang Wang
d125112aa2 Merge "Assign the bit calculation as long to prevent overflow" 2021-04-07 04:24:46 +00:00
Treehugger Robot
4755f52830 Merge "ConnectivityManager: Address review comments from aosp/1595396" am: 7fe967c611 am: 938579f701 am: dfe1a80db6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1633279

Change-Id: I05777492db3ab9d7b4c6c69131f9404780e4e832
2021-04-07 02:47:49 +00:00
Chiachang Wang
7dd2a3d7db Assign the bit calculation as long to prevent overflow
The value should be assigned as a long to do the bit calculation
as the mNetworkCapabilities is intended to be a long. Otherwise,
the value will be temporary assigned into an integer then
assigned to the target long. When the bit shift calculation
is out of the integer scope, the calculation will overflow and
result in unexpected bebavior.

Without assigning to a long, ConnectivityServiceTest will get
Out-Of-Memory in StringBuilder while generating toString() in
NetworkCapabilities after updating tests to verify
NET_CAPABILITY_VSIM and NET_CAPABILITY_BIP.

Bug: 130869457
Test: atest FrameworksNetTests
Change-Id: I4d34c1215c7efb6dc352c314107792e3fa512ad7
2021-04-07 02:06:33 +00:00
Treehugger Robot
7fe967c611 Merge "ConnectivityManager: Address review comments from aosp/1595396" 2021-04-07 00:36:27 +00:00
Roshan Pius
f75ffaaded ConnectivityManager: Address review comments from aosp/1595396
Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: I7f5d043732ae22edd14bf581b7dc676c9236b545
2021-04-06 16:42:51 +00:00
Frank Li
133733bdd2 Merge "Add session ID to VpnTransportInfo" 2021-04-06 06:50:48 +00:00
James Mattis
eac282f62e Merge "Adding per-app support for app add/remove" am: 922249e2bb am: 08119d7700 am: a208c33fcf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1633904

Change-Id: I72d9981b2a6febc218c30926e58072f43e8bf0a5
2021-04-06 06:12:06 +00:00
James Mattis
bd275dcf3d Adding per-app support for app add/remove
Adding support for per-app network functionality to react to application
installs, removals and updates. Also, opportunistic cleanup of a couple
annotations.

Bug: 177092163
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I45acbd0d2ef50d575f14a944ce82b185ed69f219
2021-04-05 09:55:44 -07:00
Chalard Jean
01a6b34d1d Merge "Fix a bug where the wrong profile is queried" am: 167cc4a044 am: 92bbfaf0a2 am: 1bc19cb6a9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1662362

Change-Id: I5498b7eb2b1b3e4e195ac47d8d3b471496b779b6
2021-04-05 08:10:29 +00:00
Chalard Jean
167cc4a044 Merge "Fix a bug where the wrong profile is queried" 2021-04-05 05:48:17 +00:00
Benedict Wong
54c906b000 Merge "Downgrade list of subIds in NetworkCapabilities to @SystemApi" am: 87e0ab8905 am: d5af88a835 am: 01001e2ddf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652974

Change-Id: I7a85feb9753ae91ff3d67dc82c8bc880a6626074
2021-04-03 02:01:25 +00:00
Chalard Jean
0a04bdb730 Fix a bug where the wrong profile is queried
UserManager#isManagedProfile() is not aware of the user
handle of the context the UM instance is created on.
Instead, call isManagedProfile(int).

Bug: 183625645
Test: ConnectivityServiceTest
Change-Id: I1fef22d67d75df25a8c2d0694f857c3e1c1a1306
2021-04-02 19:24:44 +09:00
Benedict Wong
4310e45eff Downgrade list of subIds in NetworkCapabilities to @SystemApi
This change downgrades API visibility for the list-of-subIds in the
NetworkCapabilities to SystemApi

Bug: 175662146
Test: atest NetworkCapabilitiesTest#testSubIds
Test: atest FrameworksNetTests
Change-Id: I372fa9eaa7585aefd1710948ca007456feedd578
2021-04-02 01:18:11 -07:00
Chalard Jean
4ebc0197f2 Merge "Fix testLegacyLockdownVpn flaky" am: 58b8d1eb22 am: b08d1c3095 am: 4ac82f64c9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1659998

Change-Id: Ib3ec17315225e4f0ed173d4d17165b8f21e07acb
2021-04-01 10:10:39 +00:00
lifr
375d1f5904 Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest android.net.cts.NetworkAgentTest
Change-Id: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
Merged-In: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
           (cherry-picked from ag/14011912)
2021-04-01 15:46:31 +08:00
Chalard Jean
face022980 Fix testLegacyLockdownVpn flaky
When WiFi disconnects, the VPN disconnects immediately. The
broadcast can therefore be sent before the broadcast receiver is
registered, which causes the receiver to not see the broadcast.

The puzzling part is that CONNECTIVITY_ACTION is a sticky
broadcast, so one would expect the broadcast to still be
received, even if the registration is done after the broadcast
is sent. The reason this doesn't happen is that the context used
by the test is a BroadcastInterceptingContext, which does not
treat sticky broadcasts as sticky.

Bug: 184115648
Test: atest --iterations 1000 'ConnectivityServiceTest#testLegacyLockdownVpn'
Change-Id: Ib44c92839d25951cc7d2db0f923e1b104690e1e0
2021-04-01 06:27:46 +00:00
Chalard Jean
e81dbd212a [NS10] Fix a bug where registerIgnoringScore is broken
Fixes: 184028345
Test: ConnectivityServiceTest
Change-Id: Ib5cd2c27a2bd0f53b500e8edbe48126fbf58f34d
2021-03-31 20:59:50 +09:00
Chalard Jean
b887f60347 [NS09] Implement the new ranking code
At this stage, this is turned off. Unit tests will be
in a followup change.

Test: In a followup
Bug: 167544279
Change-Id: I4448a3546fbc1a3dddf757982c031c5f39ba2889
2021-03-31 20:59:47 +09:00
Chalard Jean
d7a91befe1 Merge changes Id7ee1bd3,I5ea44a94 into sc-dev
* changes:
  [NS08] Expose public NetworkScore API
  [NS07] Add the rest of the scoring policy
2021-03-31 11:42:19 +00:00
Lorenzo Colitti
5c88750cfc Merge changes I24580ea4,Id48b8eab am: cbc6a315c5 am: ce1d32cd36 am: e4ef990c5d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1657763

Change-Id: I9d304c35374670eb0e4dcfb9caf6b065878d97e6
2021-03-30 18:33:04 +00:00
Lorenzo Colitti
cbc6a315c5 Merge changes I24580ea4,Id48b8eab
* changes:
  Allow the system to register 250 NetworkCallbacks.
  Add more test coverage for limiting the number of callbacks.
2021-03-30 16:01:58 +00:00
Chalard Jean
7851544cb5 [NS07] Add the rest of the scoring policy
Bug: 167544279
Test: FrameworksNetTests
Change-Id: I5ea44a94ac6f16486274e9091f15a84734db2341
2021-03-30 23:50:41 +09:00
Lorenzo Colitti
b4f8d8e130 Allow the system to register 250 NetworkCallbacks.
Give anyone with PERMISSION_MAINLINE_NETWORK_STACK (i.e.,
either the system or the networkstack process) a separate limit
of 250 callbacks per UID.

Bug: 183921387
Test: new unit tests
Change-Id: I24580ea48e3ad502ef584efc5fde0b5d22e392b4
2021-03-30 22:54:01 +09:00
Lorenzo Colitti
64ef4d3785 Add more test coverage for limiting the number of callbacks.
Bug: 183921387
Test: test-only change
Change-Id: Id48b8eab507fb616cb0adfeba52e00858d44b8a6
2021-03-30 20:28:36 +09:00
Treehugger Robot
364ad64fa7 Merge changes I3826b9ef,I91d68ca3
* changes:
  Add static for constant
  Get NetworkCapabilities from NetworkCallback
2021-03-30 08:22:41 +00:00
Lorenzo Colitti
61a9bf9f02 Merge changes If539cf5d,I9765f1c9,I6d3007a1 am: 2206e976c1 am: 8c9d2c1823 am: 958a701738
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652262

Change-Id: I94e5cf19a7b7dac8400cb7acf80b39a864099956
2021-03-30 02:24:00 +00:00
Lorenzo Colitti
624a47fc57 Merge "Add session ID to VpnTransportInfo" into sc-dev 2021-03-30 00:39:38 +00:00
Lorenzo Colitti
2206e976c1 Merge changes If539cf5d,I9765f1c9,I6d3007a1
* changes:
  Add test coverage for NetworkAgent callbacks.
  Add a setTeardownDelayMs API to NetworkAgent.
  Address comments on onBlockedStatusChanged(Network, int) CL.
2021-03-30 00:38:47 +00:00
Sudheer Shanka
9d483f1a54 Merge "Remove NetworkPolicyManager.isUidBlocked() API." am: 9cff99d059 am: d5da6e7182 am: b8d6d47bd5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652550

Change-Id: Ic5c9fb2603a010976bc93e5059e5548ee782005e
2021-03-29 17:45:42 +00:00
Sudheer Shanka
90358f5154 Remove NetworkPolicyManager.isUidBlocked() API.
It isn't used by ConnectivityService any more and even if
it needs such utility method in the future, we could create
one which is part of connectivity module and doesn't need
to be exposed as part of NetworkPolicyManager API surface.

Bug: 183696103
Test: atest ./tests/net/java/com/android/server/ConnectivityServiceTest.java
Change-Id: Ie3c681f88e4b2b9bb92d2224c5ea96b074f155d5
2021-03-29 12:39:12 +00:00
Lorenzo Colitti
1bc9ad0375 Add test coverage for NetworkAgent callbacks.
Tests the onNetworkCreated, onNetworkUnwanted and
onNetworkDisconnected callbacks, and the teardown delay timer.

Bug: 181941583
Test: atest --rerun-until-failure 500 ConnectivityServiceTest#testNetworkAgentCallbacks
Change-Id: If539cf5d01ba23193afab2433ed0ac4e7f0550ec
2021-03-29 21:33:11 +09:00
Junyu Lai
92a0b5130f Merge "Support Dual ViLTE stats" am: 371bd281f5 am: 4890738bde am: f4cd11179a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540920

Change-Id: I5739265c2747055b0252da7d1fb9e47d61ca111c
2021-03-29 09:05:02 +00:00
Junyu Lai
371bd281f5 Merge "Support Dual ViLTE stats" 2021-03-29 06:59:19 +00:00
Remi NGUYEN VAN
a99e50dbf7 Merge "Re-implement NetworkUtils#queryUserAccess." 2021-03-29 04:57:40 +00:00
Lorenzo Colitti
092af05525 Re-implement NetworkUtils#queryUserAccess.
Currently, queryUserAccess talks to netd via FwmarkServer.
Doing this from the module would require exposing queryUserAccess
as an NDK API or reimplementing FwmarkClient.

Because queryUserAccess really only uses information that comes
from ConnectivityService/PermissionMonitor anyway, just use that
information without calling to net.

Test: atest HostsideVpnTests
Bug: 171540887
Merged-In: If855de1ea3e1fd2ed30f2795d9b4acfcf969a2dc

Change-Id: If855de1ea3e1fd2ed30f2795d9b4acfcf969a2dc
2021-03-29 12:11:19 +09:00
lifr
5acb6b6d4e Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest android.net.cts.NetworkAgentTest
Change-Id: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
2021-03-29 10:12:17 +08:00
Lorenzo Colitti
080d3830c2 Merge changes from topic "blocked-reasons-callback-tests" am: 2108a92452 am: 7de5bd543e am: 994e2cedb1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652214

Change-Id: I4d69b1ce096d83c311620950650460024ae348c0
2021-03-26 05:27:47 +00:00
Lorenzo Colitti
9150b1ec95 Add unit tests for onBlockedStatusChanged(Network, int).
Bug: 165835257
Test: atest FrameworksNetTests
Change-Id: I0597df71aa94817835d7a2fb54bfcf9222a34b64
2021-03-26 02:37:20 +09:00
Lorenzo Colitti
60104f59a0 Add onBlockedStatusChanged(Network, int) to NetworkCallback.
This is similar to onBlockedStatusChanged(Network, boolean) but
it allows the callback holder to know the exact reason why
networking was blocked. It is useful to privileged system
components such as JobScheduler that are able to ignore some
blocked reasons but not others.

Also add a new BLOCKED_REASON_LOCKDOWN_VPN that is used when
networking is blocked because an always-on VPN is in
lockdown mode.

Also move BLOCKED_METERED_REASON_MASK to ConnectivityManager.
This is necessary because ConnectivityService must ensure that
the blocked status callbacks are correctly sent when meteredness
changes (e.g., a UID that is blocked on metered networks will
become unblocked on a network that becomes unmetered). In order
to do this it needs to know which reasons apply only on metered
networks.

Bug: 165835257
Test: unit tests in subsequent CLs in the stack
Change-Id: I647db4f5a01280be220288e73ffa85c15bec9370
2021-03-26 02:37:19 +09:00
Chalard Jean
f278aba302 [NS06] Implement the don't-reap mechanism
This exposes a mechanism for network providers to tell
the network stack that a given network must be kept up
for some specific reason. This is meant to be easier
for them than to have to file a request, in particular
because there is no guaranteed way to make sure the
request will be best matched by any given network.

Test: new test for this
Bug: 167544279
Change-Id: I238a3ee5ee9262477a23b897e4141769dd1505d1
2021-03-25 14:10:06 +00:00
Chalard Jean
7b6a33bd50 [NS05] Feed network offer callbacks
The design is very simply expressed :
An offer is needed for a request if and only if that offer
might beat the satisfier for that request.

The implementation of "might beat" is NetworkRanker#mightBeat.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Bug: 167544279
Change-Id: I0fe911eef2483ecbac48c733d56283b81538690a
2021-03-25 22:13:10 +09:00
Lucas Lin
3818accfc1 Merge "Add static for constant" into sc-dev 2021-03-25 11:34:09 +00:00
Lucas Lin
3483ccf883 Merge "Add annotation for Vpn#getNetwork()" 2021-03-25 11:29:38 +00:00