Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference. Test: m ; atest TetheringTests Bug: 161896447 Change-Id: Idc58697c72fb00896bee00185fefc50c1a24dd35
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<!-- Permissions must be defined here, and not in the base manifest, as the tethering
|
<!-- Permissions must be defined here, and not in the base manifest, as the tethering
|
||||||
running in the system server process does not need any permission, and having
|
running in the system server process does not need any permission, and having
|
||||||
privileged permissions added would cause crashes on startup unless they are also
|
privileged permissions added would cause crashes on startup unless they are also
|
||||||
added to the privileged permissions whitelist for that package. -->
|
added to the privileged permissions allowlist for that package. -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
|
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Keep class's integer static field for MessageUtils to parsing their name.
|
# Keep class's integer static field for MessageUtils to parsing their name.
|
||||||
-keep class com.android.networkstack.tethering.Tethering$TetherMasterSM {
|
-keep class com.android.networkstack.tethering.Tethering$TetherMainSM {
|
||||||
static final int CMD_*;
|
static final int CMD_*;
|
||||||
static final int EVENT_*;
|
static final int EVENT_*;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,15 +196,19 @@ public class IpServer extends StateMachine {
|
|||||||
public static final int CMD_TETHER_UNREQUESTED = BASE_IPSERVER + 2;
|
public static final int CMD_TETHER_UNREQUESTED = BASE_IPSERVER + 2;
|
||||||
// notification that this interface is down
|
// notification that this interface is down
|
||||||
public static final int CMD_INTERFACE_DOWN = BASE_IPSERVER + 3;
|
public static final int CMD_INTERFACE_DOWN = BASE_IPSERVER + 3;
|
||||||
// notification from the master SM that it had trouble enabling IP Forwarding
|
// notification from the {@link Tethering.TetherMainSM} that it had trouble enabling IP
|
||||||
|
// Forwarding
|
||||||
public static final int CMD_IP_FORWARDING_ENABLE_ERROR = BASE_IPSERVER + 4;
|
public static final int CMD_IP_FORWARDING_ENABLE_ERROR = BASE_IPSERVER + 4;
|
||||||
// notification from the master SM that it had trouble disabling IP Forwarding
|
// notification from the {@link Tethering.TetherMainSM} SM that it had trouble disabling IP
|
||||||
|
// Forwarding
|
||||||
public static final int CMD_IP_FORWARDING_DISABLE_ERROR = BASE_IPSERVER + 5;
|
public static final int CMD_IP_FORWARDING_DISABLE_ERROR = BASE_IPSERVER + 5;
|
||||||
// notification from the master SM that it had trouble starting tethering
|
// notification from the {@link Tethering.TetherMainSM} SM that it had trouble starting
|
||||||
|
// tethering
|
||||||
public static final int CMD_START_TETHERING_ERROR = BASE_IPSERVER + 6;
|
public static final int CMD_START_TETHERING_ERROR = BASE_IPSERVER + 6;
|
||||||
// notification from the master SM that it had trouble stopping tethering
|
// notification from the {@link Tethering.TetherMainSM} that it had trouble stopping tethering
|
||||||
public static final int CMD_STOP_TETHERING_ERROR = BASE_IPSERVER + 7;
|
public static final int CMD_STOP_TETHERING_ERROR = BASE_IPSERVER + 7;
|
||||||
// notification from the master SM that it had trouble setting the DNS forwarders
|
// notification from the {@link Tethering.TetherMainSM} that it had trouble setting the DNS
|
||||||
|
// forwarders
|
||||||
public static final int CMD_SET_DNS_FORWARDERS_ERROR = BASE_IPSERVER + 8;
|
public static final int CMD_SET_DNS_FORWARDERS_ERROR = BASE_IPSERVER + 8;
|
||||||
// the upstream connection has changed
|
// the upstream connection has changed
|
||||||
public static final int CMD_TETHER_CONNECTION_CHANGED = BASE_IPSERVER + 9;
|
public static final int CMD_TETHER_CONNECTION_CHANGED = BASE_IPSERVER + 9;
|
||||||
@@ -1315,7 +1319,7 @@ public class IpServer extends StateMachine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This state is terminal for the per interface state machine. At this
|
* This state is terminal for the per interface state machine. At this
|
||||||
* point, the master state machine should have removed this interface
|
* point, the tethering main state machine should have removed this interface
|
||||||
* specific state machine from its list of possible recipients of
|
* specific state machine from its list of possible recipients of
|
||||||
* tethering requests. The state machine itself will hang around until
|
* tethering requests. The state machine itself will hang around until
|
||||||
* the garbage collector finds it.
|
* the garbage collector finds it.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package android.net.util;
|
|||||||
* This class defines Message.what base addresses for various state machine.
|
* This class defines Message.what base addresses for various state machine.
|
||||||
*/
|
*/
|
||||||
public class TetheringMessageBase {
|
public class TetheringMessageBase {
|
||||||
public static final int BASE_MASTER = 0;
|
public static final int BASE_MAIN_SM = 0;
|
||||||
public static final int BASE_IPSERVER = 100;
|
public static final int BASE_IPSERVER = 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,16 +296,16 @@ public class EntitlementManager {
|
|||||||
* Reference TetheringManager.TETHERING_{@code *} for each tether type.
|
* Reference TetheringManager.TETHERING_{@code *} for each tether type.
|
||||||
*
|
*
|
||||||
* @param config an object that encapsulates the various tethering configuration elements.
|
* @param config an object that encapsulates the various tethering configuration elements.
|
||||||
* Note: this method is only called from TetherMaster on the handler thread.
|
* Note: this method is only called from @{link Tethering.TetherMainSM} on the handler thread.
|
||||||
* If there are new callers from different threads, the logic should move to
|
* If there are new callers from different threads, the logic should move to
|
||||||
* masterHandler to avoid race conditions.
|
* @{link Tethering.TetherMainSM} handler to avoid race conditions.
|
||||||
*/
|
*/
|
||||||
public void reevaluateSimCardProvisioning(final TetheringConfiguration config) {
|
public void reevaluateSimCardProvisioning(final TetheringConfiguration config) {
|
||||||
if (DBG) mLog.i("reevaluateSimCardProvisioning");
|
if (DBG) mLog.i("reevaluateSimCardProvisioning");
|
||||||
|
|
||||||
if (!mHandler.getLooper().isCurrentThread()) {
|
if (!mHandler.getLooper().isCurrentThread()) {
|
||||||
// Except for test, this log should not appear in normal flow.
|
// Except for test, this log should not appear in normal flow.
|
||||||
mLog.log("reevaluateSimCardProvisioning() don't run in TetherMaster thread");
|
mLog.log("reevaluateSimCardProvisioning() don't run in TetherMainSM thread");
|
||||||
}
|
}
|
||||||
mEntitlementCacheValue.clear();
|
mEntitlementCacheValue.clear();
|
||||||
mCurrentEntitlementResults.clear();
|
mCurrentEntitlementResults.clear();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import static android.net.TetheringManager.TETHER_ERROR_UNKNOWN_TYPE;
|
|||||||
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_FAILED;
|
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_FAILED;
|
||||||
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED;
|
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED;
|
||||||
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED;
|
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED;
|
||||||
import static android.net.util.TetheringMessageBase.BASE_MASTER;
|
import static android.net.util.TetheringMessageBase.BASE_MAIN_SM;
|
||||||
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
|
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
|
||||||
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE;
|
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE;
|
||||||
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
|
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
|
||||||
@@ -159,7 +159,7 @@ public class Tethering {
|
|||||||
private static final boolean VDBG = false;
|
private static final boolean VDBG = false;
|
||||||
|
|
||||||
private static final Class[] sMessageClasses = {
|
private static final Class[] sMessageClasses = {
|
||||||
Tethering.class, TetherMasterSM.class, IpServer.class
|
Tethering.class, TetherMainSM.class, IpServer.class
|
||||||
};
|
};
|
||||||
private static final SparseArray<String> sMagicDecoderRing =
|
private static final SparseArray<String> sMagicDecoderRing =
|
||||||
MessageUtils.findMessageNames(sMessageClasses);
|
MessageUtils.findMessageNames(sMessageClasses);
|
||||||
@@ -216,7 +216,7 @@ public class Tethering {
|
|||||||
private final ArrayMap<String, TetherState> mTetherStates;
|
private final ArrayMap<String, TetherState> mTetherStates;
|
||||||
private final BroadcastReceiver mStateReceiver;
|
private final BroadcastReceiver mStateReceiver;
|
||||||
private final Looper mLooper;
|
private final Looper mLooper;
|
||||||
private final StateMachine mTetherMasterSM;
|
private final StateMachine mTetherMainSM;
|
||||||
private final OffloadController mOffloadController;
|
private final OffloadController mOffloadController;
|
||||||
private final UpstreamNetworkMonitor mUpstreamNetworkMonitor;
|
private final UpstreamNetworkMonitor mUpstreamNetworkMonitor;
|
||||||
// TODO: Figure out how to merge this and other downstream-tracking objects
|
// TODO: Figure out how to merge this and other downstream-tracking objects
|
||||||
@@ -273,10 +273,10 @@ public class Tethering {
|
|||||||
mTetherStates = new ArrayMap<>();
|
mTetherStates = new ArrayMap<>();
|
||||||
mConnectedClientsTracker = new ConnectedClientsTracker();
|
mConnectedClientsTracker = new ConnectedClientsTracker();
|
||||||
|
|
||||||
mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper, deps);
|
mTetherMainSM = new TetherMainSM("TetherMain", mLooper, deps);
|
||||||
mTetherMasterSM.start();
|
mTetherMainSM.start();
|
||||||
|
|
||||||
mHandler = mTetherMasterSM.getHandler();
|
mHandler = mTetherMainSM.getHandler();
|
||||||
mOffloadController = mDeps.getOffloadController(mHandler, mLog,
|
mOffloadController = mDeps.getOffloadController(mHandler, mLog,
|
||||||
new OffloadController.Dependencies() {
|
new OffloadController.Dependencies() {
|
||||||
|
|
||||||
@@ -285,8 +285,8 @@ public class Tethering {
|
|||||||
return mConfig;
|
return mConfig;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mUpstreamNetworkMonitor = mDeps.getUpstreamNetworkMonitor(mContext, mTetherMasterSM, mLog,
|
mUpstreamNetworkMonitor = mDeps.getUpstreamNetworkMonitor(mContext, mTetherMainSM, mLog,
|
||||||
TetherMasterSM.EVENT_UPSTREAM_CALLBACK);
|
TetherMainSM.EVENT_UPSTREAM_CALLBACK);
|
||||||
mForwardedDownstreams = new LinkedHashSet<>();
|
mForwardedDownstreams = new LinkedHashSet<>();
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@@ -294,8 +294,8 @@ public class Tethering {
|
|||||||
// EntitlementManager will send EVENT_UPSTREAM_PERMISSION_CHANGED when cellular upstream
|
// EntitlementManager will send EVENT_UPSTREAM_PERMISSION_CHANGED when cellular upstream
|
||||||
// permission is changed according to entitlement check result.
|
// permission is changed according to entitlement check result.
|
||||||
mEntitlementMgr = mDeps.getEntitlementManager(mContext, mHandler, mLog,
|
mEntitlementMgr = mDeps.getEntitlementManager(mContext, mHandler, mLog,
|
||||||
() -> mTetherMasterSM.sendMessage(
|
() -> mTetherMainSM.sendMessage(
|
||||||
TetherMasterSM.EVENT_UPSTREAM_PERMISSION_CHANGED));
|
TetherMainSM.EVENT_UPSTREAM_PERMISSION_CHANGED));
|
||||||
mEntitlementMgr.setOnUiEntitlementFailedListener((int downstream) -> {
|
mEntitlementMgr.setOnUiEntitlementFailedListener((int downstream) -> {
|
||||||
mLog.log("OBSERVED UiEnitlementFailed");
|
mLog.log("OBSERVED UiEnitlementFailed");
|
||||||
stopTethering(downstream);
|
stopTethering(downstream);
|
||||||
@@ -945,7 +945,7 @@ public class Tethering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VDBG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION: " + networkInfo.toString());
|
if (VDBG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION: " + networkInfo.toString());
|
||||||
mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED);
|
mTetherMainSM.sendMessage(TetherMainSM.CMD_UPSTREAM_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUsbAction(Intent intent) {
|
private void handleUsbAction(Intent intent) {
|
||||||
@@ -1170,7 +1170,7 @@ public class Tethering {
|
|||||||
private void disableWifiP2pIpServingLockedIfNeeded(String ifname) {
|
private void disableWifiP2pIpServingLockedIfNeeded(String ifname) {
|
||||||
if (TextUtils.isEmpty(ifname)) return;
|
if (TextUtils.isEmpty(ifname)) return;
|
||||||
|
|
||||||
disableWifiIpServingLockedCommon(TETHERING_WIFI_P2P, ifname, /* dummy */ 0);
|
disableWifiIpServingLockedCommon(TETHERING_WIFI_P2P, ifname, /* fake */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableWifiIpServingLocked(String ifname, int wifiIpMode) {
|
private void enableWifiIpServingLocked(String ifname, int wifiIpMode) {
|
||||||
@@ -1381,23 +1381,23 @@ public class Tethering {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TetherMasterSM extends StateMachine {
|
class TetherMainSM extends StateMachine {
|
||||||
// an interface SM has requested Tethering/Local Hotspot
|
// an interface SM has requested Tethering/Local Hotspot
|
||||||
static final int EVENT_IFACE_SERVING_STATE_ACTIVE = BASE_MASTER + 1;
|
static final int EVENT_IFACE_SERVING_STATE_ACTIVE = BASE_MAIN_SM + 1;
|
||||||
// an interface SM has unrequested Tethering/Local Hotspot
|
// an interface SM has unrequested Tethering/Local Hotspot
|
||||||
static final int EVENT_IFACE_SERVING_STATE_INACTIVE = BASE_MASTER + 2;
|
static final int EVENT_IFACE_SERVING_STATE_INACTIVE = BASE_MAIN_SM + 2;
|
||||||
// upstream connection change - do the right thing
|
// upstream connection change - do the right thing
|
||||||
static final int CMD_UPSTREAM_CHANGED = BASE_MASTER + 3;
|
static final int CMD_UPSTREAM_CHANGED = BASE_MAIN_SM + 3;
|
||||||
// we don't have a valid upstream conn, check again after a delay
|
// we don't have a valid upstream conn, check again after a delay
|
||||||
static final int CMD_RETRY_UPSTREAM = BASE_MASTER + 4;
|
static final int CMD_RETRY_UPSTREAM = BASE_MAIN_SM + 4;
|
||||||
// Events from NetworkCallbacks that we process on the master state
|
// Events from NetworkCallbacks that we process on the main state
|
||||||
// machine thread on behalf of the UpstreamNetworkMonitor.
|
// machine thread on behalf of the UpstreamNetworkMonitor.
|
||||||
static final int EVENT_UPSTREAM_CALLBACK = BASE_MASTER + 5;
|
static final int EVENT_UPSTREAM_CALLBACK = BASE_MAIN_SM + 5;
|
||||||
// we treated the error and want now to clear it
|
// we treated the error and want now to clear it
|
||||||
static final int CMD_CLEAR_ERROR = BASE_MASTER + 6;
|
static final int CMD_CLEAR_ERROR = BASE_MAIN_SM + 6;
|
||||||
static final int EVENT_IFACE_UPDATE_LINKPROPERTIES = BASE_MASTER + 7;
|
static final int EVENT_IFACE_UPDATE_LINKPROPERTIES = BASE_MAIN_SM + 7;
|
||||||
// Events from EntitlementManager to choose upstream again.
|
// Events from EntitlementManager to choose upstream again.
|
||||||
static final int EVENT_UPSTREAM_PERMISSION_CHANGED = BASE_MASTER + 8;
|
static final int EVENT_UPSTREAM_PERMISSION_CHANGED = BASE_MAIN_SM + 8;
|
||||||
private final State mInitialState;
|
private final State mInitialState;
|
||||||
private final State mTetherModeAliveState;
|
private final State mTetherModeAliveState;
|
||||||
|
|
||||||
@@ -1425,7 +1425,7 @@ public class Tethering {
|
|||||||
|
|
||||||
private static final int UPSTREAM_SETTLE_TIME_MS = 10000;
|
private static final int UPSTREAM_SETTLE_TIME_MS = 10000;
|
||||||
|
|
||||||
TetherMasterSM(String name, Looper looper, TetheringDependencies deps) {
|
TetherMainSM(String name, Looper looper, TetheringDependencies deps) {
|
||||||
super(name, looper);
|
super(name, looper);
|
||||||
|
|
||||||
mInitialState = new InitialState();
|
mInitialState = new InitialState();
|
||||||
@@ -1479,7 +1479,7 @@ public class Tethering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean turnOnMasterTetherSettings() {
|
protected boolean turnOnMainTetherSettings() {
|
||||||
final TetheringConfiguration cfg = mConfig;
|
final TetheringConfiguration cfg = mConfig;
|
||||||
try {
|
try {
|
||||||
mNetd.ipfwdEnableForwarding(TAG);
|
mNetd.ipfwdEnableForwarding(TAG);
|
||||||
@@ -1506,11 +1506,11 @@ public class Tethering {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mLog.log("SET master tether settings: ON");
|
mLog.log("SET main tether settings: ON");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean turnOffMasterTetherSettings() {
|
protected boolean turnOffMainTetherSettings() {
|
||||||
try {
|
try {
|
||||||
mNetd.tetherStop();
|
mNetd.tetherStop();
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
@@ -1526,7 +1526,7 @@ public class Tethering {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
transitionTo(mInitialState);
|
transitionTo(mInitialState);
|
||||||
mLog.log("SET master tether settings: OFF");
|
mLog.log("SET main tether settings: OFF");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1730,7 +1730,7 @@ public class Tethering {
|
|||||||
// TODO: Re-evaluate possible upstreams. Currently upstream
|
// TODO: Re-evaluate possible upstreams. Currently upstream
|
||||||
// reevaluation is triggered via received CONNECTIVITY_ACTION
|
// reevaluation is triggered via received CONNECTIVITY_ACTION
|
||||||
// broadcasts that result in being passed a
|
// broadcasts that result in being passed a
|
||||||
// TetherMasterSM.CMD_UPSTREAM_CHANGED.
|
// TetherMainSM.CMD_UPSTREAM_CHANGED.
|
||||||
handleNewUpstreamNetworkState(null);
|
handleNewUpstreamNetworkState(null);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1745,9 +1745,9 @@ public class Tethering {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
// If turning on master tether settings fails, we have already
|
// If turning on main tether settings fails, we have already
|
||||||
// transitioned to an error state; exit early.
|
// transitioned to an error state; exit early.
|
||||||
if (!turnOnMasterTetherSettings()) {
|
if (!turnOnMainTetherSettings()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1819,7 +1819,7 @@ public class Tethering {
|
|||||||
if (mNotifyList.isEmpty()) {
|
if (mNotifyList.isEmpty()) {
|
||||||
// This transitions us out of TetherModeAliveState,
|
// This transitions us out of TetherModeAliveState,
|
||||||
// either to InitialState or an error state.
|
// either to InitialState or an error state.
|
||||||
turnOffMasterTetherSettings();
|
turnOffMainTetherSettings();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2329,7 +2329,7 @@ public class Tethering {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move into TetherMasterSM.
|
// TODO: Move into TetherMainSM.
|
||||||
private void notifyInterfaceStateChange(IpServer who, int state, int error) {
|
private void notifyInterfaceStateChange(IpServer who, int state, int error) {
|
||||||
final String iface = who.interfaceName();
|
final String iface = who.interfaceName();
|
||||||
synchronized (mPublicSync) {
|
synchronized (mPublicSync) {
|
||||||
@@ -2344,27 +2344,27 @@ public class Tethering {
|
|||||||
|
|
||||||
mLog.log(String.format("OBSERVED iface=%s state=%s error=%s", iface, state, error));
|
mLog.log(String.format("OBSERVED iface=%s state=%s error=%s", iface, state, error));
|
||||||
|
|
||||||
// If TetherMasterSM is in ErrorState, TetherMasterSM stays there.
|
// If TetherMainSM is in ErrorState, TetherMainSM stays there.
|
||||||
// Thus we give a chance for TetherMasterSM to recover to InitialState
|
// Thus we give a chance for TetherMainSM to recover to InitialState
|
||||||
// by sending CMD_CLEAR_ERROR
|
// by sending CMD_CLEAR_ERROR
|
||||||
if (error == TETHER_ERROR_INTERNAL_ERROR) {
|
if (error == TETHER_ERROR_INTERNAL_ERROR) {
|
||||||
mTetherMasterSM.sendMessage(TetherMasterSM.CMD_CLEAR_ERROR, who);
|
mTetherMainSM.sendMessage(TetherMainSM.CMD_CLEAR_ERROR, who);
|
||||||
}
|
}
|
||||||
int which;
|
int which;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case IpServer.STATE_UNAVAILABLE:
|
case IpServer.STATE_UNAVAILABLE:
|
||||||
case IpServer.STATE_AVAILABLE:
|
case IpServer.STATE_AVAILABLE:
|
||||||
which = TetherMasterSM.EVENT_IFACE_SERVING_STATE_INACTIVE;
|
which = TetherMainSM.EVENT_IFACE_SERVING_STATE_INACTIVE;
|
||||||
break;
|
break;
|
||||||
case IpServer.STATE_TETHERED:
|
case IpServer.STATE_TETHERED:
|
||||||
case IpServer.STATE_LOCAL_ONLY:
|
case IpServer.STATE_LOCAL_ONLY:
|
||||||
which = TetherMasterSM.EVENT_IFACE_SERVING_STATE_ACTIVE;
|
which = TetherMainSM.EVENT_IFACE_SERVING_STATE_ACTIVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.wtf(TAG, "Unknown interface state: " + state);
|
Log.wtf(TAG, "Unknown interface state: " + state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mTetherMasterSM.sendMessage(which, state, 0, who);
|
mTetherMainSM.sendMessage(which, state, 0, who);
|
||||||
sendTetherStateChangedBroadcast();
|
sendTetherStateChangedBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2384,8 +2384,8 @@ public class Tethering {
|
|||||||
mLog.log(String.format(
|
mLog.log(String.format(
|
||||||
"OBSERVED LinkProperties update iface=%s state=%s lp=%s",
|
"OBSERVED LinkProperties update iface=%s state=%s lp=%s",
|
||||||
iface, IpServer.getStateString(state), newLp));
|
iface, IpServer.getStateString(state), newLp));
|
||||||
final int which = TetherMasterSM.EVENT_IFACE_UPDATE_LINKPROPERTIES;
|
final int which = TetherMainSM.EVENT_IFACE_UPDATE_LINKPROPERTIES;
|
||||||
mTetherMasterSM.sendMessage(which, state, 0, newLp);
|
mTetherMainSM.sendMessage(which, state, 0, newLp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeTrackNewInterfaceLocked(final String iface) {
|
private void maybeTrackNewInterfaceLocked(final String iface) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ import java.util.Set;
|
|||||||
* Calling #registerMobileNetworkRequest() to bring up mobile DUN/HIPRI network.
|
* Calling #registerMobileNetworkRequest() to bring up mobile DUN/HIPRI network.
|
||||||
*
|
*
|
||||||
* The methods and data members of this class are only to be accessed and
|
* The methods and data members of this class are only to be accessed and
|
||||||
* modified from the tethering master state machine thread. Any other
|
* modified from the tethering main state machine thread. Any other
|
||||||
* access semantics would necessitate the addition of locking.
|
* access semantics would necessitate the addition of locking.
|
||||||
*
|
*
|
||||||
* TODO: Move upstream selection logic here.
|
* TODO: Move upstream selection logic here.
|
||||||
|
|||||||
@@ -337,11 +337,11 @@ public class TetheringTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class MockTetheringDependencies extends TetheringDependencies {
|
public class MockTetheringDependencies extends TetheringDependencies {
|
||||||
StateMachine mUpstreamNetworkMonitorMasterSM;
|
StateMachine mUpstreamNetworkMonitorSM;
|
||||||
ArrayList<IpServer> mIpv6CoordinatorNotifyList;
|
ArrayList<IpServer> mIpv6CoordinatorNotifyList;
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mUpstreamNetworkMonitorMasterSM = null;
|
mUpstreamNetworkMonitorSM = null;
|
||||||
mIpv6CoordinatorNotifyList = null;
|
mIpv6CoordinatorNotifyList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ public class TetheringTest {
|
|||||||
@Override
|
@Override
|
||||||
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx,
|
public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx,
|
||||||
StateMachine target, SharedLog log, int what) {
|
StateMachine target, SharedLog log, int what) {
|
||||||
mUpstreamNetworkMonitorMasterSM = target;
|
mUpstreamNetworkMonitorSM = target;
|
||||||
return mUpstreamNetworkMonitor;
|
return mUpstreamNetworkMonitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,8 +911,8 @@ public class TetheringTest {
|
|||||||
initTetheringUpstream(upstreamState);
|
initTetheringUpstream(upstreamState);
|
||||||
|
|
||||||
// Upstream LinkProperties changed: UpstreamNetworkMonitor sends EVENT_ON_LINKPROPERTIES.
|
// Upstream LinkProperties changed: UpstreamNetworkMonitor sends EVENT_ON_LINKPROPERTIES.
|
||||||
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM.sendMessage(
|
mTetheringDependencies.mUpstreamNetworkMonitorSM.sendMessage(
|
||||||
Tethering.TetherMasterSM.EVENT_UPSTREAM_CALLBACK,
|
Tethering.TetherMainSM.EVENT_UPSTREAM_CALLBACK,
|
||||||
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
||||||
0,
|
0,
|
||||||
upstreamState);
|
upstreamState);
|
||||||
@@ -1126,7 +1126,7 @@ public class TetheringTest {
|
|||||||
verify(mNetd, times(1)).ipfwdEnableForwarding(TETHERING_NAME);
|
verify(mNetd, times(1)).ipfwdEnableForwarding(TETHERING_NAME);
|
||||||
// This never gets called because of the exception thrown above.
|
// This never gets called because of the exception thrown above.
|
||||||
verify(mNetd, times(0)).tetherStartWithConfiguration(any());
|
verify(mNetd, times(0)).tetherStartWithConfiguration(any());
|
||||||
// When the master state machine transitions to an error state it tells
|
// When the main state machine transitions to an error state it tells
|
||||||
// downstream interfaces, which causes us to tell Wi-Fi about the error
|
// downstream interfaces, which causes us to tell Wi-Fi about the error
|
||||||
// so it can take down AP mode.
|
// so it can take down AP mode.
|
||||||
verify(mNetd, times(1)).tetherApplyDnsInterfaces();
|
verify(mNetd, times(1)).tetherApplyDnsInterfaces();
|
||||||
@@ -1753,8 +1753,8 @@ public class TetheringTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpstreamNetworkChanged() {
|
public void testUpstreamNetworkChanged() {
|
||||||
final Tethering.TetherMasterSM stateMachine = (Tethering.TetherMasterSM)
|
final Tethering.TetherMainSM stateMachine = (Tethering.TetherMainSM)
|
||||||
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM;
|
mTetheringDependencies.mUpstreamNetworkMonitorSM;
|
||||||
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
|
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
|
||||||
initTetheringUpstream(upstreamState);
|
initTetheringUpstream(upstreamState);
|
||||||
stateMachine.chooseUpstreamType(true);
|
stateMachine.chooseUpstreamType(true);
|
||||||
@@ -1765,8 +1765,8 @@ public class TetheringTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpstreamCapabilitiesChanged() {
|
public void testUpstreamCapabilitiesChanged() {
|
||||||
final Tethering.TetherMasterSM stateMachine = (Tethering.TetherMasterSM)
|
final Tethering.TetherMainSM stateMachine = (Tethering.TetherMainSM)
|
||||||
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM;
|
mTetheringDependencies.mUpstreamNetworkMonitorSM;
|
||||||
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
|
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
|
||||||
initTetheringUpstream(upstreamState);
|
initTetheringUpstream(upstreamState);
|
||||||
stateMachine.chooseUpstreamType(true);
|
stateMachine.chooseUpstreamType(true);
|
||||||
@@ -1891,8 +1891,8 @@ public class TetheringTest {
|
|||||||
any(), any());
|
any(), any());
|
||||||
reset(mNetd, mUsbManager);
|
reset(mNetd, mUsbManager);
|
||||||
upstreamNetwork = buildV4WifiUpstreamState(ipv4Address, 30, wifiNetwork);
|
upstreamNetwork = buildV4WifiUpstreamState(ipv4Address, 30, wifiNetwork);
|
||||||
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM.sendMessage(
|
mTetheringDependencies.mUpstreamNetworkMonitorSM.sendMessage(
|
||||||
Tethering.TetherMasterSM.EVENT_UPSTREAM_CALLBACK,
|
Tethering.TetherMainSM.EVENT_UPSTREAM_CALLBACK,
|
||||||
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
||||||
0,
|
0,
|
||||||
upstreamNetwork);
|
upstreamNetwork);
|
||||||
@@ -1929,8 +1929,8 @@ public class TetheringTest {
|
|||||||
|
|
||||||
final UpstreamNetworkState upstreamNetwork = buildV4WifiUpstreamState(
|
final UpstreamNetworkState upstreamNetwork = buildV4WifiUpstreamState(
|
||||||
upstreamAddress, 16, wifiNetwork);
|
upstreamAddress, 16, wifiNetwork);
|
||||||
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM.sendMessage(
|
mTetheringDependencies.mUpstreamNetworkMonitorSM.sendMessage(
|
||||||
Tethering.TetherMasterSM.EVENT_UPSTREAM_CALLBACK,
|
Tethering.TetherMainSM.EVENT_UPSTREAM_CALLBACK,
|
||||||
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
UpstreamNetworkMonitor.EVENT_ON_LINKPROPERTIES,
|
||||||
0,
|
0,
|
||||||
upstreamNetwork);
|
upstreamNetwork);
|
||||||
|
|||||||
Reference in New Issue
Block a user