Commit Graph

118 Commits

Author SHA1 Message Date
markchien
e31fb9d7bd Register callback and receiver after tethering is created
Tethering service is created after boot complete which means most of
the services are ready before tethering. Once tethering register the
callback, callback event may come-in immediately. Make sure all of
tethering related object is created, then register the callback,
receiver, or listener.

Bug: 149965121
Test: atest TetheringTests
      manual on/off tethering

Change-Id: I3941a186770679e7b476073d774e2310e25e44c6
2020-03-27 08:13:28 +00:00
paulhu
972f031fa5 [TNU04] Add tethering restricted notification
If tethering is restricted to the user, show restricted
notification to notify the user.

Bug: 122085773
Test: atest TetheringTests
Change-Id: Ic5baca2d6102886f4c3530ce1e321b5dab6ea9d7
2020-03-24 16:45:02 +08:00
paulhu
769e00cad2 [TNU03] Add TetheringNotificationUpdaterTest
Add new test for TetheringNotificationUpdater

Bug: 122085773
Bug: 130596698
Test: atest TetheringTests
Change-Id: I0db3df3e85dd6a8c3989c8bc66a06c50f45a0c15
2020-03-24 15:35:05 +08:00
paulhu
7bfbe253d7 [TNU02] Update tethering notification by active data subid
Tethering notification can be customized by different subid. Thus
update notification when active data subid changed.

Bug: 122085773
Bug: 130596698
Test: atest TetheringTests
Change-Id: I799d713326cfbf4dc96c712c6b15ed5a4ac18dd2
2020-03-24 14:31:03 +08:00
Mark Chien
9bfe7f7b3e Merge "TetheringManager API clean up" 2020-03-19 16:09:21 +00:00
markchien
ec0b68d491 Move NetworkCallback to last parameter for new exposed requestNetwork
Bug: 151243698
Test: atest TetheringTests
Change-Id: I87ef1d451eefa6998b9793c4eacabae978376d24
Merged-In: I87ef1d451eefa6998b9793c4eacabae978376d24
2020-03-19 11:36:07 +00:00
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
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
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
Mark Chien
6d175120a0 Merge "Support static address configuration" 2020-03-17 13:26:09 +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
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
Paul Hu
ccf6239513 Merge "[TNU01] Add Tethering notification updater" 2020-03-09 08:10:55 +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
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
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
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
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
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
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
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
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
Remi NGUYEN VAN
0ef3b75ff5 Add support for Ethernet tethering
Ethernet tethering can be started via
startTethering(TETHERING_ETHERNET).

Test: flashed, enabled ethernet tethering, verified internet access on
      downstream.
Bug: 130840861

Merged-In: I34842acd94b972e440c3622f7617df10c18acf65
Change-Id: I34842acd94b972e440c3622f7617df10c18acf65
(cherry-pick with conflicts in test-current.txt)
2020-01-28 17:52:06 +09:00
Milim Lee
45a971bd8c Local Tethering with ncm interface
Bug: 130840842
Test: build, boot
      atest TetheringTest
      manual test (call startTethering(TETHERING_NCM))

Merged-In: Icc6c4d6be39e787503cecf3a5835b40d4be12a57
Change-Id: Icc6c4d6be39e787503cecf3a5835b40d4be12a57
(clean cherry-pick)
2020-01-28 17:52:06 +09:00
Remi NGUYEN VAN
3662c1bb6d Add API for tethering clients change
Add a onClientsChanged callback to OnTetheringEventCallback.

The callback will provide information on connected clients combining
at least DHCP leases and WiFi AP information (WiFi AP tethering used).

Test: atest TetheringTests
Bug: 135411507
Change-Id: I7065d081c11bc606d691f76ac8b499dd075d6504
Merged-In: I7065d081c11bc606d691f76ac8b499dd075d6504
2020-01-24 23:39:50 +09:00
markchien
f6761bdd0c Allows the caller to specify configuration by TetheringRequest
This is initial work to allow caller to pass their prefered
configuration to start tethering. Caller may able to specify the
downstream interface ipv4 address with dhcp server disabled for
static IP configuration, or able to exempt entitlement check if
they have permission in follow up CL.

Bug: 141256482
Test: -atest TetheringTest
      -ON/OFF wifi tethering

Change-Id: Ic7c3a33195bbd7e72f9b8e73fa148be476b87bf3
Merged-In: Ic7c3a33195bbd7e72f9b8e73fa148be476b87bf3
2020-01-24 23:39:50 +09:00
markchien
249752d8a3 Make TetheringManager to system API
Also deprecated tethering APIs in ConnectivityManager.
Will have follow up change to remove @hide tethering function in
ConnectivityManager.

Bug: 145093446
Bug: 148038547
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: Ia432057bf9056727c4a0ca97d160a49274d33581
Merged-In: Ia432057bf9056727c4a0ca97d160a49274d33581
2020-01-24 23:39:49 +09:00
Jimmy Chen
ea902f6f2a p2p: revise tethering handler for shared group interface support
When leaving a group, all information are erased and no group interface
is passed to tethering service.
For separate group interface, tethering could be stopped
on p2p group interface removed. For shared group interface,
i.e. management interface and group interface share one
interface, ex. p2p0, tethering has no chance to be stopped since management
interface won't be removed after leaving a group.

Bug: 141382930
Test: atest FrameworksNetTests
Test: atest FrameworksWifiTests
Test: atest TetheringTests
Change-Id: Ib611018b67c76ff79c7e6658136721090feb145b
2020-01-16 14:33:32 +08:00
Treehugger Robot
81369f59d2 Merge "TetheringTests: Stop using @hide Wifi P2P APIs" 2020-01-16 05:51:49 +00:00
Mark Chien
18401e3bb0 Merge "Tethering: remove redundant source code" 2020-01-15 11:51:07 +00:00
Mark Chien
99c7c0fe87 Merge "Allow opening tethering when data saver ON" 2020-01-15 06:58:29 +00:00
Mark Chien
4cefaf8bc8 Merge "Tethering: switch to use tethering package resources" 2020-01-15 06:17:06 +00:00
markchien
4ddf692e11 Tethering: remove redundant source code
Bug: 143195885
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: I92cbb51a0d4fb048aa75ba9932e3b106d181bad9
2020-01-15 04:33:10 +00:00
markchien
eaaebd1f0f Allow opening tethering when data saver ON
When data saver enabled, tethering would be OFF.
Currently settings would not allow user to turning tethering back.
After aosp/1181583 is merged, user can turn tethering back without
turning data saver OFF.

Bug: 145711175
Bug: 142374233
Test: atest TetheringTests
      OFF/ON tethering when data saver ON

Change-Id: I59e662ba771a563f5f1766ba29e05246b8280220
2020-01-14 20:15:31 +08:00
junyulai
f858a57887 [SP09] Remove NetworkStatsService @hide usage in Tethering
Test: atest TetheringTest
Bug: 130855321
Change-Id: I0260524c57f7c0aa738eaff07f9b0ae8e785ed63
2020-01-14 20:15:19 +08:00
junyulai
5864a3f0aa [SP07] Remove reference of NetworkStatsService in IpServer
Currently NetworkStatsService is notified when downstream is
updated. However, it seems unnecessary given that tether stats
is persist since boot, and there is no any upstream change when
downstream is changed.

Test: atest NetworkStatsServiceTest IpServerTest
Bug: 130855321
Change-Id: Ie300bfeb0a04678fcfcf300843b6f859af9df91d
2020-01-14 20:14:59 +08:00
junyulai
b7da74af88 [SP06] Use system API to communicate with NSS in OffloadController
Test: atest FrameworksNetTests OffloadControllerTest TetheringTest
Bug: 130855321

Change-Id: I294be3a2874f8c8120857e308e629199af014fcd
2020-01-14 20:14:33 +08:00
markchien
873c64ab8f Tethering: switch to use tethering package resources
Bug: 147399354
Test: build
Change-Id: I482788cdc8be3d34c9a922bfa7eb053f0aa87c96
2020-01-14 09:48:02 +00:00
David Su
dd66bcd894 TetheringTests: Stop using @hide Wifi P2P APIs
Instead use Mockito to achieve the same thing.

Bug: 138801922
Test: atest TetheringTests
Change-Id: I41edd697017f4ce59e6707302bebc0da3d75831d
Merged-In: I41edd697017f4ce59e6707302bebc0da3d75831d
2020-01-13 13:15:14 -08:00
markchien
9a0b95d294 Migrate legacy dhcp server config to DeviceConfig
Legacy dhcp server can also be enabled by resource config.

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

Change-Id: I8ae5fa3d5bbd88129bd0890f71be6f8a1bfec0eb
2020-01-13 15:07:03 +00:00
paulhu
ffa6e34395 Replace PendingIntent/NotificationManager @hide APIs
Tethering used some PendingIntent/NotificationManager @hide APIs
but they are not able to call now. Replace them with similar
System APIs.

Bug: 122085773
Test: atest TetheringTests
Change-Id: I2201d0e44a6356b8b1974ce0ed80d9913a7aeff5
2020-01-13 15:29:12 +08:00
markchien
3470487207 Fix hidden usage of networkCapabilitiesForType
After this change, tethering only support below legacy type:
  - TYPE_BLUETOOTH
  - TYPE_ETHERNET
  - TYPE_MOBILE
  - TYPE_MOBILE_DUN
  - TYPE_MOBILE_HIPRI
  - TYPE_WIFI

Bug: 144753389
Test: build
Change-Id: I394c8306d9f88a6648580b3b410069ad219f0074
2020-01-10 14:55:54 +08:00
markchien
b799fa3e95 Fix some @hide usage in Tethering(Cont.)
Using alternative way to fix @hide usage. Do not have API change.

Bug: 144814072
Test: buid
Change-Id: Ia23e319ad3779318471d01cbfa17b8c6df4960d3
2020-01-09 05:40:42 +00:00