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

Commit 88a9b54c authored by Hugo Benichi's avatar Hugo Benichi Committed by android-build-merger
Browse files

Merge changes Ia28652e0,Id2eaafdc,I9c4c8286 into nyc-mr1-dev am: f5e34819

am: 0664017d

Change-Id: I75a518b8909e5cd85c7554ceaa11dc7519717075
parents 2df6976b 0664017d
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -26037,6 +26037,33 @@ package android.net.http {
package android.net.metrics {
  public final class ApfProgramEvent implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.metrics.ApfProgramEvent> CREATOR;
    field public static final int FLAG_HAS_IPV4_ADDRESS = 1; // 0x1
    field public static final int FLAG_MULTICAST_FILTER_ON = 0; // 0x0
    field public final int currentRas;
    field public final int filteredRas;
    field public final int flags;
    field public final long lifetime;
    field public final int programLength;
  }
  public final class ApfStats implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.metrics.ApfStats> CREATOR;
    field public final int droppedRas;
    field public final long durationMs;
    field public final int matchingRas;
    field public final int maxProgramSize;
    field public final int parseErrors;
    field public final int programUpdates;
    field public final int receivedRas;
    field public final int zeroLifetimeRas;
  }
  public final class DefaultNetworkEvent implements android.os.Parcelable {
    method public int describeContents();
    method public static void logEvent(int, int[], int, boolean, boolean);
@@ -26145,6 +26172,18 @@ package android.net.metrics {
    field public final int netId;
  }
  public final class RaEvent implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.metrics.RaEvent> CREATOR;
    field public final long dnsslLifetime;
    field public final long prefixPreferredLifetime;
    field public final long prefixValidLifetime;
    field public final long rdnssLifetime;
    field public final long routeInfoLifetime;
    field public final long routerLifetime;
  }
  public final class ValidationProbeEvent implements android.os.Parcelable {
    method public int describeContents();
    method public static void logEvent(int, long, int, int);
+137 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.metrics;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;

import java.util.Arrays;
import java.util.stream.Collectors;

import com.android.internal.util.MessageUtils;

/**
 * An event logged when there is a change or event that requires updating the
 * the APF program in place with a new APF program.
 * {@hide}
 */
@SystemApi
public final class ApfProgramEvent implements Parcelable {

    // Bitflag constants describing what an Apf program filters.
    // Bits are indexeds from LSB to MSB, starting at index 0.
    // TODO: use @IntDef
    public static final int FLAG_MULTICAST_FILTER_ON = 0;
    public static final int FLAG_HAS_IPV4_ADDRESS    = 1;

    public final long lifetime;     // Lifetime of the program in seconds
    public final int filteredRas;   // Number of RAs filtered by the APF program
    public final int currentRas;    // Total number of current RAs at generation time
    public final int programLength; // Length of the APF program in bytes
    public final int flags;         // Bitfield compound of FLAG_* constants

    /** {@hide} */
    public ApfProgramEvent(
            long lifetime, int filteredRas, int currentRas, int programLength, int flags) {
        this.lifetime = lifetime;
        this.filteredRas = filteredRas;
        this.currentRas = currentRas;
        this.programLength = programLength;
        this.flags = flags;
    }

    private ApfProgramEvent(Parcel in) {
        this.lifetime = in.readLong();
        this.filteredRas = in.readInt();
        this.currentRas = in.readInt();
        this.programLength = in.readInt();
        this.flags = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeLong(lifetime);
        out.writeInt(filteredRas);
        out.writeInt(currentRas);
        out.writeInt(programLength);
        out.writeInt(flags);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public String toString() {
        String lifetimeString = (lifetime < Long.MAX_VALUE) ? lifetime + "s" : "forever";
        return String.format("ApfProgramEvent(%d/%d RAs %dB %s %s)",
                filteredRas, currentRas, programLength, lifetimeString, namesOf(flags));
    }

    public static final Parcelable.Creator<ApfProgramEvent> CREATOR
            = new Parcelable.Creator<ApfProgramEvent>() {
        public ApfProgramEvent createFromParcel(Parcel in) {
            return new ApfProgramEvent(in);
        }

        public ApfProgramEvent[] newArray(int size) {
            return new ApfProgramEvent[size];
        }
    };

    /** {@hide} */
    public static int flagsFor(boolean hasIPv4, boolean multicastFilterOn) {
        int bitfield = 0;
        if (hasIPv4) {
            bitfield |= (1 << FLAG_HAS_IPV4_ADDRESS);
        }
        if (multicastFilterOn) {
            bitfield |= (1 << FLAG_MULTICAST_FILTER_ON);
        }
        return bitfield;
    }

    // TODO: consider using java.util.BitSet
    private static int[] bitflagsOf(int bitfield) {
        int[] flags = new int[Integer.bitCount(bitfield)];
        int i = 0;
        int bitflag = 0;
        while (bitfield != 0) {
          if ((bitfield & 1) != 0) {
              flags[i++] = bitflag;
          }
          bitflag++;
          bitfield = bitfield >>> 1;
        }
        return flags;
    }

    private static String namesOf(int bitfields) {
        return Arrays.stream(bitflagsOf(bitfields))
                .mapToObj(i -> Decoder.constants.get(i))
                .collect(Collectors.joining(", "));
    }

    final static class Decoder {
        static final SparseArray<String> constants =
                MessageUtils.findMessageNames(
                       new Class[]{ApfProgramEvent.class}, new String[]{"FLAG_"});
    }
}
+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.metrics;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * An event logged for an interface with APF capabilities when its IpManager state machine exits.
 * {@hide}
 */
@SystemApi
public final class ApfStats implements Parcelable {

    public final long durationMs;     // time interval in milliseconds these stastistics covers
    public final int receivedRas;     // number of received RAs
    public final int matchingRas;     // number of received RAs matching a known RA
    public final int droppedRas;      // number of received RAs ignored due to the MAX_RAS limit
    public final int zeroLifetimeRas; // number of received RAs with a minimum lifetime of 0
    public final int parseErrors;     // number of received RAs that could not be parsed
    public final int programUpdates;  // number of APF program updates
    public final int maxProgramSize;  // maximum APF program size advertised by hardware

    /** {@hide} */
    public ApfStats(long durationMs, int receivedRas, int matchingRas, int droppedRas,
            int zeroLifetimeRas, int parseErrors, int programUpdates, int maxProgramSize) {
        this.durationMs = durationMs;
        this.receivedRas = receivedRas;
        this.matchingRas = matchingRas;
        this.droppedRas = droppedRas;
        this.zeroLifetimeRas = zeroLifetimeRas;
        this.parseErrors = parseErrors;
        this.programUpdates = programUpdates;
        this.maxProgramSize = maxProgramSize;
    }

    private ApfStats(Parcel in) {
        this.durationMs = in.readLong();
        this.receivedRas = in.readInt();
        this.matchingRas = in.readInt();
        this.droppedRas = in.readInt();
        this.zeroLifetimeRas = in.readInt();
        this.parseErrors = in.readInt();
        this.programUpdates = in.readInt();
        this.maxProgramSize = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeLong(durationMs);
        out.writeInt(receivedRas);
        out.writeInt(matchingRas);
        out.writeInt(droppedRas);
        out.writeInt(zeroLifetimeRas);
        out.writeInt(parseErrors);
        out.writeInt(programUpdates);
        out.writeInt(maxProgramSize);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public String toString() {
        return new StringBuilder("ApfStats(")
                .append(String.format("%dms ", durationMs))
                .append(String.format("%dB RA: {", maxProgramSize))
                .append(String.format("%d received, ", receivedRas))
                .append(String.format("%d matching, ", matchingRas))
                .append(String.format("%d dropped, ", droppedRas))
                .append(String.format("%d zero lifetime, ", zeroLifetimeRas))
                .append(String.format("%d parse errors, ", parseErrors))
                .append(String.format("%d program updates})", programUpdates))
                .toString();
    }

    public static final Parcelable.Creator<ApfStats> CREATOR = new Parcelable.Creator<ApfStats>() {
        public ApfStats createFromParcel(Parcel in) {
            return new ApfStats(in);
        }

        public ApfStats[] newArray(int size) {
            return new ApfStats[size];
        }
    };
}
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.util.MessageUtils;
@SystemApi
public final class IpManagerEvent implements Parcelable {

    // TODO: use @IntDef
    public static final int PROVISIONING_OK    = 1;
    public static final int PROVISIONING_FAIL  = 2;
    public static final int COMPLETE_LIFECYCLE = 3;
+95 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.metrics;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * An event logged when the APF packet socket receives an RA packet.
 * {@hide}
 */
@SystemApi
public final class RaEvent implements Parcelable {

    // Lifetime in seconds of options found in a single RA packet.
    // When an option is not set, the value of the associated field is -1;
    public final long routerLifetime;
    public final long prefixValidLifetime;
    public final long prefixPreferredLifetime;
    public final long routeInfoLifetime;
    public final long rdnssLifetime;
    public final long dnsslLifetime;

    /** {@hide} */
    public RaEvent(long routerLifetime, long prefixValidLifetime, long prefixPreferredLifetime,
            long routeInfoLifetime, long rdnssLifetime, long dnsslLifetime) {
        this.routerLifetime = routerLifetime;
        this.prefixValidLifetime = prefixValidLifetime;
        this.prefixPreferredLifetime = prefixPreferredLifetime;
        this.routeInfoLifetime = routeInfoLifetime;
        this.rdnssLifetime = rdnssLifetime;
        this.dnsslLifetime = dnsslLifetime;
    }

    private RaEvent(Parcel in) {
        routerLifetime          = in.readLong();
        prefixValidLifetime     = in.readLong();
        prefixPreferredLifetime = in.readLong();
        routeInfoLifetime       = in.readLong();
        rdnssLifetime           = in.readLong();
        dnsslLifetime           = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeLong(routerLifetime);
        out.writeLong(prefixValidLifetime);
        out.writeLong(prefixPreferredLifetime);
        out.writeLong(routeInfoLifetime);
        out.writeLong(rdnssLifetime);
        out.writeLong(dnsslLifetime);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public String toString() {
        return new StringBuilder("RaEvent(lifetimes: ")
                .append(String.format("router=%ds, ", routerLifetime))
                .append(String.format("prefix_valid=%ds, ", prefixValidLifetime))
                .append(String.format("prefix_preferred=%ds, ", prefixPreferredLifetime))
                .append(String.format("route_info=%ds, ", routeInfoLifetime))
                .append(String.format("rdnss=%ds, ", rdnssLifetime))
                .append(String.format("dnssl=%ds)", dnsslLifetime))
                .toString();
    }

    public static final Parcelable.Creator<RaEvent> CREATOR = new Parcelable.Creator<RaEvent>() {
        public RaEvent createFromParcel(Parcel in) {
            return new RaEvent(in);
        }

        public RaEvent[] newArray(int size) {
            return new RaEvent[size];
        }
    };
}
Loading