Commit Graph

845 Commits

Author SHA1 Message Date
Paul Hu
45c1eaadb4 Remove the ServiceTypeClient after socket destroyed
The ServiceTypeClient should be removed after socket destroyed
because it's no longer used by any request. The requests will be
matched to the newly created ServiceTypeClient.

Bug: 278635632
Test: atest FrameworksNetTests CtsNetTestCases
(cherry picked from https://android-review.googlesource.com/q/commit:f2a51ac5f8cc6b1cfaaa0f8fd5c28af522806ca0)
Merged-In: Ia917b14d3666f3bfe8e874606a34800a4ce65c5a
Change-Id: Ia917b14d3666f3bfe8e874606a34800a4ce65c5a
2023-05-15 03:50:36 +00:00
Junyu Lai
8666042a78 Merge changes from topic "statsaccess" am: 9d25241337 am: a5b62b7439
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2528763

Change-Id: I858dd58dbd2c9ed415c52b12fce09f748c844fbd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-14 10:57:50 +00:00
Junyu Lai
9d25241337 Merge changes from topic "statsaccess"
* changes:
  Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
  Move checkAnyPermissionOf to PermissionUtils
2023-04-14 09:54:49 +00:00
Paul Hu
a67bd9dd49 Merge "Add missed NSD event name" am: 86179beedb am: 86130adb35
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2530787

Change-Id: I7c4329b9e7fab5545d3edd2c6dbd56f5a045e52c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-14 03:29:44 +00:00
Paul Hu
99fdf93066 Add missed NSD event name
Some events are missed their name in the EVENT_NAMES array and
shows the number on dumpsys logs. Add their name to the event
array to show correct info.

Before:
 rec[0]: time=04-12 15:15:23.553 processed=DefaultState org=EnabledState dest=<null> what=21
 rec[1]: time=04-12 15:15:23.555 processed=EnabledState org=EnabledState dest=<null> what=REGISTER_SERVICE
 rec[2]: time=04-12 15:15:24.375 processed=EnabledState org=EnabledState dest=<null> what=DISCOVER_SERVICES
 rec[3]: time=04-12 15:15:25.338 processed=EnabledState org=EnabledState dest=<null> what=23
 rec[4]: time=04-12 15:15:25.342 processed=EnabledState org=EnabledState dest=<null> what=RESOLVE_SERVICE
 rec[5]: time=04-12 15:15:25.344 processed=EnabledState org=EnabledState dest=<null> what=23
 rec[6]: time=04-12 15:15:25.358 processed=EnabledState org=EnabledState dest=<null> what=UNREGISTER_SERVICE
 rec[7]: time=04-12 15:15:25.551 processed=DefaultState org=EnabledState dest=<null> what=22

After:
 rec[0]: time=04-12 15:19:58.955 processed=DefaultState org=EnabledState dest=<null> what=REGISTER_CLIENT
 rec[1]: time=04-12 15:19:58.958 processed=EnabledState org=EnabledState dest=<null> what=REGISTER_SERVICE
 rec[2]: time=04-12 15:19:59.979 processed=EnabledState org=EnabledState dest=<null> what=DISCOVER_SERVICES
 rec[3]: time=04-12 15:20:00.768 processed=EnabledState org=EnabledState dest=<null> what=MDNS_DISCOVERY_MANAGER_EVENT
 rec[4]: time=04-12 15:20:00.777 processed=EnabledState org=EnabledState dest=<null> what=RESOLVE_SERVICE
 rec[5]: time=04-12 15:20:00.778 processed=EnabledState org=EnabledState dest=<null> what=MDNS_DISCOVERY_MANAGER_EVENT
 rec[6]: time=04-12 15:20:00.785 processed=EnabledState org=EnabledState dest=<null> what=UNREGISTER_SERVICE
 rec[7]: time=04-12 15:20:00.925 processed=DefaultState org=EnabledState dest=<null> what=UNREGISTER_CLIENT

Test: adb shell dumpsys servicediscovery
Bug: 275004614
Change-Id: I9c05efc2d2993af353a2a902fd8810f53ab2cd16
2023-04-12 15:24:02 +08:00
Junyu Lai
e68c42b888 Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
Follow up from aosp/1933093. The test failed because certain
devices use a flattened apex that lacks the NETWORK_STACK
permission for sharing with the GTS apk.
Additionally, the NetworkStatsAccess does not recognize the
GTS apk, which holds the MAINLINE_NETWORK_STACK permission.

Test: TH
Bug: 275532605
Change-Id: Icce80a3d3dbea4a84fbd369d9b5fbe0029ab463e
2023-04-11 14:56:15 +08:00
Chalard Jean
ea8ea49862 Fix a var name in a comment am: e2294fb13e am: 848e0d3589
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2526882

Change-Id: If2586cc4a74d1c8385ab67b0a37328965d727d75
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-10 04:52:41 +00:00
Jean Chalard
19b814793b Merge "Rename throwAboveU to throwAtLeastU" am: 5edc307e57 am: 175f475ded
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2527124

Change-Id: Ie754523e14ac1d37c1398d5e913b4b11aa248527
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-10 02:29:46 +00:00
Chalard Jean
e2294fb13e Fix a var name in a comment
Remaining comment from aosp/2527124

Test: comment-only change
Change-Id: Ic0418bf0bc15b854e25e211bc7399d83487fe971
2023-04-10 10:38:20 +09:00
Chalard Jean
1bfd3ccf0b Rename throwAboveU to throwAtLeastU
And address other comments on aosp/2527139

Bug: 273963543
Test: FrameworksNetTests
Change-Id: I4328aea2881badc2be667b900b7ac2a296af1678
2023-04-07 12:19:10 +09:00
Chalard Jean
843cd6ca48 Restore the null behavior of buildWifiTemplate
The old behavior was to only return those wifis that have
a null key/subscriber ID (e.g. not carrier wifi). To keep
backward compatibility, restore that behavior.

Also only crash the old methods on devices with initial
SDK U, because it can't be mandated that devices that
upgrade must not call these methods.

Bug: 273963543
Test: FrameworksNetTests
Merged-In: Iefb976ed86a732158964fae38e9e601001c2637a
Change-Id: Iefb976ed86a732158964fae38e9e601001c2637a
2023-04-07 02:49:28 +00:00
Chalard Jean
e025f40012 [automerge] Restore the null behavior of buildWifiTemplate 2p: 4c0fb401be
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/22503686

Bug: 273963543
Change-Id: I1f0c2497869e8539d84e2c39780df4bf91458cc3
2023-04-06 08:24:11 +00:00
Chalard Jean
4c0fb401be Restore the null behavior of buildWifiTemplate
The old behavior was to only return those wifis that have
a null key/subscriber ID (e.g. not carrier wifi). To keep
backward compatibility, restore that behavior.

Also only crash the old methods on devices with initial
SDK U, because it can't be mandated that devices that
upgrade must not call these methods.

Bug: 273963543
Test: FrameworksNetTests
Change-Id: Iefb976ed86a732158964fae38e9e601001c2637a
(cherry picked from commit 78f94fc15035560c279f8e9378561e60a676410a)
2023-04-06 17:23:53 +09:00
Remi NGUYEN VAN
96054db62b Merge "Do not crash when passing null into buildTemplateMobileAll" am: 8a78f043ea am: bb0baa63eb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2510560

Change-Id: Ia953c32c4e260c0d8efc34ae8d82c0f33ae049ab
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-04 02:26:46 +00:00
Remi NGUYEN VAN
8a78f043ea Merge "Do not crash when passing null into buildTemplateMobileAll" 2023-04-04 01:27:41 +00:00
Treehugger Robot
1edb3c22c4 Merge "Cleanup visibility of framework-connectivity-t.impl" am: 85de09411f am: f9021773f9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2503715

Change-Id: I60e33670b813e3c84bf059b9a95ef5b9188b2e01
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-31 05:33:00 +00:00
Treehugger Robot
85de09411f Merge "Cleanup visibility of framework-connectivity-t.impl" 2023-03-31 04:50:32 +00:00
Junyu Lai
2c12f922de Do not crash when passing null into buildTemplateMobileAll
Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkTemplateTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkTemplateTest
Bug: 273963543
Change-Id: I0a8f94df124147e92d35cf474b3d69d1dee6902c
2023-03-30 13:59:02 +08:00
Treehugger Robot
ca2dc5fccd Merge "Add androidx.annotation_annotation library" am: 9d5066b806 am: 41d8502be9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2501921

Change-Id: If0e399b4632f5f1e451970aa46487f219c41ce80
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-28 02:18:04 +00:00
Treehugger Robot
9d5066b806 Merge "Add androidx.annotation_annotation library" 2023-03-28 01:14:42 +00:00
Xinyi Zhou
0d195ae5d4 Add androidx.annotation_annotation library
Change-Id: Ia8b745d674262a312044cd4e2b4320917d550725
Test: TH
Bug: 272150669
2023-03-24 05:40:37 +00:00
Remi NGUYEN VAN
ca877a8ed0 Merge "Add back @hide NetworkTemplate methods" am: 123595655a am: 256d304921
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2500322

Change-Id: I706df010b554d0db5f25cb7ba66ba55fa6309b36
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-24 04:09:18 +00:00
Remi NGUYEN VAN
123595655a Merge "Add back @hide NetworkTemplate methods" 2023-03-24 03:37:24 +00:00
Remi NGUYEN VAN
37c4a9f222 Add back @hide NetworkTemplate methods
Add back methods that were removed in recent refactoring
(aosp/2286634).  Even though they are fully @hide, some usage by
an OEM has been found on T.

Test: atest; the methods should be unused except on the OEM device
Change-Id: Icd67fb8b7e63cc131356a30a3044458ae2f5efff
2023-03-23 18:49:28 +09:00
Cole Faust
e49c11d884 Cleanup visibility of framework-connectivity-t.impl
Fixes: 274725920
Test: Presubmits
Change-Id: I325f686af34720cddbbc63580edec8477a9acc45
2023-03-22 14:19:02 -07:00
Paul Hu
5c28b172f7 Merge "Add a CompatChange flag to enable platform backend" am: 62503cfef1 am: fa2a4f33d9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2452427

Change-Id: I8211177f9cef3b2a36ab5e00a34d77346693e5c6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-17 14:24:13 +00:00
Paul Hu
62503cfef1 Merge "Add a CompatChange flag to enable platform backend" 2023-03-17 13:14:19 +00:00
Paul Hu
2e0a88c0fa Add a CompatChange flag to enable platform backend
Apps targeting sdk < U are considered to use a legacy native
daemon as NsdManager backend, but other apps use a
platform-integration mDNS implementation as backend. So add a
CompatChange flag to enable platform backend for non-legacy
apps.

Bug: 270306772
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I7ba58f8a5186fb49ad5f8aeacc8b8234bef1eabe
2023-03-17 09:10:46 +08:00
Anton Hansson
893cd2592c Merge "Use filegroup defaults for framework sources" am: 41ad986490 am: 2b246a30df
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2489555

Change-Id: Ia00a74bb0665cda921f8ab8194c4e0dfced721be
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-16 10:01:06 +00:00
Anton Hansson
57f3d69fd5 Use filegroup defaults for framework sources
There's now a shared defaults module for this kind of filegroup. Use
that and remove the previously duplicated prop.

Bug: 271816210
Test: m
Change-Id: Ia4547984a73179fdfc98c427482dd10246f9722c
2023-03-15 10:36:52 +00:00
Junyu Lai
e7117ea1fc Merge "Remove requireNonNull check from matchesWifiNetworkKey" am: 7ee63b6895 am: c06b45d89f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2421141

Change-Id: I22a02d2a7217a96441510c691c6d104c0d575260
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-09 10:05:08 +00:00
Junyu Lai
7ee63b6895 Merge "Remove requireNonNull check from matchesWifiNetworkKey" 2023-03-09 09:13:40 +00:00
Paul Hu
649aefc156 Merge "Migrate reigster service callback backend" am: ee0e6cd701 am: 5b610505d0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2424806

Change-Id: Ie0cdd0b32a01cd0d855493277f2debb863591d41
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-08 11:29:16 +00:00
Paul Hu
ee0e6cd701 Merge "Migrate reigster service callback backend" 2023-03-08 10:27:57 +00:00
Aaron Huang
8ac1143594 Remove requireNonNull check from matchesWifiNetworkKey
matchesWifiNetworkKey expects a non-null value of the
wifiNetworkKey, however, it might be null in practice
and the null wifiNetworkKey will be stored into disk.
And then when the matchesWifiNetworkKey is called, the
requireNonNull will crash the system. Thus, remove the
requireNonNull from matchesWifiNetworkKey to avoid
system crash and handle if the wifiNetworkKey is null
then it should not match a template with non-empty
mMatchWifiNetworkKeys.

Check if WifiInfo contains a null network key then skip it
to prevent adding the identity to the network identity set.
Also, add a Log.wtf when setWifiNetworkKey(info.getNetworkKey()),
this might be useful to catch why the wifiNetworkKey is
null.

Bug: 267815242
Bug: 266598304
Test: FrmeworksNetTests
Change-Id: I9c21f7e3dca9482133c7e331741cf808105414e9
2023-03-07 18:16:55 +08:00
Cole Faust
41228921c1 Compile HalfSheetUX against framework-connectivity-t.impl
HalfSheetUX uses private apis of framework-connectivity-t. It appears
that using just "framework-connectivity-t" will compile against either
the stubs or source of framework-connectivity-t depending on if the
module was included in the same apex as it or not.

aosp/2462194 is adding the ability to compile modules like HalfSheetUX
outside of the context of the apex, at which point it will start
compiling against stubs if we don't explicetly specify to use the
implementation library.

Bug: 254205429
Test: m javac-check with aosp/2462194
Change-Id: I1d41e47aa0e4e3d320b78b28cfc181fc30c4537c
Merged-In: I1d41e47aa0e4e3d320b78b28cfc181fc30c4537c
2023-03-06 23:15:49 +00:00
Cole Faust
c944f10f61 Compile HalfSheetUX against framework-connectivity-t.impl
HalfSheetUX uses private apis of framework-connectivity-t. It appears
that using just "framework-connectivity-t" will compile against either
the stubs or source of framework-connectivity-t depending on if the
module was included in the same apex as it or not.

aosp/2462194 is adding the ability to compile modules like HalfSheetUX
outside of the context of the apex, at which point it will start
compiling against stubs if we don't explicetly specify to use the
implementation library.

Bug: 254205429
Test: m javac-check with aosp/2462194
Change-Id: I1d41e47aa0e4e3d320b78b28cfc181fc30c4537c
Merged-In: I1d41e47aa0e4e3d320b78b28cfc181fc30c4537c
2023-03-06 15:14:40 -08:00
Paul Hu
30bd70d168 Migrate reigster service callback backend
registerServiceInfoCallback currently only sends updates for
addresses added, but does not handle removes (expiration) and
TXT/SRV record updates. Thus, migrate its backend to
MdnsDiscoveryManager which can support the expiration update.

Bug: 266030646
Test: atest FrameworksNetTests CteNetTestCases
Change-Id: I72add213935dc1beacb6277007868ad30bd89c00
2023-03-06 13:49:19 +08:00
Junyu Lai
42bb19ea5a Merge changes I197fbfb8,I6375e771,I48536927 am: d3e793d8a1 am: 9cee333939
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2465771

Change-Id: I6f4164c68b964cfe5e6741cf3fe60db1d4467ac8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-03 16:58:32 +00:00
Junyu Lai
d3e793d8a1 Merge changes I197fbfb8,I6375e771,I48536927
* changes:
  Add constructor which used by Android T CTS
  Delete testUnsupportedAppUsageConstructor from coverage test
  Add some hidden APIs back to NetworkTemplate
2023-03-03 09:34:47 +00:00
Junyu Lai
84b5936e3d Add constructor which used by Android T CTS
aosp/2241257 and aosp/2241058 are included in the mainline train
release and it causes the T device can’t pass CTS-13_R2/CTS-13_R3.
It’s because some parameters of the constructor have been removed.

Add it back to keep backward compatibility.

Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkTemplateTest
      2. CTS-13_R3
Fix: 269974916
Fix: 269834366
Change-Id: I197fbfb8419e4d4885a97a93a71f13d33c3f02da
2023-03-03 15:16:36 +08:00
Aaron Huang
960c6267ca Add some hidden APIs back to NetworkTemplate
Since there's a bug about apps still call hidden
APIs, it's likely some developers might build apps
against hidden API.
To be safe, add these methods back to avoid apps
crash. These methods are still in
hiddenapi-max-target-o-low-priority.txt, so they
should not be removed without considering hidden
API usage. Removing hidden API in general isn't
forbidden, but the ones listed in hiddenapi usage
need extra care.

Bug: 269178029
Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkTemplateTest
      2. CTS-13_R3
Change-Id: I485369274ccacd314230e3d267df665d8083bf97
2023-03-03 13:54:42 +08:00
Junyu Lai
2aa87ac72c Merge "Clear calling identity before calling into DPM" am: ae04a1a842 am: 0f4f9dc068
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2445864

Change-Id: I58cd2c61217b9673e4da77ca4d86f0a93e6af756
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-02 07:31:01 +00:00
Junyu Lai
ae04a1a842 Merge "Clear calling identity before calling into DPM" 2023-03-02 05:56:51 +00:00
Junyu Lai
09330c436e Clear calling identity before calling into DPM
Test: 1. manual test with test app
      2. atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest
Fix: 249920382
Fix: 269561252
Change-Id: I4af7fd640d551be3ef62ea248e58bf8bae5e0b87
2023-03-01 15:56:59 +08:00
Aaron Huang
13318e276e Merge "Add isMatchRuleMobile back" am: 9ff2fe7747 am: 0d3e843bb2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2444979

Change-Id: Idfd3a2f9359cf9fb7414ce048c079bae2424b420
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-24 06:50:35 +00:00
Aaron Huang
9ff2fe7747 Merge "Add isMatchRuleMobile back" 2023-02-24 05:30:06 +00:00
Aaron Huang
30814f780e Merge "Fix backward compatibility issue for removed wildcard match rule" am: dbdb1d972c am: 4b5dca4216
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2424491

Change-Id: Ie035be35becd9d8d50cd4c1f2a31fd8e77bdb2b6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-22 08:56:43 +00:00
Aaron Huang
dc97905786 Add isMatchRuleMobile back
There's a user still call this method which causes the app
crash and it might be the app was built against hidden API.
The bug was observed after updating the mainline module so
adding this method back to the module to avoid apps crash
due to the method is not found in NetworkTemplate.

Bug: 269178029
Test: build
Change-Id: I06dc694b1ce060488135f5d34138f14abd50ad32
2023-02-21 17:23:48 +08:00
Aaron Huang
69086d6cbc Fix backward compatibility issue for removed wildcard match rule
A template with type MATCH_MOBILE could have empty subscriber
IDs but it should not contain one of subscriber IDs is null.

An app might still build a template through the constructor
which is annotated with @UnsupportedAppUsage. NetworkTemplate
will throw an exception when the app trying to construct a
template with type *_WILDCARD. The constructor should be
backward compatible with old version so this change is to add
the backward compatibility to have NetworkTemplate not throw
an exception.

Bug: 267701889
Test: FrameworksNetTests
Change-Id: I23a607dae508e0c53520e2edf187cb611ed36b68
2023-02-21 14:07:15 +08:00