Commit Graph

12346 Commits

Author SHA1 Message Date
junyulai
f3ca0ef14c [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
5a6212753b 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
7f11b46a43 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
Lorenzo Colitti
91fccfe42f Merge "Don't start clatd if disabled by vendor property." 2021-03-11 12:22:34 +00:00
Lorenzo Colitti
877ef7634f Merge "Unbreak extraInfo values returned to apps." 2021-03-11 08:06:03 +00:00
Lorenzo Colitti
ab2f3d3cb5 Merge "Set extraInfo on cellular TestNetworkAgents." 2021-03-11 03:31:49 +00:00
Aaron Huang
f3827cf444 Merge "Remove IBatteryStats from ConnectivityService module" 2021-03-11 02:04:41 +00:00
Chiachang Wang
f4956c7502 Merge "Remove hidden APIs usage regarding to dump" 2021-03-11 00:28:54 +00:00
Chiachang Wang
9ddf7d3c36 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
4c9e202a44 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
386f9a3662 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
5845859186 Merge "frameworks: add test group for auto tests" 2021-03-10 15:12:49 +00:00
Lorenzo Colitti
ad4e8837af 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
e0b54f9303 Merge "Replace PendingIntent#getIntent" 2021-03-10 02:13:11 +00:00
Chalard Jean
3b50ce7a6f Merge "Fix a bug where listen callbacks would not be called" 2021-03-10 00:32:58 +00:00
Jun
76df56c7e3 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
Aaron Huang
c3f79207ef 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
f619c9967d 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
77ed87e072 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
d67ab4df87 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
aaef65de42 Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity" 2021-03-09 07:41:13 +00:00
Aaron Huang
e044c46257 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
94c60a99c7 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
627c6a5258 Merge "Use ArraySet#add() instead of ArraySet#append()" 2021-03-09 04:52:42 +00:00
Zoey Chen
dbc2df30cb [Telephony] Use TelephonyCallback instead of PhoneStateListener part1
Since the redesign of PhoneStateListener, use TelephonyCallback to get the callback of EVENT_*

Bug: 167684594
Test: make
Change-Id: Ia3b777b12142b104b5798804f50b34748f9bf28c
Merged-In: Ia3b777b12142b104b5798804f50b34748f9bf28c
2021-03-08 20:25:00 +08:00
Remi NGUYEN VAN
c61a6fc426 Merge "Move OemNetworkPreferences to Connectivity" 2021-03-08 08:41:04 +00:00
Paul Hu
3483a8be68 Merge "Replace Inet[4|6]Address#ANY" 2021-03-08 07:20:21 +00:00
paulhu
ee4cd637e3 Replace Inet[4|6]Address#ANY
Connectivity is becoming a mainline module in S but mainline
modules are not allowed to use non-formal APIs. Thus, replace
non-formal API Inet[4|6]Address#ANY to
NetworkStackConstants#IPV[4|6]_ADDR_ANY.

Bug: 181756157
Test: FrameworksNetTests
Change-Id: Id4d2fc551c1384f549a586e87ab68356ba05b995
2021-03-08 07:18:31 +00:00
Remi NGUYEN VAN
9930f13c67 Move OemNetworkPreferences to Connectivity
The data class supports a ConnectivityManager API, so it should be
together with the ConnectivityManager API surface.

Bug: 181512874
Test: m
Change-Id: I5642486ea0febcb08cadcbd4cd3f0c6056deae0e
2021-03-08 09:26:41 +09:00
lifr
c33ea4de7d [CS10]Remove the hidden API usage of BitUtils
The connection service will become the main line module.
It is difficult to include BitUtils in the module. and so
Move the hidden API needed in BitUtils to NetworkCapabilitiesUtils.

Bug: 170598012
Test: atest ConnectivityServiceTest
      atest NetworkCapabilitiesTest
      atest DnsUtilsTest
Change-Id: Ibc81827e25a54fc3ff94f78d810fe4f5073e3a98
2021-03-06 16:21:16 +00:00
James Mattis
3f0925ee2e Merge "Applying OEM network pref to all users" 2021-03-05 19:09:24 +00:00
Remi NGUYEN VAN
4d2ad2a68a Merge "Move NetworkState to Connectivity" 2021-03-05 10:27:57 +00:00
Aaron Huang
74850ac20e Merge "Use NetworkCallback in BatteryStatsService to get connectivity change" 2021-03-05 07:03:51 +00:00
Treehugger Robot
bcbc04f329 Merge "[FUI22] Support getAllNetworkStateSnapshot" 2021-03-05 05:16:43 +00:00
Remi NGUYEN VAN
a923322f24 Merge "Replace user with debuggable check in ConnectivityService" 2021-03-05 05:09:46 +00:00
Chalard Jean
b639d79547 Merge "Generalize some PANS methods" 2021-03-05 04:48:39 +00:00
Chiachang Wang
86dce50c72 Merge "Have the DataConnectionStat started from BSS" 2021-03-05 02:59:33 +00:00
Janis Danisevskis
c410b053b9 Merge "Keystore 2.0: Make VPN Keystore 2.0 ready." 2021-03-05 02:57:34 +00:00
Treehugger Robot
73e63132a6 Merge "Fix CaptivePortalTest before R" 2021-03-05 02:28:55 +00:00
Remi NGUYEN VAN
072b33fc6c Move NetworkState to Connectivity
NetworkState is becoming an internal implementation class, with
NetworkStateSnapshot replacing it as a proper API. Considering this it
belongs inside Connectivity.

Bug: 174123988
Test: m
Change-Id: I201f1a07c50d9da31e33f5c207875da8863ef57c
2021-03-05 08:56:55 +09:00
James Mattis
3bf8b7a1b9 Applying OEM network pref to all users
Updating handleSetOemNetworkPreference so that the given policy is
applied to all users on the device. Additionally, remove uids for all
users/apps so that stale uids don't stay present after rematch. Finally,
small cleanup on how we deal with remote exceptions.

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

Change-Id: I214717ee0c78cfe8322e551c2c2e9dc01c0242b2
2021-03-04 11:32:10 -08:00
Chalard Jean
9a3a0eac07 Generalize some PANS methods
These methods will be reused for 5G slicing and should
have a more generic name/signature.

This is a no-op refactoring.

Test: FrameworksNetTests
Change-Id: I13cf9fc405fef7dc650d5ea7df44d025f6713b46
2021-03-04 22:15:27 +09:00
Remi NGUYEN VAN
2c6d33f451 Replace user with debuggable check in ConnectivityService
IS_USER is a hidden symbol, whereas IS_DEBUGGABLE is part
of the module API.
The check is generally equivalent, as non-user builds are eng or
userdebug, which are debuggable.

Bug: 170598012
Change-Id: I7d09939652844eb2e3a6f0200b1ba50691a147da
Test: atest FrameworksNetTests
2021-03-04 13:12:34 +00:00
Chalard Jean
f0717a9ffe Merge changes Ide2567b2,I0ee0ce92,Iac3f55af
* changes:
  Fix a bug where callbacks would see blips
  Fix a bug where a request would not be refcounted
  Fix a bug where UID ranges would not be removed
2021-03-04 13:12:20 +00:00
Chalard Jean
018dbe4182 Fix a bug where callbacks would see blips
When a new OemPreference object is set, the requests
tracking that default will be re-created to track the
new default. This is true regardless of whether that
particular default has changed.

Because the new copied request doesn't know about the
old satisfier, the rematch code will mistakenly think
this callback didn't have a network and will send a
spurious onAvailable to it.

This patch fixes this by simply copying the satisfier
together with the rest of the NRI. The matching code
will then understand the correct previous status.

As a drive-by fix, this also fixes the annotations on
the reassignment contents that can be null. They have
more complex interactions (not everything can be null
at the same time), but the old annotations were just
putting @NonNull on nullable stuff.
In the same line, while there used to be a case with
a satisfier but no request when the satisfier is the
no-service network, there may now be a case where the
old satisfier is known but the old request isn't.

Test: FrameworksNetTests
Test: TODO : need a unit test for this
Change-Id: Ide2567b226722ea9d35ebd8205943363e27647a2
2021-03-04 13:11:59 +00:00
Chalard Jean
52d7b73c0d Fix a bug where a request would not be refcounted
This ends up crashing the system when the request
is unregistered, because the ref counter finds the
count associated with the relevant UID is zero.

Test: FrameworksNetTests
Test: TODO : this needs a new unit test
Change-Id: I0ee0ce925a826d35d8fd58cefb8a870e98ce9add
2021-03-04 22:08:09 +09:00
Chalard Jean
07dc18662a Fix a bug where UID ranges would not be removed
When a new preferences object is sent that no longer contains
a particular app, a new set of requests will be generated. All
requests corresponding to that app will be unregistered, and
no new ones will be filed since the preferences no longer
contain that app.

The place where the UID ranges are removed however is in
makeDefaultForApps(), which takes a request. As there no
longer is a default request for this app, makeDefaultForApps()
will never be called with a request for it, and the UID ranges
will never be removed.

This change applies an emergency fix with some side effects
when setting a new preference. This is acceptable, but should
ideally be fixed ; see TODO in the code for details.

Test: FrameworksNetTests
Test: TODO : Need a unit test for this
Change-Id: Iac3f55af5d00d174460e1d4cdd31f581835dbaa6
2021-03-04 22:08:09 +09:00
Aaron Huang
fdffbaecb4 Use NetworkCallback in BatteryStatsService to get connectivity change
Currently, battery stats service uses noteConnectivityChanged in
connectivity service(CS) to pass connection state and the type of
connection for BatteryStats. However, CS is going to be a mainline
module which can only access formal API. noteConnectivityChanged
is a hidden API and it pass LegacyNetworkType which has been
deprecated years ago, so it should avoid to expose this API with
a deprecated argument. Thus, register a NetworkCallback in
BattyeryStatsService to listen the network capabilities changed to
remove the noteConnectivityChanged from connectivity service.
Besides, let noteConnectivityChanged take display transport instead
of legacy network type.

Bug: 171686421
Test: atest FrameworksNetTests
      atest FrameworksCoreTests:BatteryStatsTests
(cherry-picked from ag/13749983)
Change-Id: I3dac94ec06f673aa719e124f1ef3d8169f68f9fb
Merged-In: I3dac94ec06f673aa719e124f1ef3d8169f68f9fb
2021-03-04 13:06:06 +00:00
Treehugger Robot
63383e755e Merge changes Ie8d98359,I4d5cadfd
* changes:
  Fix a bug in RequestReassignment#toString
  Cleanup some of the PANS code
2021-03-04 12:39:04 +00:00
Remi NGUYEN VAN
3fa91ba437 Fix CaptivePortalTest before R
The last change broke the test on Q and R. Fix it to check
Q and R behavior properly, so the test can be run in presubmit
on such devices too.

Bug: 181844595
Change-Id: I99847ea30d49d690d9011d4763a7345126807119
Test: atest CtsNetTestCasesLatestSdk
2021-03-04 10:45:02 +00:00