Commit Graph

552 Commits

Author SHA1 Message Date
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
Aaron Huang
f4f5de3993 Hold wifi and mobile interfaces since boot in NetworkStatsService
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.

This change also remove interface name from all entries before
the method returns the result.

Bug: 231514741
Test: FrameworksNetTests
      manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
Merged-In: Ie60829a65d0d9b5b63ad353695a820c0586e3665
2022-06-06 13:19:11 +08:00
Remi NGUYEN VAN
0c334548f8 Merge "Ensure callbacks are run properly on executor" am: 411d2bd07d am: f8224f5364
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2111166

Change-Id: I70f6ccf9f42717b846e816067e90916792cec143
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 09:42:25 +00:00
Aaron Huang
ab097b28d5 Hold wifi and mobile interfaces since boot in NetworkStatsService am: a2f1cf3576
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18710006

Change-Id: Ie53afd7a2c6cfdd46a1ed3954a1aceac9bd120eb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 09:25:50 +00:00
Remi NGUYEN VAN
411d2bd07d Merge "Ensure callbacks are run properly on executor" 2022-06-03 09:04:29 +00:00
Aaron Huang
a2f1cf3576 Hold wifi and mobile interfaces since boot in NetworkStatsService
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.

This change also remove interface name from all entries before
the method returns the result.

Ignore-AOSP-First: non-AOSP CL is included in the same topic
Bug: 231514741
Test: FrameworksNetTests
      manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
2022-06-03 15:51:19 +09:00
Remi NGUYEN VAN
9133888e0c Ensure callbacks are run properly on executor
NsdManager callbacks were run on a provided executor by capturing the
handler message in a lambda, but the message will be recycled
immediately after handleMessage returns. This means that any non-inline
executor would see bogus callbacks, as they have an empty Message. Fix
it by not capturing the Message in the lambda, but capturing its
contents instead.
This was broken when updating the class to support executors in change
ID: I4c31e2d7ae601ea808b1fd64df32d116c6fff97f; before that, callbacks
were all run on the NsdManager handler.

Also, DelegatingDiscoveryListener is being run on the NsdManager handler
thread for notifyAllServicesLost, causing onServiceLost to be run there,
but other methods are run on the provided Executor, even though they
access maps maintained on the handler thread, like mPerNetworkListeners.

Revert DelegatingDiscoveryListener to run on the handler thread as
before, and only use the provided executor to execute any app-facing
callback instead.

Bug: 234419509
Test: atest NsdManagerTest

Change-Id: Icca64511b02dad2f725a2849d2a1e871135b3286
2022-06-02 18:16:42 +09:00
Paul Hu
6773b82577 Merge "Remove the DisabledState from NsdService" am: d65740346e am: 537e5289fe
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110094

Change-Id: I86da81dbd9e5d55042a9cf2df8d5876a4f244e03
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 10:17:28 +00:00
Paul Hu
d65740346e Merge "Remove the DisabledState from NsdService" 2022-06-01 09:25:11 +00:00
Remi NGUYEN VAN
2bd25cdc84 Merge "Fix service resolve on tethering downstreams" am: 5eaefa21bf am: d0a31d8e08
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110084

Change-Id: I14bf75238dd36a9d5c834f26964d1e861d1e714e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 06:09:12 +00:00
Paul Hu
29f4359856 Remove the DisabledState from NsdService
In order to increase the line coverage for the Connectivity
module, remove the DisabledState from NsdService which is
uselss for a while.

Bug: 234315786
Test: atest FrameworksNetTests CtsNetTestCases \
      ConnectivityCoverageTest
Change-Id: I29c7ef608d97037084b25daa70ad5829f474e20a
2022-06-01 05:57:59 +00:00
Remi NGUYEN VAN
0102c9440a Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
(cherry picked from commit 1a8ee102d3)
Merged-In: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
2022-06-01 05:35:36 +00:00
Remi NGUYEN VAN
5eaefa21bf Merge "Fix service resolve on tethering downstreams" 2022-06-01 05:31:14 +00:00
Natasha Lee
bcdb3c12ee Merge changes from topic "stats-migration"
* changes:
  Skip PersistentIntTest on S- device
  Don't clobber existing history entries.
  Ensure NetworkStats migrated snapshot is identical
  [MS82.1] Support network stats data migration process
  Add a PersistentInt class.
2022-06-01 03:03:02 +00:00
Remi NGUYEN VAN
1a8ee102d3 Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
2022-05-31 13:06:22 +09:00
Junyu Lai
323b8b23d1 Return sorted NetworkStatsHistory am: 25c6d60f8a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18581718

Change-Id: I6335ae844d2fbbc1c325a92592da4f8d009c6fd3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 14:16:31 +00:00
Junyu Lai
25c6d60f8a 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.

Ignore-AOSP-First: Base change not in AOSP, will cherry-pick
                   immediately after
Test: atest android.net.netstats.NetworkStatsHistoryTest#testBuilder
Bug: 233825704
Change-Id: If3187384bd1e90770ca5873b8ec73e852fff543d
2022-05-26 22:04:43 +08:00
Patrick Rohr
268e1c6d2e Merge "Remove automotive restriction from enable/disableInterface" am: 345655f7bc am: 1d0e33db3a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2103746

Change-Id: Iaa4e13f6babe0074c7123c6a8728102b9d29b8a3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 02:51:26 +00:00
Patrick Rohr
345655f7bc Merge "Remove automotive restriction from enable/disableInterface" 2022-05-25 02:00:51 +00:00
Patrick Rohr
fd829a5cb2 Remove automotive restriction from enable/disableInterface
Allow calling enable/disableInterface on non-automotive devices. Also,
fixing the naming of these functions to be consistent with the API.

Test: atest EthernetManagerTest
Bug: 171872016
Bug: 225317990
Change-Id: Ic20185a855d0e639582132bf1103e0183f6f78c3
2022-05-24 03:54:38 +00:00
Lorenzo Colitti
ec2fbb7159 Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
Merged-In: Ic8647ff28fca78d579d5f759f96a864877f8158b
  (pure cherry-picked from ag/18453213)
2022-05-24 11:37:42 +08:00
Remi NGUYEN VAN
c62261f140 Ensure NetworkStats migrated snapshot is identical
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.

This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.

Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
Merged-In: I857ad18183d63d1aa16e89f89eb24009648720a2
  (pure cherry-picked from ag/18452103)
2022-05-24 11:37:12 +08:00
Yan Yan
3ca3e7cf2d Merge "Throw IAE when Network's LinkProperties is null" am: 5345fa1144 am: b5a6b0118a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2101892

Change-Id: I7f2663d1a67141b652204d6fcc97f936c2f68b33
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-23 17:59:34 +00:00
Yan Yan
be3eb3d56a Throw IAE when Network's LinkProperties is null
Improve the setUnderlyingNetwork method by throwing IAE
when Network's LinkProperties is null. Also update the
API doc to give caller more guidance in using this API

Bug: 232309601
Test: UT: IpSecServiceParameterizedTest, IpSecServiceTest,
      IpSecServiceRefcountedResourceTest, IpSecManagerTest, VpnTest
Test: CTS: IpSecManagerTest, IpSecManagerTunnelTest, Ikev2VpnTest
Test: make doc-comment-check-docs
Change-Id: Idab4706b0db42ed2222fb48b168589ed005d2f2f
2022-05-20 17:03:07 -07:00
Lorenzo Colitti
b36e57a004 Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
2022-05-18 23:51:03 +08:00
Remi NGUYEN VAN
3776d862e2 Ensure NetworkStats migrated snapshot is identical
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.

This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.

Ignore-AOSP-First: in a topic with internal-only changes
Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
2022-05-18 23:51:03 +08:00
Junyu Lai
108d20f84a [MS81] Support remove history before cutoff timestamp
This is needed to ensure corrupted data can be clean up if
the data migration process dones't go well.

Test: NetworkStatsCollectionTest
Bug: 197717846
Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
(cherry picked from commit 306a00316c)
Merged-In: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
2022-05-16 05:53:02 +00:00
Junyu Lai
306a00316c [MS81] Support remove history before cutoff timestamp
This is needed to ensure corrupted data can be clean up if
the data migration process dones't go well.

Test: NetworkStatsCollectionTest
Bug: 197717846
Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
2022-05-12 16:31:39 +08:00