Merge changes Ib8fe719f,Ia8c05780 am: 7648833bd4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729160 Change-Id: Ia8ff14142da45de950d2bac507ed5b943d81533e
This commit is contained in:
@@ -1054,8 +1054,16 @@ public class IpServer extends StateMachine {
|
|||||||
mLastRaParams = newParams;
|
mLastRaParams = newParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logMessage(State state, int what) {
|
private void maybeLogMessage(State state, int what) {
|
||||||
mLog.log(state.getName() + " got " + sMagicDecoderRing.get(what, Integer.toString(what)));
|
switch (what) {
|
||||||
|
// Suppress some CMD_* to avoid log flooding.
|
||||||
|
case CMD_IPV6_TETHER_UPDATE:
|
||||||
|
case CMD_NEIGHBOR_EVENT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mLog.log(state.getName() + " got "
|
||||||
|
+ sMagicDecoderRing.get(what, Integer.toString(what)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendInterfaceState(int newInterfaceState) {
|
private void sendInterfaceState(int newInterfaceState) {
|
||||||
@@ -1095,7 +1103,7 @@ public class IpServer extends StateMachine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
logMessage(this, message.what);
|
maybeLogMessage(this, message.what);
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_REQUESTED:
|
case CMD_TETHER_REQUESTED:
|
||||||
mLastError = TetheringManager.TETHER_ERROR_NO_ERROR;
|
mLastError = TetheringManager.TETHER_ERROR_NO_ERROR;
|
||||||
@@ -1180,7 +1188,6 @@ public class IpServer extends StateMachine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
logMessage(this, message.what);
|
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_UNREQUESTED:
|
case CMD_TETHER_UNREQUESTED:
|
||||||
transitionTo(mInitialState);
|
transitionTo(mInitialState);
|
||||||
@@ -1238,7 +1245,7 @@ public class IpServer extends StateMachine {
|
|||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (super.processMessage(message)) return true;
|
if (super.processMessage(message)) return true;
|
||||||
|
|
||||||
logMessage(this, message.what);
|
maybeLogMessage(this, message.what);
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_REQUESTED:
|
case CMD_TETHER_REQUESTED:
|
||||||
mLog.e("CMD_TETHER_REQUESTED while in local-only hotspot mode.");
|
mLog.e("CMD_TETHER_REQUESTED while in local-only hotspot mode.");
|
||||||
@@ -1306,7 +1313,7 @@ public class IpServer extends StateMachine {
|
|||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (super.processMessage(message)) return true;
|
if (super.processMessage(message)) return true;
|
||||||
|
|
||||||
logMessage(this, message.what);
|
maybeLogMessage(this, message.what);
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_REQUESTED:
|
case CMD_TETHER_REQUESTED:
|
||||||
mLog.e("CMD_TETHER_REQUESTED while already tethering.");
|
mLog.e("CMD_TETHER_REQUESTED while already tethering.");
|
||||||
@@ -1417,7 +1424,7 @@ public class IpServer extends StateMachine {
|
|||||||
class WaitingForRestartState extends State {
|
class WaitingForRestartState extends State {
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
logMessage(this, message.what);
|
maybeLogMessage(this, message.what);
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_UNREQUESTED:
|
case CMD_TETHER_UNREQUESTED:
|
||||||
transitionTo(mInitialState);
|
transitionTo(mInitialState);
|
||||||
|
|||||||
@@ -495,11 +495,11 @@ public class Tethering {
|
|||||||
// See NetlinkHandler.cpp: notifyInterfaceChanged.
|
// See NetlinkHandler.cpp: notifyInterfaceChanged.
|
||||||
if (VDBG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up);
|
if (VDBG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up);
|
||||||
if (up) {
|
if (up) {
|
||||||
maybeTrackNewInterfaceLocked(iface);
|
maybeTrackNewInterface(iface);
|
||||||
} else {
|
} else {
|
||||||
if (ifaceNameToType(iface) == TETHERING_BLUETOOTH
|
if (ifaceNameToType(iface) == TETHERING_BLUETOOTH
|
||||||
|| ifaceNameToType(iface) == TETHERING_WIGIG) {
|
|| ifaceNameToType(iface) == TETHERING_WIGIG) {
|
||||||
stopTrackingInterfaceLocked(iface);
|
stopTrackingInterface(iface);
|
||||||
} else {
|
} else {
|
||||||
// Ignore usb0 down after enabling RNDIS.
|
// Ignore usb0 down after enabling RNDIS.
|
||||||
// We will handle disconnect in interfaceRemoved.
|
// We will handle disconnect in interfaceRemoved.
|
||||||
@@ -535,12 +535,12 @@ public class Tethering {
|
|||||||
|
|
||||||
void interfaceAdded(String iface) {
|
void interfaceAdded(String iface) {
|
||||||
if (VDBG) Log.d(TAG, "interfaceAdded " + iface);
|
if (VDBG) Log.d(TAG, "interfaceAdded " + iface);
|
||||||
maybeTrackNewInterfaceLocked(iface);
|
maybeTrackNewInterface(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void interfaceRemoved(String iface) {
|
void interfaceRemoved(String iface) {
|
||||||
if (VDBG) Log.d(TAG, "interfaceRemoved " + iface);
|
if (VDBG) Log.d(TAG, "interfaceRemoved " + iface);
|
||||||
stopTrackingInterfaceLocked(iface);
|
stopTrackingInterface(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startTethering(final TetheringRequestParcel request, final IIntResultListener listener) {
|
void startTethering(final TetheringRequestParcel request, final IIntResultListener listener) {
|
||||||
@@ -694,14 +694,14 @@ public class Tethering {
|
|||||||
mEthernetCallback = new EthernetCallback();
|
mEthernetCallback = new EthernetCallback();
|
||||||
mEthernetIfaceRequest = em.requestTetheredInterface(mExecutor, mEthernetCallback);
|
mEthernetIfaceRequest = em.requestTetheredInterface(mExecutor, mEthernetCallback);
|
||||||
} else {
|
} else {
|
||||||
stopEthernetTetheringLocked();
|
stopEthernetTethering();
|
||||||
}
|
}
|
||||||
return TETHER_ERROR_NO_ERROR;
|
return TETHER_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopEthernetTetheringLocked() {
|
private void stopEthernetTethering() {
|
||||||
if (mConfiguredEthernetIface != null) {
|
if (mConfiguredEthernetIface != null) {
|
||||||
stopTrackingInterfaceLocked(mConfiguredEthernetIface);
|
stopTrackingInterface(mConfiguredEthernetIface);
|
||||||
mConfiguredEthernetIface = null;
|
mConfiguredEthernetIface = null;
|
||||||
}
|
}
|
||||||
if (mEthernetCallback != null) {
|
if (mEthernetCallback != null) {
|
||||||
@@ -718,7 +718,7 @@ public class Tethering {
|
|||||||
// Ethernet callback arrived after Ethernet tethering stopped. Ignore.
|
// Ethernet callback arrived after Ethernet tethering stopped. Ignore.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maybeTrackNewInterfaceLocked(iface, TETHERING_ETHERNET);
|
maybeTrackNewInterface(iface, TETHERING_ETHERNET);
|
||||||
changeInterfaceState(iface, getRequestedState(TETHERING_ETHERNET));
|
changeInterfaceState(iface, getRequestedState(TETHERING_ETHERNET));
|
||||||
mConfiguredEthernetIface = iface;
|
mConfiguredEthernetIface = iface;
|
||||||
}
|
}
|
||||||
@@ -729,7 +729,7 @@ public class Tethering {
|
|||||||
// onAvailable called after stopping Ethernet tethering.
|
// onAvailable called after stopping Ethernet tethering.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stopEthernetTetheringLocked();
|
stopEthernetTethering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1030,7 +1030,7 @@ public class Tethering {
|
|||||||
// We can see this state on the way to both enabled and failure states.
|
// We can see this state on the way to both enabled and failure states.
|
||||||
break;
|
break;
|
||||||
case WifiManager.WIFI_AP_STATE_ENABLED:
|
case WifiManager.WIFI_AP_STATE_ENABLED:
|
||||||
enableWifiIpServingLocked(ifname, ipmode);
|
enableWifiIpServing(ifname, ipmode);
|
||||||
break;
|
break;
|
||||||
case WifiManager.WIFI_AP_STATE_DISABLING:
|
case WifiManager.WIFI_AP_STATE_DISABLING:
|
||||||
// We can see this state on the way to disabled.
|
// We can see this state on the way to disabled.
|
||||||
@@ -1038,7 +1038,7 @@ public class Tethering {
|
|||||||
case WifiManager.WIFI_AP_STATE_DISABLED:
|
case WifiManager.WIFI_AP_STATE_DISABLED:
|
||||||
case WifiManager.WIFI_AP_STATE_FAILED:
|
case WifiManager.WIFI_AP_STATE_FAILED:
|
||||||
default:
|
default:
|
||||||
disableWifiIpServingLocked(ifname, curState);
|
disableWifiIpServing(ifname, curState);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1062,7 @@ public class Tethering {
|
|||||||
|
|
||||||
// if no group is formed, bring it down if needed.
|
// if no group is formed, bring it down if needed.
|
||||||
if (p2pInfo == null || !p2pInfo.groupFormed) {
|
if (p2pInfo == null || !p2pInfo.groupFormed) {
|
||||||
disableWifiP2pIpServingLockedIfNeeded(mWifiP2pTetherInterface);
|
disableWifiP2pIpServingIfNeeded(mWifiP2pTetherInterface);
|
||||||
mWifiP2pTetherInterface = null;
|
mWifiP2pTetherInterface = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1078,12 +1078,12 @@ public class Tethering {
|
|||||||
mLog.w("P2P tethered interface " + mWifiP2pTetherInterface
|
mLog.w("P2P tethered interface " + mWifiP2pTetherInterface
|
||||||
+ "is different from current interface "
|
+ "is different from current interface "
|
||||||
+ group.getInterface() + ", re-tether it");
|
+ group.getInterface() + ", re-tether it");
|
||||||
disableWifiP2pIpServingLockedIfNeeded(mWifiP2pTetherInterface);
|
disableWifiP2pIpServingIfNeeded(mWifiP2pTetherInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally bring up serving on the new interface
|
// Finally bring up serving on the new interface
|
||||||
mWifiP2pTetherInterface = group.getInterface();
|
mWifiP2pTetherInterface = group.getInterface();
|
||||||
enableWifiIpServingLocked(mWifiP2pTetherInterface, IFACE_IP_MODE_LOCAL_ONLY);
|
enableWifiIpServing(mWifiP2pTetherInterface, IFACE_IP_MODE_LOCAL_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUserRestrictionAction() {
|
private void handleUserRestrictionAction() {
|
||||||
@@ -1164,7 +1164,7 @@ public class Tethering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableWifiIpServingLockedCommon(int tetheringType, String ifname, int apState) {
|
private void disableWifiIpServingCommon(int tetheringType, String ifname, int apState) {
|
||||||
mLog.log("Canceling WiFi tethering request -"
|
mLog.log("Canceling WiFi tethering request -"
|
||||||
+ " type=" + tetheringType
|
+ " type=" + tetheringType
|
||||||
+ " interface=" + ifname
|
+ " interface=" + ifname
|
||||||
@@ -1191,23 +1191,23 @@ public class Tethering {
|
|||||||
: "specified interface: " + ifname));
|
: "specified interface: " + ifname));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableWifiIpServingLocked(String ifname, int apState) {
|
private void disableWifiIpServing(String ifname, int apState) {
|
||||||
// Regardless of whether we requested this transition, the AP has gone
|
// Regardless of whether we requested this transition, the AP has gone
|
||||||
// down. Don't try to tether again unless we're requested to do so.
|
// down. Don't try to tether again unless we're requested to do so.
|
||||||
// TODO: Remove this altogether, once Wi-Fi reliably gives us an
|
// TODO: Remove this altogether, once Wi-Fi reliably gives us an
|
||||||
// interface name with every broadcast.
|
// interface name with every broadcast.
|
||||||
mWifiTetherRequested = false;
|
mWifiTetherRequested = false;
|
||||||
|
|
||||||
disableWifiIpServingLockedCommon(TETHERING_WIFI, ifname, apState);
|
disableWifiIpServingCommon(TETHERING_WIFI, ifname, apState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableWifiP2pIpServingLockedIfNeeded(String ifname) {
|
private void disableWifiP2pIpServingIfNeeded(String ifname) {
|
||||||
if (TextUtils.isEmpty(ifname)) return;
|
if (TextUtils.isEmpty(ifname)) return;
|
||||||
|
|
||||||
disableWifiIpServingLockedCommon(TETHERING_WIFI_P2P, ifname, /* fake */ 0);
|
disableWifiIpServingCommon(TETHERING_WIFI_P2P, ifname, /* fake */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableWifiIpServingLocked(String ifname, int wifiIpMode) {
|
private void enableWifiIpServing(String ifname, int wifiIpMode) {
|
||||||
// Map wifiIpMode values to IpServer.Callback serving states, inferring
|
// Map wifiIpMode values to IpServer.Callback serving states, inferring
|
||||||
// from mWifiTetherRequested as a final "best guess".
|
// from mWifiTetherRequested as a final "best guess".
|
||||||
final int ipServingMode;
|
final int ipServingMode;
|
||||||
@@ -1224,7 +1224,7 @@ public class Tethering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(ifname)) {
|
if (!TextUtils.isEmpty(ifname)) {
|
||||||
maybeTrackNewInterfaceLocked(ifname);
|
maybeTrackNewInterface(ifname);
|
||||||
changeInterfaceState(ifname, ipServingMode);
|
changeInterfaceState(ifname, ipServingMode);
|
||||||
} else {
|
} else {
|
||||||
mLog.e(String.format(
|
mLog.e(String.format(
|
||||||
@@ -2437,7 +2437,7 @@ public class Tethering {
|
|||||||
mTetherMainSM.sendMessage(which, state, 0, newLp);
|
mTetherMainSM.sendMessage(which, state, 0, newLp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeTrackNewInterfaceLocked(final String iface) {
|
private void maybeTrackNewInterface(final String iface) {
|
||||||
// If we don't care about this type of interface, ignore.
|
// If we don't care about this type of interface, ignore.
|
||||||
final int interfaceType = ifaceNameToType(iface);
|
final int interfaceType = ifaceNameToType(iface);
|
||||||
if (interfaceType == TETHERING_INVALID) {
|
if (interfaceType == TETHERING_INVALID) {
|
||||||
@@ -2457,10 +2457,10 @@ public class Tethering {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybeTrackNewInterfaceLocked(iface, interfaceType);
|
maybeTrackNewInterface(iface, interfaceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeTrackNewInterfaceLocked(final String iface, int interfaceType) {
|
private void maybeTrackNewInterface(final String iface, int interfaceType) {
|
||||||
// If we have already started a TISM for this interface, skip.
|
// If we have already started a TISM for this interface, skip.
|
||||||
if (mTetherStates.containsKey(iface)) {
|
if (mTetherStates.containsKey(iface)) {
|
||||||
mLog.log("active iface (" + iface + ") reported as added, ignoring");
|
mLog.log("active iface (" + iface + ") reported as added, ignoring");
|
||||||
@@ -2477,7 +2477,7 @@ public class Tethering {
|
|||||||
tetherState.ipServer.start();
|
tetherState.ipServer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopTrackingInterfaceLocked(final String iface) {
|
private void stopTrackingInterface(final String iface) {
|
||||||
final TetherState tetherState = mTetherStates.get(iface);
|
final TetherState tetherState = mTetherStates.get(iface);
|
||||||
if (tetherState == null) {
|
if (tetherState == null) {
|
||||||
mLog.log("attempting to remove unknown iface (" + iface + "), ignoring");
|
mLog.log("attempting to remove unknown iface (" + iface + "), ignoring");
|
||||||
|
|||||||
Reference in New Issue
Block a user