Move the DscpPolicy status constants and IntDef to NetworkAgent.
As requested by API council.
Also fix lint errors in the test.
Fix: 217366078
Test: existing tests modified in this CL
Change-Id: I8f7cd0e78bf29aeb52ec6a08a5d635d25fa2205d
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index 7b97cec..7a57426 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -104,12 +104,6 @@
field @NonNull public static final android.os.Parcelable.Creator<android.net.DscpPolicy> CREATOR;
field public static final int PROTOCOL_ANY = -1; // 0xffffffff
field public static final int SOURCE_PORT_ANY = -1; // 0xffffffff
- field public static final int STATUS_DELETED = 4; // 0x4
- field public static final int STATUS_INSUFFICIENT_PROCESSING_RESOURCES = 3; // 0x3
- field public static final int STATUS_POLICY_NOT_FOUND = 5; // 0x5
- field public static final int STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED = 2; // 0x2
- field public static final int STATUS_REQUEST_DECLINED = 1; // 0x1
- field public static final int STATUS_SUCCESS = 0; // 0x0
}
public static final class DscpPolicy.Builder {
@@ -271,6 +265,12 @@
method public final void setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
method public void unregister();
method public void unregisterAfterReplacement(@IntRange(from=0, to=0x1388) int);
+ field public static final int DSCP_POLICY_STATUS_DELETED = 4; // 0x4
+ field public static final int DSCP_POLICY_STATUS_INSUFFICIENT_PROCESSING_RESOURCES = 3; // 0x3
+ field public static final int DSCP_POLICY_STATUS_POLICY_NOT_FOUND = 5; // 0x5
+ field public static final int DSCP_POLICY_STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED = 2; // 0x2
+ field public static final int DSCP_POLICY_STATUS_REQUEST_DECLINED = 1; // 0x1
+ field public static final int DSCP_POLICY_STATUS_SUCCESS = 0; // 0x0
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
field public static final int VALIDATION_STATUS_VALID = 1; // 0x1
}
diff --git a/framework/src/android/net/DscpPolicy.java b/framework/src/android/net/DscpPolicy.java
index cda8205..6af795b 100644
--- a/framework/src/android/net/DscpPolicy.java
+++ b/framework/src/android/net/DscpPolicy.java
@@ -16,7 +16,6 @@
package android.net;
-import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -26,8 +25,6 @@
import com.android.net.module.util.InetAddressUtils;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.Objects;
@@ -49,36 +46,6 @@
*/
public static final int SOURCE_PORT_ANY = -1;
- /**
- * Policy was successfully added.
- */
- public static final int STATUS_SUCCESS = 0;
-
- /**
- * Policy was rejected for any reason besides invalid classifier or insufficient resources.
- */
- public static final int STATUS_REQUEST_DECLINED = 1;
-
- /**
- * Requested policy contained a classifier which is not supported.
- */
- public static final int STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED = 2;
-
- /**
- * TODO: should this error case be supported?
- */
- public static final int STATUS_INSUFFICIENT_PROCESSING_RESOURCES = 3;
-
- /**
- * Policy was deleted.
- */
- public static final int STATUS_DELETED = 4;
-
- /**
- * Policy was not found during deletion.
- */
- public static final int STATUS_POLICY_NOT_FOUND = 5;
-
/** The unique policy ID. Each requesting network is responsible for maintaining policy IDs
* unique within that network. In the case where a policy with an existing ID is created, the
* new policy will update the existing policy with the same ID.
@@ -112,17 +79,6 @@
return 0;
}
- /** @hide */
- @IntDef(prefix = "STATUS_", value = {
- STATUS_SUCCESS,
- STATUS_REQUEST_DECLINED,
- STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED,
- STATUS_INSUFFICIENT_PROCESSING_RESOURCES,
- STATUS_DELETED
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface DscpPolicyStatus {}
-
/* package */ DscpPolicy(
int policyId,
int dscp,
diff --git a/framework/src/android/net/NetworkAgent.java b/framework/src/android/net/NetworkAgent.java
index 07b6227..29add1c 100644
--- a/framework/src/android/net/NetworkAgent.java
+++ b/framework/src/android/net/NetworkAgent.java
@@ -25,7 +25,6 @@
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
-import android.net.DscpPolicy.DscpPolicyStatus;
import android.os.Build;
import android.os.Bundle;
import android.os.ConditionVariable;
@@ -435,6 +434,48 @@
public static final int CMD_DSCP_POLICY_STATUS = BASE + 28;
/**
+ * DSCP policy was successfully added.
+ */
+ public static final int DSCP_POLICY_STATUS_SUCCESS = 0;
+
+ /**
+ * DSCP policy was rejected for any reason besides invalid classifier or insufficient resources.
+ */
+ public static final int DSCP_POLICY_STATUS_REQUEST_DECLINED = 1;
+
+ /**
+ * Requested DSCP policy contained a classifier which is not supported.
+ */
+ public static final int DSCP_POLICY_STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED = 2;
+
+ /**
+ * Requested DSCP policy was not added due to insufficient processing resources.
+ */
+ // TODO: should this error case be supported?
+ public static final int DSCP_POLICY_STATUS_INSUFFICIENT_PROCESSING_RESOURCES = 3;
+
+ /**
+ * DSCP policy was deleted.
+ */
+ public static final int DSCP_POLICY_STATUS_DELETED = 4;
+
+ /**
+ * DSCP policy was not found during deletion.
+ */
+ public static final int DSCP_POLICY_STATUS_POLICY_NOT_FOUND = 5;
+
+ /** @hide */
+ @IntDef(prefix = "DSCP_POLICY_STATUS_", value = {
+ DSCP_POLICY_STATUS_SUCCESS,
+ DSCP_POLICY_STATUS_REQUEST_DECLINED,
+ DSCP_POLICY_STATUS_REQUESTED_CLASSIFIER_NOT_SUPPORTED,
+ DSCP_POLICY_STATUS_INSUFFICIENT_PROCESSING_RESOURCES,
+ DSCP_POLICY_STATUS_DELETED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DscpPolicyStatus {}
+
+ /**
* Sent by the NetworkAgent to ConnectivityService to notify that this network is expected to be
* replaced within the specified time by a similar network.
* arg1 = timeout in milliseconds