Commit graph android_packages_modules_Co.../services/core/java/com/android/server/ConnectivityService.java
Message SHA1
Move connectivity sources to packages/Connectivity
The service-connectivity sources should be in
packages/modules/Connectivity. Move them to
frameworks/base/packages/Connectivity, so that the whole directory can
be moved to the dedicated packages/modules/Connectivity git project.

Bug: 186628461
Test: m
Merged-In: I26d1a274058fa38763ad4f605549d880865b4d76
Change-Id: Ie0562db92ebee269b901926d763ae907bde61b98

Remi NGUYEN VAN   commited 2021-05-13 18:18:42 +00:00
4febb21cb6
Merge "[DO NOT MERGE] Revert "Reference unreachable netId from INetd""
Ken Chen   authored and   Gerrit Code Review   commited 2021-05-13 17:59:00 +00:00
b566375c5d
[DO NOT MERGE] Revert "Reference unreachable netId from INetd"
This reverts commit 9c4436ec22.

Reason for revert: Automerge conflict on sc-dev. The target file has been moved to other folder in sc-dev (ag/14516148). Revert this change and check-in again from AOSP bases on aosp/1706845.

Change-Id: I93a8bf4a3f59d789d88adceb3760c586b9951750

Ken Chen   commited 2021-05-13 17:40:51 +00:00
d973820fcc
Merge "Reference unreachable netId from INetd"
Ken Chen   authored and   Gerrit Code Review   commited 2021-05-13 16:10:49 +00:00
0b08f1712a
Merge "[NS04] Introduce Network Offers and their callbacks"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-05-13 15:11:45 +00:00
5dd83f217e
[NS04] Introduce Network Offers and their callbacks
This patch introduces the concept of a network offer that
providers send to Connectivity to register for relevant
requests. This lets them see only requests that they can
hope to satisfy considering their capabilities and score
filters.

This is meant to replace the filtering mechanism currently
implemented by NetworkFactory. The reason for replacing
this mechanism is that the old mechanism does caps and
score filtering on the factory side, which requires these
two filters to be contextless and available system-wide,
including in separate processes from the system server.
These constraints severely limit and complexify in
particular what the score comparisons may look like. In
the past the score comparison was only integer-based,
making the code duplication not much of a problem, but as
this scheme is becoming unsustainable by spreading the
complexity of the selection across the entire stack, a
centralized mechanism is now necessary.

This patch only introduces the new objects and has CS
keep track of them, but does not actually use them yet.
Followup patches will implement the logic of calling
the offer callbacks.

Test: FrameworksNetTests NetworkStackTests FrameworksWifiTests
Bug: 167544279
Merged-In: Idec1fe8eb4ac6f562bf098e3dd470f11024d04f2
(clean cherry-pick)

Change-Id: Idec1fe8eb4ac6f562bf098e3dd470f11024d04f2

Chalard Jean   authored and   Remi NGUYEN VAN   commited 2021-05-13 13:20:43 +00:00
cdd68bcc3a
Do not automatically redact TransportInfo objects.
Currently, NetworkCapabilities always redacts the TransportInfo
objects it contains whenever a defensive copy is made. This makes
it impossible to make a defensive copy on a TransportInfo
parcelled from another process without redacting it.

Stop redacting by default; instead rely on ConnectivityService
explicitly calling NetworkCapabilities' redacting constructor
when it returns a NetworkCapabilities object to an app via a
callback or synchronous call. This is currently done by
- createWithLocationInfoSanitizedIfNecessaryWhenParceled, which
  is called from callCallbackForRequest, getNetworkCapabilities,
  and getDefaultNetworkCapabilitiesForUser.
- getNetworkCapabilitiesWithoutUids, which is used when sending
  ConnectivityDiagnosticsManager callbacks. In this method,
  unconditionally redact all information, which is what the code
  did previously due to the default redaction setting for empty
  NetworkCapabilities objects being REDACT_ALL.

Bug: 183938194
Test: atest NetworkCapabilitiesTest
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Change-Id: I3108ee94cb0930958e071ba678c3554525b0db82

Lorenzo Colitti   commited 2021-05-13 20:24:19 +09:00
6424cf294f
Reference unreachable netId from INetd
Bug: 181579204
Test: m; atest FrameworksNetTests
Change-Id: I7b59483d888e556ae50a37da539501b046295c16

Ken Chen   commited 2021-05-13 09:45:18 +08:00
9c4436ec22
Merge "Better log in createNativeNetwork"
Ken Chen   authored and   Gerrit Code Review   commited 2021-05-13 01:21:47 +00:00
44f99098a1
Merge "Switch from networkCreate[Physical/Vpn] to networkCreate"
Ken Chen   authored and   Gerrit Code Review   commited 2021-05-13 01:20:39 +00:00
6bab439131
Merge "Update PrivateDnsMode from StringDef to IntDef"
Lucas Lin   authored and   Gerrit Code Review   commited 2021-05-12 17:09:50 +00:00
6813b1b794
Better log in createNativeNetwork
Dump more information from NetworkAgentInfo in error log.

Bug: N/A
Test: m
Change-Id: I92981c03ad80e8b1d7ffaf45d50cc0bfd0b283b0

Ken Chen   commited 2021-05-12 13:44:40 +08:00
755a4e7715
Switch from networkCreate[Physical/Vpn] to networkCreate
networkCreatePhysical and networkCreateVpn are non-extensible. In order
to pass OEM requested VPN type to Netd, we need to migrate to
networkCreate API.

Modify test code accordingly since networkCreatePhysical and
networkCreateVpn have been deprecated on Netd.

Bug: 171872481
Test: atest FrameworksNetTests
atest atest HostsideVpnTests

Change-Id: I50ab8615346c49559c16e815482e7804a1e765c8

Ken Chen   commited 2021-05-11 16:06:54 +08:00
6df7a90c1f
Update PrivateDnsMode from StringDef to IntDef
Update PrivateDnsMode from StringDef to IntDef because IntDef is
the normal way of representing multiple choices in public API.
Also update other related files.

Bug: 185311744
Test: 1. make update-api
      2. atest FrameworksNetTests CtsNetTestCases CtsNetTestCasesLatestSdk
      3. atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I23e7ec140066979726d769cabc5f7057bb2167e6
Merged-In: I23e7ec140066979726d769cabc5f7057bb2167e6
    (Cherry-picked from ag/14227609)

lucaslin   authored and   Lucas Lin   commited 2021-05-05 03:19:51 +00:00
b1ff1b2139
Add missed break
Bug: none
Test: atest FrameworksNetTests
Change-Id: I8e8d0223de50c75732b06b053b3e60ccf4ef1684

paulhu   commited 2021-05-05 11:04:59 +08:00
cbe2b2686a
Merge "Add getters to NetworkStateSnapshot"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-29 09:20:34 +00:00
0c85894c8b
Merge "Rename getAllNetworkStateSnapshot which should be pluralized"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-29 04:40:51 +00:00
bd9d954805
Merge "Changing per-app default request to TRACK_DEFAULT"
James Mattis   authored and   Gerrit Code Review   commited 2021-04-26 14:39:44 +00:00
c1c37218da
Merge "Address API review feedback"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-04-26 00:22:27 +00:00
79a90c3b8e
Changing per-app default request to TRACK_DEFAULT
Changing the per-app default request flows to fallback to a request of
type TRACK_DEFAULT as opposed to type REQUEST. The main benefit of this
change is that these requests will no longer be sent to the factories
which is desired.

Bug: 180452284
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I312e55a54f70aa82953a32ab9369d5afc02b75e5
Merged-In: I312e55a54f70aa82953a32ab9369d5afc02b75e5

James Mattis   commited 2021-04-23 07:47:11 -07:00
a117e28565
Merge "Use connectivity resources in service-connectivity"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-04-23 05:42:13 +00:00
eb239b6bd4
Address API review feedback
Address API review feedback to:
 - Rename NetworkAgent#setTeardownDelayMs to
   NetworkAgent#setTeardownDelayMillis
 - Use getters instead of fields in VpnTransportInfo
 - Rename registerDefaultNetworkCallbackAsUid to
   registerDefaultNetworkCallbackForUid in ConnectiivityManager

Bug: 183972850
Bug: 185246410
Fix: 184735863
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
Merged-In: I5e8c4bed8bda40d507afa894c359b5e24ee5d868

Chiachang Wang   commited 2021-04-23 02:46:05 +00:00
6ec9b8daed
Use connectivity resources in service-connectivity
Migrate resource usage to the connectivity resource package.
For framework resources that have known overlays, keep a fallback until
the overlays can be migrated.

Bug: 182125649
Test: atest FrameworksNetTests
Merged-In: I778d94a5aac0c4e20e78b1ba3a002495c17a38a0
(clean cherry-pick)

Change-Id: I778d94a5aac0c4e20e78b1ba3a002495c17a38a0

Remi NGUYEN VAN   commited 2021-04-23 10:36:15 +09:00
97fad72128
Add getters to NetworkStateSnapshot
Address API council feedback, add getters to NetworkStateSnapshot
instead of exposing the bare fields directly.

(cherry picked from ag/14233655)
Bug: 183972826
Test: FrameworksNetTests
Merged-In: Id1707753b42ae88d2b95e4bd00a792609434e4f5
Change-Id: Id1707753b42ae88d2b95e4bd00a792609434e4f5

Aaron Huang   commited 2021-04-22 18:21:00 +08:00
b8f56644fb
Rename getAllNetworkStateSnapshot which should be pluralized
Address API review feedback, ConnectivityManager#getAllNetworkStateSnapshot
should be pluralized so rename the method to getAllNetworkStateSnapshots

(cherry picked from ag/14221105)
Bug: 183972554
Test: make, FrameworksNetTests
      FrameworksServicesTests
Merged-In: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
Change-Id: Ic18d17d05984fa2466c962c7843c0ef7183ce77c

Aaron Huang   commited 2021-04-22 17:45:22 +08:00
ee78b1fbbf
Merge "[VCN19] Rename get/setSubIds to get/setSubscriptionIds"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-22 04:43:26 +00:00
935946812a
Hide NetworkPolicyManager.blockedReasonsToString API.
BLOCKED_REASON_* constants have been moved to ConnectivityManager
and blockedReasonsToString() util method doesn't belong in
NetworkPolicyManager as an API. So, just removing it for now.

Bug: 185967486
Test: treehugger
Change-Id: Ie04044980fdfc7ec772444be13fc659880953bd1

Sudheer Shanka   commited 2021-04-21 07:23:54 +00:00
f0ffc77d80
Correctly count nri uid request counts
Correctly count nri uid request counts in the per-app functionality in
connectivity currently used by set profile and set oem network
preference APIs. Previously, upon creation, nris would be created prior
to removing them. This would cause the uid request counts to
artificially increase and incorrectly throw an error if the request
count limit was hit even though in actuality an apps request count was
valid.

E.g., if there was an existing request for per-app functionality and
its owning app made a change to the per-app requests, it would double
count the existing requests. If the current count was say, one under the
limit, an error would be thrown even though it was being replaced which
should have resulted in no net change to the request count limit if
working correctly.

This patch will allow for the requests to be removed prior to creation
so that request counts are tabulated correctly.

Bug: 185849563
Bug: 183785319
Test: atest FrameworksNetTests
Change-Id: I13da0c81256cc02bea6aff2fe1ef99d6f6b0e764

James Mattis   commited 2021-04-19 19:28:23 -07:00
20a4a8b2a5
[VCN19] Rename get/setSubIds to get/setSubscriptionIds
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215036
Merged-In: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
Change-Id: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
  (cherry-picked from ag/14198665)

junyulai   commited 2021-04-19 17:41:01 +08:00
2217becf8d
Merge "Update the permission check for dump"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-04-19 05:37:09 +00:00
6cab3df7dc
Update the permission check for dump
ServicePermissionsTest#testDumpProtected expects to see nothing
from dump() if the caller does not have the required permission.

After the refactor the ConnectivityService#dump(). It does not
leak real information for those callers without permission but
show the title of dumpsys, i.e. it shows "DUMP OF SERVICE HIGH
connectivity". This breaks the test since the test expects to
see nothing.

Move the permission check to the front of dump call stack since
there is no way to call other private dump related methods.

Bug: 185425662
Test: atest android.security.cts.ServicePermissionsTest
Test: adb shell dumpsys connectivity
Change-Id: I173c968a4f1c4d6f618ed87725a6ccda8d309988

Chiachang Wang   commited 2021-04-19 11:09:15 +08:00
a101f85b13
Merge "Don't expose raw IBinder APIs."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-04-16 07:22:13 +00:00
fe3676b6f2
Handle null pointer cases in ConnectivityService
If a method is called by adb command "service call"
with no parameters. It will cause to crash because
of a null object reference.

Add a null check for them to avoid system server crash.

Bug: 172885426
Test: FrameworksNetTest
      adb shell service call connectivity #
Change-Id: I8748fc5c6a7a6e82db3581e3026a3f75909a357e

Aaron Huang   commited 2021-04-16 00:15:25 +08:00
c65e7fa170
Don't expose raw IBinder APIs.
APIs should not expose raw IBinder objects.

Fix: 184735751
Test: builds, boots
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCases:android.net.cts.DnsResolverTest
Change-Id: Ia0c4170def31123f0b79318fec2cfe02e4fcd3bf

Lorenzo Colitti   commited 2021-04-15 18:47:21 +09:00
34a294fc76
Merge "Make getUid a method on UserHandle itself instead of static"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-04-13 08:15:47 +00:00
34d1abd51d
Merge "Add debug logging to requestRouteToHostAddress."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-04-12 14:24:58 +00:00
6bbdbe140d
Add debug logging to requestRouteToHostAddress.
Results in:

04-10 00:52:44.887  1511  2362 D ConnectivityService: requestRouteToHostAddress /192.0.2.3 [101 CELLULAR] ok=true

Bug: 182963397
Test: atest ConnectivityManagerLegacyTest
Change-Id: I4eeb17dd9096705d959516018aedb9173ff97023

Lorenzo Colitti   commited 2021-04-10 01:04:05 +09:00
a2e1fe8497
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

James Mattis   commited 2021-04-08 17:40:06 -07:00
cb1e036fe5
Make getUid a method on UserHandle itself instead of static
This commit addresses the API review feedback that getUid()
will be better to make it be a method on UserHandle itself
rather than a static method.

Update as it is and update the corresponding usages.

Fix: 184735865
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I33844309224d84764704255d251fadc8940202ca

Chiachang Wang   commited 2021-04-09 08:33:07 +08:00
612cc034a1
Replace IS_DEBUGGABLE with isDebuggable module API
Introduce a Build.isDebuggable() getter instead of the IS_DEBUGGABLE
static member.

Also make it module API as APK modules now have access to module APIs in
S, but also TestApi so it can be tested.

Test: m
Fixes: 182345786
Change-Id: I25d0848aee758792bbaba8ab73b5dd997a7250b3

Remi NGUYEN VAN   commited 2021-04-08 13:50:31 +09:00
10c379a8f2
Merge "Split networkDestroy() and destroyNetworkCache()"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-07 05:05:46 +00:00
7b57b98e26
Merge "ConnectivityManager: Address review comments from aosp/1595396"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-07 00:36:27 +00:00
caae5a26a6
ConnectivityManager: Address review comments from aosp/1595396
Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: I7f5d043732ae22edd14bf581b7dc676c9236b545

Roshan Pius   commited 2021-04-06 16:42:51 +00:00
e12202665f
Merge "Cleanup setGlobalProxy"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-04-06 06:19:01 +00:00
c32e1c90d6
Merge "Adding per-app support for app add/remove"
James Mattis   authored and   Gerrit Code Review   commited 2021-04-06 04:35:37 +00:00
73df776af2
Merge "Downgrade the log level of exception log"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-06 04:01:59 +00:00
a6f483233c
Downgrade the log level of exception log
This exception log is usually printed when the device connects to
a wifi. The cause is that when the device connects to a wifi,
wifi will send CONNECTING state first, then CONNECTED state.
And in CONNECTING state, wifi will send the LinkProperties to
ConnectivityService and ConnectivityService will try to update
that LinkProperties(including interface) to netd. But the netid
hasn't set to netd yet before wifi CONNECTED, so this exception
log will be printed.
There is no really issue in this case, so downgrade the log level
might be a better thing for all Android developer.

Bug: 181269159
Test: m
Change-Id: I61c09352225a610fcd6d3dd33b782ee114c35fc5

lucaslin   authored and   Lucas Lin   commited 2021-04-06 02:02:50 +00:00
ecdaf2393c
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

James Mattis   commited 2021-04-05 09:55:44 -07:00
02220e23c0
Merge "Fix broken testCaptivePortalApp"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-04-05 13:05:41 +00:00
a7d7793a88
Merge "Fix a bug where the wrong profile is queried"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-04-05 05:48:17 +00:00
e32a1efd36