Commit Graph

529 Commits

Author SHA1 Message Date
Aaron Huang
2a69e41772 Merge "Tempates with different subscriber ID should be not equal" 2023-02-10 08:06:07 +00:00
Aaron Huang
c9371d05fe Tempates with different subscriber ID should be not equal
mSubscriberId was removed from NetworkTemplate and equals/hashCode
does not check the mMatchSubscriberIds. This will cause tempates
with different subscriber ID matching that are equal now. Thus
adding the check for mMatchSubscriberIds to fix it.

Bug: 267968247
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I2956bf4c8cf2c4d73ebe102d53e755fbcc5d7642
2023-02-10 08:04:53 +00:00
Yuyang Huang
90a2cbdd8d Moves all compatibility flags to ConnectivityCompatChanges.java
ConnectivityCompatChanges.java becomes the centralized place for all the
CompatChanges used in the Connectivity module. By putting all the
CompatChanges here, we are able to manage them under a single
platform_compat_config.

Bug: 268440216
Test: atest FrameworksNetTests
Change-Id: I3e17af545718073d7d1c96e27298e7790563fd33
2023-02-09 19:51:37 +09:00
Paul Hu
b2c0f3407f Rename onResolveStopped to onResolutionStopped
Rename the method onResolveStopped(NsdServiceInfo) to
onResolutionStopped(NsdServiceInfo) for consistency as API
review feedback.

Bug: 266811051
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I788b5903ecaf78a9aa960dd3b7413a22f171c72f
2023-01-30 08:53:15 +00:00
Paul Hu
18aecccc9d New API to listen service update
Currently, the resolution is a one shot query, it only notifies
the first finding service information. There is no way to listen
the service update. Thus, add a new API that can register a
callback to listen to the service updates continuously.

Bug: 245369943
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I0e9d92b9028375feb3e344ab6c4acb515c5b2be9
2023-01-19 20:16:03 +09:00
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
38f5d4661b Merge "Implement service resolved callback" 2023-01-18 01:43:28 +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
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
Maciej Żenczykowski
c95f0d8abf Merge "fix argument to CloseGuard.open()" 2023-01-13 12:12:20 +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
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
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
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
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
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
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
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
Chalard Jean
1d420b3b76 Move bit utilities to BitUtils.
Test: BitUtilsTest
Change-Id: I3e100c6087f61c2a13aa8558ee8f9a9ad480c681
2022-10-12 16:39:37 +09: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
Aaron Huang
4705518156 Merge "Cleanup constructor of NetworkStats#Entry" am: 0ab4d265d6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2167482

Change-Id: Ie9dfc1e735af3842a40b31015bd90f09d2038cdc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-05 08:37:59 +00:00
Aaron Huang
8b9ecdad6d Cleanup constructor of NetworkStats#Entry
Have all callers to use the same constructor and remove the
unused constructors.

Bug: 238843364
Test: FrameworksNetTests
Change-Id: Ieb1d0bc4ff8d2238c7a802189f8d91f4a9978eb8
2022-08-02 22:49:16 +08:00
Remi NGUYEN VAN
a5803006e9 Merge "Add back compat config for NSD" am: a39d54bf43
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2157803

Change-Id: I7567e5dd6d38815a1055a4ecc54a76eba7ff56ed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 08:41:54 +00:00
Remi NGUYEN VAN
348bbb0231 Add back compat config for NSD
Add back compat config for RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS, which was
lost when moving NsdManager to framework-connectivity-t.

This causes NsdManager to start mdnsresponder again when used by apps
with target SDK < 31.

The change also changes the compat ID used, to make sure it does not
conflict with the ID already in use in S and below, when the module is
installed on such a platform. This is the only ChangeId used by
framework-t.

Also add a CtsNetTestCasesMaxTargetSdk30 test to verify that behavior.

Bug: 235355681
Test: atest CtsNetTestCasesMaxTargetSdk30
Change-Id: I7ca6051d0a4ba5aff3e44bece2cbac22eb1be32d
2022-07-27 19:53:25 +09:00
Aaron Huang
059a7f9526 Merge "Migrate buildTemplate* to use NetworkTemplate.Builder" am: c37d806dfd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2152658

Change-Id: If75f307a6e46677cfc1932d8f968226729819ba1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-26 07:58:23 +00:00
Aaron Huang
c37d806dfd Merge "Migrate buildTemplate* to use NetworkTemplate.Builder" 2022-07-26 07:40:49 +00:00
Aaron Huang
1c14fa9b08 Migrate buildTemplate* to use NetworkTemplate.Builder
Use new Builder API which was introduced in Android T.

Bug: 238843364
Test: FrameworksNetTests
      dumpsys netstats --checkin and check the output
Change-Id: Ieb0a2ee04056a1cedb71274ea710ff5153e2d68c
2022-07-25 11:30:13 +08:00
Aaron Huang
f49be5f320 Merge "Fix style errors in NetworkStats" am: b84de74137
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2138534

Change-Id: Ide39fea8d06b563bb3eb5e7ca3bc67c2b2caca7a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 09:40:30 +00:00
Aaron Huang
b84de74137 Merge "Fix style errors in NetworkStats" 2022-07-20 09:24:33 +00:00
Aaron Huang
f7c1042aaf Fix style errors in NetworkStats
Test: build
Change-Id: I4366480e7a71004612d775bfa54744cc74c1fd7b
2022-07-20 05:48:17 +00:00
Aaron Huang
be198dcc5c Merge "Replace buildTemplate* with NetworkTemplate.Builder" am: 1ba1febf2b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2155326

Change-Id: I0837739ae0b1d8daadbbd2311a6c65eb61c139f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 03:13:07 +00:00
Aaron Huang
1ba1febf2b Merge "Replace buildTemplate* with NetworkTemplate.Builder" 2022-07-20 02:56:33 +00:00
Aaron Huang
a4fcb8b4cf Replace buildTemplate* with NetworkTemplate.Builder
Use Builder API which was provided in Android T to
build a template.

Bug: 238843364
Test: build, FrameworksNetTests:NetworkStatsManagerTest
Change-Id: Ibf1ac16541d6f3ddaf9b241e2f47ae04acbedf93
2022-07-18 17:16:49 +08:00
Chiachang Wang
d2e4c1f915 Merge "Correct javadoc usage" am: b7f81e4a6d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2153593

Change-Id: I72c6695348fb9b5f81f5e89064ec10d166fa23bf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-15 07:56:03 +00:00
chiachangwang
9473c59980 Correct javadoc usage
"{@see" aren't rendered properly. Replace them with "See {@link"
or @see depending on the usage.

Bug: 238753273
Test: make doc-comment-check-docs ; Check the doc result
Change-Id: I70cb2f36e7c5fa8102b5949054df5184d755202c
2022-07-15 03:44:46 +00:00
Aaron Huang
5804b5c5df Merge "Hold wifi and mobile interfaces since boot in NetworkStatsService" 2022-06-07 07:36:26 +00:00
Treehugger Robot
5c74cab9a8 Merge changes from topic "historybuildertest"
* changes:
  Return sorted NetworkStatsHistory
  Use fallback method if the importer throws
2022-06-07 06:06:45 +00:00
Junyu Lai
bfdd4407eb Return sorted NetworkStatsHistory
NetworkStatsHistory internally assumes that bucketStart is
sorted at all times. However, in the fields, we've found there
are some buckets of NetworkStatsHistory do not preserve the
order of timestamp, which is caught by the IAE when addEntry
is called.

In order to provide backward compatibility, return sorted items
instead of throwing IAE when adding entry into
NetworkStatsHistory instance.

Test: atest android.net.netstats.NetworkStatsHistoryTest#testBuilder
Bug: 233825704
Change-Id: If3187384bd1e90770ca5873b8ec73e852fff543d
Merged-In: If3187384bd1e90770ca5873b8ec73e852fff543d
  (pure cherry-picked from ag/18581718)
2022-06-07 10:51:52 +08:00