Commit Graph

12406 Commits

Author SHA1 Message Date
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
62b1df44a2 Remove connectivity dependency on Preconditions
Preconditions.checkNotNull is deprecated to be replaced by
Objects.requireNonNull, and other methods can easily be replaced by
inline checks.

Preconditions is an internal API class that should not be used by
unbundled jars.

Bug: 177046265
Test: m
Change-Id: If14a75439ff332c927dc4114ae0eecb89f53c6c7
2021-03-11 20:49:13 +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
Aaron Huang
be9a6d2b6c Revert^2 "Refactor setCurrentProxyScriptUrl to a void method"
setCurrentProxyScriptUrl is used by ProxyTracker which is
included in connectivity service mainline module. To make
this method @SystemApi in follow-up patch, change this
from a boolean method to a void method. Moving the send or
not send broadcast logic to caller because it can know
whether it needs to send a broadcast or not.

The original change was reverted because it broke DeviceOwnerTest
and HostsideVpnTests. The new patch fixes no broadcast sent bug.
The logic was reversed when a PAC file URL is empty so the
broadcast did not send when proxy change.

Bug: 179225084
Bug: 177035719
Test: FrameworksNetTests
      CtsHostsideNetworkTests:HostsideVpnTests#testSetProxy
      CtsHostsideNetworkTests:HostsideVpnTests#testBindToNetworkWithProxy
      CtsHostsideNetworkTests:HostsideVpnTests#testNoProxy
      CtsDevicePolicyManagerTestCases:DeviceOwnerTest#testProxyPacProxyTest
      CtsDevicePolicyManagerTestCases:DeviceOwnerTest#testProxyStaticProxyTest

Change-Id: I029c33913264bfee336a559c4bd048ddd027322b
2021-03-10 23:19:12 +08: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
Aaron Huang
082f1d8a97 Create a service-connectivity-pre-jarjar library
This is needed for FrameworksNetTests because it inculdes
service-connectivity. Without this library, the service-connectivity
is already jarjar-ed which will cause the util classes couldn't be
found when running the tests. So let the tests inculde the pre-jarjar
version and service-connectivity applies the jarjar to this library.

Bug: 177046265
Test: FrameworksNetTests
Change-Id: I1acd95ff9bec99b918646e8ec3a57f3ef156e2ca
Merged-In: I1acd95ff9bec99b918646e8ec3a57f3ef156e2ca
2021-03-10 22:25:45 +08: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
Zoey Chen
1b4ea1877b [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
557708171c Merge "Move OemNetworkPreferences to Connectivity" 2021-03-08 08:41:04 +00:00
Paul Hu
055920ba58 Merge "Replace Inet[4|6]Address#ANY" 2021-03-08 07:20:21 +00:00
paulhu
b534331f2a 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
6954022e11 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
ade6c2a5e9 [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
5062ffb6f5 Merge "Applying OEM network pref to all users" 2021-03-05 19:09:24 +00:00
Remi NGUYEN VAN
9e516fd9b6 Merge "Move NetworkState to Connectivity" 2021-03-05 10:27:57 +00:00
Aaron Huang
3b615a6838 Merge "Use NetworkCallback in BatteryStatsService to get connectivity change" 2021-03-05 07:03:51 +00:00
Treehugger Robot
b55e8e82a3 Merge "[FUI22] Support getAllNetworkStateSnapshot" 2021-03-05 05:16:43 +00:00
Remi NGUYEN VAN
5ccfaf9d29 Merge "Replace user with debuggable check in ConnectivityService" 2021-03-05 05:09:46 +00:00
Chalard Jean
b43c5a29e6 Merge "Generalize some PANS methods" 2021-03-05 04:48:39 +00:00
Chiachang Wang
9c0877fda9 Merge "Have the DataConnectionStat started from BSS" 2021-03-05 02:59:33 +00:00
Janis Danisevskis
d1320fac29 Merge "Keystore 2.0: Make VPN Keystore 2.0 ready." 2021-03-05 02:57:34 +00:00
Treehugger Robot
bad87904b0 Merge "Fix CaptivePortalTest before R" 2021-03-05 02:28:55 +00:00
Remi NGUYEN VAN
56a15b30f3 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
ae9aeb0c3b 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