Support setting the default interface to null again. am: 876e5e16a9 am: 65c1bc7c5d am: ac350dddc6
Change-Id: Ifad7deba00f8e40a50014ec5922ecb9fae465188
This commit is contained in:
@@ -240,17 +240,17 @@ final class EthernetTracker {
|
|||||||
|
|
||||||
private void maybeUntetherDefaultInterface() {
|
private void maybeUntetherDefaultInterface() {
|
||||||
if (mTetheredInterfaceRequests.getRegisteredCallbackCount() > 0) return;
|
if (mTetheredInterfaceRequests.getRegisteredCallbackCount() > 0) return;
|
||||||
// mDefaultInterface null means that there never was a default interface (it is never set
|
if (mDefaultInterfaceMode == INTERFACE_MODE_CLIENT) return;
|
||||||
// to null).
|
|
||||||
if (mDefaultInterfaceMode == INTERFACE_MODE_CLIENT || mDefaultInterface == null) return;
|
|
||||||
|
|
||||||
setDefaultInterfaceMode(INTERFACE_MODE_CLIENT);
|
setDefaultInterfaceMode(INTERFACE_MODE_CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultInterfaceMode(int mode) {
|
private void setDefaultInterfaceMode(int mode) {
|
||||||
|
Log.d(TAG, "Setting default interface mode to " + mode);
|
||||||
mDefaultInterfaceMode = mode;
|
mDefaultInterfaceMode = mode;
|
||||||
removeInterface(mDefaultInterface);
|
if (mDefaultInterface != null) {
|
||||||
addInterface(mDefaultInterface);
|
removeInterface(mDefaultInterface);
|
||||||
|
addInterface(mDefaultInterface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getInterfaceMode(final String iface) {
|
private int getInterfaceMode(final String iface) {
|
||||||
@@ -264,6 +264,13 @@ final class EthernetTracker {
|
|||||||
mFactory.removeInterface(iface);
|
mFactory.removeInterface(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopTrackingInterface(String iface) {
|
||||||
|
removeInterface(iface);
|
||||||
|
if (iface.equals(mDefaultInterface)) {
|
||||||
|
mDefaultInterface = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addInterface(String iface) {
|
private void addInterface(String iface) {
|
||||||
InterfaceConfiguration config = null;
|
InterfaceConfiguration config = null;
|
||||||
// Bring up the interface so we get link status indications.
|
// Bring up the interface so we get link status indications.
|
||||||
@@ -406,7 +413,7 @@ final class EthernetTracker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void interfaceRemoved(String iface) {
|
public void interfaceRemoved(String iface) {
|
||||||
mHandler.post(() -> removeInterface(iface));
|
mHandler.post(() -> stopTrackingInterface(iface));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +592,6 @@ final class EthernetTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateIfaceMatchRegexp() {
|
private void updateIfaceMatchRegexp() {
|
||||||
final String testInterfaceMatch = TEST_TAP_PREFIX + ".*";
|
|
||||||
final String match = mContext.getResources().getString(
|
final String match = mContext.getResources().getString(
|
||||||
com.android.internal.R.string.config_ethernet_iface_regex);
|
com.android.internal.R.string.config_ethernet_iface_regex);
|
||||||
mIfaceMatch = mIncludeTestInterfaces
|
mIfaceMatch = mIncludeTestInterfaces
|
||||||
@@ -604,6 +610,8 @@ final class EthernetTracker {
|
|||||||
pw.println("Ethernet interface name filter: " + mIfaceMatch);
|
pw.println("Ethernet interface name filter: " + mIfaceMatch);
|
||||||
pw.println("Default interface: " + mDefaultInterface);
|
pw.println("Default interface: " + mDefaultInterface);
|
||||||
pw.println("Default interface mode: " + mDefaultInterfaceMode);
|
pw.println("Default interface mode: " + mDefaultInterfaceMode);
|
||||||
|
pw.println("Tethered interface requests: "
|
||||||
|
+ mTetheredInterfaceRequests.getRegisteredCallbackCount());
|
||||||
pw.println("Listeners: " + mListeners.getRegisteredCallbackCount());
|
pw.println("Listeners: " + mListeners.getRegisteredCallbackCount());
|
||||||
pw.println("IP Configurations:");
|
pw.println("IP Configurations:");
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
|
|||||||
Reference in New Issue
Block a user