Merge "Add experiment flag for tethering refactor" into main
This commit is contained in:
@@ -33,7 +33,6 @@ import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
|
|||||||
|
|
||||||
import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH;
|
import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH;
|
||||||
import static com.android.net.module.util.NetworkStackConstants.RFC7421_PREFIX_LENGTH;
|
import static com.android.net.module.util.NetworkStackConstants.RFC7421_PREFIX_LENGTH;
|
||||||
import static com.android.networkstack.tethering.TetheringConfiguration.USE_SYNC_SM;
|
|
||||||
import static com.android.networkstack.tethering.UpstreamNetworkState.isVcnInterface;
|
import static com.android.networkstack.tethering.UpstreamNetworkState.isVcnInterface;
|
||||||
import static com.android.networkstack.tethering.util.PrefixUtils.asIpPrefix;
|
import static com.android.networkstack.tethering.util.PrefixUtils.asIpPrefix;
|
||||||
import static com.android.networkstack.tethering.util.TetheringMessageBase.BASE_IPSERVER;
|
import static com.android.networkstack.tethering.util.TetheringMessageBase.BASE_IPSERVER;
|
||||||
@@ -316,6 +315,7 @@ public class IpServer extends StateMachineShim {
|
|||||||
|
|
||||||
private final TetheringMetrics mTetheringMetrics;
|
private final TetheringMetrics mTetheringMetrics;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
private final boolean mIsSyncSM;
|
||||||
|
|
||||||
// TODO: Add a dependency object to pass the data members or variables from the tethering
|
// TODO: Add a dependency object to pass the data members or variables from the tethering
|
||||||
// object. It helps to reduce the arguments of the constructor.
|
// object. It helps to reduce the arguments of the constructor.
|
||||||
@@ -325,7 +325,7 @@ public class IpServer extends StateMachineShim {
|
|||||||
@Nullable LateSdk<RoutingCoordinatorManager> routingCoordinator, Callback callback,
|
@Nullable LateSdk<RoutingCoordinatorManager> routingCoordinator, Callback callback,
|
||||||
TetheringConfiguration config, PrivateAddressCoordinator addressCoordinator,
|
TetheringConfiguration config, PrivateAddressCoordinator addressCoordinator,
|
||||||
TetheringMetrics tetheringMetrics, Dependencies deps) {
|
TetheringMetrics tetheringMetrics, Dependencies deps) {
|
||||||
super(ifaceName, USE_SYNC_SM ? null : handler.getLooper());
|
super(ifaceName, config.isSyncSM() ? null : handler.getLooper());
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mLog = log.forSubComponent(ifaceName);
|
mLog = log.forSubComponent(ifaceName);
|
||||||
mNetd = netd;
|
mNetd = netd;
|
||||||
@@ -338,6 +338,7 @@ public class IpServer extends StateMachineShim {
|
|||||||
mLinkProperties = new LinkProperties();
|
mLinkProperties = new LinkProperties();
|
||||||
mUsingLegacyDhcp = config.useLegacyDhcpServer();
|
mUsingLegacyDhcp = config.useLegacyDhcpServer();
|
||||||
mP2pLeasesSubnetPrefixLength = config.getP2pLeasesSubnetPrefixLength();
|
mP2pLeasesSubnetPrefixLength = config.getP2pLeasesSubnetPrefixLength();
|
||||||
|
mIsSyncSM = config.isSyncSM();
|
||||||
mPrivateAddressCoordinator = addressCoordinator;
|
mPrivateAddressCoordinator = addressCoordinator;
|
||||||
mDeps = deps;
|
mDeps = deps;
|
||||||
mTetheringMetrics = tetheringMetrics;
|
mTetheringMetrics = tetheringMetrics;
|
||||||
@@ -515,7 +516,7 @@ public class IpServer extends StateMachineShim {
|
|||||||
|
|
||||||
private void handleError() {
|
private void handleError() {
|
||||||
mLastError = TETHER_ERROR_DHCPSERVER_ERROR;
|
mLastError = TETHER_ERROR_DHCPSERVER_ERROR;
|
||||||
if (USE_SYNC_SM) {
|
if (mIsSyncSM) {
|
||||||
sendMessage(CMD_SERVICE_FAILED_TO_START, TETHER_ERROR_DHCPSERVER_ERROR);
|
sendMessage(CMD_SERVICE_FAILED_TO_START, TETHER_ERROR_DHCPSERVER_ERROR);
|
||||||
} else {
|
} else {
|
||||||
sendMessageAtFrontOfQueueToAsyncSM(CMD_SERVICE_FAILED_TO_START,
|
sendMessageAtFrontOfQueueToAsyncSM(CMD_SERVICE_FAILED_TO_START,
|
||||||
@@ -1170,7 +1171,7 @@ public class IpServer extends StateMachineShim {
|
|||||||
// in previous versions of the mainline module.
|
// in previous versions of the mainline module.
|
||||||
// TODO : remove sendMessageAtFrontOfQueueToAsyncSM after migrating to the Sync
|
// TODO : remove sendMessageAtFrontOfQueueToAsyncSM after migrating to the Sync
|
||||||
// StateMachine.
|
// StateMachine.
|
||||||
if (USE_SYNC_SM) {
|
if (mIsSyncSM) {
|
||||||
sendSelfMessageToSyncSM(CMD_SERVICE_FAILED_TO_START, mLastError);
|
sendSelfMessageToSyncSM(CMD_SERVICE_FAILED_TO_START, mLastError);
|
||||||
} else {
|
} else {
|
||||||
sendMessageAtFrontOfQueueToAsyncSM(CMD_SERVICE_FAILED_TO_START, mLastError);
|
sendMessageAtFrontOfQueueToAsyncSM(CMD_SERVICE_FAILED_TO_START, mLastError);
|
||||||
|
|||||||
@@ -132,15 +132,15 @@ public class TetheringConfiguration {
|
|||||||
|
|
||||||
public static final String TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION =
|
public static final String TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION =
|
||||||
"tether_force_random_prefix_base_selection";
|
"tether_force_random_prefix_base_selection";
|
||||||
|
|
||||||
|
public static final String TETHER_ENABLE_SYNC_SM = "tether_enable_sync_sm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default value that used to periodic polls tether offload stats from tethering offload HAL
|
* Default value that used to periodic polls tether offload stats from tethering offload HAL
|
||||||
* to make the data warnings work.
|
* to make the data warnings work.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS = 5000;
|
public static final int DEFAULT_TETHER_OFFLOAD_POLL_INTERVAL_MS = 5000;
|
||||||
|
|
||||||
/** A flag for using synchronous or asynchronous state machine. */
|
|
||||||
public static final boolean USE_SYNC_SM = false;
|
|
||||||
|
|
||||||
public final String[] tetherableUsbRegexs;
|
public final String[] tetherableUsbRegexs;
|
||||||
public final String[] tetherableWifiRegexs;
|
public final String[] tetherableWifiRegexs;
|
||||||
public final String[] tetherableWigigRegexs;
|
public final String[] tetherableWigigRegexs;
|
||||||
@@ -174,6 +174,7 @@ public class TetheringConfiguration {
|
|||||||
|
|
||||||
private final boolean mEnableWearTethering;
|
private final boolean mEnableWearTethering;
|
||||||
private final boolean mRandomPrefixBase;
|
private final boolean mRandomPrefixBase;
|
||||||
|
private final boolean mEnableSyncSm;
|
||||||
|
|
||||||
private final int mUsbTetheringFunction;
|
private final int mUsbTetheringFunction;
|
||||||
protected final ContentResolver mContentResolver;
|
protected final ContentResolver mContentResolver;
|
||||||
@@ -292,6 +293,7 @@ public class TetheringConfiguration {
|
|||||||
mEnableWearTethering = shouldEnableWearTethering(ctx);
|
mEnableWearTethering = shouldEnableWearTethering(ctx);
|
||||||
|
|
||||||
mRandomPrefixBase = mDeps.isFeatureEnabled(ctx, TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION);
|
mRandomPrefixBase = mDeps.isFeatureEnabled(ctx, TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION);
|
||||||
|
mEnableSyncSm = mDeps.isFeatureEnabled(ctx, TETHER_ENABLE_SYNC_SM);
|
||||||
|
|
||||||
configLog.log(toString());
|
configLog.log(toString());
|
||||||
}
|
}
|
||||||
@@ -385,6 +387,10 @@ public class TetheringConfiguration {
|
|||||||
return mRandomPrefixBase;
|
return mRandomPrefixBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSyncSM() {
|
||||||
|
return mEnableSyncSm;
|
||||||
|
}
|
||||||
|
|
||||||
/** Does the dumping.*/
|
/** Does the dumping.*/
|
||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
pw.print("activeDataSubId: ");
|
pw.print("activeDataSubId: ");
|
||||||
@@ -438,6 +444,9 @@ public class TetheringConfiguration {
|
|||||||
|
|
||||||
pw.print("mRandomPrefixBase: ");
|
pw.print("mRandomPrefixBase: ");
|
||||||
pw.println(mRandomPrefixBase);
|
pw.println(mRandomPrefixBase);
|
||||||
|
|
||||||
|
pw.print("mEnableSyncSm: ");
|
||||||
|
pw.println(mEnableSyncSm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the string representation of this object.*/
|
/** Returns the string representation of this object.*/
|
||||||
|
|||||||
@@ -754,4 +754,26 @@ public class TetheringConfigurationTest {
|
|||||||
new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID, mDeps);
|
new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID, mDeps);
|
||||||
assertEquals(p2pLeasesSubnetPrefixLength, p2pCfg.getP2pLeasesSubnetPrefixLength());
|
assertEquals(p2pLeasesSubnetPrefixLength, p2pCfg.getP2pLeasesSubnetPrefixLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setTetherEnableSyncSMFlagEnabled(Boolean enabled) {
|
||||||
|
mDeps.setFeatureEnabled(TetheringConfiguration.TETHER_ENABLE_SYNC_SM, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertEnableSyncSMIs(boolean value) {
|
||||||
|
assertEquals(value, new TetheringConfiguration(
|
||||||
|
mMockContext, mLog, INVALID_SUBSCRIPTION_ID, mDeps).isSyncSM());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnableSyncSMFlag() throws Exception {
|
||||||
|
// Test default disabled
|
||||||
|
setTetherEnableSyncSMFlagEnabled(null);
|
||||||
|
assertEnableSyncSMIs(false);
|
||||||
|
|
||||||
|
setTetherEnableSyncSMFlagEnabled(true);
|
||||||
|
assertEnableSyncSMIs(true);
|
||||||
|
|
||||||
|
setTetherEnableSyncSMFlagEnabled(false);
|
||||||
|
assertEnableSyncSMIs(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user