Commit Graph

928 Commits

Author SHA1 Message Date
Paul Hu
b58deb706c New API to stop service resolution
Resolve service may take long time due to network issue or
using wrong service information, but users are not able to stop
it. They can only wait for the callback of resolveService to end,
which sometimes takes a long time. Thus, add the new API that
users can stop the service resolution.

Bug: 245369943
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I6b6183c8c73f8db981b9afa51fbc73bf886d9ed3
2023-01-18 10:10:25 +00:00
Paul Hu
dd102b8075 Merge "Implement service resolved callback" am: 38f5d4661b am: e0910d37c6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2242853

Change-Id: I1e5875f32e9298e393b7d4f1796f38b9be6a6672
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-18 02:28:41 +00:00
Paul Hu
38f5d4661b Merge "Implement service resolved callback" 2023-01-18 01:43:28 +00:00
Paul Hu
8a6a59eb54 Merge changes I298816ac,I3f41b4fe,Ibd782029 am: f71485f351 am: 32b836d627 am: 303f025667
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2238117

Change-Id: I2fb912ad00b81b7800fa5516bd3e29fed43089a2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-17 17:44:51 +00:00
Paul Hu
f71485f351 Merge changes I298816ac,I3f41b4fe,Ibd782029
* changes:
  Implement service lost callback
  Implement service found callback
  Use MdnsDiscoveryManager for discovery
2023-01-17 15:51:54 +00:00
Paul Hu
75069ed47e Implement service resolved callback
Service resolved should be notified when receive the
onServiceFound callbacks from MdnsServiceBrowserListener

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I681720065084bf3449c5b1ab44cd4ed6a659dcdb
2023-01-17 23:25:08 +08:00
Paul Hu
019621e070 Implement service found callback
Service found should be notified when receives the
onServiceNameDiscovered callbacks from
MdnsServiceBrowserListener.

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I3f41b4fe85cd85ad356fa764663187a88914412c
2023-01-17 20:07:22 +08:00
Paul Hu
23fa202478 Use MdnsDiscoveryManager for discovery
Register/Unregister the listener to/from MdnsDiscoveryManager
when discovery started/stopped.

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestsCases
Change-Id: Ibd782029826ac5856c608165928cd942e46dd9a4
2023-01-17 19:16:50 +08:00
Aaron Huang
154234a9a8 Merge "Remove *_WILDCARD constants from NetworkTemplate" am: 2500069488 am: 6c821202b7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2228859

Change-Id: If1edbc52438d95e3ec90a129ce00e127aef6f942
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-16 08:58:49 +00:00
Aaron Huang
8091f030f2 Merge "Remove mSubscriberId from NetworkTemplate" am: 99348b1664 am: 6e93a9025b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2241058

Change-Id: I76f848d4ed0c952a362ead0786aa1fc27f0319fb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-16 08:58:24 +00:00
Aaron Huang
2500069488 Merge "Remove *_WILDCARD constants from NetworkTemplate" 2023-01-16 07:56:09 +00:00
Aaron Huang
99348b1664 Merge "Remove mSubscriberId from NetworkTemplate" 2023-01-16 07:55:26 +00:00
Xinyi Zhou
db8608825b Merge "[API] Add onError API" 2023-01-13 19:15:33 +00:00
Maciej Żenczykowski
1cb94f1903 Merge "fix argument to CloseGuard.open()" am: c95f0d8abf am: 4268348a59
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2379468

Change-Id: Id0571fd332602536a00a5c4b73b9da5b8a846491
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-13 13:09:30 +00:00
Maciej Żenczykowski
c95f0d8abf Merge "fix argument to CloseGuard.open()" 2023-01-13 12:12:20 +00:00
Xinyi Zhou
b90b2015db [API] Add Offload Callback API
go/presence_api_u

Test: -m
Ignore-AOSP-First: nearby_not_in_aosp_yet
Bug: 265353983
Change-Id: Ie00a1bd5bcdf42d7b4678a3ffbaf18ebfbe735e6
2023-01-12 21:44:59 -08:00
Xinyi Zhou
9afce39c43 [API] Add onError API
go/presence_api_u

Test: Unit test
Ignore-AOSP-First: nearby_not_in_aosp_yet
Fix: 263907284
Change-Id: I87df0b4592b32f241eb7d22405357bc039766cb8
2023-01-11 15:41:45 -08:00
Yan Yan
e30102f29c Merge "Expose APIs to migrate IpSecTransform" am: 19aa23db7e am: bd3a05ce90 am: 0d066bd27e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2264321

Change-Id: I1d53fd8eb673dd483a93eae8aa07a59b44c35627
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-11 21:02:27 +00:00
Yan Yan
19aa23db7e Merge "Expose APIs to migrate IpSecTransform" 2023-01-11 18:52:59 +00:00
Yan Yan
81c2160a63 Expose APIs to migrate IpSecTransform
This commit exposes APIs to migrate a tunnel mode transform to
new source/destination addresses, as required by MOBIKE.

By calling the exposed API, the caller only caches the new
address in the transform. To complete the migration, caller
MUST apply the tranform to the appropriate tunnel.

This API design is mainly based on the kernel interface and use
cases. The Linux kernel requires Android to provide both the
IpSecTransform and the IpSecTunnelInterface to perform the
migration. And in most cases those two instances are managed
by different entities: IpSecTranform is managed by the key
exchange protocol (e.g. IKE) and IpSecTunnelInterface is managed by
the security tunnel provider (e.g. VPN, VCN, and IWLAN). Thus the
migration process has been designed to have two steps where the
key exchange protocol negotiates and caches the new address,
passes out the updated transform, and the security tunnel
provider applies the transform to a tunnel.

Another benefit of this API is it can also apply to the case
where the network peer does not support MOBIKE and thus cannot
update the existing transforms. In this case, the key exchange
protocol can create a new transform and give it to the security
tunnel provider, and the tunnel provider can still call "apply"
to perform migration without needing to know the details of the
transform update process.

Bug: 169171001
Test: atest FrameworksNetTests, IpSecManagerTunnelTest
Change-Id: I0658cdb09fb31f7e0fb9d0b07f37c2b72b6e705f
2023-01-10 19:09:05 +00:00
Maciej Żenczykowski
f903b92274 Merge "fix argument to CloseGuard.open()" am: 33b2163412 am: fc42b88845 am: 87c49db3b3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2379328

Change-Id: I96034af29eef93ed35fa7635b91c923dab10aded
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-07 11:38:04 +00:00
Maciej Żenczykowski
401122894d fix argument to CloseGuard.open()
Based on documentation, String parameter to CloseGuard.open() should be the name of the method to close the resource (in this case Resource.close()).

As currently written, the debug output from warnIfOpen() will be "Resource failed to call constructor."

Bug: 131838407
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I25f005a7944bf3995ae6dc4c021ed1034f2187dd
2023-01-07 10:03:47 +00:00
Maciej Żenczykowski
223b5cc371 fix argument to CloseGuard.open()
Based on documentation, String parameter to CloseGuard.open() should be the name of the method to close the resource (in this case Resource.close()).

As currently written, the debug output from warnIfOpen() will be "Resource failed to call constructor."

Bug: 131838407
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9b8a71f9076712014bb883bbde5e5fbdb018b2d5
2023-01-07 01:00:18 +00:00
Aaron Huang
77d9195186 Merge "Remove mSubscriberIdMatchRule from NetworkTemplate" am: b97fbbf5e0 am: 1972c16a3d am: 4683405502
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2241257

Change-Id: Ie6353221a77c93f84b94dcb8fa1a3863a8f32c9f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-03 03:58:42 +00:00
Aaron Huang
ece181997c Remove *_WILDCARD constants from NetworkTemplate
NetworkTemplate was moved into mainline module and
provide Builder for external users to build template.
MATCH_MOBILE_WILDCARD and MATCH_WIFI_WILDCARD are not
exposed so currently the usage of these two constants
only in module. This change is to remove the constants.

After removing the constants, two methods matchesWifi
and matchesMobile are changed to adapt the original
matches[Wifi|Mobile]Wildcard behavior.

Bug: 238843364
Test: FrameworksNetTests
Change-Id: I9e156b504ce4eb903b39279e443fad27bc921186
2022-12-28 18:49:37 +08:00
Aaron Huang
ee23c03121 Remove mSubscriberId from NetworkTemplate
Currently NetworkTemplate provides Builder for users to build a
template and it supports multiple subscriber ids. The mSubscriberId
is a local variable in current design so it can be removed from
NetworkTemplate and also can be removed from the parameter of a
constructor as long as the constructor is not annotated with
@UnsupportedAppUsage.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic6a695e1c1719111bf26ba905a38673952a24736
2022-12-28 12:09:21 +08:00
Aaron Huang
4854d055bb Remove mSubscriberIdMatchRule from NetworkTemplate
Currently, mSubscriberIdMatchRule is only used in NetworkTemplate
and it depends on if mMatchSubscriberIds is empty or not. Thus,
remove it since is not really necessary and replace it with
checking matchSubscriberIds if needed.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic66d2ff2826846778b004bb15a4718a62fa1f470
2022-12-28 12:09:09 +08:00
Yan Yan
0ec2189b81 Merge changes I3dd45b29,Ic177015f am: 67c7cd81a7 am: e55d007efe am: 0ed7c5fd7e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2264261

Change-Id: Iebebbfe0838e5808a81c97d381af4d23ac6f5b6a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-22 21:34:46 +00:00
Yan Yan
a48dcd9d1f Require IPSEC_TUNNEL_MIGRATION feature flag to migrate transforms
Bug: 169169973
Test: atest IpSecServiceParameterizedTest (new tests added)
Change-Id: I3dd45b29163cd1e0cdbef08cb8aabdb629cf73bc
2022-12-21 23:12:48 +00:00
Yan Yan
e114b38f07 Support IPsec transform migration
This commit adds methods to support migrating tunnel mode
IpSecTransform to new source/destination addresses.

Bug: 169171001
Test: atest FrameworksNetTests (new tests added)
Change-Id: Ic177015fba5b62d3f73009633118109d3631086f
2022-12-21 23:12:35 +00:00
Treehugger Robot
e882a30d94 Merge "Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage" am: 841b1f33d5 am: 8b889cccc9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2324993

Change-Id: Icc1d4bb74c653e8dab62c104f0982fe3c8ae4afe
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-02 12:25:35 +00:00
Treehugger Robot
841b1f33d5 Merge "Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage" 2022-12-02 11:27:27 +00:00
Aaron Huang
c5a05d1d8f Revert consider TEMPORARILY_NOT_METERED as unmetered in data usage
Currently, NET_CAPABILITY_TEMPORARILY_NOT_METERED traffic is
counted as unmetered data usage, and "mobile data usage"
settings screen shows metered data usage which means it doesn't
include TEMPORARILY_NOT_METERED traffic. However, some carriers
show TEMPORARILY_NOT_METERED data usage in customer's bill which
would be confusing if the data usage in the device shows different
results. Thus, revert the change to avoid confusing.

Bug: 183776809
Test: FrameworksNetTests
Change-Id: I4ef25095462adf30b1ecf82134996739f167930d
2022-12-02 16:04:55 +08:00
Aaron Huang
fb76842cac Merge "Make mMatchSubscriberIds as a NonNull variable" am: b4b8198b89 am: 25e9424f81
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2282318

Change-Id: I80b5529399dc9e5c6e404478f969d193e04844b9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-02 04:09:33 +00:00
Aaron Huang
5dacb8cd8e Merge "Remove unused methods from NetworkTemplate" am: 23d8cd11c7 am: 6426d81853
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2286634

Change-Id: Ib0ccb82de0084ac0d4d82bdb3e1944fd83c148f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-01 06:55:03 +00:00
Aaron Huang
859884a48f Make mMatchSubscriberIds as a NonNull variable
In current design, mMatchSubscriberIds can be null which has the
same meaning with empty set, and is not easy to maintain since it
need more checks for this variable when mSubscriberId is null.
Thus make mMatchSubscriberIds NonNull for the maintenance.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I6cfc529b5f4a39ded8598283ff968f2f4d1bc89f
2022-11-30 16:38:24 +00:00
Aaron Huang
a8a6da0db9 Remove unused methods from NetworkTemplate
NetworkTemplate.Builder was introduced in Android T and the callers
outside of Connectivity module should use this Builder to build a
template instead. Thus remove the buildTemplate* methods from
NetworkTemplate class. Also, deprecate the methods which are
annotated with @UnsupportedAppUsage and also use Builder to build
the template.

Bug: 238843364
Test: build, FrameworksNetTests
Change-Id: I3190325f6663e4771edf5c7a19bf5ecc7780bf12
2022-11-30 16:38:19 +00:00
Maciej Żenczykowski
828b55d3ab Merge "ipsec - use ro.vendor.api_level instead of ro.product.first_api_level" am: 82a4e0a42e am: 96e93319bb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2264601

Change-Id: I6a9c3ffadbea8cc26b9b0e088d0a8406a80c6260
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-09 23:49:44 +00:00
Maciej Żenczykowski
82a4e0a42e Merge "ipsec - use ro.vendor.api_level instead of ro.product.first_api_level" 2022-11-09 22:38:36 +00:00
Maciej Żenczykowski
5d78c63662 ipsec - use ro.vendor.api_level instead of ro.product.first_api_level
Bug: 254143771
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9f91fc250e0fa40c9dc9ee3e7a2f7bc3cf2ebc75
2022-11-09 00:47:13 +00:00
Treehugger Robot
7dd2c767fe Merge "Fix errorprone warnings that should be errors" am: edceea23f4 am: 7ce1742a53
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2256437

Change-Id: Id76f88e7b66f25fb1d488124d858ca50761c379b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-02 20:40:02 +00:00
Cole Faust
22f05839f5 Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I7625fa386afe93823b97cb2ecb8fd09a5856c05b
2022-11-02 10:13:14 -07:00
Jean Chalard
3fa24377c6 Merge "Move bit utilities to BitUtils." am: e45e581cff am: d856878ceb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2251614

Change-Id: If80e57705d8ecc6d816005ae3680f51fc5397156
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-14 05:57:52 +00:00
Chalard Jean
1d420b3b76 Move bit utilities to BitUtils.
Test: BitUtilsTest
Change-Id: I3e100c6087f61c2a13aa8558ee8f9a9ad480c681
2022-10-12 16:39:37 +09:00
Paul Duffin
d75708c808 Merge "Make the hiddenapi*-tiramisu.txt files part of framework-connectivity-t" am: dadf95ff6a am: 82822d8671
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2186255

Change-Id: Ie8ec2e4ef5fa9999c59a52f4c0e567db5a24e621
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-15 12:47:45 +00:00
Paul Duffin
c8164e4963 Make the hiddenapi*-tiramisu.txt files part of framework-connectivity-t
Previously, the hiddenapi*-tiramisu.txt files that were created as part
of the work for creating framework-connecvity-t were just added to the
list of hidden API files on the bootclasspath_fragment. Unfortunately,
that made it impossible to exclude those when generating an sdk
snapshot for S which cannot include framework-connectivity-t.

This change moves those files to be part of framework-connectivity-t
instead of the bcpf so that they will only be used in an sdk snapshot
when the library is part of the snapshot.

Bug: 240406019
Test: packages/modules/common/build/mainline_modules_sdks.sh
      # Ran the previous command with and without this change to make
      # sure that this change does not change the sdk snapshot
      # contents. A follow up change will exclude the
      # framework-connectivity-t library from the S sdk snapshot.
Change-Id: Ib5c5c6046d96b911c8e9e5ac3729ce963f1b6907
2022-09-13 15:13:15 +00:00
Junyu Lai
2b00eb6adf Merge "[ST01] Attributes data usage of test network by specifier" am: 1c685c1e97 am: be039ead35 am: 5f2319ac2a am: 77a51ea20a am: 1f883694cf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2164649

Change-Id: I3ed7e84611f23b46e2d1ef68eb6ae72a16830a35
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-30 08:16:50 +00:00
Junyu Lai
c9f1ca62d9 [ST01] Attributes data usage of test network by specifier
Currently, data usage of all test networks are all attributed to
the same NetworkIdentity, which does not allow services to
distinguish upload & download traffic of different test networks.

Thus, this CL put specifier that comes along with
TestNetworkAgent into wifiNetworkKey field to build different
NetworkIdentity to attribute data usage to different for
individual networks. And allow querying test network usage with
wifiNetworkKeys.

Bug: 139774492
Test: atest FrameworksNetTests
      atest android.net.cts.ConnectivityManagerTest
Change-Id: I1bb38fd20781eaf3105735440a04b27bef36fcae
2022-08-29 13:55:08 +08:00
Xinyi Zhou
4af0e0f784 Add back getFastPairScanEnabled and setFastPairScanEnabled System API
Test: -m
Ignore-AOSP-First: nearby_not_in_aosp_yet
Change-Id: Ic0af4c235db14dfd8601c4cf75690af78d4821fd
2022-08-11 01:45:20 +00:00
Aaron Huang
d5ffa6e10f Merge "Cleanup constructor of NetworkStats#Entry" am: 0ab4d265d6 am: 457730a2cd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2167482

Change-Id: Ie0a1712564e725858a7e7af58eeb50f9d0bb3525
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-05 08:58:42 +00:00