Commit Graph

80 Commits

Author SHA1 Message Date
markchien
48e271bdcb Add TetheredInterface{Request, Callback} interface
Define interfaces that match the signature of the existing
EthernetManager.TetheredInterfaceRequest and TetheredInterfaceCallback
classes and make EthernetManager.TetheredInterfaceRequest and
TetheredInterfaceCallback implement/subinterface these interfaces. The
new bluetooth API could also implement these interfaces to make API surface
consistent.

Test: TH would test the existing tests that use the subclass.
Bug: 190438212
Change-Id: I093972c111cb1d921076782492716d5a046be8fc
2021-11-08 16:44:34 +08:00
Treehugger Robot
f8d1f3d1cd Merge "Unregister the tethering internal callback in finalize" 2021-10-20 08:40:08 +00:00
markchien
819e19ea2a Unregister the tethering internal callback in finalize
Bug: 177265744
Bug: 191798390
Bug: 187972579
Test: atest TetheringServiceTest
Change-Id: Ie7f9535b923db5073a59329ead22546a54e6ef47
2021-10-20 06:57:58 +00:00
Treehugger Robot
d7d41a73e7 Merge "Fix TetheringManager memory leak" 2021-10-20 03:59:59 +00:00
markchien
1110b725a0 Fix TetheringManager memory leak
TetheringCallbackInteranl is inner class which explicitly reference
TetheringManager object. This causes TetheringManager can't be GC. Using
static nested class which has its own lifecycle and weak reference
TetheringManager object.

Still have a leak inside Tethering that TetheringCallbackInternal is
never unregistered. Currently it rely on binder died to remove the
reference, which usually happen in kill process. If process keep alive,
the TetheringCallbackInternal would not be freed even TetheringManager is
gone. Will have follow CL to fix this.

Bug: 177265744
Bug: 191798390
Bug: 187972579
Test: 1. lunch Settings with ON/OFF tethering, dump java heap.
      2. close Settings and restart Settings again, dump java heap.
      3. Compare java heap between step 1 and step 2.
Change-Id: I0e2a21b7988115098a033a581cd98da8bffe2791
2021-10-14 14:02:11 +08:00
Mark Chien
da862b2a35 Merge "Support set test network to tethering upstream" am: 473d864d20
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1797991

Change-Id: Ifd5c76a943886dfe55e9b68eeb77931dae6fe204
2021-09-30 12:48:15 +00:00
markchien
2fbd3e72d3 Support set test network to tethering upstream
Test: atest EthernetTetheringTest

Change-Id: Ief2a92bc6c573a6bb75c72b7a0630e5c0accfa73
2021-09-30 10:14:58 +00:00
markchien
35ad54b25e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S

Merged-In: I91bcccd676d109c1b974497ac29bd366a41b8899
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-06-01 14:35:39 +08:00
markchien
9935dbe03e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S
Ignore-AOSP-First: Currently aosp would automerge to mainlne-prod, merge
to sc-dev first to avoid adding new API to mainline-prod

CTS-Coverage-Bug: I already add cts test(ag/14622456), but Lint
still complaint because my cts is under packages/modules/Connectivity/
but it only check whether CL touching platform/cts
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-05-18 14:47:43 +00:00
Lorenzo Colitti
f772ab1c61 Merge "Allow callers of startTethering to choose local-only mode." am: ac9ce08d45 am: af691a13b6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1674232

Change-Id: I9c88d0d05c6dbb0bac65b72e8d54df5eb25b4060
2021-04-19 14:51:21 +00:00
Lorenzo Colitti
8a36c297bc Allow callers of startTethering to choose local-only mode.
This is useful for OEMs that want to use RNDIS or NCM as a
local-only link that is directly connected to some other host.
This can be used to implement USB tethering using NCM, which
currently only supports local-only mode.

Bug: 175090447
Test: TetheringIntegrationTests:EthernetTetheringTest#testLocalOnlyTethering
Change-Id: I0ffaa46e4640e5b235340a15d25909106ceb0c07
2021-04-19 20:25:58 +09:00
Anton Hansson
44b2ebcf34 Remove Tethering @TestApi
Modules shouldn't have TestApis, as documented in go/android-api-types.
Additionally, nothing depends on these TestApis existing.

Bug: 170395679
Test: m checkapi
Exempt-From-Owner-Approval: cherry-pick
Change-Id: I6e2c8298e90b4b54f0264be974d036fa08cd5632
2020-10-15 07:42:41 +00:00
Anton Hansson
87b8363cb9 Remove Tethering @TestApi
Modules shouldn't have TestApis, as documented in go/android-api-types.
Additionally, nothing depends on these TestApis existing.

Bug: 170395679
Test: m checkapi
Change-Id: I6e2c8298e90b4b54f0264be974d036fa08cd5632
Merged-In: I6e2c8298e90b4b54f0264be974d036fa08cd5632
2020-10-14 16:03:57 +01:00
Makoto Onuki
aefd8b4e25 Merge "Proper API hierarchy between MODULE_LIBS and PRIV_APPS system APIs" am: df5d88796b am: e39fdf0a5f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1360884

Change-Id: Ie45f32b2d46c8ac989a4a9242017eb4c2b73484b
2020-07-15 16:00:22 +00:00
Makoto Onuki
d682ebc33c Proper API hierarchy between MODULE_LIBS and PRIV_APPS system APIs
Test: build / treehugger
Bug: 146727827
Exempt-From-Owner-Approval: Cherry-picking from goog/master to aosp/master
Merged-in: Ie1ad6711c490c679ebcfacd97154380a8810ba1c
Change-Id: Ie1ad6711c490c679ebcfacd97154380a8810ba1c
2020-07-15 01:36:38 +00:00
Makoto Onuki
7197b67343 Proper API hierarchy between MODULE_LIBS and PRIV_APPS system APIs
Test: build / treehugger
Bug: 146727827
Change-Id: Ie1ad6711c490c679ebcfacd97154380a8810ba1c
2020-07-14 17:46:10 +00:00
Mark Chien
93743bb990 Merge "Tethering: Add WiGig support" am: 65fadfc134 am: 6c5b5b0803 am: fdf89ee7fb am: 45fa4f9c88 am: 5131fee94b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1177323

Change-Id: I2d3971390e897be6669d2f2d4b261eb73875c267
2020-06-23 00:09:17 +00:00
Mark Chien
fdf89ee7fb Merge "Tethering: Add WiGig support" am: 65fadfc134 am: 6c5b5b0803
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1177323

Change-Id: Ib48182d51cc6e4586cb43f8ca51ea673ee14d1d7
2020-06-22 23:43:43 +00:00
Dedy Lansky
6896f6193f Tethering: Add WiGig support
This change is a combination of following changes:

1) Tethering: add TETHERING_WIGIG type
   Currently both WIFI and WIGIG use the same tethering type,
   TETHERING_WIFI. This causes conflicts between the frameworks,
   when both WIFI and WIGIG SoftAPs are started, one or both will
   not work.
   Fix this by using a seperate tethering type for WIGIG.

2) Tethering: remove TETHERING_WIGIG state machine on interface down
   The wigig state machine relies on a TETHERING_STATE_CHANGED broadcast
   that is sent when the tethering state machine is first created, during
   interface up. Currently the tethering state machine is not removed
   on interface down except for TETHERING_BLUETOOTH, and as a result
   wigig tethering only works the first time SoftAP is started.
   In order to fix this, remove the tethering state machine on interface
   down for TETHERING_WIGIG as well.

Bug: 143356416
Test: TetheringCoverageTests

Change-Id: Ic4d3aca0ed69234093af7f0206dab3335938c52a
2020-06-22 21:17:46 +08:00
markchien
902043f5c3 Pass entitlement configuration to Settings for entitlement check
Tethering resource configuration is move from framwork to tethering
module. Since tethering resource would not be accessible from outside
of tethering module, EntitlementManager would tell Settings the
entitlement configuration via intent extra when run entitlement check.

Bug: 146918263
Test: atest TetheringTests
Change-Id: I6f23553bb1da5f0b767f920b32a86fafb9e00b9e
Merged-In: I6f23553bb1da5f0b767f920b32a86fafb9e00b9e
2020-06-20 10:19:21 +08:00
Mark Chien
37867cc26b Merge "Revert "Revert "Pass entitlement configuration to Settings for entitlement check""" into rvc-dev am: 404c3adad7 am: 7e501e2967 am: bccb89a187 am: 36a6c56989
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11836350

Change-Id: Ic89fe046e75a76aebf05e47c8754010f52a45536
2020-06-17 07:02:13 +00:00
Mark Chien
7e501e2967 Merge "Revert "Revert "Pass entitlement configuration to Settings for entitlement check""" into rvc-dev am: 404c3adad7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11836350

Change-Id: Ibfea2e6f2564942eca60c84a5df5583acc1b9e8b
2020-06-17 06:24:22 +00:00
Mark Chien
c55e229dcb Revert "Revert "Pass entitlement configuration to Settings for entitlement check""
Add commit message here for reference:
Tethering resource configuration is move from framework to tethering
module. The resource would not be accessible from outside of tethering
module.
List the replacements of framework resources usage and intent extra:
1. R.string.config_mobile_hotspot_provision_response
    --> android.net.extra.TETHER_PROVISIONING_RESPONSE.
2. R.string.config_mobile_hotspot_provision_app_no_ui
    --> android.net.extra.TETHER_UI_PROVISIONING_APP_NAME
3. R.array.config_mobile_hotspot_provision_app
    --> android.net.extra.TETHER_SILENT_PROVISIONING_ACTION
Besides, the current active subId would put in
android.net.extra.TETHER_SUBID

Note: They are not APIs because of API freeze. Now both tethering module
and Settings define these strings independently.

Bug: 146918263
Test: atest TetherServiceTest
      atest TetherProvisioningActivityTest

This reverts commit 9988903174.

Reason for revert: Resume the CL and put this CL with settings part in the same topic to avoid break.

Change-Id: I114b4c258743661df51e5a969e150047a292e035
2020-06-15 16:38:53 +00:00
Mark Chien
03a094dfce Merge "Revert "Pass entitlement configuration to Settings for entitlement check"" into rvc-dev am: f1b2407490 am: b4ac5bc5b4 am: b05fa7f798 am: a7cec49bfc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11836348

Change-Id: I53318fdc3d116127dd9d22bb449b8868313a38ba
2020-06-12 18:10:27 +00:00
Mark Chien
b4ac5bc5b4 Merge "Revert "Pass entitlement configuration to Settings for entitlement check"" into rvc-dev am: f1b2407490
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11836348

Change-Id: I9436ba6a4fe7ef3eb38316d831e047957302bc49
2020-06-12 17:45:36 +00:00
Mark Chien
9988903174 Revert "Pass entitlement configuration to Settings for entitlement check"
Original CL has dependencies with unmerged settings change: https://googleplex-android-review.git.corp.google.com/c/platform/packages/apps/Settings/+/11524847
They should be in the same topic, revert it first. Will resume it and put the same with settings part CL.

This reverts commit 217d7b01f8.

Reason for revert: This break hotspot because it should merged with settings part together.

Bug: 158836492

Change-Id: I94d3ee25168cfb3d125030654c4bb8ddd670abfc
2020-06-12 15:29:39 +00:00
TreeHugger Robot
8613dab375 Merge "Pass entitlement configuration to Settings for entitlement check" into rvc-dev am: 03cfdd49b6 am: 56a635ceb5 am: aa0f47ccb3 am: 1f6f0a7743
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11560353

Change-Id: I9d0da41702117523bc1570ce9eead4283192b768
2020-06-11 16:19:17 +00:00
TreeHugger Robot
1f6f0a7743 Merge "Pass entitlement configuration to Settings for entitlement check" into rvc-dev am: 03cfdd49b6 am: 56a635ceb5 am: aa0f47ccb3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11560353

Change-Id: I4ad9c2e14018c888e9a0b27f0b16643f233a7f6b
2020-06-11 15:57:28 +00:00
TreeHugger Robot
10ede1fcae Merge "Pass entitlement configuration to Settings for entitlement check" into rvc-dev am: 03cfdd49b6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11560353

Change-Id: I213f7fa7116f58ae63cb32ecbf9f62e8306a83d2
2020-06-11 15:14:42 +00:00
markchien
217d7b01f8 Pass entitlement configuration to Settings for entitlement check
Tethering resource configuration is move from framwork to tethering
module. Since tethering resource would not be accessible from outside
of tethering module, EntitlementManager would tell Settings the
entitlement configuration via intent extra when run entitlement check.

Bug: 146918263
Test: atest TetheringTests
Change-Id: I6f23553bb1da5f0b767f920b32a86fafb9e00b9e
2020-06-11 13:53:27 +08:00
Philip P. Moltmann
8d5c1d7efb Merge "Set attributionTag for noteOp(WRITE_SETTINGS) calls" am: 83ba9531d7 am: 319db1af8b
Change-Id: I099944752fc3006c1e98750dd46dbebf5e50789f
2020-04-22 15:19:14 +00:00
Philip P. Moltmann
b94bb42096 Set attributionTag for noteOp(WRITE_SETTINGS) calls
Test: atest FrameworksNetTests
Bug: 136595429
Change-Id: I33f787644c44d7b0e5ce17a433820cfcd985cdfb
Exempt-From-Owner-Approval: Merge from AOSP
2020-04-21 21:46:34 +00:00
Philip P. Moltmann
64343b0b8d Set attributionTag for noteOp(WRITE_SETTINGS) calls
Test: atest FrameworksNetTests TetheringTests:TetheringServiceTest
Bug: 136595429
Merged-In: I33f787644c44d7b0e5ce17a433820cfcd985cdfb
Change-Id: Ic3d937e7bb5141798234ed5b2852c1f768e97495
2020-04-20 18:00:03 -07:00
Treehugger Robot
5da1070d8f Assign specific client address to dhcp server
Bug: 141256482
Test: manual
      atest TetheringTests

Merged-In: Ief76c98c843ba5420224cbf0f34464f366c891b7
Change-Id: Ief76c98c843ba5420224cbf0f34464f366c891b7
2020-04-10 10:03:20 +00:00
Treehugger Robot
a3fbca5f60 Merge "Assign specific client address to dhcp server" am: 037becbf64 am: 815ab636c3
Change-Id: Ia0e4a913faa5eac5d5ccba837eb7774d59670d27
2020-03-30 04:23:55 +00:00
Treehugger Robot
037becbf64 Merge "Assign specific client address to dhcp server" 2020-03-30 03:38:46 +00:00
markchien
1d0aebc713 Hide startTethering with type function to module-lib only
Bug: 151918384
Test: m
Change-Id: Icef8b363aae97dd020d618bcb397f661aa6c4750
Merged-In: Icef8b363aae97dd020d618bcb397f661aa6c4750
2020-03-25 08:07:01 +00:00
junyulai
a8b377747b Address API council review comment about TetheringRequest
Test: atest TetheringTests FrameworksNetTests NetworkStackTests
Bug: 152055812
Change-Id: I0158d88e364772f9ac258bd18955edcdad266ad8
Merged-In: I0158d88e364772f9ac258bd18955edcdad266ad8
(this is a clean cherry-pick from ag/10796412)

Change-Id: I64f1527d79085cc5dfd78c01a6c49c4df87c82e7
2020-03-23 14:14:22 +08:00
junyulai
e3b9708c3a Address API council review comment about TetheringRequest
Test: atest TetheringTests FrameworksNetTests NetworkStackTests
Bug: 152055812
Change-Id: I0158d88e364772f9ac258bd18955edcdad266ad8
2020-03-23 12:13:57 +08:00
markchien
b1bfea5367 Hide startTethering with type function to module-lib only
Bug: 151918384
Test: m
Change-Id: Icef8b363aae97dd020d618bcb397f661aa6c4750
2020-03-19 21:04:04 +08: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
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
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
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
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
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
Automerger Merge Worker
943fb5b686 Change TetheringConstants class to final
Bug: 151322331
Test: m doc-comment-check-docs

Change-Id: Ieca36d81b7799988b8dbb9c0d22de690136303ab
Merged-In: Ia02be3d1d91a08ae4a56b25560ed448c96a693db
(cherry picked from commit 5e2740b24658ba340a6b47a46c89cfd642afe394)
2020-03-16 07:43:05 +00:00
Mark Chien
0c5f387efe Merge "Change TetheringConstants class to final" 2020-03-16 05:25:40 +00:00
markchien
4b896ba32b Change TetheringConstants class to final
Bug: 151322331
Test: m doc-comment-check-docs
Change-Id: Ia02be3d1d91a08ae4a56b25560ed448c96a693db
2020-03-15 22:54:57 +08:00