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

Commit 09f02e05 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6538416 from 59b66b8f to rvc-release

Change-Id: I542a62f6108b527920952b7a5761da0f58d41977
parents 0dffbf5b 59b66b8f
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -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) {
+1 −3
Original line number Diff line number Diff line
@@ -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 */);
    }

    /**
+12 −12
Original line number Diff line number Diff line
@@ -23,15 +23,15 @@ import android.os.SystemClock;
 * @hide
 */
public class Stopwatch {
    private long mStartTimeMs;
    private long mStopTimeMs;
    private long mStartTimeNs;
    private long mStopTimeNs;

    public boolean isStarted() {
        return (mStartTimeMs > 0);
        return (mStartTimeNs > 0);
    }

    public boolean isStopped() {
        return (mStopTimeMs > 0);
        return (mStopTimeNs > 0);
    }

    public boolean isRunning() {
@@ -43,31 +43,31 @@ public class Stopwatch {
     */
    public Stopwatch start() {
        if (!isStarted()) {
            mStartTimeMs = SystemClock.elapsedRealtime();
            mStartTimeNs = SystemClock.elapsedRealtimeNanos();
        }
        return this;
    }

    /**
     * Stop the Stopwatch.
     * @return the total time recorded, in milliseconds, or 0 if not started.
     * @return the total time recorded, in microseconds, or 0 if not started.
     */
    public long stop() {
        if (isRunning()) {
            mStopTimeMs = SystemClock.elapsedRealtime();
            mStopTimeNs = SystemClock.elapsedRealtimeNanos();
        }
        // Return either the delta after having stopped, or 0.
        return (mStopTimeMs - mStartTimeMs);
        return (mStopTimeNs - mStartTimeNs) / 1000;
    }

    /**
     * Return the total time recorded to date, in milliseconds.
     * Return the total time recorded to date, in microseconds.
     * If the Stopwatch is not running, returns the same value as stop(),
     * i.e. either the total time recorded before stopping or 0.
     */
    public long lap() {
        if (isRunning()) {
            return (SystemClock.elapsedRealtime() - mStartTimeMs);
            return (SystemClock.elapsedRealtimeNanos() - mStartTimeNs) / 1000;
        } else {
            return stop();
        }
@@ -77,7 +77,7 @@ public class Stopwatch {
     * Reset the Stopwatch. It will be stopped when this method returns.
     */
    public void reset() {
        mStartTimeMs = 0;
        mStopTimeMs = 0;
        mStartTimeNs = 0;
        mStopTimeNs = 0;
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public class DnsUtils {
        } catch (TimeoutException | InterruptedException e) {
            errorMsg = "Timeout";
        } finally {
            logDnsResult(result, watch.stop() /* latency */, logger, type, errorMsg);
            logDnsResult(result, watch.stop() / 1000 /* latencyMs */, logger, type, errorMsg);
        }

        if (null != errorMsg) throw new UnknownHostException(host);
@@ -155,8 +155,9 @@ public class DnsUtils {
        return result.toArray(new InetAddress[0]);
    }

    private static void logDnsResult(@Nullable final List<InetAddress> results, final long latency,
            @Nullable final DnsLogFunc logger, int type, @NonNull final String errorMsg) {
    private static void logDnsResult(@Nullable final List<InetAddress> results,
            final long latencyMs, @Nullable final DnsLogFunc logger, int type,
            @NonNull final String errorMsg) {
        if (logger == null) {
            return;
        }
@@ -166,9 +167,9 @@ public class DnsUtils {
            for (InetAddress address : results) {
                builder.append(',').append(address.getHostAddress());
            }
            logger.log(String.format("%dms OK %s", latency, builder.substring(1)));
            logger.log(String.format("%dms OK %s", latencyMs, builder.substring(1)));
        } else {
            logger.log(String.format("%dms FAIL in type %s %s", latency, dnsTypeToStr(type),
            logger.log(String.format("%dms FAIL in type %s %s", latencyMs, dnsTypeToStr(type),
                    errorMsg));
        }
    }
+5 −5
Original line number Diff line number Diff line
@@ -1412,11 +1412,11 @@ public class NetworkMonitor extends StateMachine {
                time = watch.stop();
                final String strIps = Arrays.toString(ips);
                success = (ips != null && ips.length > 0);
                validationLog(PROBE_PRIVDNS, host, String.format("%dms: %s", time, strIps));
                validationLog(PROBE_PRIVDNS, host, String.format("%dus: %s", time, strIps));
            } catch (UnknownHostException uhe) {
                time = watch.stop();
                validationLog(PROBE_PRIVDNS, host,
                        String.format("%dms - Error: %s", time, uhe.getMessage()));
                        String.format("%dus - Error: %s", time, uhe.getMessage()));
            }
            logValidationProbe(time, PROBE_PRIVDNS, success ? DNS_SUCCESS : DNS_FAILURE);
            return success;
@@ -2943,18 +2943,18 @@ public class NetworkMonitor extends StateMachine {
        if (mEvaluationTimer.isRunning()) {
            int[] transports = mNetworkCapabilities.getTransportTypes();
            mMetricsLog.log(mCleartextDnsNetwork, transports,
                    new NetworkEvent(evtype, mEvaluationTimer.stop()));
                    new NetworkEvent(evtype, mEvaluationTimer.stop() / 1000));
            mEvaluationTimer.reset();
        }
    }

    private void logValidationProbe(long durationMs, int probeType, int probeResult) {
    private void logValidationProbe(long durationUs, int probeType, int probeResult) {
        int[] transports = mNetworkCapabilities.getTransportTypes();
        boolean isFirstValidation = validationStage().mIsFirstValidation;
        ValidationProbeEvent ev = new ValidationProbeEvent.Builder()
                .setProbeType(probeType, isFirstValidation)
                .setReturnCode(probeResult)
                .setDurationMs(durationMs)
                .setDurationMs(durationUs / 1000)
                .build();
        mMetricsLog.log(mCleartextDnsNetwork, transports, ev);
    }
Loading