Commit Graph

561 Commits

Author SHA1 Message Date
Lucas Lin
b851d80de2 Merge "Simplify the return condition in stop()" into sc-dev 2021-07-01 09:09:39 +00:00
Remi NGUYEN VAN
3a8198c3ba Make notification icons and autocancel overlayable
Allow overlays to change the connectivity notification icons, and
whether the notifications are auto-cancelled.

This does not change default behavior, but is necessary to allow vendors
to adapt the notifications to their standards.

Bug: 173171709
Bug: 172048052
Test: atest NetworkNotificationManagerTest
      Added test overlay, verified icon replaced
Change-Id: Ibbb765a5e828b8b870cbfb81e89df2dbd2828be7
2021-07-01 16:04:09 +09:00
Lucas Lin
5ca769ef4a Simplify the return condition in stop()
Previously, the return condition in stop() will check if the state
is STOPPING and the reason is ERROR_INVALID_NETWORK. The condition
is too restricted so that if another event is happened after binder
died, the exception will be thrown and crash the system.
Since calling stop() twice doesn't make sense, so relax the condition
of return when the state is STOPPING.

Bug: 182586681
Test: atest FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1729690
Merged-In: I2454c1c080d8954dd3785d4ac6e96fc4131fdb47
Change-Id: I2454c1c080d8954dd3785d4ac6e96fc4131fdb47
2021-07-01 06:57:53 +00:00
paulhu
de2a23958d Use Netd new added/removed uid range methods
Replace network[Add|Remove]UidRanges to
network[Add|Remove]UidRangesParcel. The new methods are passing
NativeUidRangeConfig which contains priority value for each uid
range rules.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
Ignore-AOSP-First: Need cherry-pick
Change-Id: I08bbdbcb8450b08e6208fa730137348550f9e3d2
2021-07-01 03:10:45 +00:00
Lucas Lin
b278aac2a3 Merge "Simplify the return condition in stop()" am: 584ab08627 am: c955dcc84d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729690

Change-Id: I2dcd10df1d339a1a24e31632b399f960f749d44a
2021-07-01 02:13:04 +00:00
Lucas Lin
584ab08627 Merge "Simplify the return condition in stop()" 2021-07-01 01:46:59 +00:00
Treehugger Robot
282f743a8c Fix network callback with the same PendingIntent does not release
Currently, ConnectivityService uses EVENT_REGISTER_NETWORK_LISTENER
to dispatch registering network callback with pending intent, this
is wrong since the code flow will not check if the pending intent
is duplicated. Thus, the registration will be duplicated if the
caller uses the same pending intent and register multiple times.

This change fixes the logic by using
EVENT_REGISTER_NETWORK_LISTENER_WITH_INTENT instead of
EVENT_REGISTER_NETWORK_LISTENER when dispatching register network
callback with pending intent.

Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkRequest_identicalPendingIntents
Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkCallback_identicalPendingIntents
Test: atest ConnectivityServiceTest#testNetworkCallbackMaximum
Test: 1. Use test app to file callback with same PendingIntent
       2. Check dumpsys output
Bug: 189868426
Original-Change: https://android-review.googlesource.com/1727470
Merged-In: I38bdea3a026a78a6dc34b5200d43a75b3cd1ac0c
Change-Id: I38bdea3a026a78a6dc34b5200d43a75b3cd1ac0c
2021-07-01 01:44:56 +00:00
Treehugger Robot
8711b078ff Merge "Fix network callback with the same PendingIntent does not release" am: 6d908a513a am: e6517c060f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1727470

Change-Id: I2a27b0f3d3204fcfc3cb2d787fa5c998d45e54de
2021-06-30 22:12:04 +00:00
lucaslin
40d931c474 Simplify the return condition in stop()
Previously, the return condition in stop() will check if the state
is STOPPING and the reason is ERROR_INVALID_NETWORK. The condition
is too restricted so that if another event is happened after binder
died, the exception will be thrown and crash the system.
Since calling stop() twice doesn't make sense, so relax the condition
of return when the state is STOPPING.

Bug: 182586681
Test: atest FrameworksNetTests
Change-Id: I2454c1c080d8954dd3785d4ac6e96fc4131fdb47
2021-07-01 02:29:53 +08:00
Ansik
605e77055c Change to REQUEST from LISTEN for mobile data preferred uids feature
- If Mobile data always on is OFF, mobile data preferred uids
  feature does not work.
- We need to request mobile data when MDO list is not empty.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases

Signed-off-by: Ansik <ansik.shin@samsung.com>
Change-Id: Ie9d6b3e39ef16813c4be3979900d226c8f3d656d
2021-06-30 14:22:34 +00:00
WeiZhang
1cc3f17413 Fix network callback with the same PendingIntent does not release
Currently, ConnectivityService uses EVENT_REGISTER_NETWORK_LISTENER
to dispatch registering network callback with pending intent, this
is wrong since the code flow will not check if the pending intent
is duplicated. Thus, the registration will be duplicated if the
caller uses the same pending intent and register multiple times.

This change fixes the logic by using
EVENT_REGISTER_NETWORK_LISTENER_WITH_INTENT instead of
EVENT_REGISTER_NETWORK_LISTENER when dispatching register network
callback with pending intent.

Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkRequest_identicalPendingIntents
Test: atest android.net.cts.ConnectivityManagerTest#testRegisterNetworkCallback_identicalPendingIntents
Test: atest ConnectivityServiceTest#testNetworkCallbackMaximum
Test: 1. Use test app to file callback with same PendingIntent
       2. Check dumpsys output
Bug: 189868426
Change-Id: I38bdea3a026a78a6dc34b5200d43a75b3cd1ac0c
2021-06-30 12:05:43 +00:00
Paul Hu
eefacbcb5c Merge "Use appId instead of uid" into sc-dev 2021-06-30 09:38:26 +00:00
paulhu
4ac225baed Listen EXTERNAL_APPLICATIONS_AVAILABLE intent
- Some applications are installed on external storage and they
  are unavailable until exernal storage installed them
  completely. And their permission need update after becoming
  available. Thus, listen EXTERNAL_APPLICATIONS_AVAILABLE intent
  and update those package whose is listed in chaged package
  list.
- Remove user argument on buildPackageInfo() because the uid on
  ApplicationInfo is based uid.

Bug: 145234989
Test: atest FrameworksNetTests
Ignore-AOSP-First: Need cherry-pick
Change-Id: Ia11ca4a7ba6fc1b87c27c0c40e36c91d9cdb322a
2021-06-30 17:07:47 +08:00
Remi NGUYEN VAN
aec0e35349 Merge "Re-skip connectivity unit tests before S" am: a9230c1bf7 am: 1f3d8dc5e8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1749684

Change-Id: I5ce3c5b7dc333c802890831daf8289985c61301d
2021-06-30 08:18:57 +00:00
Remi NGUYEN VAN
a9230c1bf7 Merge "Re-skip connectivity unit tests before S" 2021-06-30 07:43:08 +00:00
Remi NGUYEN VAN
ea395bf6a0 Merge "Add option to make sign-in notification ongoing" 2021-06-30 05:12:09 +00:00
Remi NGUYEN VAN
154cf1da20 Re-skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

This applies a previous change, this time using DevSdkIgnoreRunner,
as SdkSuppress does not work as expected in branches that have a
codename 2 versions above the SDK version, as is the case in AOSP.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
      atest FrameworksNetTests on S
Change-Id: I5808d34459a4c19238baf8873afa7cf942828460
2021-06-30 12:00:28 +09:00
Remi NGUYEN VAN
57c0380135 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
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ic187d2a2b7e49ad152ea2aa35bb784864b97473c
2021-06-30 11:59:11 +09:00
Treehugger Robot
6da2b28e57 Merge "Revert "Skip connectivity unit tests before S"" am: b0c9e64d33 am: af5ae307f2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1749498

Change-Id: Ibacbb3f4ca829931b723893a1dd84a2d21de914e
2021-06-29 08:57:56 +00:00
Treehugger Robot
b0c9e64d33 Merge "Revert "Skip connectivity unit tests before S"" 2021-06-29 08:14:26 +00:00
Victor Chang
e4132c8ca0 Merge "Partial cherry-pick to remove IoUtils#deleteContents usage in FrameworksNetTests" into sc-dev 2021-06-29 08:12:04 +00:00
Paul Hu
dca7230c1d Use appId instead of uid
Multiple user's ares of mApps are not initialized in startMonitoring(),
so mApps.get(uid) of multi-user's app returns null in onPackageAdded().
As the result, permission of system uid is updated to "Network" and
any system application cannot use dedicated apn like IMS.
Using appId avoids this problem.

Bug: 168932048
Test: atest FrameworksNetTests

Signed-off-by: Sangcheol Lee <goodsc.lee@samsung.com>
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733212
Merged-In: Ib8ea2185d8056bddb2ca5a8006f83afb3cffc9f4

Change-Id: Ib8ea2185d8056bddb2ca5a8006f83afb3cffc9f4
2021-06-29 16:07:54 +08:00
Remi NGUYEN VAN
284b3c028c Revert "Skip connectivity unit tests before S"
This reverts commit 05dd1ba540.

Reason for revert: Skips more tests than it should in AOSP
Bug: 192302892

Change-Id: I7c5638d8c1cc626354d240a06af758e1cdd92e94
2021-06-29 01:08:00 +00:00
Remi NGUYEN VAN
819045fc60 Partial cherry-pick to remove IoUtils#deleteContents usage in FrameworksNetTests
It's a partial cherry-pick of https://r.android.com/1731232

Bug: 154796679
eest: atest ConnectivityCoverageTests
Merged-In: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
Change-Id: I23565c4144e665130585a86ce66cee6c2da07b60
2021-06-28 16:53:15 +01:00
Paul Hu
e6e75faf1d Merge "Use appId instead of uid" am: 683c386403 am: 9658c8ea69
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733212

Change-Id: Ic23e289c26e4b61864d1343eb0e6494f8cd43587
2021-06-28 04:07:10 +00:00
Paul Hu
683c386403 Merge "Use appId instead of uid" 2021-06-28 03:35:45 +00:00
Remi NGUYEN VAN
1e832f336b Merge "Skip connectivity unit tests before S" am: ef34fd2e21 am: 7ab2d7440c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736507

Change-Id: I8f1d639243617f21ab220685108adab2a3e8d3a3
2021-06-25 06:07:10 +00:00
Remi NGUYEN VAN
05dd1ba540 Skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
Change-Id: I10da45ae023e7f1e8cd11ec857b84346892a3fa8
2021-06-25 10:10:12 +09:00
Chalard Jean
6b2f09272c Make yield-to-bad-wifi behavior backward compatible with R
Yielding cell wins to exiting wifi (whether good or bad).
It loses to bad wifi that's not exiting.

In R, yielding to bad wifi only affects wifis that are
unvalidated, but a wifi that is exiting should still be
dropped in favor of a cell that yields to bad wifi.

I had misunderstood the policy and implemented it wrong.
Now it's implemented right, and has careful tests.

Test: new tests for this
Bug: 186458024
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ib8637100d491e72a2edb837584ce55b7dda58524
Change-Id: Ib8637100d491e72a2edb837584ce55b7dda58524
  (cherry-picked from ag/14486203)
2021-06-24 03:33:05 +00:00
Junyu Lai
92c29c56d7 Add more unit tests for ConnectivityManager S APIs
Test: atest android.net.ConnectivityManagerTest
Bug: 188657173
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I33612650eb89486a14fcfc440ba0c357f4bb513c
Change-Id: I33612650eb89486a14fcfc440ba0c357f4bb513c
  (cherry-picked from ag/14640282)
2021-06-24 03:20:39 +00:00
TreeHugger Robot
e7ac3ffec5 Merge changes I77dc5556,If772078c,Idb19b0f7 into sc-dev
* changes:
  Add test for CM#setAvoidUnvalidated
  Provide a way to override the avoid bad wifi configuration
  Remove ConnectivityServiceTest signature perms use
2021-06-23 16:16:03 +00:00
Luke Huang
18e0d49a44 Fix the comments from aosp/1719018
1. Test {start,stop}-service
2. Add waitForIdle

Bug: 181810560
Test: atest NsdServiceTest
Original-Change: https://android-review.googlesource.com/1729691
Merged-In: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
Change-Id: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
2021-06-23 09:55:11 +00:00
Remi NGUYEN VAN
b5f0819d35 Move ConnectivityDiagnosticsManagerTest to common
The tests are also useful in CTS to ensure that the
ConnectivityDiagnosticsManager class API is implemented properly
(including behavior of the DataStallReport class for example).

Bug: 187935317
Test: atest ConnectivityDiagnosticsManagerTest
Original-Change: https://android-review.googlesource.com/1742075
Merged-In: I86f39238054f43403f9a1e383dd2a935de84f06f
Change-Id: I86f39238054f43403f9a1e383dd2a935de84f06f
2021-06-23 09:16:53 +00:00
Chiachang Wang
fad30e3d84 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1733788
Merged-In: If772078c61a9b12926f104d5dfc9c9071e844732
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-23 08:42:47 +00:00
Remi NGUYEN VAN
ff55aeb916 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Merged-In: If309d653ac2e9bbcf1b94bcee6336367289df359
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615

(cherry picked from commit 595dda3604)

Change-Id: Idb19b0f7cb87bb4d9de7a0b1a0e4128c2d6b9c6d
2021-06-23 08:39:38 +00:00
Luke Huang
226281b698 Merge "Fix the comments from aosp/1719018" am: 0c20c4901f am: 9adee2f105
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729691

Change-Id: I65dd02aacd50acb92d15c76457f8415b0cc8b73e
2021-06-23 06:29:30 +00:00
Luke Huang
0c20c4901f Merge "Fix the comments from aosp/1719018" 2021-06-23 03:36:02 +00:00
Remi NGUYEN VAN
5b20059b56 Merge "Move ConnectivityDiagnosticsManagerTest to common" am: ef21082033 am: cb88733c59
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1742075

Change-Id: I5a0959b0dacbed1662a7852ad8d191cfa57c57e4
2021-06-23 03:11:12 +00:00
Remi NGUYEN VAN
ef21082033 Merge "Move ConnectivityDiagnosticsManagerTest to common" 2021-06-23 02:31:03 +00:00
Chiachang Wang
403836f671 Merge "Provide a way to override the avoid bad wifi configuration" am: 38e8c2c94b am: 4ef85d615b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733788

Change-Id: Ibe05bc988f0020eec8485023c3529bcc1696bd80
2021-06-23 02:08:44 +00:00
Chiachang Wang
38e8c2c94b Merge "Provide a way to override the avoid bad wifi configuration" 2021-06-23 00:48:17 +00:00
Chiachang Wang
6eac9fb787 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-22 14:54:02 +08:00
Remi NGUYEN VAN
3d25f6e8a7 Merge "Add connectivity coverage tests" am: cc79d7c0f8 am: 68114fe408
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731232

Change-Id: I6cc7f3a3abe97fccc59e14e77e99a0843f3363bb
2021-06-21 13:56:37 +00:00
Remi NGUYEN VAN
cc79d7c0f8 Merge "Add connectivity coverage tests" 2021-06-21 10:55:33 +00:00
Remi NGUYEN VAN
7e23f18158 Move ConnectivityDiagnosticsManagerTest to common
The tests are also useful in CTS to ensure that the
ConnectivityDiagnosticsManager class API is implemented properly
(including behavior of the DataStallReport class for example).

Bug: 187935317
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: I86f39238054f43403f9a1e383dd2a935de84f06f
2021-06-21 19:33:28 +09:00
Luke Huang
05b013c83f Fix the comments from aosp/1719018
1. Test {start,stop}-service
2. Add waitForIdle

Bug: 181810560
Test: atest NsdServiceTest
Change-Id: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
2021-06-21 04:54:33 +00:00
Lucas Lin
1b64ae6b87 Merge "Send a proxy broadcast when apps moved from/to a VPN" into sc-dev 2021-06-18 02:47:24 +00:00
Lucas Lin
950a65f8cc Send a proxy broadcast when apps moved from/to a VPN
When the apps moved from/to a VPN, a proxy broadcast is needed to
inform the apps that the proxy might be changed since the default
network satisfied by the apps might also changed.
Since the framework does not track the defautlt network of every
apps, thus, this is done when:
  1. VPN connects/disconnects.
  2. List of uids that apply to the VPN has changed.
While 1 is already covered by the current design, the CL implements
2 in order to fulfill the case that different networks have
different proxies.

Bug: 178727215
Test: atest FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1717735
Merged-In: Ifa103dd66394026d752b407a1bee740c9fcdad2b
Change-Id: Ifa103dd66394026d752b407a1bee740c9fcdad2b
2021-06-17 11:10:46 +00:00
Sangcheol Lee
1e5d742596 Use appId instead of uid
Multiple user's ares of mApps are not initialized in startMonitoring(),
so mApps.get(uid) of multi-user's app returns null in onPackageAdded().
As the result, permission of system uid is updated to "Network" and
any system application cannot use dedicated apn like IMS.
Using appId avoids this problem.

Bug: 168932048
Test: atest FrameworksNetTests

Signed-off-by: Sangcheol Lee <goodsc.lee@samsung.com>
Change-Id: Ib8ea2185d8056bddb2ca5a8006f83afb3cffc9f4
2021-06-17 13:35:58 +09:00
Remi NGUYEN VAN
aec3a5e548 Merge "Make tests compatible with mockito-extended" am: ad7108ce34 am: c3d789bff1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1737400

Change-Id: Ie5b04c5ea05d330dcc97d098720b08d4797927de
2021-06-16 13:56:01 +00:00