Add TetherConfigParcel to improve tetherStartWithConfiguration
tetherStartWithConfiguration doesn't take a configuration, it
takes a boolean. But for extensibility purposes, it should
take some sort of configuration parcel. This is because in
AIDL, once we add a method we cannot ever change its signature
or add parameters, because there cannot be two methods with the
same name. Create a new parcel to improve this.
Bug: 145777247
Test: atest FrameworksNetTests
Test: atest netd_integration_test:BinderTest#TetherStartStopStatus
Test: build, flash, on/off tethering
Change-Id: I0d34a25fc9a187e218d37a058b8316ea2423a5da
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 9e217f5..322604a 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -906,16 +906,19 @@
}
binder::Status NetdNativeService::tetherStart(const std::vector<std::string>& dhcpRanges) {
- return tetherStartWithConfiguration(true, dhcpRanges);
+ TetherConfigParcel config;
+ config.usingLegacyDnsProxy = true;
+ config.dhcpRanges = dhcpRanges;
+ return tetherStartWithConfiguration(config);
}
-binder::Status NetdNativeService::tetherStartWithConfiguration(
- bool usingLegacyDnsProxy, const std::vector<std::string>& dhcpRanges) {
+binder::Status NetdNativeService::tetherStartWithConfiguration(const TetherConfigParcel& config) {
NETD_LOCKING_RPC(gCtls->tetherCtrl.lock, PERM_NETWORK_STACK, PERM_MAINLINE_NETWORK_STACK);
- if (dhcpRanges.size() % 2 == 1) {
+ if (config.dhcpRanges.size() % 2 == 1) {
return statusFromErrcode(-EINVAL);
}
- int res = gCtls->tetherCtrl.startTethering(usingLegacyDnsProxy, dhcpRanges);
+ // TODO: Pass TetherConfigParcel directly.
+ int res = gCtls->tetherCtrl.startTethering(config.usingLegacyDnsProxy, config.dhcpRanges);
return statusFromErrcode(res);
}