Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Merge changes from topic "PermissionMonitorOnHandlerThread"
* changes:
  Add synchronized to UidRange getter and dump methods
  Deal with permission update on handler thread
  Running PermissionMonitor#startMonitoring on handler thread

Paul Hu   authored and   Gerrit Code Review   commited 2022-11-23 02:59:17 +00:00
562cdacfee
Deal with permission update on handler thread
To ensure that permission cannot change while CS is doing works,
scoring networks, sending callbacks, etc. So making all
permission update are running on handler thread.

Bug: 232048835
Test: FrameworksNetTests CtsNetTestCases
Change-Id: I5380ec8ff1282a1056d9063848e0fff8b3a570ec

Paul Hu   commited 2022-11-22 07:18:36 +00:00
51f816be4a
Merge "Wait for launcher is shown after calling pressHome"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-11-22 07:06:16 +00:00
a814e9c364
Wait for launcher is shown after calling pressHome
In current code, the test will call pressHome before show
network notification but it does not verify the home screen
is shown. The test might be failed due to the notification
shade is still opened. Thus adding an assertion to verify
the launcher is shown.

Bug: 255643296
Test: FrameworksNetTest:NetworkNotificationManagerTest
Change-Id: Iee3476a26030b9ba72994dee624e0e6974c9369f

Aaron Huang   commited 2022-11-21 10:47:58 +00:00
2c07b827e7
Merge "Refactor CarrierPrivilegeAuthenticatorTest"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-18 12:05:53 +00:00
adb9c9e83a
Merge "Add MdnsNsecRecord"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-11-17 08:00:15 +00:00
0f92b69af7
Merge changes I0f8e6590,I61a1bb91
* changes:
  Add MdnsAnyRecord
  Add constructors to MDNS records

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-11-16 09:12:57 +00:00
b683dfcea5
Add MdnsNsecRecord
NSEC records are included as mDNS negative responses, as per
RFC6762 6.1.

Bug: 241738458
Test: atest
Change-Id: I1546a2c10447ad46321f595b714c7ee7f6dc34c7

Remi NGUYEN VAN   commited 2022-11-16 15:57:30 +09:00
3ce3a4a9ca
Merge "Verify bypassability in the VPN network capabilities"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-11-16 05:57:00 +00:00
b7577c6d42
Merge "ethernet: consolidate interface enabling functions in EthernetTracker"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-16 05:51:42 +00:00
b6f2a3e587
Add MdnsAnyRecord
The record is useful for mDNS questions in mDNS probes.

Bug: 241738458
Test: atest
Change-Id: I0f8e659048b6e1d7c3ae1640fbd2d57d723ea9b1

Remi NGUYEN VAN   commited 2022-11-16 14:40:47 +09:00
e8d3e6d58c
Refactor CarrierPrivilegeAuthenticatorTest
Refactor this test to make it easier to test the no-op
refactoring coming as a follow-up

Test: this
Change-Id: I47c81bdec2b8f9575835ba664b61721d5f2c69ff

Chalard Jean   commited 2022-11-15 19:27:56 +09:00
23890c29c5
Verify bypassability in the VPN network capabilities
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I6600714e5fc7c5d78fa7b8bb29c0c8840ec69637

chiachangwang   authored and   Chiachang Wang   commited 2022-11-15 05:36:24 +00:00
d0a2805616
Merge "Remove unnecessary permission mock for registerSystemDefaultNetwork"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-11-15 02:23:39 +00:00
c1294c2584
Merge "[Feature sync] Resolve class-level nullness suppression"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-10 13:53:31 +00:00
0448f36d60
Merge "Revert "Partially enforce permission when calling getNetworkInfoForUid""
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-10 12:13:56 +00:00
016269fbb8
Revert "Partially enforce permission when calling getNetworkInfoForUid"
This reverts commit 163cb98751.

Reason for revert: b/257407201

Change-Id: I412140117d25f4a4b439fff5aaa50785f33b0689

Junyu Lai   authored and   Gerrit Code Review   commited 2022-11-10 03:19:06 +00:00
d0cf7784dc
[Feature sync] Resolve class-level nullness suppression
This is a chery-picked commit from internal branch which is to
add nullability to reslove the nullness suppression.

Bug: 242631897
Bug: 254155029
Test: atest FrameworksNetTests
Change-Id: I289b0408c0c4ccdefc498d3b6d3f381c2b04132e

Paul Hu   commited 2022-11-10 01:57:46 +00:00
6c74a13512
Merge "[Feature sync] Fix issue where multiple SRV records with same host are not fully resolved"
Paul Hu   authored and   Gerrit Code Review   commited 2022-11-09 06:38:22 +00:00
b800e5903b
Merge "Allow USE_RESTRICTED_NETWORKS for registerSystemDefaultNetworkCallback"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-09 05:49:54 +00:00
31ee1c1121
Merge "Notify NetworkStatsService if TEMPORARILY_NOT_METERED changed"
Aaron Huang   authored and   Gerrit Code Review   commited 2022-11-08 11:55:53 +00:00
4bf6a92a0a
Notify NetworkStatsService if TEMPORARILY_NOT_METERED changed
Currently 5G usage includes both metered and unmetered usage.
To support 5G unmetered usage metrics, unmetered usage should
be separated from the 5G usage. Thus, ConnectivityService needs
to inform NetworkStatsService if TEMPORARILY_NOT_METERED has
changed. Then NSS will count temporarily not metered usage as
unmetered.

Bug: 222339311
Bug: 183776809
Test: FrameworksNetTests:ConnectivityServiceTest
Change-Id: I0c7e1eb98925184f36e322e09b4d3d8c6f056fa6

Aaron Huang   commited 2022-11-08 16:01:54 +08:00
c067c87672
Merge "Make onPackage[Added|Removed] as non-public methods"
Paul Hu   authored and   Gerrit Code Review   commited 2022-11-07 01:35:11 +00:00
bd92295269
Merge "Update tests for new isValidationRequired args"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-04 11:14:41 +00:00
94ec30203b
Update tests for new isValidationRequired args
Bug: 253989196
Test: atest NetworkMonitorTest

Change-Id: I70633d748cc09a7f695cdc2b4c835d5bf187ec3d

Remi NGUYEN VAN   commited 2022-11-04 17:09:50 +09:00
21093ce089
Merge "Fix errorprone warnings that should be errors"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-02 19:38:39 +00:00
edceea23f4
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

Cole Faust   commited 2022-11-02 10:13:14 -07:00
22f05839f5
Remove unnecessary permission mock for registerSystemDefaultNetwork
registerSystemDefaultNetwork now can be accessed via
CONNECTIVITY_USE_RESTRICTED_NETWORKS, there is no need
to mock NETWORK_SETTINGS prior to test.

Test: atest com.android.server.ConnectivityServiceTest
Change-Id: I408094959286f3782496ce7f356f84a6a47c0902

Junyu Lai   commited 2022-11-02 14:17:33 +08:00
f2edd6477d
Allow USE_RESTRICTED_NETWORKS for registerSystemDefaultNetworkCallback
Some callers (e.g. iwlan) need to learn about system default
network but they cannot have NETWORK_SETTINGS permission.
To allow them to use this API but prevent from misuse by
unprivileged apps, enforce USE_RESTRICTED_NETWORKS for this API.

Test: atest com.android.server.ConnectivityServiceTest#testRegisterPrivilegedDefaultCallbacksRequireNetworkSettings android.net.cts.ConnectivityManagerTest#testRegisterNetworkCallback
Fix: 242456635
Change-Id: I80ab27445af874328c9c0f4814a8fbf035ae5df4

Junyu Lai   commited 2022-11-02 14:16:36 +08:00
aa4ad8c2d1
Use expect instead of expectCallback
This use was checked in after the cleanup that changed the latter into the former

Bug: 157405399
Test: FrameworksNetTests
Change-Id: I2b27ad712ee218322209bbc6af6e8147a0a41430

Chalard Jean   authored and   Jean Chalard   commited 2022-11-02 05:40:03 +00:00
0e184ac0dd
Merge "Fix policy leak by deleting forwarding security policies"
Yan Yan   authored and   Gerrit Code Review   commited 2022-11-02 00:47:09 +00:00
18ddc7daab
Test dynamically calculated VPN MTUs
This change adds testing for VPN MTU calculations, and in particular
cases where IPv6 is not supported due to MTUs being too small.

Bug: 245612827
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ib064e6670244cf3b53b5d03bd62c86b2139ff32a

lucaslin   authored and   Lucas Lin   commited 2022-11-01 08:09:37 +00:00
afe76f3b77
Fix policy leak by deleting forwarding security policies
Fix the policy leak by deleting forwarding policies when deleting
the IPsec tunnel interface.

Bug: 254566085
Test: atest IpSecServiceParameterizedTest (new tests added)
Change-Id: I29dd4810abb978fe886776b2fbacdfc74325436d

Yan Yan   commited 2022-10-31 22:51:08 +00:00
f4eceba0a9
Merge "[Feature sync] Fix flaky test in MdnsSocketClientTests"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-10-28 08:25:08 +00:00
9a726855f2
[Feature sync] Fix flaky test in MdnsSocketClientTests
The interface index is only propagated if there is an A/AAAA
record in the response. Since the responses here are not entirely
controlled in the test, we just want to verify that we get a
response with the target we expect.

Verified by running the test 1400 times via --runs_per_test flag.

Bug: 254155029
Fix: 255922416
Test: atest MdnsSocketClientTests#startDiscovery_andPropagate\
      InterfaceIndex_includesInterfaceIndex --iteration 100
Change-Id: Icb0fe7a58a1e626b7f781ff24c2389a3095d4dc6

Paul Hu   commited 2022-10-28 10:26:15 +08:00
cd04d83e68
ClatCoordinatorTest: override test generateIpv6Address correctly
aosp/2267683 adds the new param "mark" in generateIpv6Address and
TestDependencies#generateIpv6Address needs to override for this change
correctly.

Change-Id: Ia526bcdf80a428948d55a28bd5adec405530a634
Test: TH

Nucca Chen   commited 2022-10-27 10:11:28 +00:00
f76b8d67f8
Merge "Notify NetworkStats only when interfaces changed in updateLinkProperties"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-10-27 06:49:33 +00:00
0f4cb380f0
Merge "Test session reset on VPN data stall"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-10-27 05:13:45 +00:00
c39c3759ca
Test session reset on VPN data stall
Add tests to verify ike session being triggered when data stall.

Bug: 238692379
Test: atest FrameworksNetTests
Change-Id: I656ea0973072b0bbdd54863eccbe105adb02d6ad

chiachangwang   commited 2022-10-26 03:05:59 +00:00
f60356f273
Merge "[Feature sync] Propagate network interface index to MdnsServiceInfo"
Paul Hu   authored and   Gerrit Code Review   commited 2022-10-26 01:17:10 +00:00
e3aa5c0e06
Merge "[Feature sync] fix handling arbitrary bytes in TXT value"
Paul Hu   authored and   Gerrit Code Review   commited 2022-10-26 01:05:55 +00:00
df7335f3cd
ethernet: consolidate interface enabling functions in EthernetTracker
I want to add some logic to setInterfaceEnabled in a follow up, so
consolidating the functions prevents redundancy.

Test: atest EthernetManagerTest
Change-Id: I5756a09be392a970bc545612220595c6984f2b54

Patrick Rohr   commited 2022-10-25 19:15:17 +00:00
6150134515
Merge "Bypass VPN lockdown for clat initialization"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-10-25 07:43:12 +00:00
9592fa89b3
Notify NetworkStats only when interfaces changed in updateLinkProperties
In ConnectivityService, updateLinkProperties calls NetworkStats
even though the ip address or interface name has not changed and
only the tcp buffer size has changed. This is noisy and could
be problematic when RAT change occurs frequently, since when
RAT changes tcp buffer size configuration also changes.

This CL also fixes a wrong nullability annotation where the oldLp
of updateLinkProperties could be null when updateNetworkInfo
is called.

Test: atest ConnectivityServiceTest#testStatsIfacesChanged
Fix: 232048480
Change-Id: Ic226eb4a8aa1f38cba293510813f1cb55f0ea658

Junyu Lai   commited 2022-10-25 15:27:53 +08:00
2ed7d4182a
Merge changes I0789d9bd,Idf4cf74a
* changes:
  Disable ignoring validation on roam just after boot.
  Minor cleanups for ignore validation failures after roam tests.

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-10-25 02:15:29 +00:00
a40faea28d
Bypass VPN lockdown for clat initialization
This allows clat to initialize properly when VPNs are configured
with "Block connections without VPN", rather than to error out with
"no IPv6 addresses were available for clat".

This issue primarily affects particular mobile networks configured
with NAT64 (without direct IPv4 connectivity).

Bug: 255040839
Change-Id: I4a8ee0295e0f5d1e330f7529856347b8bd10360c

t-m-w   authored and   Maciej Żenczykowski   commited 2022-10-25 01:54:51 +00:00
130e75b0ab
Merge "Improve tests for notifyIfacesChangedForNetworkStats."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-10-24 23:35:35 +00:00
5edd296baa
Disable ignoring validation on roam just after boot.
shouldIgnoreValidationFailureAfterRoam will incorrectly return
true in the first few seconds after boot even if the network
never roamed. This is extremely unlikely to happen, but add a
check for that just in case.

Fix: 230450214
Test: new unit test
Change-Id: I0789d9bdaa0bd9e78673e8f4248a2ca610052f1e

Lorenzo Colitti   commited 2022-10-24 23:28:56 +09:00
580d0d53be
Minor cleanups for ignore validation failures after roam tests.
- Confirm that the default network switches to cell for the right
  reason.
- Test the behaviour on T as well (always disabled).
- Minor code cleanups.

Bug: 216567577
Test: test-only change
Change-Id: Idf4cf74aec3d40246f67519d211dbd45e739a6dc

Lorenzo Colitti   commited 2022-10-24 23:28:54 +09:00
6bf9bb3e58
[Feature sync] Fix issue where multiple SRV records with same host are not fully resolved
For Matter, a device may have a single host with multiple A/AAAA
records, but multiple PTR/SRV pairs that represent different
operational identities for the same device.

Currently, MdnsResponseDecoder looks for only a single matching
MdnsResponse by hostname when looping through the A/AAAA records
(which will leave the second response incomplete). Updated with a
flag that will allow returning all MdnsResponses which match the
given hostname and update the Inet records for all responses.

Bug: 254155029
Test: atest FrameworksNetTests
      Verified with a Matter device with two identities that the
      second response is incomplete without this change.
      Additionally, added unit tests to verify the before and
      after behavior with a real packet capture from the device.
Change-Id: Ic4a101b305c039f6cd7fd557246a2bfdaf0c781a

Paul Hu   commited 2022-10-24 07:29:44 +00:00
e62d151d1e