156 Commits

Author SHA1 Message Date
Treehugger Robot
794e6ba285 Merge "Address comment from aosp/1232197" 2020-06-09 17:19:33 +00:00
Treehugger Robot
6856cb3182 Merge "[BOT.6] Make BpfCoordinator to support data limit" 2020-06-09 12:58:20 +00:00
Hungming Chen
a4c9570222 [BOT.6] Make BpfCoordinator to support data limit
The BPF tethering coordinator listens to the forwarding rule
changes for updating data limit which is applied in the following
conditions.
- After adding the first rule on a given upstream, add data limit.
- After removing the last rule on a given upstream, clear data limit.
- The service applies a new data limit on current upstream.

The reason for relying on rule changes is because the Tethering and
IpServer objects have multi-internal state machines. It is hard to
synchronize all of their states.

Note that the data limit cleanup for stopping or switching upstream
relies on offload rules are all removed as well.

Bug: 150736748
Test: manual
Change-Id: I829d36339973f9473fe6b616c48aa288f18d1c46
2020-06-09 17:33:03 +08:00
Lorenzo Colitti
8cf0793c43 Merge "[BOT.9] Add unit test for data warning in BpfCoordinator" 2020-06-09 02:22:59 +00:00
Paul Hu
720a4dac92 Merge "Make tether settings intent explicit" 2020-06-08 10:31:21 +00:00
Hungming Chen
613af4b288 [BOT.9] Add unit test for data warning in BpfCoordinator
Bug: 150736748
Test: atest BpfCoordinatorTest
Change-Id: Ic1f37de75b064d7c8717e1b496e13174bb8693ec
2020-06-08 17:31:51 +08:00
paulhu
05ebcd34c2 Make tether settings intent explicit
Currently tethering notification is sending a pending intent for
redirecting user to tether settings page. However, this intent
is implicit that only create with
Settings.ACTION_TETHER_SETTINGS. For security reasons, this
intetnt should specify an explicit component to be delivered to.
Thus, specify the settings package name to this intent.

Test: atest TetheringTests
Bug: 156353008
Change-Id: I49187aee8a004caa890e2a73c0a28d280215c7d4
2020-06-08 06:04:19 +00:00
Treehugger Robot
618edf7fda Merge "Gate exemptFromEentitlementCheck by Network_STACK permission" 2020-06-02 03:31:24 +00:00
Nucca Chen
c869c9df4c Merge changes from topic "tether_offload_data_limit"
* changes:
  Make tethering module to use netd_aidl_interface-unstable-java
  [BOT.5] Move class Ipv6ForwardingRule from IpServer to the coordinator
  [BOT.3] Add unit test for polling network stats in the coordinator
  [BOT.2] Create a coordinator and stats provider to provide tether stats
  [BOT.1] Add a class ForwardedStats in TetheringUtils
2020-06-01 23:33:24 +00:00
Paul Hu
f3022ca483 Merge "Use Class#getSimpleName instead of KClass#getSimpleName" 2020-06-01 06:43:13 +00:00
Hungming Chen
c0c30326c4 [BOT.3] Add unit test for polling network stats in the coordinator
Verify that the coordinator could fetch tether stats from BPF maps and
report the network stats to the service.

Bug: 150736748
Test: atest BpfCoordinatorTest
Change-Id: Ib1756159a2047c5db7d31359b0f288f840bd1bb1
2020-05-29 20:23:31 +08:00
Hungming Chen
2c90fda34c [BOT.2] Create a coordinator and stats provider to provide tether stats
Make BPF tethering offload coordinator, BpfCoordinator,
registers a network stats provider, BpfTetherStatsProvider, and
provide the tethering stats from the BPF map.

Bug: 150736748
Test: new test BpfCoordinatorTest

Change-Id: I22e71f87b67668f7e733e4f215d93bf5b2c9380d
2020-05-29 20:23:22 +08:00
markchien
7e9b5c0875 Gate exemptFromEentitlementCheck by Network_STACK permission
Shell has TETHER_PRIVILEGED permission. To avoid any service to adopt
shell identity by lunching service with Shell process, gate
exemptFromEentitlementCheck by NETWORK_STACK.

Bug: 157702014
Test: atest TetheringCoverageTests
Change-Id: I6ddfda23d36ea9981e3e1eb5a87767f452a65852
2020-05-29 06:46:22 +00:00
Mark Chien
b50a0a3765 Merge "Tethering: ensure downstream prefix do not conflict with upstream" 2020-05-29 03:34:45 +00:00
markchien
c38a3eb3b3 Address comment from aosp/1232197
1. Call maybeRemoveDeprecatedUpstreams from Tethering rather than inside
PrivateAddressCoordinator because the building logic of this method based
on implementation details of Tethering.
2. Fix typo

Bug: 130879722
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: I7584253b728bc17fc648fc19e492ca9f7ad2ff46
2020-05-29 11:24:08 +08:00
paulhu
7293a504f2 Use Class#getSimpleName instead of KClass#getSimpleName
KClass#getSimpleName need refer to kotlin-reflect.jar which need
include it in Andorid.bp. However, it's not necessary to use
KClass#getSimpleName but use Class#getSimpleName instead.

Test: atest TetheringTests
Bug: 157527499
Change-Id: I49bc336a276d30152402eba926cc583bc81e8e5c
Merged-In: I49bc336a276d30152402eba926cc583bc81e8e5c
2020-05-29 00:29:22 +08:00
Paul Duffin
9adce17ab4 Switch framework-tethering to use java_sdk_library
The names of the individual modules do not quite follow the pattern
that java_sdk_library uses so this temporarily sets the following:
    naming_scheme: "frameworks-modules"

That causes java_sdk_library to use a naming scheme that matches the
one used by the individual modules of this. It will be cleaned up
later.

Part of the purpose of the java_sdk_library is to hide the
implementation code and force users of the library to depend on stubs
for a well defined API. Ideally, it would allow access to the
implementation in those cases where it is safe, e.g. from within the
same APEX, or from tests for the implementation. Unfortunately, due to
limitations in the build it does not yet have enough information to
make that decision correctly which means that any code that needs to
compile against the implementation is broken which would prevent us
from converting the module to java_sdk_library.

However, the only way to provide the additional information to allow
the implementation to be correctly exposed is to convert the modules
to java_sdk_library; a cycle.

In order to break that cycle the java_sdk_library creates a special
<module>.impl target which is used directly by tests and any other code
that needs it. Once all the modules have been converted to a
java_sdk_library then we can resolve the limitations in the build and
remove the direct references to <module>.impl.

Test: m update-api
Bug: 155164730
Merged-In: If5c115f482751f9f4b5f047e9e401a18e36799ef
Merged-In: Id1c2e848430c49a2da7402244814cd084f5da77c
Change-Id: Id1c2e848430c49a2da7402244814cd084f5da77c
2020-05-28 13:14:52 +00:00
Treehugger Robot
3a7c2abef7 Merge "Extend timeout for requesting tethered interface" 2020-05-28 08:19:10 +00:00
markchien
3639c015f2 Extend timeout for requesting tethered interface
Extend the timeout to lower the EthernetTetheringTest flaky.

Besides, also explicitly exempt entitlement check in
EtetherntTetheringTest because it do not test tethering upstream
currently. Thus, the tests would not be interrupted by entitlement
check if test SIM is entitlement required.

Bug: 156713866
Test: TetheringCoverageTests, CtsTehteringTest

Change-Id: I45e8e8d737486def9d0de8943ec7f09ca0942a0b
2020-05-28 12:13:14 +08:00
markchien
f53ec879f0 Tethering: ensure downstream prefix do not conflict with upstream
- Add New class PrivateAddressCoordinator to coordinate the private
  address conflict problem.
- Downstream prefix would be random in 192.168.0.0/24 ~
  192.168.255.0/24.
- If new upstream prefix is conflict with existing downstream prefix,
  downstream would be kicked out and it would request a new one.
- The last conflict upstream prefixes would be blacklist. Avoid to
select downstream prefix which is conflict with prefixes in blacklist.

Bug: 130879722
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: Ib45b87bcd9eeb5da03fb7ec90b1af9ca53998cf5
2020-05-27 21:36:01 +08:00
markchien
fa270050cb Remove platform cert from Tethering tests
Bug: 156866746
Test: atest TetheringTests, TetheringCoverageTests
Change-Id: I7c539f1f4a447b5913164b222601c6113c6fe645
2020-05-26 09:31:16 +08:00
Mark Chien
09952a8e12 Merge "Adjust TTL for ipv6 tethering" 2020-05-25 01:42:36 +00:00
markchien
aa8cecec81 Adjust TTL for ipv6 tethering
If upstream is cellular, set the TTL in Router Advertisements to
"network-set TTL - 1" for carrier requirement. For other non-cellular
upstream, set TTL as "network-set TTL + 1" to preventing arbitrary
distinction between tethered and untethered traffic.

Bug: 154776299
Test: atest TetheringTests

Change-Id: I7f2696a642f96c6aafb5613b980bf5bcdd08bbda
2020-05-24 22:52:44 +08:00
markchien
85ce1ebd79 Fix TetheringServiceTest test WRITE_SETTINGS permission failure
AdoptShellPermissionIdentity can not pass permission check by
Settings#checkAndNoteWriteSettingsOperation. It would compare the caller
uid and its package name. See error below:
1. java.lang.SecurityException:
Specified package com.android.shell under uid 10239 but it is really 2000
2. java.lang.SecurityException:
uid 10245 does not have android.permission.UPDATE_APP_OPS_STATS.

Override the method and test if caller hold WRITE_SETTINGS directly.

Bug: 154869719
Test: TetheringTests, TetheringCoverageTests, NetworkStackNextTests,
NetworkStackCoverageTests

Change-Id: I2a60c4d66ef30028f9663159f85464ea815248e2
2020-05-20 16:56:33 +08:00
Treehugger Robot
342a73c40c Merge "TetheringServiceTest: test caller permission" 2020-05-19 02:40:03 +00:00
markchien
aebd81875e TetheringServiceTest: test caller permission
Bug: 154869719
Test: atest TetheringTests
Change-Id: I7beea3f011d930e433443ed62d772a3f8cce5d78
2020-05-19 09:04:43 +08:00
Treehugger Robot
8f40ffebae Merge "Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests" 2020-05-14 16:00:27 +00:00
markchien
32e772f9ce Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests
Bug: 156557122
Test: atest TetheringTests

Change-Id: Id9c0397306f3872fc23520d1354f338035a96dc9
2020-05-14 16:42:22 +08:00
Xiao Ma
1e83ce23e1 Merge "Support MirrorLink DHCPDECLINE." 2020-05-14 06:27:16 +00:00
Treehugger Robot
5d36f01873 Merge "Make members final in TetheringService" 2020-05-13 16:04:58 +00:00
Xiao Ma
2b539941ba Support MirrorLink DHCPDECLINE.
Add the specific implementation of onNewPrefixRequest callback
on IpServer side, also refactor some common code.

Bug: 130741856
Test: atest TetheringTests
Change-Id: If2871bf899cb5890bbfee18063a194c92b6f474e
2020-05-13 23:29:49 +09:00
markchien
9ee6a954fd Make members final in TetheringService
1. Move isTetheringSupport logic from TetheringService to Tethering.
2. Small readability improvement in TetheringTest. Also change
config_tether_upstream_automatic from false to true in TetheringTest.
So TetheringTests would default run automatic select upstream flow
instead of selecting by legacy perferred network type list.

Bug: 153609486
Test: atest TetheringTest
Change-Id: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
Merged-In: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
2020-05-13 12:25:15 +00:00
Mark Chien
f77020b25e Merge "Add test for OffloadHardwareInterface" 2020-05-13 08:39:32 +00:00
markchien
2c5c657ab1 Add test for OffloadHardwareInterface
Bug: 145490751
Test: atest TetheringTests

Change-Id: Ia402a6caaa0dfaa05d25a02101c515bbd884d33f
2020-05-13 14:36:42 +08:00
Nucca Chen
c26ad188b7 Merge changes I2d6f80f0,I9c26852d
* changes:
  Use device option to control BPF offload features
  Add tether BPF offload config to device config and resource
2020-05-12 11:00:04 +00:00
markchien
7f2ec3593f Allow to exempt from entitlement check
To exempt from entitlement check, caller need to hold TETHER_PRIVILEGED
permission.

Bug: 141256482
Test: atest TetheringTests

Change-Id: I2eb37f5e92f5f5150a7fb7c25b945e28704d27a0
2020-05-08 18:55:26 +08:00
markchien
8a37bc9406 Address the comment of aosp/1288493
Bug: 141256482
Test: atest TetheringTests
Change-Id: I0cf337625cee31a47879c59e9b18657ea7624eb4
2020-05-08 15:51:52 +08:00
markchien
7eabad685f Test tethering log dump
Bug: 145490751
Test: atest TetheringTests
Change-Id: I01fc6969041711f7a15880144ee5eac591086ecd
2020-05-06 17:00:37 +08:00
Hungming Chen
938859891a Use device option to control BPF offload features
If BPF offload device config is not enabled:
- Does not add/remove offload forwarding rules through disabling IP
  neighbor monitor.
- Does not apply the RA MTU reduction.

Bug: 149997301
Test: atest IpServerTest
Change-Id: I2d6f80f0229f580c4b16243a064e889a6c37f77a
2020-05-05 17:43:50 +08:00
Hungming Chen
8b42d7cedc Add tether BPF offload config to device config and resource
The tether bpf offload can be enabled by resource config and
device config. The device config has higher priority and it
could override this config which is set by resource config.

Bug: 149997301
Test: -build, flash, boot
      -atest TetheringConfigurationTest
Change-Id: I9c26852d2c926786e141ece6da53df3801c049b2
2020-05-05 17:37:32 +08:00
junyulai
34073efb57 [SP18.6] Make offload controller poll interval configurable
Test: atest TetheringTests
Bug: 149467454

Change-Id: I0b07a0b520dedb479bf863fbfe898ae85b84b0f3
2020-05-05 11:45:36 +08:00
junyulai
d9a4ed3bb3 [SP18.5] Create offload controller poll interval to resource
Test: atest TetheringConfigurationTest
Bug: 149467454
Change-Id: I8b4ad920a4945504914d3741a9fba5c096fbf452
2020-05-04 14:56:37 +08:00
junyulai
99b8f7646e [SP18.4] Add unit test for polling network stats in OffloadController
Test: atest OffloadControllerTest
Bug: 149467454
Change-Id: I9b9c9c096a2366aaf383d5c2d567db6682f02dad
2020-05-04 14:56:37 +08:00
junyulai
fbbf13e1fc [SP18.3] Adapt TestableNetworkStatsProviderCbBinder
This is a no-op refactoring to adapt new test provider callback.
Also this patch adapts TestLooper to allow better control on
delay messages that will be verified in subsequent tests.

Test: atest OffloadControllerTest
Bug: 149467454
Change-Id: Icfd6ff289d6689ae2d5753d3fe472516c808dc7a
2020-05-04 14:56:36 +08:00
Treehugger Robot
22a224f951 Merge "[SP18.1] add dependency object to OffloadController" 2020-04-29 12:08:22 +00:00
junyulai
5d3d5aa518 [SP18.1] add dependency object to OffloadController
In order to mock constant in unit test, a dependency object is
introduced with minimum code change to achieve this.

Test: atest TetheringTests
Bug: 149467454
Change-Id: I38628daddcb7be7c74846e78d36dc88f065b97d9
2020-04-28 18:27:57 +08:00
Mark Chien
339e06ba90 Merge "Remove Preconditions usage to stop dependecy with non-updatble class" 2020-04-27 10:54:19 +00:00
Remi NGUYEN VAN
152c94589a Merge "Address comments on NetworkStack AIDL v6" 2020-04-24 11:56:32 +00:00
Remi NGUYEN VAN
b955ac2f73 Address comments on NetworkStack AIDL v6
Address issues found during AIDL review:
 - Rename clientAddr to singleClientAddr
 - Do not use a ParcelableBundle for notifyNetworkTested or
   notifyDataStallSuspected; instead use AIDL parcelables for stronger
   backwards compatibility guarantees.

Test: atest NetworkMonitorTest ConnectivityServiceTest
      ConnectivityServiceIntegrationTest, manual
Bug: 153500847
Change-Id: Id9b71784e5f6294d203230e57737979e063ff0f8
2020-04-24 18:52:02 +09:00
markchien
2a52c09dda Remove Preconditions usage to stop dependecy with non-updatble class
Stop depending on Preconditions that is not released on the same cadence
as the module, and is maintained as part of the framework.

Bug: 148636687
Test: atest TetheringTests NetworkStackNextTests

Change-Id: Id0dcec44f362f79bc8c046d722635687a7388aa2
2020-04-24 00:47:56 +08:00