Commit Graph

12372 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
94e5fff53d Add ParseException constructors to API
ParseException constructors are used by both platform and mainline
module code, so they can't be package-private.
Removing dependencies on either side is not possible as the class
itself is part of the public API, and supports APIs on both sides.

Having the constructors part of the API makes the class usable by both
sides.

Fixes: 182705505
Test: CtsNetTestCases for APIs using the exception
Change-Id: Ia396ab2fa3afaed3cf474c8e60f72fc7f3f4fded
2021-03-15 10:26:02 +09:00
Remi NGUYEN VAN
7d3fe9570b Merge "Remove usage of hidden InetSocketAddress constructor" 2021-03-12 09:02:15 +00:00
Treehugger Robot
cd6324c135 Merge "Remove hidden @NetworkType in NetworkInfo" 2021-03-12 08:59:35 +00:00
Treehugger Robot
122c15f5d5 Merge "Remove hidden INVALID_RESOURCE_ID in unused param" 2021-03-12 08:57:55 +00:00
Treehugger Robot
f050e5d627 Merge "Use ParcelDescriptor.fromSocket instead of getFileDescriptor" 2021-03-12 08:57:47 +00:00
Junyu Lai
d12480ed60 Merge changes from topics "vcn04", "vcn12"
* changes:
  [VCN12] Expose setSubIds/getSubIds APIs
  [VCN04] Add Subscription Id set into NetworkCapabilities
2021-03-12 07:12:59 +00:00
Roshan Pius
2bead69f56 Merge "ConnectivityManager: Provide API's to include location sensitive info" 2021-03-12 05:56:29 +00:00
Paul Hu
738f6020bb Merge "Stop using PackageManagerInternal in PermissionMonitor" 2021-03-12 05:23:05 +00:00
Treehugger Robot
64d0760e87 Merge "Remove Slog usage in NetworkState" 2021-03-12 05:12:26 +00:00
Remi NGUYEN VAN
bd372ae3fa Merge "Move ParseException to Connectivity" 2021-03-12 04:27:55 +00:00
Lucas Lin
54307cc3fc Merge changes Ib80f814f,Ic605e489
* changes:
  Use new API - getIpSecNetIdRange() in IpSecService
  Add a new API to get the network ID range of IPSec tunnel interface
2021-03-12 03:30:32 +00:00
Frank Li
be1c85ffee Merge "[CS17]Remove useless code(AsyncChannel) from ConnectivityService" 2021-03-12 02:45:30 +00:00
Roshan Pius
951c003ef4 ConnectivityManager: Provide API's to include location sensitive info
Existing NetworkCallback users will get NetworkCapabilities with
location sensitive data removed (except for ownerUid which will be
added for existing apps for backwards compatibility). Apps
have to opt-in to receive location sensitive data.

Note: This was chosen because WifiInfo is the only TransportInfo tha
has location sensitive info & that was added only in Android 12. If we
choose to default to true, all existings apps retrieving
NetworkCapabilities for wifi networks will be blamed for location access
unnecessarily.

Changes:
i) Add a flag in NetworkCallback creation to retrieve
NetworkCapabilities with location sensitive info in their callback.
(More flags are being planned for NetworkCallback for throttling
callback frequency, etc)
ii) For NetworkCapabilities.getOwnerUid(), we will continue to send the
data for apps targeting older SDK (since this is an existing field and
the new flag defaults location sensitive data to off).

Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: If70b5ea6f5c8885f0c353c8df08a826d55fe7f7a
2021-03-11 18:27:18 -08:00
Remi NGUYEN VAN
b833c6bcbd Merge changes from topic "ethernet_specifier"
* changes:
  Fix common tests on Q and R
  Add Ethernet, TestNetworkSpecifier API
2021-03-11 23:51:49 +00:00
lucaslin
30e70a82c0 Add a new API to get the network ID range of IPSec tunnel interface
- Add a new API to get the network ID range of IPSec tunnel
interface.
- Use the new API in IpSecServiceTest to make sure the result is
the same. Follow-up commit will change the logic in
IpSecService#reserveNetId(), the modified test can ensure the
correctness of the new change.

Bug: 172183305
Test: atest FrameworksNetTests:IpSecServiceTest
Change-Id: Ic605e48941fc9d6482cdcd01a8adcdc9b6d586a6
2021-03-12 00:46:33 +08:00
junyulai
e53fbc08c9 [VCN12] Expose setSubIds/getSubIds APIs
Test: atest NetworkCapabilitiesTest
Bug: 175662146
Change-Id: Ia4b98bc6c5fcefee44233f3b7fbb6517a0e8870e
2021-03-11 23:03:19 +08:00
junyulai
e587a4c39e [VCN04] Add Subscription Id set into NetworkCapabilities
This is a generic way to request networks that has different
subId but belongs to the same carrier. For example, cellular
networks with different SIM card, or carrier Wifi that
provided by the operator.

Test: atest NetworkCapabilitiesTest#testSubIds
Test: m doc-comment-check-docs -j
Test: atest CtsNetTestCases
Bug: 175662146

Change-Id: Ifca766f5acc73c285948d6251ec31506d9bb0bcb
2021-03-11 23:03:05 +08:00
Remi NGUYEN VAN
90ca2615a4 Fix common tests on Q and R
The common tests cannot reference EthernetNetworkSpecifier,
as it did not exist in Q and R yet.

Bug: 179329291
Merged-In: Iec8ef874a3ca6dcc65944bbbaa3575a5ae0f4989
Change-Id: Iec8ef874a3ca6dcc65944bbbaa3575a5ae0f4989
Test: atest CtsNetTestCasesLatestSdk
2021-03-11 23:02:02 +08:00
Remi NGUYEN VAN
57c9cc2614 Add Ethernet, TestNetworkSpecifier API
Rename StringNetworkSpecifier to EthernetNetworkSpecifier (its only
production user), and make it module-lib API.
The original StringNetworkSpecifier file is actually kept to satisfy
some invalid dependencies; it will be removed separately.

This allows specifying an Ethernet interface with a non-deprecated API:
until this change the only way to do so would be to use
NetworkRequest#setSpecifier(String), which is deprecated.

Similarly, add the TestNetworkSpecifier API for TestNetworkManager, to
replace previous usage of StringNetworkSpecifier. TestNetworkManager is
module API, so TestNetworkSpecifier should be module API too. This
allows tests to request the test interface specifically, without using
the deprecated NetworkRequest#setSpecifier(String).

Bug: 179329291
Test: m
Merged-In: Iee569f5c8bbdc4bc979610e1191308281f3d4620

Change-Id: Iee569f5c8bbdc4bc979610e1191308281f3d4620
2021-03-11 23:02:02 +08:00
junyulai
962bdb8677 [VCN11] Make requestBackgroundNetwork requires handler
Test: atest FrameworksNetTests android.net.cts.ConnectivityManagerTest
Bug: 175662146
Change-Id: Iac9487e8de8bfdd87fc7a0153b228ae2a7ba4e19
2021-03-11 21:05:27 +08:00
junyulai
7514e3187b [VCN10] Add new API to listen for highest score network
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback
Bug: 175662146
Change-Id: Ifa411c7b53da789c74fff7e1a95f9c9ebf5bd05c
2021-03-11 21:04:06 +08:00
Lorenzo Colitti
82ff67f3cf Merge "Don't start clatd if disabled by vendor property." 2021-03-11 12:22:34 +00:00
Remi NGUYEN VAN
ba5ac3ec4a Remove Slog usage in NetworkState
Slog should not be used in unbundled jars as it is a hidden API; use the
standard Log utility instead.

Bug: 172050541
Test: m
Change-Id: I54b2b99b2aedbb5194e9ec24068d2f2ce46d67fc
2021-03-11 21:01:30 +09:00
Remi NGUYEN VAN
d4a9ed4b1a Remove hidden @NetworkType in NetworkInfo
The NetworkType annotation is a hidden telephony symbol, and should be
kept hidden as annotations are disallowed by API guidelines.

Remove its usage in NetworkInfo as users of annotated constants that
build against API stubs are expected not to use the annotation.

Bug: 182451544
Test: m
Change-Id: I6658c1faa147c527c989b87d67f1af166c488dde
2021-03-11 20:29:10 +09:00
Remi NGUYEN VAN
ce355501df Remove hidden INVALID_RESOURCE_ID in unused param
INVALID_RESOURCE_ID is a hidden API so its usage should be avoided.
The current usage is for an unused parameter, so just use a literal instead.

Bug: 182451544
Change-Id: I066d9c34f735434adee4ee72e8a7fe1ceb900c3c
Test: m
2021-03-11 10:57:01 +00:00
lifr
af3a3492fa [CS17]Remove useless code(AsyncChannel) from ConnectivityService
The caller of AsyncChannel has been deleted in the last commit
(Remove legacy network factories), so the useless code of
AsyncChannel should also be deleted.

Bug: 170917042
Test: atest FrameworksNetTests
Change-Id: I6ce164fe5e3d592f1ed63753e8d3c0086bf61fa2
2021-03-11 09:57:41 +00:00
Remi NGUYEN VAN
ff0a5a7f72 Move ParseException to Connectivity
ParseException is a public API class used to support Connectivity APIs,
so it should be in the same API surface as connectivity.

Bug: 181512874
Test: m
Change-Id: Ie1213de0d0facc8f409f7b4c2553abb382e4afbf
2021-03-11 17:19:18 +09:00
Lorenzo Colitti
73aa86d8c9 Merge "Unbreak extraInfo values returned to apps." 2021-03-11 08:06:03 +00:00
Remi NGUYEN VAN
d059f21318 Remove usage of hidden InetSocketAddress constructor
The constructor is a hidden API, and used in a code path that can
never happen.
Replace it with a thrown exception (which should never be thrown either).

Bug: 170598012
Change-Id: Ie2c671c1a75accb8e94b08de9901d14b72caaf7e
Test: m
2021-03-11 07:43:43 +00:00
paulhu
2adf56309b Stop using PackageManagerInternal in PermissionMonitor
- Replace the PackageManagerInternal#getPackageList() with
receiving PACKAGE_{ADDED|REMOVED} intent.
- Also remove the onPackageChanged method because the traffaic
permissions(INTERNET, UPDATE_DEVICE_STATS) are not changed after
package changed(Disable or enable package).

Bug: 176788468
Test: atest FrameworksNetTests
Change-Id: I5505d1c77db66a7e65fc336ea0e99846e78c6b36
2021-03-11 07:16:11 +00:00
Lorenzo Colitti
97f7b04b45 Merge "Set extraInfo on cellular TestNetworkAgents." 2021-03-11 03:31:49 +00:00
Aaron Huang
a0d00e1964 Merge "Remove IBatteryStats from ConnectivityService module" 2021-03-11 02:04:41 +00:00
Chiachang Wang
8bf00e241f Merge "Remove hidden APIs usage regarding to dump" 2021-03-11 00:28:54 +00:00
Chiachang Wang
96e1a0bfcb Remove hidden APIs usage regarding to dump
Classes inside the incoming connectivity module will not be able
to access hidden APIs. The hidden DUMP_FLAG_PRIORITY_* flags
usage should be replaced. It was used to control the dump
priority. DEFAULT priority for services which is treated the
same as NORMAL priority. ConnectivityServiceInitializer took
both NORMAL and HIGH. It trigger different information dumped.
It's replaced with dumpsys that does not send "--dump-priority"
arguments to the service. Thus, design is replaced with
local parsing inside ConnectivitySerivce to provide equivalent
dump.

Bug: 172183305
Test: m ; flash and boot up
Test: adb bugreport ; adb dumpsys connectivity
Change-Id: Ib3c9d8692eb4382cd106734a1a716df6f48ffca4
2021-03-11 00:28:47 +00:00
Lorenzo Colitti
9b8b90be2b Don't start clatd if disabled by vendor property.
Fix: 182333299
Test: new unit tests
Change-Id: Ic15dc4fff6a13aa916e3d2dc6203829e96ddeda4
2021-03-11 00:59:14 +09:00
Lorenzo Colitti
e30db8d2a7 Unbreak extraInfo values returned to apps.
These were broken by aosp/1553463, which made filterNetworkInfo
unconditionally call setDetailedState with a reason of "" and an
extraInfo of null.

Fix both synchronous getter APIs (e.g., getNetworkInfo) and
CONNECTIVITY_ACTION broadcasts by calling a new
filterForLegacyLockdown method that behaves similarly to how the
now-deleted LockdownVpnTracker#augmentNetworkInfo used to behave.

While I'm at it, move back to private a method that was public
only because LockdownVpnTracker used it.

Fix: 181855958
Test: new unit test coverage
Change-Id: I2c7b88fcec9dd36b45cb51db8d19b3ee8bad44a6
2021-03-11 00:59:14 +09:00
James Mattis
ad2bfe8c27 Merge "frameworks: add test group for auto tests" 2021-03-10 15:12:49 +00:00
Lorenzo Colitti
8affa9ee66 Set extraInfo on cellular TestNetworkAgents.
This makes the test more realistic, since telephony always puts
the APN name in the extraInfo field. It also makes it easy to
test that various APIs properly return the extra info without
plumbing a new parameter through TestNetworkAgentWrapper,
NetworkAgentWrapper, and InstrumentedNetworkAgent.

Also make the extraInfo and the legacyType available to tests.
This will be used in future tests that assert the contents of
extraInfo.

Bug: 181855958
Test: test-only change
Change-Id: If4eddb6cd9e70bb33e10d72aceebaea843244246
2021-03-10 23:33:08 +09:00
Paul Hu
411d98802d Merge "Replace PendingIntent#getIntent" 2021-03-10 02:13:11 +00:00
Chalard Jean
4a00da2054 Merge "Fix a bug where listen callbacks would not be called" 2021-03-10 00:32:58 +00:00
Jun
a3a8d01d0e frameworks: add test group for auto tests
Adding a seperate test tag into postsubmit so as to identify which tests
we want to run for automotive builds.

Test: atest --test-mapping [src]:auto-postsubmit
bug: 179917339
Change-Id: I3860fb6bf4f4174fad26cce5f7d6b43fd6494c0f
2021-03-09 15:54:39 -08:00
Remi NGUYEN VAN
0942ad9f73 Use ParcelDescriptor.fromSocket instead of getFileDescriptor
Socket.getFileDescriptor$ is a hidden API. Instead, replace it with
ParcelDescriptor.fromSocket, which was created to handle such use-cases.

Bug: 170598012
Change-Id: I9e218e4ec29d2b7fe5d2faeb1c2e1cafc63dc923
Test: m
2021-03-09 23:54:03 +00:00
Aaron Huang
2aac0cd79d Remove IBatteryStats from ConnectivityService module
Currently ConnectivityService calls the methods in
BatteryStatsService through BatteryStatsManager so
IBatteryStats can be removed from ConnectivityService.

Bug: 171686421
Test: FrameworksNetTests
Change-Id: I559369c9900e8100cdae187bc9cec603ed85a131
2021-03-09 21:39:17 +08:00
Zoey Chen
b77aaa1e63 Merge changes from topic "PSL_TelephonyCallback"
* changes:
  [Telephony] Use TelephonyCallback instead of PhoneStateListener part1
  [PhoneStateListener] Redesign PhoneStateListener: Use TelephonyCallback
2021-03-09 10:36:03 +00:00
Aaron Huang
eac59ebbf8 Merge changes I1d1f0d2d,Ifbd4a978
* changes:
  Communicate with BatteryStatsService through BatteryStatsManager
  Add a new API in BatteryStatsManager for connectivity service
2021-03-09 10:33:56 +00:00
Chalard Jean
b5becbca0a Fix a bug where listen callbacks would not be called
NetworkAgentInfos cache the list of requests they satisfy,
and that list is used to send callbacks. Therefore, when
the TRACK_DEFAULTs are copied, this list needs to be
updated.

The best way to do this is to figure out what was the old
active request and find which requests corresponds to it
in the new list, and then upon registering adding the
active request to the relevant satisfier if present.

A few other ways can be considered like replacing the
request as it gets added, but this would temporarily
increase the number of callbacks allocated to the app
and risks crashing it for no good reason ; furthermore
the call to remove would have to be eschewed somehow
for those requests that are replaced. This is much
simpler.

Test: new test for this. This also passes the future
      tests for per-profile default network preference.
Change-Id: I001351e5c478c2c77cbf2844abca77b205291778
2021-03-09 19:05:55 +09:00
Chalard Jean
d3844d856d Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity" 2021-03-09 07:41:13 +00:00
Aaron Huang
330a4c0bfa Communicate with BatteryStatsService through BatteryStatsManager
Mainline connectivity service is only allowed to use formal
APIs. Use new system API in BatteryStatsManager instead of
calling BatteryStatsService directly.

Bug: 171686421
Test: FrameworksNetTests
Change-Id: I1d1f0d2d456003e842ad77519667c0532995610d
Merged-In: I1d1f0d2d456003e842ad77519667c0532995610d
2021-03-09 06:29:30 +00:00
paulhu
90b43ff5e1 Replace PendingIntent#getIntent
Connectivity is becoming a mainline module in S but mainline
modules are not allowed to use non-formal APIs. Thus, replace
non-formal API PendingIntent#getIntent to new formal API
PendingIntent#intentFilterEquals.

Bug: 174237997
Test: FrameworksNetTests
Change-Id: Ic5e27f812bd42dbc80b9d29d81303df4dd5e8199
2021-03-09 05:43:05 +00:00
Lucas Lin
cb2213216c Merge "Use ArraySet#add() instead of ArraySet#append()" 2021-03-09 04:52:42 +00:00