summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXiao Ma <xiaom@google.com>2020-05-25 09:03:44 +0000
committerXiao Ma <xiaom@google.com>2020-05-25 13:33:04 +0000
commit5b129a638db700c2069a85efec84753c88f1af29 (patch)
treeda4bd33ff8bdafc0a2935a9152553e34aff788e8 /src
parent7bfc08f95f981e77279cdc30371804db8d801fe1 (diff)
Enable DHCP INIT-REBOOT state on R.
Bug: 156575243 Test: atest NetworkStackTests NetworkStackIntegrationTests Test: atest NetworkStackNextIntegrationTests Test: manual test: 1. connect to AP successfully at the first time 2. disconnect wifi 3. reconnect to the same AP 4. checked client broadcasts REQUEST instead of DISCOVER 5. checked client broadcasts DISCOVER if lease has expired Merged-In: I62d1ab6b94be1ee95fbaa2ecce62eaba01e7892d Change-Id: I62d1ab6b94be1ee95fbaa2ecce62eaba01e7892d
Diffstat (limited to 'src')
-rw-r--r--src/android/net/dhcp/DhcpClient.java23
-rwxr-xr-xsrc/android/net/util/NetworkStackUtils.java4
2 files changed, 19 insertions, 8 deletions
diff --git a/src/android/net/dhcp/DhcpClient.java b/src/android/net/dhcp/DhcpClient.java
index 6d48c0c..011cbaf 100644
--- a/src/android/net/dhcp/DhcpClient.java
+++ b/src/android/net/dhcp/DhcpClient.java
@@ -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;
@@ -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;
@@ -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);
}
/**
@@ -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) {
diff --git a/src/android/net/util/NetworkStackUtils.java b/src/android/net/util/NetworkStackUtils.java
index 3f63266..99563ee 100755
--- a/src/android/net/util/NetworkStackUtils.java
+++ b/src/android/net/util/NetworkStackUtils.java
@@ -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 */);
}
/**