Merge "Add experiment flag for enabling sync sm" into main
This commit is contained in:
commit
c1647a0efc
3 changed files with 41 additions and 1 deletions
|
|
@ -368,6 +368,7 @@ public class Tethering {
|
|||
|
||||
// Load tethering configuration.
|
||||
updateConfiguration();
|
||||
mConfig.readEnableSyncSM(mContext);
|
||||
// It is OK for the configuration to be passed to the PrivateAddressCoordinator at
|
||||
// construction time because the only part of the configuration it uses is
|
||||
// shouldEnableWifiP2pDedicatedIp(), and currently do not support changing that.
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ public class TetheringConfiguration {
|
|||
|
||||
public static final String 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
|
||||
* to make the data warnings work.
|
||||
|
|
@ -139,7 +142,7 @@ public class TetheringConfiguration {
|
|||
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 static boolean USE_SYNC_SM = false;
|
||||
|
||||
public final String[] tetherableUsbRegexs;
|
||||
public final String[] tetherableWifiRegexs;
|
||||
|
|
@ -385,6 +388,16 @@ public class TetheringConfiguration {
|
|||
return mRandomPrefixBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether sync SM is enabled then set it to USE_SYNC_SM. This should be called once
|
||||
* when tethering is created. Otherwise if the flag is pushed while tethering is enabled,
|
||||
* then it's possible for some IpServer(s) running the new sync state machine while others
|
||||
* use the async state machine.
|
||||
*/
|
||||
public void readEnableSyncSM(final Context ctx) {
|
||||
USE_SYNC_SM = mDeps.isFeatureEnabled(ctx, TETHER_ENABLE_SYNC_SM);
|
||||
}
|
||||
|
||||
/** Does the dumping.*/
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.print("activeDataSubId: ");
|
||||
|
|
@ -438,6 +451,9 @@ public class TetheringConfiguration {
|
|||
|
||||
pw.print("mRandomPrefixBase: ");
|
||||
pw.println(mRandomPrefixBase);
|
||||
|
||||
pw.print("USE_SYNC_SM: ");
|
||||
pw.println(USE_SYNC_SM);
|
||||
}
|
||||
|
||||
/** Returns the string representation of this object.*/
|
||||
|
|
|
|||
|
|
@ -754,4 +754,27 @@ public class TetheringConfigurationTest {
|
|||
new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID, mDeps);
|
||||
assertEquals(p2pLeasesSubnetPrefixLength, p2pCfg.getP2pLeasesSubnetPrefixLength());
|
||||
}
|
||||
|
||||
private void setTetherEnableSyncSMFlagEnabled(Boolean enabled) {
|
||||
mDeps.setFeatureEnabled(TetheringConfiguration.TETHER_ENABLE_SYNC_SM, enabled);
|
||||
new TetheringConfiguration(
|
||||
mMockContext, mLog, INVALID_SUBSCRIPTION_ID, mDeps).readEnableSyncSM(mMockContext);
|
||||
}
|
||||
|
||||
private void assertEnableSyncSM(boolean value) {
|
||||
assertEquals(value, TetheringConfiguration.USE_SYNC_SM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnableSyncSMFlag() throws Exception {
|
||||
// Test default disabled
|
||||
setTetherEnableSyncSMFlagEnabled(null);
|
||||
assertEnableSyncSM(false);
|
||||
|
||||
setTetherEnableSyncSMFlagEnabled(true);
|
||||
assertEnableSyncSM(true);
|
||||
|
||||
setTetherEnableSyncSMFlagEnabled(false);
|
||||
assertEnableSyncSM(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue