Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bad8926 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6284977 from 4c59f492 to mainline-release

Change-Id: Ic95e79121df1919edcd501d22bedac01226d76cd
parents bdc7f697 4c59f492
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import androidx.annotation.VisibleForTesting;
import com.android.networkstack.apishim.CaptivePortalDataShim;
import com.android.networkstack.apishim.NetworkInformationShim;

import java.net.Inet4Address;

/**
 * Compatibility implementation of {@link NetworkInformationShim}.
 *
@@ -84,4 +86,10 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return new LinkProperties(lp);
    }

    @Override
    public void setDhcpServerAddress(@NonNull LinkProperties lp,
            @NonNull Inet4Address serverAddress) {
        // Not supported on this API level: no-op
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import java.net.Inet4Address;

/**
 * Compatibility implementation of {@link NetworkInformationShim}.
 */
@@ -81,4 +83,10 @@ public class NetworkInformationShimImpl extends
    public LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull final LinkProperties lp) {
        return lp.makeSensitiveFieldsParcelingCopy();
    }

    @Override
    public void setDhcpServerAddress(@NonNull LinkProperties lp,
            @NonNull Inet4Address serverAddress) {
        lp.setDhcpServerAddress(serverAddress);
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.net.Inet4Address;

/**
 * Compatibility interface for network info classes such as {@link LinkProperties} and
 * {@link NetworkCapabilities}.
@@ -56,4 +58,12 @@ public interface NetworkInformationShim {
     */
    @NonNull
    LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull LinkProperties lp);

    /**
     * @see LinkProperties#setDhcpServerAddress()
     */
    @NonNull
    void setDhcpServerAddress(@NonNull LinkProperties lp,
            @NonNull Inet4Address serverAddress);

}
+5 −0
Original line number Diff line number Diff line
@@ -1195,6 +1195,10 @@ public class IpClient extends StateMachine {
                newLp.setMtu(mDhcpResults.mtu);
            }

            if (mDhcpResults.serverAddress != null) {
                mShim.setDhcpServerAddress(newLp, mDhcpResults.serverAddress);
            }

            final String capportUrl = mDhcpResults.captivePortalApiUrl;
            // Uri.parse does no syntax check; do a simple regex check to eliminate garbage.
            // If the URL is still incorrect data fetching will fail later, which is fine.
@@ -1272,6 +1276,7 @@ public class IpClient extends StateMachine {

        if (DBG) {
            Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")");
            Log.d(mTag, "handleIPv4Success newLp{" + newLp + "}");
        }
        mCallback.onNewDhcpResults(dhcpResults);
        maybeSaveNetworkToIpMemoryStore();
+29 −1
Original line number Diff line number Diff line
@@ -141,6 +141,14 @@ public class NetworkStackUtils {
     */
    public static final String DHCP_IP_CONFLICT_DETECT_VERSION = "dhcp_ip_conflict_detect_version";

    /**
     * Minimum module version at which to enable dismissal CaptivePortalLogin app in validated
     * network feature. CaptivePortalLogin app will also use validation facilities in
     * {@link NetworkMonitor} to perform portal validation if feature is enabled.
     */
    public static final String DISMISS_PORTAL_IN_VALIDATED_NETWORK =
            "dismiss_portal_in_validated_network";

    static {
        System.loadLibrary("networkstackutilsjni");
    }
@@ -270,12 +278,32 @@ 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);
    }

    /**
     * Check whether or not one specific experimental feature for a particular namespace from
     * {@link DeviceConfig} is enabled by comparing NetworkStack module version {@link NetworkStack}
     * with current version of property. If this property version is valid, the corresponding
     * experimental feature would be enabled, otherwise disabled.
     * @param context The global context information about an app environment.
     * @param namespace The namespace containing the property to look up.
     * @param name The name of the property to look up.
     * @param defaultEnabled The value to return if the property does not exist or its value is
     *                       null.
     * @return true if this feature is enabled, or false if disabled.
     */
    public static boolean isFeatureEnabled(@NonNull Context context, @NonNull String namespace,
            @NonNull String name, boolean defaultEnabled) {
        try {
            final int propertyVersion = getDeviceConfigPropertyInt(namespace, name,
                    0 /* default value */);
            final long packageVersion = context.getPackageManager().getPackageInfo(
                    context.getPackageName(), 0).getLongVersionCode();
            return (propertyVersion != 0 && packageVersion >= (long) propertyVersion);
            return (propertyVersion == 0 && defaultEnabled)
                    || (propertyVersion != 0 && packageVersion >= (long) propertyVersion);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Could not find the package name", e);
            return false;
Loading