Commit Graph

2791 Commits

Author SHA1 Message Date
Junyu Lai
4bdfd01aee Merge "Fix network callback with the same PendingIntent does not release" into sc-dev am: 8ba13e99e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15164991

Change-Id: Ic875052f9a045c32a19457fa5d154b1502a6a1ab
2021-07-01 09:37:23 +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
Paul Hu
e15012586e Merge "Use appId instead of uid" into sc-dev am: eefacbcb5c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15123902

Change-Id: I5ffb87c6a9bfc30899f0c7c4607758f28aa00443
2021-06-30 09:51:46 +00:00
Paul Hu
eefacbcb5c Merge "Use appId instead of uid" into sc-dev 2021-06-30 09:38:26 +00:00
TreeHugger Robot
f156d482f6 Merge "Fix null PendingIntent in network listens" into sc-dev am: 4fd9dfef2d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15136918

Change-Id: Ie000ca0d22891120f5dda8a8088596ef84f02005
2021-06-29 13:49:15 +00:00
TreeHugger Robot
4fd9dfef2d Merge "Fix null PendingIntent in network listens" into sc-dev 2021-06-29 13:36:15 +00:00
Victor Chang
25b288225b Merge "Partial cherry-pick to remove IoUtils#deleteContents usage in FrameworksNetTests" into sc-dev am: e4132c8ca0
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15108481

Change-Id: If24c0e920f55f5046fd2a93bfd16004c28f389df
2021-06-29 08:42:12 +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
4cb6189802 Fix null PendingIntent in network listens
In S ConnectivityService was changed to use getActiveRequest() to fill
EXTRA_NETWORK_REQUEST, but there is no active request in the case of
listens.

When getActiveRequest() is missing, use the first mRequest instead. This
should match previous behavior.

Bug: 191713869
Test: atest android.net.cts.ConnectivityManagerTest
Original-Change: https://android-review.googlesource.com/1748153
Merged-In: Id7343a4cc020aba16b7979b16334721c56b2839c
Change-Id: Id7343a4cc020aba16b7979b16334721c56b2839c
2021-06-29 07:07:28 +00:00
Remi NGUYEN VAN
f0a8dff500 Merge "Fix flakes in tests running after testIsPrivateDnsBroken" into sc-dev am: 64168015f1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15135741

Change-Id: Ia82e72dce1742c122e711b4796db98feb6a53f24
2021-06-29 06:58:06 +00:00
Treehugger Robot
b91d44a64a Fix flakes in tests running after testIsPrivateDnsBroken
The test would not reconnect wifi after restoring the private DNS setting,
so validation would not be triggered, and it would remain identified as
having broken private DNS.

Reconnect wifi after the test to avoid affecting subsequent tests.

Original-Change: https://android-review.googlesource.com/1749560
Merged-In: Id9beba94e0fed85bd26c0509ad61369be794f3c3
Change-Id: Id9beba94e0fed85bd26c0509ad61369be794f3c3
Test: atest android.net.cts.ConnectivityManagerTest
Bug: 182296835
2021-06-29 04:04:07 +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
Victor Chang
e1aae8471e Merge "Remove usage of internal APIs from InetAddress and ServerSocket" into sc-dev am: 99c7bdb1a4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15015192

Change-Id: Ie62012e26e1d44b02ec58beea554e5429aca3088
2021-06-28 14:28:01 +00:00
Victor Chang
99c7bdb1a4 Merge "Remove usage of internal APIs from InetAddress and ServerSocket" into sc-dev 2021-06-28 14:17:12 +00:00
Victor Chang
6fae863801 Remove usage of internal APIs from InetAddress and ServerSocket
It affects the test only.

Bug: 154796679
Test: atest CtsNetTestCases
Merged-In: I77a419c459ee53b36d24f324ecab2b5dae5744de
Change-Id: I77a419c459ee53b36d24f324ecab2b5dae5744de
(cherry picked from commit ef88fadc2e)
2021-06-28 12:11:52 +01:00
Junyu Lai
5202b76a71 Check null NetworkSpecifier before redacting am: 4ad09c4a74
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15121422

Change-Id: I9092bfd9eedf04b68fc5f6d8091dcff733d943b7
2021-06-28 06:19:10 +00:00
Junyu Lai
4ad09c4a74 Check null NetworkSpecifier before redacting
Do null check before redacting, since NetworkSpecifier will not
always be attached. For example, NetworkSpecifier of wifi
network is only attached when a wifi network is created
in response to a network request with specifier attached.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testGetAllNetworkStateSnapshots \
      --rerun-until-failure 100
      (tested on cuttlefish mobile and wifi)
Bug: 191944987
Original-Change: https://android-review.googlesource.com/1747893
Merged-In: I5df3547995111fe6340facb94a577296d2228694
Change-Id: I5df3547995111fe6340facb94a577296d2228694
2021-06-28 01:22:42 +00:00
Lorenzo Colitti
b0a55740ab Add CTS for BatteryStatsManager new API am: 9d3a5ede58
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15082047

Change-Id: Ie217e2bec3c63284f73cedabb035f7d079fa8121
2021-06-24 09:44:07 +00:00
Lorenzo Colitti
9d3a5ede58 Add CTS for BatteryStatsManager new API
Bug: 189308158
Test: This test and
      run testReportNetworkInterfaceForTransports
      with --rerun-until-failure 500
Original-Change: https://android-review.googlesource.com/1722770
Merged-In: I654b8920d6ea1dada782a618776b13870f7f98df
Change-Id: I654b8920d6ea1dada782a618776b13870f7f98df
2021-06-24 03:15:03 +00:00
Yan Yan
aa5e681d92 Merge "Test updating underlying network of IpSecTunnelInterface" into sc-dev am: dfc9b497fd
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068514

Change-Id: I9d2a9a3d806cc6cf76994b0762dab31771166045
2021-06-24 01:27:53 +00:00
Yan Yan
dfc9b497fd Merge "Test updating underlying network of IpSecTunnelInterface" into sc-dev 2021-06-24 01:05:26 +00:00
paulhu
85b11cfd19 Add test for CSM#[get|set]UidsAllowedOnRestrictedNetworks am: 342ee18b57
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15081393

Change-Id: I0d23b667251e1372d76601805bb55d90dc916739
2021-06-23 19:35:04 +00:00
Paul Hu
341971c0e1 Merge "Add ConnectivitySettingsManagerTest" into sc-dev am: a244f13f21
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15079711

Change-Id: I621d54f7290c45d73db9369364a19f544915943c
2021-06-23 16:47:11 +00:00
paulhu
342ee18b57 Add test for CSM#[get|set]UidsAllowedOnRestrictedNetworks
Bug: 185149952
Test: atest ConnectivityManagerTest
Original-Change: https://android-review.googlesource.com/1740740
Merged-In: Ie9391d9332ded58cf1e63c8c5c6f5ba85c950bc6

Change-Id: Ie9391d9332ded58cf1e63c8c5c6f5ba85c950bc6
2021-06-23 16:34:01 +00:00
Paul Hu
a244f13f21 Merge "Add ConnectivitySettingsManagerTest" into sc-dev 2021-06-23 16:29:20 +00:00
TreeHugger Robot
e89ecee138 Merge changes I77dc5556,If772078c,Idb19b0f7 into sc-dev am: e7ac3ffec5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15079710

Change-Id: I3bb589deffd64544931966e94502a658f3945d10
2021-06-23 16:24:57 +00:00
Chiachang Wang
8bb531f3af Provide a way to override the avoid bad wifi configuration am: fad30e3d84
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068262

Change-Id: I918e3af3e637cfa20c0943c197780411f99e41f1
2021-06-23 16:24:55 +00:00
Remi NGUYEN VAN
3e19171609 Remove ConnectivityServiceTest signature perms use am: ff55aeb916
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076673

Change-Id: I82e8d3473fab1c5190b18e123f6ced4ad9a7bc1d
2021-06-23 16:24:52 +00:00
TreeHugger Robot
30ebf987bb Merge "Add basic tests for InvalidPacketException" into sc-dev am: 06b27811c8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076675

Change-Id: I028a47e25820a13a2ebfb4354f52618564a954e7
2021-06-23 16:23:50 +00:00
TreeHugger Robot
c0459cdcb8 Merge "Move ConnectivityDiagnosticsManagerTest to common" into sc-dev am: ac6a28907a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076674

Change-Id: I593327a7edc6327e3f0277b08d204ec4474579c9
2021-06-23 16:23:36 +00:00
Remi NGUYEN VAN
feda9bfeaa Added tests for QosCallback am: 763f3a0fb3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076670

Change-Id: Ib0d640796639efd7c95fed7cec1bf798b0f22dc4
2021-06-23 16:23:21 +00:00
Remi NGUYEN VAN
798e8c2747 Add tests for duplicate PendingIntent requests am: 3674367bcc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068269

Change-Id: Icb70a514e3a0650932351eb7abd86e569c010bf4
2021-06-23 16:23:12 +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
TreeHugger Robot
06b27811c8 Merge "Add basic tests for InvalidPacketException" into sc-dev 2021-06-23 16:09:25 +00:00
TreeHugger Robot
ac6a28907a Merge "Move ConnectivityDiagnosticsManagerTest to common" into sc-dev 2021-06-23 16:09:23 +00:00
paulhu
0903f73e1f Add ConnectivitySettingsManagerTest
- Add tests for ConnectivitySettingsManager.
- Also address leftover javadoc comments.

Bug: 182538166
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Original-Change: https://android-review.googlesource.com/1738353
Merged-In: I8161c1bca84b41964578d59ee5d6ab07b2380707
Change-Id: I8161c1bca84b41964578d59ee5d6ab07b2380707
2021-06-23 20:02:27 +08:00
Chiachang Wang
79f6827d45 Add test for CM#setAvoidUnvalidated
Bug: 186061922
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk
Original-Change: https://android-review.googlesource.com/1733789
Merged-In: I77dc5556458c2e824f7abd5a7b79e8aeed8dabf3
Change-Id: I77dc5556458c2e824f7abd5a7b79e8aeed8dabf3
2021-06-23 10:31:17 +00:00
Remi NGUYEN VAN
bdd448e641 Add basic tests for InvalidPacketException
The test simply verify the constructor. They only apply on S+ as
InvalidPacketException is not updatable before S.

Bug: 187935317
Test: atest InvalidPacketExceptionTest
Original-Change: https://android-review.googlesource.com/1742076
Merged-In: I33f1ee1702672204a46063e6e75c3880d5e7600b
Change-Id: I33f1ee1702672204a46063e6e75c3880d5e7600b
2021-06-23 09:16:59 +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
Remi NGUYEN VAN
763f3a0fb3 Added tests for QosCallback
Tests for the newly added QosCallback functionality

Bug: 155176305
Test: Added to cts/NetworkAgentTest
Original-Change: https://android-review.googlesource.com/1558648
Merged-In: I29769fc8be074a5105bfe4ac34e30980c5f8744a
Change-Id: I29769fc8be074a5105bfe4ac34e30980c5f8744a
2021-06-23 07:15:31 +00:00
Remi NGUYEN VAN
3674367bcc Add tests for duplicate PendingIntent requests
Add tests for requestNetwork and registerNetworkCallback with
PendingIntents that are equal as per PendingIntent.intentFilterEquals.

In such situations, the first request is documented to be automatically
unregistered. This means that the PendingIntent should only be fired
once, instead of being fired for both requests.

Currently this behavior is broken for network callbacks (not for network
requests).

Test: atest ConnectivityManagerTest
Bug: 174237997
Original-Change: https://android-review.googlesource.com/1742073
Merged-In: Ic636c731c71474ef09043d7a26ccfd6e2bb5c39f
Change-Id: Ic636c731c71474ef09043d7a26ccfd6e2bb5c39f
2021-06-23 07:15:24 +00:00
Frank Li
a94b8e1489 Ignore some ConnectivityManagerTest CTS tests that can't be run in the instant app mode am: e7d085e87d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068259

Change-Id: I20baa5a6730b594679ff558bbf218c478dda1517
2021-06-23 05:45:41 +00:00
Frank Li
e7d085e87d Ignore some ConnectivityManagerTest CTS tests that can't be run in the instant app mode
1. testIsPrivateDnsBroken: It requires the
   permission:android.permission.WRITE_SECURE_SETTINGS. But the
   WRITE_SECURE_SETTINGS permission can't be granted to instant
   apps.
2. testSetOemNetworkPreferenceForTestOnlyPref: Instant apps can't
   create test networks.
3. testSetOemNetworkPreferenceForTestPref: Instant apps can't
   create test networks.

Bug: 191678254
Bug: 191680108
Test: atest android.net.cts.ConnectivityManagerTest --instant
      atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest --instant
Original-Change: https://android-review.googlesource.com/1743373
Merged-In: Ice43bcf7a1dc34f4a54fefba7f408767f0a4341e
Change-Id: Ice43bcf7a1dc34f4a54fefba7f408767f0a4341e
2021-06-23 02:24:55 +00:00
Lorenzo Colitti
2f329557bd Merge changes from topic "connectivity-cts-cherrypicks" into sc-dev am: 77fb999ed0
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057280

Change-Id: I197cb49c4f4515fd652ee1056120abf01088ed56
2021-06-22 23:29:53 +00:00
Lucas Lin
22d513f17b Add CTS for systemReady() & getIpSecNetIdRange() am: 03a1a97bf9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14185507

Change-Id: Ib2f17932bd37c65bc693ae06aa2af53d82a9e920
2021-06-22 23:29:51 +00:00
Lucas Lin
c948e1e561 Call ConnectivitySettingsUtils to set/get private DNS related settings am: 611bc021e6
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14728963

Change-Id: I00d62fe6df6b229050de2cd5dfbad28aa843923d
2021-06-22 23:29:48 +00:00
Lucas Lin
a42cb345fc Add CTS for isUidNetworkingBlocked & isUidRestrictedOnMeteredNetworks am: 77cb456671
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057281

Change-Id: Ic269ff69cda4d9c340ad66530a5987b0c79bde02
2021-06-22 23:29:46 +00:00