Fix Automated API Review issues.

These API's argument/return value must be marked either @NonNull
or @Nullable.

Bug: 126701148
Bug: 126699090
Bug: 126701058
Bug: 126700772
Bug: 126699941
Bug: 126701299
Bug: 126700007
Bug: 126700900
Test: atest FrameworksNetTests
Change-Id: Id030a9f1116178b96aa3d4614b10969a537b2fc4
diff --git a/core/java/android/net/metrics/ApfProgramEvent.java b/core/java/android/net/metrics/ApfProgramEvent.java
index 8601005..30d3b84 100644
--- a/core/java/android/net/metrics/ApfProgramEvent.java
+++ b/core/java/android/net/metrics/ApfProgramEvent.java
@@ -17,6 +17,7 @@
 package android.net.metrics;
 
 import android.annotation.IntDef;
+import android.annotation.NonNull;
 import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.annotation.UnsupportedAppUsage;
@@ -95,7 +96,7 @@
     /**
      * Utility to create an instance of {@link ApfProgramEvent}.
      */
-    public static class Builder {
+    public static final class Builder {
         private long mLifetime;
         private long mActualLifetime;
         private int mFilteredRas;
@@ -106,6 +107,7 @@
         /**
          * Set the maximum computed lifetime of the program in seconds.
          */
+        @NonNull
         public Builder setLifetime(long lifetime) {
             mLifetime = lifetime;
             return this;
@@ -114,6 +116,7 @@
         /**
          * Set the effective program lifetime in seconds.
          */
+        @NonNull
         public Builder setActualLifetime(long lifetime) {
             mActualLifetime = lifetime;
             return this;
@@ -122,6 +125,7 @@
         /**
          * Set the number of RAs filtered by the APF program.
          */
+        @NonNull
         public Builder setFilteredRas(int filteredRas) {
             mFilteredRas = filteredRas;
             return this;
@@ -130,6 +134,7 @@
         /**
          * Set the total number of current RAs at generation time.
          */
+        @NonNull
         public Builder setCurrentRas(int currentRas) {
             mCurrentRas = currentRas;
             return this;
@@ -138,6 +143,7 @@
         /**
          * Set the length of the APF program in bytes.
          */
+        @NonNull
         public Builder setProgramLength(int programLength) {
             mProgramLength = programLength;
             return this;
@@ -146,6 +152,7 @@
         /**
          * Set the flags describing what an Apf program filters.
          */
+        @NonNull
         public Builder setFlags(boolean hasIPv4, boolean multicastFilterOn) {
             mFlags = flagsFor(hasIPv4, multicastFilterOn);
             return this;
@@ -154,6 +161,7 @@
         /**
          * Build a new {@link ApfProgramEvent}.
          */
+        @NonNull
         public ApfProgramEvent build() {
             return new ApfProgramEvent(mLifetime, mActualLifetime, mFilteredRas, mCurrentRas,
                     mProgramLength, mFlags);
diff --git a/core/java/android/net/metrics/ApfStats.java b/core/java/android/net/metrics/ApfStats.java
index 844a134..ddc788d 100644
--- a/core/java/android/net/metrics/ApfStats.java
+++ b/core/java/android/net/metrics/ApfStats.java
@@ -16,6 +16,7 @@
 
 package android.net.metrics;
 
+import android.annotation.NonNull;
 import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.annotation.UnsupportedAppUsage;
@@ -125,7 +126,7 @@
      */
     @SystemApi
     @TestApi
-    public static class Builder {
+    public static final class Builder {
         private long mDurationMs;
         private int mReceivedRas;
         private int mMatchingRas;
@@ -140,6 +141,7 @@
         /**
          * Set the time interval in milliseconds these statistics covers.
          */
+        @NonNull
         public Builder setDurationMs(long durationMs) {
             mDurationMs = durationMs;
             return this;
@@ -148,6 +150,7 @@
         /**
          * Set the number of received RAs.
          */
+        @NonNull
         public Builder setReceivedRas(int receivedRas) {
             mReceivedRas = receivedRas;
             return this;
@@ -156,6 +159,7 @@
         /**
          * Set the number of received RAs matching a known RA.
          */
+        @NonNull
         public Builder setMatchingRas(int matchingRas) {
             mMatchingRas = matchingRas;
             return this;
@@ -164,6 +168,7 @@
         /**
          * Set the number of received RAs ignored due to the MAX_RAS limit.
          */
+        @NonNull
         public Builder setDroppedRas(int droppedRas) {
             mDroppedRas = droppedRas;
             return this;
@@ -172,6 +177,7 @@
         /**
          * Set the number of received RAs with a minimum lifetime of 0.
          */
+        @NonNull
         public Builder setZeroLifetimeRas(int zeroLifetimeRas) {
             mZeroLifetimeRas = zeroLifetimeRas;
             return this;
@@ -180,6 +186,7 @@
         /**
          * Set the number of received RAs that could not be parsed.
          */
+        @NonNull
         public Builder setParseErrors(int parseErrors) {
             mParseErrors = parseErrors;
             return this;
@@ -188,6 +195,7 @@
         /**
          * Set the number of APF program updates from receiving RAs.
          */
+        @NonNull
         public Builder setProgramUpdates(int programUpdates) {
             mProgramUpdates = programUpdates;
             return this;
@@ -196,6 +204,7 @@
         /**
          * Set the total number of APF program updates.
          */
+        @NonNull
         public Builder setProgramUpdatesAll(int programUpdatesAll) {
             mProgramUpdatesAll = programUpdatesAll;
             return this;
@@ -204,6 +213,7 @@
         /**
          * Set the number of APF program updates from allowing multicast traffic.
          */
+        @NonNull
         public Builder setProgramUpdatesAllowingMulticast(int programUpdatesAllowingMulticast) {
             mProgramUpdatesAllowingMulticast = programUpdatesAllowingMulticast;
             return this;
@@ -212,6 +222,7 @@
         /**
          * Set the maximum APF program size advertised by hardware.
          */
+        @NonNull
         public Builder setMaxProgramSize(int maxProgramSize) {
             mMaxProgramSize = maxProgramSize;
             return this;
@@ -220,6 +231,7 @@
         /**
          * Create a new {@link ApfStats}.
          */
+        @NonNull
         public ApfStats build() {
             return new ApfStats(mDurationMs, mReceivedRas, mMatchingRas, mDroppedRas,
                     mZeroLifetimeRas, mParseErrors, mProgramUpdates, mProgramUpdatesAll,
diff --git a/core/java/android/net/metrics/DhcpClientEvent.java b/core/java/android/net/metrics/DhcpClientEvent.java
index 3008115..93063cb 100644
--- a/core/java/android/net/metrics/DhcpClientEvent.java
+++ b/core/java/android/net/metrics/DhcpClientEvent.java
@@ -16,6 +16,7 @@
 
 package android.net.metrics;
 
+import android.annotation.NonNull;
 import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.annotation.UnsupportedAppUsage;
@@ -51,13 +52,14 @@
     /**
      * Utility to create an instance of {@link ApfProgramEvent}.
      */
-    public static class Builder {
+    public static final class Builder {
         private String mMsg;
         private int mDurationMs;
 
         /**
          * Set the message of the event.
          */
+        @NonNull
         public Builder setMsg(String msg) {
             mMsg = msg;
             return this;
@@ -66,6 +68,7 @@
         /**
          * Set the duration of the event in milliseconds.
          */
+        @NonNull
         public Builder setDurationMs(int durationMs) {
             mDurationMs = durationMs;
             return this;
@@ -74,6 +77,7 @@
         /**
          * Create a new {@link DhcpClientEvent}.
          */
+        @NonNull
         public DhcpClientEvent build() {
             return new DhcpClientEvent(mMsg, mDurationMs);
         }
diff --git a/core/java/android/net/metrics/IpConnectivityLog.java b/core/java/android/net/metrics/IpConnectivityLog.java
index 5b5a235..680c015 100644
--- a/core/java/android/net/metrics/IpConnectivityLog.java
+++ b/core/java/android/net/metrics/IpConnectivityLog.java
@@ -16,6 +16,7 @@
 
 package android.net.metrics;
 
+import android.annotation.NonNull;
 import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.net.ConnectivityMetricsEvent;
@@ -41,7 +42,7 @@
 
     /** @hide */
     public static final String SERVICE_NAME = "connmetrics";
-
+    @NonNull
     private IIpConnectivityMetrics mService;
 
     /**
@@ -57,7 +58,7 @@
 
     /** @hide */
     @VisibleForTesting
-    public IpConnectivityLog(IIpConnectivityMetrics service) {
+    public IpConnectivityLog(@NonNull IIpConnectivityMetrics service) {
         mService = service;
     }
 
@@ -83,7 +84,7 @@
      * @return true if the event was successfully logged.
      * @hide
      */
-    public boolean log(ConnectivityMetricsEvent ev) {
+    public boolean log(@NonNull ConnectivityMetricsEvent ev) {
         if (!checkLoggerService()) {
             if (DBG) {
                 Log.d(TAG, SERVICE_NAME + " service was not ready");
@@ -109,7 +110,7 @@
      * @param data is a Parcelable instance representing the event.
      * @return true if the event was successfully logged.
      */
-    public boolean log(long timestamp, Event data) {
+    public boolean log(long timestamp, @NonNull Event data) {
         ConnectivityMetricsEvent ev = makeEv(data);
         ev.timestamp = timestamp;
         return log(ev);
@@ -121,7 +122,7 @@
      * @param data is a Parcelable instance representing the event.
      * @return true if the event was successfully logged.
      */
-    public boolean log(String ifname, Event data) {
+    public boolean log(@NonNull String ifname, @NonNull Event data) {
         ConnectivityMetricsEvent ev = makeEv(data);
         ev.ifname = ifname;
         return log(ev);
@@ -135,7 +136,7 @@
      * @param data is a Parcelable instance representing the event.
      * @return true if the event was successfully logged.
      */
-    public boolean log(Network network, int[] transports, Event data) {
+    public boolean log(@NonNull Network network, @NonNull int[] transports, @NonNull Event data) {
         return log(network.netId, transports, data);
     }
 
@@ -147,7 +148,7 @@
      * @param data is a Parcelable instance representing the event.
      * @return true if the event was successfully logged.
      */
-    public boolean log(int netid, int[] transports, Event data) {
+    public boolean log(int netid, @NonNull int[] transports, @NonNull Event data) {
         ConnectivityMetricsEvent ev = makeEv(data);
         ev.netId = netid;
         ev.transports = BitUtils.packBits(transports);
@@ -159,7 +160,7 @@
      * @param data is a Parcelable instance representing the event.
      * @return true if the event was successfully logged.
      */
-    public boolean log(Event data) {
+    public boolean log(@NonNull Event data) {
         return log(makeEv(data));
     }
 
diff --git a/core/java/android/net/metrics/ValidationProbeEvent.java b/core/java/android/net/metrics/ValidationProbeEvent.java
index a43dc60..9eb87ef 100644
--- a/core/java/android/net/metrics/ValidationProbeEvent.java
+++ b/core/java/android/net/metrics/ValidationProbeEvent.java
@@ -17,6 +17,7 @@
 package android.net.metrics;
 
 import android.annotation.IntDef;
+import android.annotation.NonNull;
 import android.annotation.SystemApi;
 import android.annotation.TestApi;
 import android.os.Parcel;
@@ -81,7 +82,7 @@
     /**
      * Utility to create an instance of {@link ValidationProbeEvent}.
      */
-    public static class Builder {
+    public static final class Builder {
         private long mDurationMs;
         private int mProbeType;
         private int mReturnCode;
@@ -89,6 +90,7 @@
         /**
          * Set the duration of the probe in milliseconds.
          */
+        @NonNull
         public Builder setDurationMs(long durationMs) {
             mDurationMs = durationMs;
             return this;
@@ -97,6 +99,7 @@
         /**
          * Set the probe type based on whether it was the first validation.
          */
+        @NonNull
         public Builder setProbeType(int probeType, boolean firstValidation) {
             mProbeType = makeProbeType(probeType, firstValidation);
             return this;
@@ -105,6 +108,7 @@
         /**
          * Set the return code of the probe.
          */
+        @NonNull
         public Builder setReturnCode(int returnCode) {
             mReturnCode = returnCode;
             return this;
@@ -113,6 +117,7 @@
         /**
          * Create a new {@link ValidationProbeEvent}.
          */
+        @NonNull
         public ValidationProbeEvent build() {
             return new ValidationProbeEvent(mDurationMs, mProbeType, mReturnCode);
         }