Use new bluetooth API to enable/disable bt tethering after T
This change only apply to the device after T. Use new bluetooth API to change bluetooth tethering settings and the new API provide the callback to to notify Tethering when bluetooth interface is ready. Tethering doesn't use bluetooth interface status change event from netlink to add/remove IpServer anymore. Tag: #feature Bug: 190438212 Test: TetheringTest Change-Id: Iae92d98d500f83b116da7282cf1130fb8fecf53d
This commit is contained in:
@@ -614,10 +614,8 @@ public class IpServer extends StateMachine {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mInterfaceType == TetheringManager.TETHERING_BLUETOOTH) {
|
||||
// BT configures the interface elsewhere: only start DHCP.
|
||||
// TODO: make all tethering types behave the same way, and delete the bluetooth
|
||||
// code that calls into NetworkManagementService directly.
|
||||
if (shouldNotConfigureBluetoothInterface()) {
|
||||
// Interface was already configured elsewhere, only start DHCP.
|
||||
return configureDhcp(enabled, mIpv4Address, null /* clientAddress */);
|
||||
}
|
||||
|
||||
@@ -651,12 +649,15 @@ public class IpServer extends StateMachine {
|
||||
return configureDhcp(enabled, mIpv4Address, mStaticIpv4ClientAddr);
|
||||
}
|
||||
|
||||
private boolean shouldNotConfigureBluetoothInterface() {
|
||||
// Before T, bluetooth tethering configures the interface elsewhere.
|
||||
return (mInterfaceType == TetheringManager.TETHERING_BLUETOOTH) && !SdkLevel.isAtLeastT();
|
||||
}
|
||||
|
||||
private LinkAddress requestIpv4Address(final boolean useLastAddress) {
|
||||
if (mStaticIpv4ServerAddr != null) return mStaticIpv4ServerAddr;
|
||||
|
||||
if (mInterfaceType == TetheringManager.TETHERING_BLUETOOTH) {
|
||||
return new LinkAddress(BLUETOOTH_IFACE_ADDR);
|
||||
}
|
||||
if (shouldNotConfigureBluetoothInterface()) return new LinkAddress(BLUETOOTH_IFACE_ADDR);
|
||||
|
||||
return mPrivateAddressCoordinator.requestDownstreamAddress(this, useLastAddress);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user