Commit Graph

248 Commits

Author SHA1 Message Date
markchien
8146b56d01 TetheringManager API clean up
Per API review:
- @IntDef defined on the type integer parameter
- have getters on each parameter that is set in the
  TetheringRequest.Builder
- new added API should not be deprecated
Below APIs is moved from system-current to module-lib-current that only
plafrom code(e.g. ConnectivityManager and Settings) can use them.
TetheringRequest.
onTetherableInterfaceRegexpsChanged, TetheringInterfaceRegexps:
Only platform code can use them because interfaces by regular
expressions are a mechanism which is planning to be deprecated.

Also rename some constants for easier to understand.

Bug: 149858697
Bug: 151243337
Test: m doc-comment-check-docs
      atest TetheringTests
Change-Id: I45cb21d5bc919f6d32c42650326597d5173ea028
Merged-In: Idd041f0fbeca411ea23e49786a50dd7feb77ef45
2020-03-19 19:32:50 +08:00
markchien
ac580f9826 Move NetworkCallback to last parameter for new exposed requestNetwork
Bug: 151243698
Test: atest TetheringTests
Change-Id: I87ef1d451eefa6998b9793c4eacabae978376d24
2020-03-19 19:10:23 +08:00
markchien
f1332573bb TetheringManager API clean up
Per API review:
- @IntDef defined on the type integer parameter
- have getters on each parameter that is set in the
  TetheringRequest.Builder
- new added API should not be deprecated
Below APIs is moved from system-current to module-lib-current that only
plafrom code(e.g. ConnectivityManager and Settings) can use them.
TetheringRequest.
onTetherableInterfaceRegexpsChanged, TetheringInterfaceRegexps:
Only platform code can use them because interfaces by regular
expressions are a mechanism which is planning to be deprecated.

Also rename some constants for easier to understand.

Bug: 149858697
Bug: 151243337
Test: m doc-comment-check-docs
      atest TetheringTests
Change-Id: Idd041f0fbeca411ea23e49786a50dd7feb77ef45
2020-03-19 16:32:37 +08:00
markchien
dc651f03da Expose netId by adding getter API
Bug: 151156820
Test: m
      atest TetetheringTests
Change-Id: Ieb1483c146aa2f7d8f251157e6e81d71c44ae899
(cherry picked from commit 8831c4b54178753013d568c0b76bbf7487db8122)
2020-03-19 15:57:31 +09:00
Automerger Merge Worker
9462a3c9f0 Support static address configuration
Application can specify static ipv4 server and client address to setup
tethering and this is one shot configuration. Tethering service would
not save the configuration and the configuration would be reset when
tethering stop or start failure.

When startTethering callback fired, it just mean tethering is requested
successful. Therefore, callers may call startTethering again if
startTethering successful but do not receive following tethering active
notification for a while. Tethering service never actually does anything
synchronously when startTethering is called:
  -startProvisioningIfNeeded just posts a message to the handler thread.
  -enableTetheringInternal doesn't do anything synchronously, it just
  asks the downstreams to get their interfaces ready and waits for
  callbacks.
If tethering is already enabled with a different request,
tethering would be disabled and re-enabled.

Bug: 141256482
Test: -build, flash, boot
      -atest TetheringTests
      -atest CtsTetheringTest

Change-Id: I2b2dd965a673e6f1626738d41b5d443f0f9fbd0e
Merged-In: I0399917e7cefa1547d617e688225544c4fc1a231
(cherry picked from commit 5d6723e24e21154bef3967585a8adc069e007f49)
2020-03-19 12:39:46 +08:00
Remi NGUYEN VAN
06b45ca764 Merge changes from topic "netstack_api_review" into rvc-dev
* changes:
  Remove usage of Context.NETWORK_STACK_SERVICE
  Remove NETWORK_STACK_SERVICE constant
2020-03-19 01:21:29 +00:00
markchien
245352ed07 Assign specific client address to dhcp server
Bug: 141256482
Test: manual
      atest TetheringTests

Change-Id: Ief76c98c843ba5420224cbf0f34464f366c891b7
2020-03-19 01:47:25 +08:00
Remi NGUYEN VAN
b8fecf4b32 Remove usage of Context.NETWORK_STACK_SERVICE
The NetworkStack.getService() API should be used instead.

Bug: 151243982
Test: atest FrameworksNetTests TetheringTests
      Manual tethering test
Change-Id: I7855090bffbe895c8349ad4903b8f2eb55515f0b
2020-03-18 18:31:39 +09:00
Junyu Lai
2a17338e44 Merge "[SP25] Rename functions that add Entry conditionally" 2020-03-18 03:16:41 +00:00
junyulai
36a172910e [SP25] Rename functions that add Entry conditionally
Currently, in NetworkStats, there are many methods to manipulate
the records. However, some methods are similar and ambiguous,
such as addEntry, addValues, setValues, addIfaceValues,
combineValues and combineAllValues.

Thus, properly grouping and renaming methods are necessary.
In this change, for methods that add one record conditionally,
name them addEntry.
  addValues -> addEntry

Test: atest FrameworksNetTests ImsPhoneCallTrackerTest TetheringTests
Fix: 148895143
Change-Id: I9495a198cf247e6c79100f7ac1edcea370b071de
Merged-In: I9495a198cf247e6c79100f7ac1edcea370b071de
(cherry picked from ag/10700816)
2020-03-18 00:29:15 +00:00
junyulai
abb0596a0a [SP25] Rename functions that add Entry conditionally
Currently, in NetworkStats, there are many methods to manipulate
the records. However, some methods are similar and ambiguous,
such as addEntry, addValues, setValues, addIfaceValues,
combineValues and combineAllValues.

Thus, properly grouping and renaming methods are necessary.
In this change, for methods that add one record conditionally,
name them addEntry.
  addValues -> addEntry

Test: atest FrameworksNetTests ImsPhoneCallTrackerTest TetheringTests
Fix: 148895143
Change-Id: I9495a198cf247e6c79100f7ac1edcea370b071de
2020-03-17 14:59:59 +00:00
junyulai
4aa86b782b [SP21] Address comments for API council review about aosp/1172143
Test: atest FrameworksNetTests ImsPhoneCallTrackerTest
Test: atest TetheringTests NetworkStackTests
Test: m doc-comment-check-docs
Fix: 148552904

Change-Id: I141393f229e772d2eb9f7c156849e379bd71b845
Merged-In: I141393f229e772d2eb9f7c156849e379bd71b845
(cherry picked from aosp/1253717)
2020-03-17 14:57:59 +00:00
Mark Chien
6d175120a0 Merge "Support static address configuration" 2020-03-17 13:26:09 +00:00
Remi NGUYEN VAN
677a3b5e92 Merge "Cleanup the TetheredClients API" into rvc-dev 2020-03-17 04:49:06 +00:00
markchien
f053e4b6f5 Support static address configuration
Application can specify static ipv4 server and client address to setup
tethering and this is one shot configuration. Tethering service would
not save the configuration and the configuration would be reset when
tethering stop or start failure.

When startTethering callback fired, it just mean tethering is requested
successful. Therefore, callers may call startTethering again if
startTethering successful but do not receive following tethering active
notification for a while. Tethering service never actually does anything
synchronously when startTethering is called:
  -startProvisioningIfNeeded just posts a message to the handler thread.
  -enableTetheringInternal doesn't do anything synchronously, it just
  asks the downstreams to get their interfaces ready and waits for
  callbacks.
If tethering is already enabled with a different request,
tethering would be disabled and re-enabled.

Bug: 141256482
Test: -build, flash, boot
      -atest TetheringTests
      -atest CtsTetheringTest

Change-Id: I0399917e7cefa1547d617e688225544c4fc1a231
2020-03-17 00:11:16 +08:00
Automerger Merge Worker
0010ca0c70 Cleanup the TetheredClients API
Add comments to getters as requested in API review, and remove the
expirationTime private field that was planned to be replaced with
LinkAddress expiration.

Test: atest TetheringTests
Fixes: 150878126
Change-Id: Iecf65859cdeeaac2fa7b817b4f505c510424ac89
Merged-In: Iecf65859cdeeaac2fa7b817b4f505c510424ac89
(cherry picked from commit 594d0eae38c13e2bb03de0b3ae1f8781991c321e)
2020-03-16 10:11:29 +00:00
Junyu Lai
12b21035c4 Merge "[SP21] Address comments for API council review about aosp/1172143" 2020-03-16 02:41:19 +00:00
Remi NGUYEN VAN
dfdf750417 Cleanup the TetheredClients API
Add comments to getters as requested in API review, and remove the
expirationTime private field that was planned to be replaced with
LinkAddress expiration.

Test: atest TetheringTests
Fixes: 150878126
Change-Id: Iecf65859cdeeaac2fa7b817b4f505c510424ac89
2020-03-13 19:01:15 +09:00
junyulai
5752baa6b6 [SP21] Address comments for API council review about aosp/1172143
Test: atest FrameworksNetTests ImsPhoneCallTrackerTest
Test: atest TetheringTests NetworkStackTests
Test: m doc-comment-check-docs
Fix: 148552904

Change-Id: I141393f229e772d2eb9f7c156849e379bd71b845
2020-03-12 21:34:17 +08:00
Automerger Merge Worker
9cb35621a6 [TNU01] Add Tethering notification updater
There are lots of Carrier/OEM requests for tethering
notification customization. So add a new tethering notification
updater class which can let OEM customize the behavior they
wanted.

Bug: 122085773
Test: atest TetheringTests
Change-Id: I7faacde7ac84e93ea0dfe03dd33d2cc41c589225
Merged-In: I7faacde7ac84e93ea0dfe03dd33d2cc41c589225
(cherry picked from aosp/1137358)
2020-03-12 01:42:35 +00:00
Lorenzo Colitti
407e9eb150 Merge "[SP19] Reduce log when set limit and request stats update" into rvc-dev 2020-03-10 03:06:21 +00:00
Paul Hu
ccf6239513 Merge "[TNU01] Add Tethering notification updater" 2020-03-09 08:10:55 +00:00
Automerger Merge Worker
74f27e6f63 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 hotspotf

Change-Id: Ifb16dcedc8081833fa95a39596fe5cdc309ededd
Merged-In: Ifb16dcedc8081833fa95a39596fe5cdc309ededd
Merged-In: Ia0398601144b0e5f61dc0c5771eacf13e7cfbb59
(cherry picked from commit cd266076bed28459234c5d74ad373867944df116)
2020-03-09 07:59:29 +00:00
Automerger Merge Worker
cee6cd88ee [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
AOSP-Change: 1242601
Change-Id: I01c0191d5b89942fa69b167b8a6b40ed2821300b
Merged-In: I92d214f4648fec6be13e04147290ecdd156fab4e
(cherry picked from commit b9565c7db00e44b50f9983691b603ebd6918ee45)
2020-03-09 07:54:27 +00:00
Mark Chien
cf9a67a5db Merge "Fix crash and duplicated ethernet tethering request" into rvc-dev 2020-03-09 07:51:43 +00:00
Automerger Merge Worker
f1194880cb Merge the following changes to tethering:
======
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
======
Clear IPv6 forwarding rules when losing upstream or stopping.

Test: new unit test
Change-Id: I8626932e43e0daa300dad5fe6a81f47a6d667030
======

Bug: 149963652
Change-Id: I691053b22cb0b20e49419212f378cc473b1f35dc
(cherry picked from commit 3384bb9a4d7bd85370fe64e59f2872a5cab644d7)
2020-03-09 03:25:23 +00:00
Automerger Merge Worker
0a368b10bc 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: Ibd3ea6bc6751bd65647ff381f9b0124bc3395c09
Merged-In: I7c5127e96d80d077735010d2e62c7227805ccb10
Merged-In: Ibd3ea6bc6751bd65647ff381f9b0124bc3395c09
(cherry picked from commit 72702b979654234c18045f04270040056a74cf90)
2020-03-09 02:02:23 +00:00
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
paulhu
08294f9c09 [TNU01] Add Tethering notification updater
There are lots of Carrier/OEM requests for tethering
notification customization. So add a new tethering notification
updater class which can let OEM customize the behavior they
wanted.

Bug: 122085773
Test: atest TetheringTests
Change-Id: I7faacde7ac84e93ea0dfe03dd33d2cc41c589225
2020-03-09 09:20:19 +08: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
9821f7e940 Merge "[SP19] Reduce log when set limit and request stats update" 2020-02-25 09:14:24 +00: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
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
Automerger Merge Worker
3bd7306154 Merge "Use exposed permission defintion in Tethering" am: f1a0c3abea am: e8f538b03a am: d53db580d7
Change-Id: Ieba1160f9f333ac9b112941a8fdcc15e9b563d5b
2020-02-21 12:21:04 +00: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
Automerger Merge Worker
cce2909d0f Merge "Tethering: Don't crash if wifi unavailable." am: 084e8536d1 am: b1b7db8c76 am: 911b4cf5cd
Change-Id: I62927826271d36eb89f39ac076f0bf9522a61423
2020-02-20 04:29:18 +00:00
Automerger Merge Worker
6bc4e1f98c Merge "Tethering offload: add/remove IPv6 forwarding rules on ND events." am: 9a1f9d4669 am: 8d78f124e7 am: 2353495350
Change-Id: If7947436f2a26786f69377712ad0ff1234ac93fe
2020-02-19 23:12:04 +00:00
Automerger Merge Worker
75f615e14c Merge "Reduce advertised ipv6 mtu by 16 to fit ethernet header" am: b23d20fea7 am: 376e086fef am: f0fff78d9d
Change-Id: I2ce8d87603b1628735b376efe21da43d3ea53225
2020-02-19 23:11:06 +00: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
Lorenzo Colitti
9a1f9d4669 Merge "Tethering offload: add/remove IPv6 forwarding rules on ND events." 2020-02-19 13:41:10 +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
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
c8871c1b66 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
2020-02-18 13:32:16 +08:00
Treehugger Robot
5cce783b41 Merge "Catch correct exception for adding route fail" am: c2050ac731 am: 55c0f41695 am: b6589dc1f6
Change-Id: Ie79acf53b0cdb532f81d4e61e669bdb101b71c0a
2020-02-17 14:19:32 +00: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
Automerger Merge Worker
481eb3b9fc Merge "Move offload config hidl usage from native to java" am: b03a821085 am: b5930afb19 am: 5fac37b596
Change-Id: I92cfc902c44e9e263828d142fd6ff360b39e97e6
2020-02-10 09:46:28 +00:00