Release the interface request when Ethernet tethering is stopped.
When the Ethernet interface becomes unavailable (e.g., because
the cable was unplugged or the interface was removed), or when
setEthernetTethering(false) is called, release the Ethernet
interface request.
This ensures that:
- The Ethernet interface immediately becomes available for use in
client mode.
- If an interface later becomes available, tethering is not
automatically started. This is consistent with what happens for
other downstream types such as wifi and USB. Evey time one of
those downstreams goes down, tethering is stopped and will not
be restarted.
Test: manual
Bug: 148824036
Change-Id: Iaf85e800569f2e08c39f7ebb96f8aa34f6e53133
Merged-In: Iaf85e800569f2e08c39f7ebb96f8aa34f6e53133
(cherry picked from commit e54c92e565)
This commit is contained in:
committed by
Lorenzo Colitti
parent
a7aededa7d
commit
41c81248e8
@@ -641,21 +641,21 @@ public class Tethering {
|
|||||||
mEthernetIfaceRequest = em.requestTetheredInterface(mExecutor, mEthernetCallback);
|
mEthernetIfaceRequest = em.requestTetheredInterface(mExecutor, mEthernetCallback);
|
||||||
} else {
|
} else {
|
||||||
stopEthernetTetheringLocked();
|
stopEthernetTetheringLocked();
|
||||||
if (mEthernetCallback != null) {
|
|
||||||
mEthernetIfaceRequest.release();
|
|
||||||
mEthernetCallback = null;
|
|
||||||
mEthernetIfaceRequest = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TETHER_ERROR_NO_ERROR;
|
return TETHER_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopEthernetTetheringLocked() {
|
private void stopEthernetTetheringLocked() {
|
||||||
if (mConfiguredEthernetIface == null) return;
|
if (mConfiguredEthernetIface != null) {
|
||||||
changeInterfaceState(mConfiguredEthernetIface, IpServer.STATE_AVAILABLE);
|
stopTrackingInterfaceLocked(mConfiguredEthernetIface);
|
||||||
stopTrackingInterfaceLocked(mConfiguredEthernetIface);
|
mConfiguredEthernetIface = null;
|
||||||
mConfiguredEthernetIface = null;
|
}
|
||||||
|
if (mEthernetCallback != null) {
|
||||||
|
mEthernetIfaceRequest.release();
|
||||||
|
mEthernetCallback = null;
|
||||||
|
mEthernetIfaceRequest = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EthernetCallback implements EthernetManager.TetheredInterfaceCallback {
|
private class EthernetCallback implements EthernetManager.TetheredInterfaceCallback {
|
||||||
|
|||||||
Reference in New Issue
Block a user