Commit Graph

135 Commits

Author SHA1 Message Date
markchien
05bee8027d Send offload status changed callback
The callback would be fired when offload started, stopped, or failed.
If offload is not supported, "failed" callback would be fired when user
enable tethering. Enabling multiple tethering would not have multiple
offload status callbacks because offload should already be started or
failed.

Bug: 130596697
Test: -build, flash, boot
      -atest TetheringTests
      -ON/OFF hotspot
Change-Id: Ia0398601144b0e5f61dc0c5771eacf13e7cfbb59
2020-03-09 01:51:20 +00:00
Jiyong Park
067c45b1ee Merge "Mark updatable APEXes" 2020-02-29 15:10:24 +00:00
Jiyong Park
5c72ad41f0 Mark updatable APEXes
Mark updatable APEXes as updatable: true so that they are opted-out from
optimizations that make sense only for non-updatable modules; such as
symlinking to the libs in the system partition.

Bug: 149805758
Test: m and check that there is no symlink from the APEX to the system
partition.

Exempt-From-Owner-Approval: cherry-pick from internal

Merged-In: Idb55300a60a261c7bb6359439ed220ff51fcf06c
(cherry picked from commit 8201bdfab070fb2b93a997947095fad003060da9)
Change-Id: Idb55300a60a261c7bb6359439ed220ff51fcf06c
2020-02-29 09:18:24 +00:00
Lorenzo Colitti
048c96276b Merge "Fix crash and duplicated ethernet tethering request" 2020-02-28 02:37:45 +00:00
markchien
3849d89111 Fix crash and duplicated ethernet tethering request
This change fix two things:
1. Handle ethernet callback in internal thread to avoid crash. IpServer
should be created from tethering thread, otherwise mIpNeighborMonitor of
IpServer would throw
   IllegalStateException("start() called from off-thread")
2. Ethernet tethering request may be duplicated if multiple
startTethering is called but no stopTethering

Bug: 130840861
Bug: 148824036
Test: ON/OFF ethernet tehtering manually
      atest TetheringTests

Change-Id: I7c5127e96d80d077735010d2e62c7227805ccb10
2020-02-27 14:50:16 +08:00
Treehugger Robot
02dd6fdfd3 Merge "tethering: transitive deps from jni_libs" 2020-02-25 22:13:19 +00:00
Treehugger Robot
9821f7e940 Merge "[SP19] Reduce log when set limit and request stats update" 2020-02-25 09:14:24 +00:00
Jooyung Han
cfea439ba4 tethering: transitive deps from jni_libs
The build system collects transtive deps from jni_libs for APKs.
No need to list them explicitly in android_app definition.

Bug: 146992436
Test: m com.android.tethering
      deapexer extract com.android.tethering.apex apex
      unzip apex/priv-app/Tethering/Tethering.apk -u apk
      ls apk/lib/arm64-v8a

Change-Id: Icba6ea3611c443cbf22ad6363d0239377d16ac9e
2020-02-25 17:35:18 +09:00
junyulai
fd4a2f0528 [SP19] Reduce log when set limit and request stats update
setLimit can be ignored if the quota is unlimited and not
changed, and the log could be omitted since it will still be
logged in HAL. Request stats update will print error log in
service if it is not correctly responded in time.

Test: atest TetheringTests
Test: manual
Fix: 149735152

Change-Id: I01c0191d5b89942fa69b167b8a6b40ed2821300b
2020-02-25 15:02:10 +08:00
Lorenzo Colitti
0f0bff0594 Merge changes I4a624ea4,I8626932e
* changes:
  Fix a logic error in IpServerTest#addRemoveipv6ForwardingRules
  Clear IPv6 forwarding rules when losing upstream or stopping.
2020-02-25 03:54:59 +00:00
Lorenzo Colitti
6c8147ea56 Fix a logic error in IpServerTest#addRemoveipv6ForwardingRules
When checking that link-local and multicast neighbours are
ignored, make sure the test neighbours are added on the correct
interface. Otherwise, they might be ignored because events on the
wrong interface are ignored, and not necessarily because
link-local and multicast neighbours are ignored.

Test: atest TetheringTests
Change-Id: I4a624ea4ce9ee9a9352afccbc7bf866587d4cdfa
2020-02-25 09:26:36 +09:00
Lorenzo Colitti
c61fc087b2 Clear IPv6 forwarding rules when losing upstream or stopping.
Test: new unit test
Change-Id: I8626932e43e0daa300dad5fe6a81f47a6d667030
2020-02-25 09:26:36 +09:00
markchien
9e0792f8dc Build framework-tethering against module_current
Test: build
Change-Id: Iad504f0e709daadfb4d86205c07f0faf429f5a8f
2020-02-25 00:22:44 +08:00
Lorenzo Colitti
a429d3b551 Merge "Support losing the upstream in IpServerTest." 2020-02-23 10:18:02 +00:00
Colin Cross
131380ff26 Remove liblog from Tethering jni_libs
Tethering's JNI libraries use the NDK version of liblog, it should
not package the platform version of liblog into the APK.

Bug: 149591340
Test: m checkbuild
Change-Id: If208c1078d2755907f57d7853a5c545bf12458c2
2020-02-21 14:49:40 -08:00
Lorenzo Colitti
03a734f352 Support losing the upstream in IpServerTest.
Allow dispatchTetherConnectionChanged to pass in a null
upstream interface and/or null LinkProperties. This will allow
future tests to check what happens when the upstream interface
goes away.

Test: test-only change
Change-Id: I7cfc32d072f23644159d33700d6cd830c426ea19
2020-02-21 20:23:59 +09:00
Chiachang Wang
1784f25df5 Use exposed permission defintion in Tethering
The permissions are checked by Tethering; mainline modules should be
able to do permission checks based on these permissions.

Bug: 135411507
Test: m
Change-Id: Ib7f2aedfaaa909bbc356196114c62af9345f2593
2020-02-21 17:50:18 +08:00
Mark Chien
e19cd8f3ab Merge "Stop exposing constructor of TetheringConstants" 2020-02-20 12:46:19 +00:00
Anton Hansson
703048d08b Merge "Stop exposing generated AIDL from Tethering" 2020-02-20 12:18:34 +00:00
markchien
1bec13e963 Stop exposing constructor of TetheringConstants
Fully-static utility classes must not have constructor.

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

Change-Id: I18e1129ef8717211d667ccd3b4110169dd7905b4
2020-02-20 16:11:35 +08:00
Peter Collingbourne
9969e5dff7 Tethering: Don't crash if wifi unavailable.
r.android.com/1213016 seems to have caused the following crash on devices
without wifi:

FATAL EXCEPTION: main
Process: com.android.networkstack.process, PID: 1041
java.lang.RuntimeException: Unable to create service com.android.server.connectivity.tethering.TetheringService: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.net.wifi.WifiManager.registerSoftApCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager$SoftApCallback)' on a null object reference
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4005)
	at android.app.ActivityThread.access$1500(ActivityThread.java:220)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:216)
	at android.app.ActivityThread.main(ActivityThread.java:7396)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.net.wifi.WifiManager.registerSoftApCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager$SoftApCallback)' on a null object reference
	at com.android.server.connectivity.tethering.Tethering.<init>(Tethering.java:317)
	at com.android.server.connectivity.tethering.TetheringService.makeTethering(TetheringService.java:90)
	at com.android.server.connectivity.tethering.TetheringService.onCreate(TetheringService.java:81)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:3993)

Fix it by null checking wifiManager before calling a method on it.

Bug: 142352330
Change-Id: I46e2f3053a59d3dba6a186a9eed34fa63b45d03e
2020-02-19 12:55:44 -08:00
Anton Hansson
c82ea10ea2 Stop exposing generated AIDL from Tethering
We don't want new modules exposing stable aidl directly. APIs should
be defined as java @SystemApi. It also seems like nothing actually
depend on these interfaces, except one simple exception.

Bug: 147200698
Test: m
Change-Id: Ia4222fa35a9a2f3c75cebb12f75c536f27e2fe16
Merged-In: Ia4222fa35a9a2f3c75cebb12f75c536f27e2fe16
2020-02-19 16:26:05 +00:00
Lorenzo Colitti
9a1f9d4669 Merge "Tethering offload: add/remove IPv6 forwarding rules on ND events." 2020-02-19 13:41:10 +00:00
Lorenzo Colitti
ffd4bf34be Merge "Minimal support for IPv6 upstreams in IpServer tests." 2020-02-19 13:38:00 +00:00
Lorenzo Colitti
5e15d7b06a Tethering offload: add/remove IPv6 forwarding rules on ND events.
Use IpNeighborMonitor to listen for ND cache events on the
downstream interface, and push downstream IPv6 fowarding rules
to netd.

Rules are pushed when:
- IPv6 neighbours appear/disappear on the downstream interface.
- The upstream changes.

Test: new unit test
Change-Id: I7b01ba179a4d6bb248fd6c4994e48800613a4efa
2020-02-19 20:50:43 +09:00
Treehugger Robot
b23d20fea7 Merge "Reduce advertised ipv6 mtu by 16 to fit ethernet header" 2020-02-19 11:20:29 +00:00
Maciej Żenczykowski
da0fb1bca8 Reduce advertised ipv6 mtu by 16 to fit ethernet header
This is a temporary hack to workaround the inability of current
kernel's ebpf bpf_skb_change_mode() function to prefix a 14-byte
ethernet header on to a packet without going over the upstream
(source, rawip) interface's mtu *before* we bpf_redirect() to
the downstream (destination, ethernet) interface.

Test: build, atest, atest TetheringTests
Bug: 149816401
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I646148ebfd978a2489c0cd065e4b671b01150add
2020-02-19 10:44:54 +00:00
Lorenzo Colitti
d50b3ed6c7 Minimal support for IPv6 upstreams in IpServer tests.
This makes the IpServer tests a bit more realistic. It is needed
by an upcoming change that adds new functionality, and is in its
own commit because it modifies the behaviour of all the existing
tests.

Test: atest TetheringTests
Change-Id: I8c3267bea983d1453c010b7b6b85548b9481a153
2020-02-19 19:43:23 +09:00
Mark Chien
5ea7a9466b Merge "Add tethering client callbacks" 2020-02-19 10:41:30 +00:00
Mark Chien
907976e0a2 Merge "Fix usage of annotations in TetheringLib" 2020-02-19 09:54:13 +00:00
Mark Chien
b8a6208240 Merge "Use framework-tethering-stub instead of framework-tethering" 2020-02-19 09:46:24 +00:00
Remi NGUYEN VAN
b9379a518c Add tethering client callbacks
The callbacks are fired when the list of connected clients or their IP
addresses / hostname change.

Test: flashed, connected 2 devices, verified callbacks
Test: atest TetheringTests
Bug: 135411507
Change-Id: I96291038cf7b39a67547a5f74fcd7cbedc1ca002
Merged-In: I96291038cf7b39a67547a5f74fcd7cbedc1ca002
2020-02-19 17:05:00 +08:00
Remi NGUYEN VAN
293d351b7e Fix usage of annotations in TetheringLib
Annotations such as @SystemApi cannot be jarjared to a different
package, as the members would not match the system API declarations.

Instead, only build against the annotations from
framework-annotations-lib, but do not include them as classes in the
output jar; annotations are not required to be available to the
classloader at runtime.

Test: builds, boots, tethering working
Bug: 147812912
Fixes: 148609988
Change-Id: I1fae97a1c1e0ba07fa3e2d64cde7650cd26d0acd
Merged-In: I1fae97a1c1e0ba07fa3e2d64cde7650cd26d0acd
2020-02-19 16:32:26 +08:00
markchien
b6ad1966c4 Use framework-tethering-stub instead of framework-tethering
The non-updatable part of the platform now is built with
framework-tethering-stub, which is a stub library of
framework-tethering.

Bug: 147200698
Test: m
Change-Id: I97ef83f7f9b4c1376f373713036f5256318f1050
Merged-In: I97ef83f7f9b4c1376f373713036f5256318f1050
2020-02-19 15:10:44 +08:00
markchien
7261420793 Add TetheringTests to postsubmit
The tethering unit tests were in FrameworksNetTests, but were moved out
so were no longer run in presubmit. Now put them to postsubmit first.
Should be moved to presubmit after a while.

Bug: 148998835
Test: atest --test-mapping frameworks/base/packages/Tethering:postsubmit

Change-Id: I9ca36cba7bfde8409a06dbeb7166337c55b39691
2020-02-19 14:43:16 +08:00
markchien
6c2b7cc4bd Catch correct exception for adding route fail
Bug: 149535950
Test: OFF/ON hotspot
Change-Id: Ic52e2b2f3cec1a39a70302c41ab67ec1a1a55b1a
2020-02-15 11:35:00 +08:00
Remi NGUYEN VAN
8451e20d98 Merge "Fix TetheredClient and TetheredClientTest" 2020-02-12 21:58:07 +00:00
Mark Chien
b03a821085 Merge "Move offload config hidl usage from native to java" 2020-02-10 09:01:12 +00:00
markchien
547e168540 Move offload config hidl usage from native to java
TetheringUtil JNI is too big that it statically linking hidl and its
dependency library. To remove these static libraries, calling hidl in java
directly instead of using JNI.

Bug: 148984662
Test: -build, flash, boot
      -manually ON/OFF tethering

Change-Id: Id5a9759eb453fddaf0c3b7a31da17224e35e963e
2020-02-10 15:25:19 +08:00
Treehugger Robot
b569cf369b Merge "rm libbinderthreadstate" 2020-02-09 23:06:21 +00:00
Remi NGUYEN VAN
bb60ee8f10 Fix TetheredClient and TetheredClientTest
- Ensure that addAddresses preserves the ordering of addresses
 - Fix assertion that was supposed to check equality of TetheredClient
   with a different tethering type, and used the same type.

Bug: 148996181
Test: atest TetheringTests
Change-Id: I86cef7b834d7ae7afa3d1d748ccac6b3a7e57ebc
2020-02-07 19:55:33 +09:00
Mark Chien
8cbc588f5e Merge "Always report non-null TetherStatesParcel" 2020-02-07 10:48:28 +00:00
Steven Moreland
1d89dfc93e rm libbinderthreadstate
This library is empty, and its functionality has moved
into libbinder/libhwbinder.

Bug: 148692216
Test: N/A
Change-Id: I3ee973cef68281cb57b4912b4b66c798b5d9d715
2020-02-06 13:23:47 -08:00
markchien
f5a7c1647b Always report non-null TetherStatesParcel
Before this change, tetherStatesParcel may be null when there is no
avaialbe tethering interface yet. TetheringManager should handle null
case. But it is annoy to check null case each time and easy to have error.
Report non-null empty TetherStatesParcel object instead.

Bug: 148874619
Test: -build, flash, boot
      -atest TetheringTests
      -OFF/ON hotspot

Change-Id: I0717e7958c9409648170498d5e76322207856de3
2020-02-06 17:18:39 +08:00
Mark Chien
a156a16654 Merge "Fix NPE that netd callback call null TetheringConfiguration object" 2020-02-06 09:03:39 +00:00
markchien
7dda458908 Fix NPE that netd callback call null TetheringConfiguration object
Bug: 148386056
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: I3b1dd958fc107fdc9a6059fbdcf358af4822ebde
2020-02-06 15:25:47 +08:00
Mark Chien
ee013e376a Merge "Fix NPE in tethering startup" 2020-02-03 02:52:43 +00:00
Remi NGUYEN VAN
db2365d74c Merge "Tethering: build tethering as unbundled APP" 2020-01-31 07:40:30 +00:00
Remi NGUYEN VAN
95a55b3839 Merge "Tethering: Fix hidden API selectBestRoute" 2020-01-31 07:40:16 +00:00
markchien
674a25d84e Fix NPE in tethering startup
mUserManager should be ready before #makeTethering because mTethering may
call isTetheringSupported which need to reference mUserManager

Bug: 148642028
Test: build
Change-Id: I100b5d6cc8f49640c33fa930b819033de5d6492c
2020-01-31 14:04:36 +08:00