diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2020-03-19 15:52:09 +0000 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2020-03-19 15:54:05 +0000 |
commit | b66a87d950719bc65cd883284e1cab419f19fb7f (patch) | |
tree | 947906e2693fa22e549e39be4a681475e2641a06 | |
parent | bbb550ceb7e22bbfb730cc83011ec2498eb08b6c (diff) | |
download | ethernet-b66a87d950719bc65cd883284e1cab419f19fb7f.tar.gz |
Send tethered interface callbacks based on interface existence.
Currently, callbacks for tethered interface availability are sent
based on interface link state. This is incorrect:
- It is acceptable and expected to be able to enable tethering on
an interface that does not yet have link up.
- It doesn't seem useful to disable Ethernet tethering if link
temporarily goes down.
Instead, only base the callbacks on whether an interface exists
or not.
Bug: 150644681
Test: WIP tests in aosp/1260100 pass
Change-Id: I015219cbd03626c38fb5156d0cb2991ba7d7def7
Merged-In: I015219cbd03626c38fb5156d0cb2991ba7d7def7
(cherry picked from commit 64d12ea20ce3cd822518e0f15ed7483a2fb91a50)
-rw-r--r-- | java/com/android/server/ethernet/EthernetTracker.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java index d1f1402..336ddef 100644 --- a/java/com/android/server/ethernet/EthernetTracker.java +++ b/java/com/android/server/ethernet/EthernetTracker.java @@ -262,6 +262,7 @@ final class EthernetTracker { private void removeInterface(String iface) { mFactory.removeInterface(iface); + maybeUpdateServerModeInterfaceState(iface, false); } private void stopTrackingInterface(String iface) { @@ -308,6 +309,8 @@ final class EthernetTracker { Log.d(TAG, "Started tracking interface " + iface); mFactory.addInterface(iface, hwAddress, nc, ipConfiguration); + } else { + maybeUpdateServerModeInterfaceState(iface, true); } // Note: if the interface already has link (e.g., if we crashed and got @@ -341,12 +344,9 @@ final class EthernetTracker { } mListeners.finishBroadcast(); } - - updateServerModeInterfaceState(iface, up, mode); } - private void updateServerModeInterfaceState(String iface, boolean up, int mode) { - final boolean available = up && (mode == INTERFACE_MODE_SERVER); + private void maybeUpdateServerModeInterfaceState(String iface, boolean available) { if (available == mTetheredInterfaceWasAvailable || !iface.equals(mDefaultInterface)) return; final int pendingCbs = mTetheredInterfaceRequests.beginBroadcast(); |