Commit Graph

2690 Commits

Author SHA1 Message Date
Hungming Chen
e28d70804d EthernetTetheringTest: remove isEthernetTetheringSupported
isEthernetTetheringSupported() has been not used since
using TetheringManager#isTetheringSupported in aosp/2143272.

Bug: 258637850
Test: EthernetTetheringTest
Change-Id: Ifc560613301393eeadb6df11688944b2dc629c35
2022-11-17 10:59:33 +08:00
Hungming Chen
d15eb88619 TetheringConfiguration: force to select upstream automatically on U+
Simply the upstream selection since U+ device for tethering refactor.

Changes:
1. Support automatic mode only on U+ device.

2. Add two tethering tests to make sure that the resource config can't
   control automatic mode anymore. Expect that always automatic mode
   on U+ device. Also limit some existing tethering tests for R, S,
   or T.
   Changes of TetheringTest:
   - testAutomaticUpstreamSelectionWithConfigDisabled (U+) [new]
   - testLegacyUpstreamSelection (T-)
   - testChooseDunUpstreamByLegacyMode (T-)
   - testChooseDunUpstreamByAutomaticModeWithConfigDisabled (U+) [new]

3. Add two tethering configuration tests to make sure that automatic
   mode is always enabled no mater what the resource config or flag
   are on U+ device. Also limit some existing tethering tests for R,
   S, or T.
   Changes of TetheringConfiguration:
   - testChooseUpstreamAutomatically (T-)
   - testChooseUpstreamAutomaticallyAfterT (U+) [new]
   - testChooseUpstreamAutomatically_FlagOverride (R)
   - testChooseUpstreamAutomatically_FlagOverrideOnSAndT (S, T)
     (Renamed from testChooseUpstreamAutomatically_FlagOverrideAfterR)
   - testChooseUpstreamAutomatically_FlagOverrideAfterT (U+) [new]

Bug: 257941865
Bug: 257408654
Test: atest TetheringTest
Change-Id: I7ace317a1529177a84557741dc07d732b7f8cf89
2022-11-15 22:14:21 +08:00
Mark Chien
3074dd6cd5 Merge "Remove try/catch of UnsupportedOperationException" 2022-11-15 12:15:31 +00:00
Treehugger Robot
6660d2375f Merge "Add isTetheringFeatureEnabled which use tethering namespace" 2022-11-15 08:58:23 +00:00
Mark
25d3ac54fe Add isTetheringFeatureEnabled which use tethering namespace
This is no-op change. Tethering shouldn't use connectivity namespace
because it already be used for NetworkStack module. The new feature
should check isTetheringFeatureEnabled instead.

Bug: 238274852
Test: atest TetheringTests
Change-Id: I009f654d0bf8df7051b822e666e3206dd70a5523
2022-11-14 15:51:55 +00:00
Michael Groover
a49c13f7e8 Merge "Add not exported flag to receiver in EntitlementManager" 2022-11-11 15:32:07 +00:00
Michael Groover
3d6b8c83ce Add not exported flag to receiver in EntitlementManager
Android T allows apps to declare a runtime receiver as not exported
by invoking registerReceiver with a new RECEIVER_NOT_EXPORTED flag;
receivers registered with this flag will only receive broadcasts from
the platform and the app itself. However to ensure developers can
properly protect their receivers, all apps targeting a future
platform release and registering a receiver for non-system
broadcasts must specify either the exported or not exported flag
when invoking #registerReceiver; if one of these flags is not
provided, the platform will throw a SecurityException. This commit
adds the RECEIVER_NOT_EXPORTED flag to the receiver in
EntitlementManager since this broadcast is sent as a PendingIntent
alarm.

Bug: 234659204
Test: atest com.android.networkstack.tethering.EntitlementManagerTest
Change-Id: I46c2df038ccf7669636166f50fe0331efcc42e4b
2022-11-10 12:20:35 -06:00
Remi NGUYEN VAN
5033f855ff Merge "Add libconnectivity_native" 2022-11-07 02:07:45 +00:00
Remi NGUYEN VAN
fb70eba6bf Add libconnectivity_native
The library provides an interface to interface with the
ConnectivityNative service, and implement port blocking APIs.

Bug: 179733303
Test: atest connectivity_native_test
Change-Id: Iad1c84b5eeab835aca14a2db72a900e099aa3c1c
2022-11-03 21:01:26 -07:00
Treehugger Robot
edceea23f4 Merge "Fix errorprone warnings that should be errors" 2022-11-02 19:38:39 +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
Motomu Utsumi
c146d8753b Merge changes from topic "cronet_in_tethering"
* changes:
  Rename org.chromium.net.cronet to framework-cronet
  Add Cronet .so and .jar to tethering apex
2022-11-02 08:18:36 +00:00
Harshit Mahajan
956300ff15 Merge "[TetheringGoogle] Remove explicit targetSdkVersion" 2022-10-28 09:17:18 +00:00
Victor Liu
702a2ab49c Merge "Revert "Use r launch defaults for dcla for com.android.tethering."" 2022-10-27 19:24:52 +00:00
Brad Hinegardner
b40444a07a Revert "Use r launch defaults for dcla for com.android.tethering."
This reverts commit d44b293171.

Reason for revert: b/255986188

Change-Id: Ida999c15203b77aae1420be96dece22396c4ede1
2022-10-27 19:16:26 +00:00
Nada Hussein
b4c9d59b86 Merge "Use r launch defaults for dcla for com.android.tethering." 2022-10-27 16:21:42 +00:00
Motomu Utsumi
402b18d56d Add Cronet .so and .jar to tethering apex
Also remove cronet apex related modules and files

Bug: 251054736
Test: atest CronetApiTest
Change-Id: Idd41785fd2f74a153c5bb03f4c00c7cccdb50e7a
2022-10-27 19:12:29 +09:00
Harshit Mahajan
e210c27140 [TetheringGoogle] Remove explicit targetSdkVersion
Going forward targetSdkVersion would be set by build system.
It would be by default set to 10000 before SDK finalization,
and updated to the new API level after finalization.

Effectively it would mean:
1. '10000' in aosp and internal master
2. Finalized number in development branches like "33" in "tm-dev"
3. As sdk hasn't been finalised in "udc-dev", it would be "10000"
which would be automatically updated to finalized version after sdk finalization.

Removing the target sdk version declaration from the blueprint and manifest files.
More details can be found here go/mainline-modules-target-sdk-version-fix

Bug: b/242296003
Test: croot; sdks=`find ./out -name 'TetheringGoogle.apk' | grep -v .intermediates`; echo $sdks; for sdk in $sdks;do aapt2 dump badging `echo $sdk` | grep targetSdkVersion:; done
1. outputs 33 in tm-mainline-prod
2. outputs 10000 in master

Change-Id: I2657901f066a5220ae0f807846b32b9c41afcce9
2022-10-27 09:47:16 +00:00
Treehugger Robot
319c97705f Merge changes I63467371,Id4405b70
* changes:
  BpfCoordinatorTest: add testDumpDoesNotCrash
  Move error count BPF map initialization into class Dependencies
2022-10-27 07:27:08 +00:00
Nucca Chen
db4ac8ea40 Merge "IpServerTest: add test addRemoveTetherClient" 2022-10-26 06:49:22 +00:00
Hungming Chen
df57abfd4b BpfCoordinatorTest: add testDumpDoesNotCrash
Simple dump test for improving tethering test coverage.

Bug: 255466740
Test: atest BpfCoordinatorTest
Test: dump the content of testDump

Output:
mIsBpfEnabled: true
Polling not started
Stats provider registered
Upstream quota: {}
Polling interval: 5000 ms
Bpf shim: mBpfDownstream6Map{OK}, mBpfUpstream6Map{OK}, mBpfDownstream4Map{OK}, mBpfUpstream4Map{OK}, mBpfStatsMap{OK}, mBpfLimitMap{OK}, mBpfDevMap{OK}
Forwarding stats:
 <empty>
BPF stats:
 ifindex: 1001: rxPackets: 0, rxBytes: 0, rxErrors: 0, txPackets: 0, txBytes: 0, txErrors: 0

Forwarding rules:
 IPv6 Forwarding rules by downstream interface:
  [null]: iif(iface) oif(iface) v6addr [srcmac] [dstmac]
   1001(rmnet0) 1003(1003) 2001:db8::1 [12:34:56:78:90:ab] [00:00:00:00:00:0a]
 IPv6 Upstream: iif(iface) [inDstMac] -> oif(iface) etherType [outSrcMac] [outDstMac]
  1003(1003) [12:34:56:78:90:ab] -> 1001(rmnet0) 86dd [00:00:00:00:00:00] [00:00:00:00:00:00]
 IPv6 Downstream: iif(iface) [inDstMac] neigh6 -> oif(iface) etherType [outSrcMac] [outDstMac]
  1001(rmnet0) [00:00:00:00:00:00] 2001:db8::1 -> 1003(1003) 86dd [12:34:56:78:90:ab] [00:00:00:00:00:0a]
 IPv4 Upstream: proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  tcp [12:34:56:78:90:ab] 1003(1003) 192.168.80.12:-3087 -> 1001(rmnet0) 1.0.0.1:-3087 -> 140.112.8.116:443 [00:00:00:00:00:00] -
 IPv4 Downstream: proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  tcp [00:00:00:00:00:00] 1001(rmnet0) 140.112.8.116:443 -> 1003(1003) 1.0.0.1:-3087 -> 192.168.80.12:-3087 [00:00:00:00:00:0a] -

Device map:
 ifindex (iface) -> ifindex (iface)
  1001 (rmnet0) -> 1001 (rmnet0)
Client Information:
 <empty>
IPv4 Upstream Indices:
 <empty>

Forwarding counters:
 INVALID_IPV4_VERSION: 1000

Change-Id: I6346737157936cff7e164bbfe78d9a98dab3395a
2022-10-26 05:48:03 +00:00
Hungming Chen
771bc597b6 Move error count BPF map initialization into class Dependencies
The preparation for testing BpfCoordinator#dump().
Used to wrap error count BPF map access to avoid SYS_SECCOMP on some
test device. Ex: cuttlefish.
https://android-build.googleplex.com/builds/tests/view?invocationId=I01200010101524265&testResultId=TR03228338750686157

Bug: 255466740
Test: atest BpfCoordinatorTest

Change-Id: Id4405b70bc6d500b35943b4f81b88e7515fff3b0
2022-10-26 13:47:19 +08:00
Mark Chien
381e339647 Merge "Remove unused TetheringConfigurationParcel fileds" 2022-10-21 07:50:23 +00:00
Nucca Chen
df46aeb098 Merge "Add toString() to Ipv6ForwardingRule" 2022-10-14 07:27:03 +00:00
Wayne Ma
a0824ead07 Merge "Add new fields - |upstream_events| and |duration_millis| in stats.proto" 2022-10-14 02:23:31 +00:00
Mark
0fd561386a Remove try/catch of UnsupportedOperationException
registerLocalOnlyHotspotSoftApCallback implementation is availble in
AOSP, remove unnecessary UnsupportedOperationException catch.

Bug: 240113156
Test: device can boot sucessfully
Change-Id: If010879ddc58285cf01cc8794b4c3ded7d0b0316
2022-10-13 07:43:05 +00:00
Chalard Jean
88edc35da6 Keep primitive members used by MessageUtils.
This includes in particular {Full,Network}Score.POLICY_* members
which were removed recently.

Before :
  Policies : 55&62&63
After :
  Policies : EVER_EVALUATED&EVER_VALIDATED&IS_VALIDATED

This patch also unifies the directives under Tethering/ for
simplicity.

Test: adb logcat & dumpsys connectivity & dumpsys tethering
Change-Id: I3d231fbaaebe233b2633da8bb880b5ad1613a32f
2022-10-13 13:11:53 +09:00
Nada Hussein
d44b293171 Use r launch defaults for dcla for com.android.tethering.
DCLA (Dynamic Common Library Apex) is a mechanism used by Mainline, which places shared c++ libraries into a separate apex in order to de-duplicate them, with the goal of reducing the overall size of a train.

This change results in two packages being built:
If the APEX_BUILD_FOR_PRE_S_DEVICES=1 is set, the apex will have min_sdk set to 30 as before, and this will deliver to Android 11.
If the flag is not set, the second package will have min_sdk set to 31, and will deliver to Android 12 and beyond.

If developers intend to build an apex for use in R as before, they must set the flag APEX_BUILD_FOR_PRE_S_DEVICES=1, which will set the min_sdk to 30 as before. If not set, the new default behavior will set the min_sdk to 31.

This new variant will be post-processed and trimmed by Mainline infrastructure, and the resulting trimmed module can only be installed on S+ devices, requiring that we set the min_sdk to 31.

Test: APEX_BUILD_FOR_PRE_S_DEVICES=1 m com.android.tethering & verify
      sdk_version = 30
Test: m com.android.tethering & verify sdk_version = 31
Bug: 247762791
Change-Id: I2d6563867e3ca36f678fe0abadbe197946a82094
2022-10-12 20:14:08 +00:00
Wayne Ma
fe6ecc6333 Add new fields - |upstream_events| and |duration_millis| in stats.proto
Revise annotations in previous fields and deprecate |upstream_type|.

Ignore-AOSP-First: Merge conflict if submits in AOSP first.
Bug: 153942334
Test: statsd_testdrive 303
Change-Id: Id4d594f9238e18266dce5bf2ba238c1f86f655db
(cherry picked from commit 71c8495cea)
Merged-In: Id4d594f9238e18266dce5bf2ba238c1f86f655db
2022-10-12 05:32:12 +00:00
Hungming Chen
afdf104d68 IpServerTest: add test addRemoveTetherClient
Bug: 250552545
Test: atest IpServerTest
Change-Id: Id8e801ccbf9a958c6b82de6022165d921761a86f
2022-10-04 23:14:55 +08:00
Hungming Chen
de5fb7370b Add toString() to Ipv6ForwardingRule
Needed because default Ipv6ForwardingRule#toString doesn't dump
actual data. It is hard to know why two rule comparison failed
in the test failure.

Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: Iaf29c888238573c7c9a0a4e0bd65fbe468084e51
2022-10-04 23:14:55 +08:00
Hungming Chen
09d163dfa8 BpfCoordinator: ignore stopping event monitoring if never started
Ignore stopping monitoring if the monitor has never started
for a given IpServer.

Also fix the related bug in
BpfCoordinator#testStartStopConntrackMonitoring.

Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: I7ac71f0ed52bf52244aadaa3c90ca8df239873e4
2022-10-03 11:56:38 +00:00
Junyu Lai
3e7778805b Merge "Revert^2 "[ST02.2] Use the getters of DnsHeader"" 2022-09-22 02:39:42 +00:00
Sorin Basca
14343732c3 Fix errorprone 2.15.0 errors
Bug: 246761518
Test: RUN_ERROR_PRONE=true m javac-check lint-check dist
Change-Id: I4b81ef161fab5ee80a1713de87b89500a88e625e
2022-09-21 13:29:19 +01:00
Treehugger Robot
75a819d9ff Merge "EthernetTetheringTest: test testTetherClatTcp on S+ device" 2022-09-21 02:03:45 +00:00
Hungming Chen
c79efc8e8e EthernetTetheringTest: test testTetherClatTcp on S+ device
Only test testTetherClatTcp on S+ device because R device test
is blocked on b/234727688.

Bug: 234727688
Test: atest EthernetTetheringTest
Change-Id: I65a4a8c4fe13b8320b036380b9038af094ac95a5
2022-09-20 10:24:32 +00:00
Nucca Chen
e729389bd2 Merge "EthernetTetheringTest: add testTetherClatTcp" 2022-09-19 15:55:13 +00:00
Nucca Chen
19adc7adbc Merge changes from topic "test-tethering-icmp"
* changes:
  EthernetTetheringTest: add testTetherTcpV6
  EthernetTetheringTest: add testTetherTcpV4
  EthernetTetheringTest: add testIcmpv4Echo
  EthernetTetheringTest: add testTetherClatIcmp
2022-09-19 15:53:43 +00:00
Hungming Chen
b4f8a08825 EthernetTetheringTest: add testTetherClatTcp
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: Ic66c22040ca8aa29b8399fabed066107a736e842
2022-09-19 19:43:34 +08:00
Hungming Chen
2ef51d11eb EthernetTetheringTest: add testTetherTcpV6
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I476a8d984eb8ccb6b2e64d6c36dbb455029a4c51
2022-09-19 19:43:30 +08:00
Hungming Chen
53ce3df628 EthernetTetheringTest: add testTetherTcpV4
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I411ac8dc0a36413e2e65633375218b25c412e004
2022-09-19 19:43:14 +08:00
Hungming Chen
e2fb681aec EthernetTetheringTest: add testIcmpv4Echo
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I96278c17ce97b63860b9379675c6ac2941b4016f
2022-09-19 15:53:15 +08:00
Hungming Chen
90551145ae EthernetTetheringTest: add testTetherClatIcmp
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I9dad9b559e0963a2d3a3f6a4c8d3b159a185801d
2022-09-19 15:53:11 +08:00
Junyu Lai
4c93f83290 Revert^2 "[ST02.2] Use the getters of DnsHeader"
Reason for revert: November mainline trains has been branched,
                   re-submit CLs and request API review.

Re-submitted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets

Change-Id: Ifb727e464d3523bd8dee0f2d919a8fb4a9d207c5
2022-09-16 07:41:27 +00:00
Maciej Żenczykowski
49e9660e0e handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
aosp/1536721 is merged, so this code duplication should not be needed any more.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic05adfc46495086d7f681322aac7acddc30a2260
2022-09-16 06:35:32 +00:00
Maciej Żenczykowski
1686030e6c Improve accept/reject comment readability.
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If4cad0b83d2e62bfbbc0f65e9ffeefc69381c371
2022-09-15 18:46:10 +00:00
Paul Duffin
dadf95ff6a Merge "Make the hiddenapi*-tiramisu.txt files part of framework-connectivity-t" 2022-09-15 11:55:36 +00:00
Treehugger Robot
1949d98e81 Merge "Revert "UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE"" 2022-09-14 14:25:13 +00:00
Treehugger Robot
4e81086326 Merge "EthernetTetheringTest: toggle wifi while test network is not selected" 2022-09-14 14:25:13 +00:00
Hungming Chen
d09bb0773a EthernetTetheringTest: toggle wifi while test network is not selected
Used to avoid flaky test because upstream changed events
order can't be guaranteed. Once tethering choose non-test
upstream {wifi, ..}, test network wont't be chosen.

Fix flaky tests which are using initTetheringTester():
testIcmpv6Echo
testTetherClatUdp
testTetherUdpV4_VerifyBpf
testTetherUdpV4
testTetherUdpV4Dns
testTetherUdpV6

Moreover, add permission ACCESS_WIFI_STATE to AndroidManifest.xml
to avoid nested runAsShell while using CtsNetUtils to access WIFI.

STACKTRACE:
java.lang.IllegalStateException: adoptShellPermissionIdentity calls must not be nested
at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:49)
at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:70)
at com.android.testutils.TestPermissionUtil.runAsShell$default(TestPermissionUtil.kt:65)
at com.android.testutils.TestPermissionUtil.runAsShell(Unknown Source:16)
at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:293)
at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:255)
at android.net.cts.util.CtsNetUtils.toggleWifi(CtsNetUtils.java:160)

Bug: 243314243
Test: atest EthernetTetheringTest
Change-Id: I814899ae71f5c302d490a0dd81d7210ac138faa5
2022-09-14 04:03:24 +00:00