Loading src/android/net/dhcp/DhcpClient.java +18 −5 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import android.net.util.InterfaceParams; import android.net.util.NetworkStackUtils; import android.net.util.PacketReader; import android.net.util.SocketUtils; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.PowerManager; Loading @@ -98,6 +99,7 @@ import com.android.internal.util.WakeupMessage; import com.android.networkstack.R; import com.android.networkstack.apishim.CaptivePortalDataShimImpl; import com.android.networkstack.apishim.SocketUtilsShimImpl; import com.android.networkstack.apishim.common.ShimUtils; import com.android.networkstack.arp.ArpPacket; import java.io.FileDescriptor; Loading Loading @@ -407,8 +409,10 @@ public class DhcpClient extends StateMachine { * Return whether a feature guarded by a feature flag is enabled. * @see NetworkStackUtils#isFeatureEnabled(Context, String, String) */ public boolean isFeatureEnabled(final Context context, final String name) { return NetworkStackUtils.isFeatureEnabled(context, NAMESPACE_CONNECTIVITY, name); public boolean isFeatureEnabled(final Context context, final String name, boolean defaultEnabled) { return NetworkStackUtils.isFeatureEnabled(context, NAMESPACE_CONNECTIVITY, name, defaultEnabled); } /** Loading Loading @@ -496,23 +500,32 @@ public class DhcpClient extends StateMachine { /** * check whether or not to support caching the last lease info and INIT-REBOOT state. * * INIT-REBOOT state is supported on Android R by default if there is no experiment flag set to * disable this feature explicitly, meanwhile we still hope to be able to control this feature * on/off by pushing experiment flag for A/B testing and metrics collection on both of Android * Q and R version, however it's disbled on Android Q by default. */ public boolean isDhcpLeaseCacheEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_INIT_REBOOT_VERSION); final boolean defaultEnabled = ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); return mDependencies.isFeatureEnabled(mContext, DHCP_INIT_REBOOT_VERSION, defaultEnabled); } /** * check whether or not to support DHCP Rapid Commit option. */ public boolean isDhcpRapidCommitEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_RAPID_COMMIT_VERSION); return mDependencies.isFeatureEnabled(mContext, DHCP_RAPID_COMMIT_VERSION, false /* defaultEnabled */); } /** * check whether or not to support IP address conflict detection and DHCPDECLINE. */ public boolean isDhcpIpConflictDetectEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_IP_CONFLICT_DETECT_VERSION); return mDependencies.isFeatureEnabled(mContext, DHCP_IP_CONFLICT_DETECT_VERSION, false /* defaultEnabled */); } private void confirmDhcpLease(DhcpPacket packet, DhcpResults results) { Loading src/android/net/util/NetworkStackUtils.java +1 −3 Original line number Diff line number Diff line Loading @@ -355,9 +355,7 @@ public class NetworkStackUtils { */ public static boolean isFeatureEnabled(@NonNull Context context, @NonNull String namespace, @NonNull String name) { final int propertyVersion = getDeviceConfigPropertyInt(namespace, name, 0 /* default value */); return isFeatureEnabled(context, namespace, name, false); return isFeatureEnabled(context, namespace, name, false /* defaultEnabled */); } /** Loading tests/integration/src/android/net/ip/IpClientIntegrationTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ import com.android.server.NetworkObserverRegistry; import com.android.server.NetworkStackService.NetworkStackServiceManager; import com.android.server.connectivity.ipmemorystore.IpMemoryStoreService; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; import com.android.testutils.HandlerUtilsKt; import com.android.testutils.TapPacketReader; Loading Loading @@ -320,7 +321,8 @@ public class IpClientIntegrationTest { NetworkStackIpMemoryStore ipMemoryStore) { return new DhcpClient.Dependencies(ipMemoryStore) { @Override public boolean isFeatureEnabled(final Context context, final String name) { public boolean isFeatureEnabled(final Context context, final String name, final boolean defaultEnabled) { switch (name) { case NetworkStackUtils.DHCP_RAPID_COMMIT_VERSION: return mIsDhcpRapidCommitEnabled; Loading Loading @@ -1067,7 +1069,7 @@ public class IpClientIntegrationTest { assertIpMemoryStoreNetworkAttributes(null, currentTime, TEST_DEFAULT_MTU); } @Test @Test @IgnoreAfter(Build.VERSION_CODES.Q) // INIT-REBOOT is enabled on R. public void testHandleDisableInitRebootState() throws Exception { performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, Loading Loading
src/android/net/dhcp/DhcpClient.java +18 −5 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import android.net.util.InterfaceParams; import android.net.util.NetworkStackUtils; import android.net.util.PacketReader; import android.net.util.SocketUtils; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.PowerManager; Loading @@ -98,6 +99,7 @@ import com.android.internal.util.WakeupMessage; import com.android.networkstack.R; import com.android.networkstack.apishim.CaptivePortalDataShimImpl; import com.android.networkstack.apishim.SocketUtilsShimImpl; import com.android.networkstack.apishim.common.ShimUtils; import com.android.networkstack.arp.ArpPacket; import java.io.FileDescriptor; Loading Loading @@ -407,8 +409,10 @@ public class DhcpClient extends StateMachine { * Return whether a feature guarded by a feature flag is enabled. * @see NetworkStackUtils#isFeatureEnabled(Context, String, String) */ public boolean isFeatureEnabled(final Context context, final String name) { return NetworkStackUtils.isFeatureEnabled(context, NAMESPACE_CONNECTIVITY, name); public boolean isFeatureEnabled(final Context context, final String name, boolean defaultEnabled) { return NetworkStackUtils.isFeatureEnabled(context, NAMESPACE_CONNECTIVITY, name, defaultEnabled); } /** Loading Loading @@ -496,23 +500,32 @@ public class DhcpClient extends StateMachine { /** * check whether or not to support caching the last lease info and INIT-REBOOT state. * * INIT-REBOOT state is supported on Android R by default if there is no experiment flag set to * disable this feature explicitly, meanwhile we still hope to be able to control this feature * on/off by pushing experiment flag for A/B testing and metrics collection on both of Android * Q and R version, however it's disbled on Android Q by default. */ public boolean isDhcpLeaseCacheEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_INIT_REBOOT_VERSION); final boolean defaultEnabled = ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); return mDependencies.isFeatureEnabled(mContext, DHCP_INIT_REBOOT_VERSION, defaultEnabled); } /** * check whether or not to support DHCP Rapid Commit option. */ public boolean isDhcpRapidCommitEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_RAPID_COMMIT_VERSION); return mDependencies.isFeatureEnabled(mContext, DHCP_RAPID_COMMIT_VERSION, false /* defaultEnabled */); } /** * check whether or not to support IP address conflict detection and DHCPDECLINE. */ public boolean isDhcpIpConflictDetectEnabled() { return mDependencies.isFeatureEnabled(mContext, DHCP_IP_CONFLICT_DETECT_VERSION); return mDependencies.isFeatureEnabled(mContext, DHCP_IP_CONFLICT_DETECT_VERSION, false /* defaultEnabled */); } private void confirmDhcpLease(DhcpPacket packet, DhcpResults results) { Loading
src/android/net/util/NetworkStackUtils.java +1 −3 Original line number Diff line number Diff line Loading @@ -355,9 +355,7 @@ public class NetworkStackUtils { */ public static boolean isFeatureEnabled(@NonNull Context context, @NonNull String namespace, @NonNull String name) { final int propertyVersion = getDeviceConfigPropertyInt(namespace, name, 0 /* default value */); return isFeatureEnabled(context, namespace, name, false); return isFeatureEnabled(context, namespace, name, false /* defaultEnabled */); } /** Loading
tests/integration/src/android/net/ip/IpClientIntegrationTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ import com.android.server.NetworkObserverRegistry; import com.android.server.NetworkStackService.NetworkStackServiceManager; import com.android.server.connectivity.ipmemorystore.IpMemoryStoreService; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; import com.android.testutils.HandlerUtilsKt; import com.android.testutils.TapPacketReader; Loading Loading @@ -320,7 +321,8 @@ public class IpClientIntegrationTest { NetworkStackIpMemoryStore ipMemoryStore) { return new DhcpClient.Dependencies(ipMemoryStore) { @Override public boolean isFeatureEnabled(final Context context, final String name) { public boolean isFeatureEnabled(final Context context, final String name, final boolean defaultEnabled) { switch (name) { case NetworkStackUtils.DHCP_RAPID_COMMIT_VERSION: return mIsDhcpRapidCommitEnabled; Loading Loading @@ -1067,7 +1069,7 @@ public class IpClientIntegrationTest { assertIpMemoryStoreNetworkAttributes(null, currentTime, TEST_DEFAULT_MTU); } @Test @Test @IgnoreAfter(Build.VERSION_CODES.Q) // INIT-REBOOT is enabled on R. public void testHandleDisableInitRebootState() throws Exception { performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, Loading