Merge "Move sensitive field parceling bool to constructor" into rvc-dev
diff --git a/api/system-current.txt b/api/system-current.txt
index 7a5373b..fd37989 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6217,6 +6217,7 @@
public final class LinkProperties implements android.os.Parcelable {
ctor public LinkProperties(@Nullable android.net.LinkProperties);
+ ctor public LinkProperties(@Nullable android.net.LinkProperties, boolean);
method public boolean addDnsServer(@NonNull java.net.InetAddress);
method public boolean addLinkAddress(@NonNull android.net.LinkAddress);
method public boolean addPcscfServer(@NonNull java.net.InetAddress);
@@ -6239,7 +6240,6 @@
method public boolean isIpv6Provisioned();
method public boolean isProvisioned();
method public boolean isReachable(@NonNull java.net.InetAddress);
- method @NonNull public android.net.LinkProperties makeSensitiveFieldsParcelingCopy();
method public boolean removeDnsServer(@NonNull java.net.InetAddress);
method public boolean removeLinkAddress(@NonNull android.net.LinkAddress);
method public boolean removeRoute(@NonNull android.net.RouteInfo);
diff --git a/api/test-current.txt b/api/test-current.txt
index df56f2c..66d6af9 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1789,6 +1789,7 @@
public final class LinkProperties implements android.os.Parcelable {
ctor public LinkProperties(@Nullable android.net.LinkProperties);
+ ctor public LinkProperties(@Nullable android.net.LinkProperties, boolean);
method public boolean addDnsServer(@NonNull java.net.InetAddress);
method public boolean addLinkAddress(@NonNull android.net.LinkAddress);
method @Nullable public android.net.Uri getCaptivePortalApiUrl();
@@ -1803,7 +1804,6 @@
method public boolean isIpv6Provisioned();
method public boolean isProvisioned();
method public boolean isReachable(@NonNull java.net.InetAddress);
- method @NonNull public android.net.LinkProperties makeSensitiveFieldsParcelingCopy();
method public boolean removeDnsServer(@NonNull java.net.InetAddress);
method public boolean removeLinkAddress(@NonNull android.net.LinkAddress);
method public boolean removeRoute(@NonNull android.net.RouteInfo);
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 02e9b50..2c356e4 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -167,7 +167,19 @@
this(source, false /* parcelSensitiveFields */);
}
- private LinkProperties(@Nullable LinkProperties source, boolean parcelSensitiveFields) {
+ /**
+ * Create a copy of a {@link LinkProperties} that may preserve fields that were set
+ * based on the permissions of the process that originally received it.
+ *
+ * <p>By default {@link LinkProperties} does not preserve such fields during parceling, as
+ * they should not be shared outside of the process that receives them without appropriate
+ * checks.
+ * @param parcelSensitiveFields Whether the sensitive fields should be kept when parceling
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ public LinkProperties(@Nullable LinkProperties source, boolean parcelSensitiveFields) {
mParcelSensitiveFields = parcelSensitiveFields;
if (source == null) return;
mIfaceName = source.mIfaceName;
@@ -1583,22 +1595,6 @@
}
/**
- * Create a copy of this {@link LinkProperties} that will preserve fields that were set
- * based on the permissions of the process that received this {@link LinkProperties}.
- *
- * <p>By default {@link LinkProperties} does not preserve such fields during parceling, as
- * they should not be shared outside of the process that receives them without appropriate
- * checks.
- * @hide
- */
- @SystemApi
- @TestApi
- @NonNull
- public LinkProperties makeSensitiveFieldsParcelingCopy() {
- return new LinkProperties(this, true /* parcelSensitiveFields */);
- }
-
- /**
* Compares this {@code LinkProperties} instance against the target
* LinkProperties in {@code obj}. Two LinkPropertieses are equal if
* all their fields are equal in values.
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 748c366..4309b84 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -1713,7 +1713,7 @@
}
if (checkSettingsPermission(callerPid, callerUid)) {
- return lp.makeSensitiveFieldsParcelingCopy();
+ return new LinkProperties(lp, true /* parcelSensitiveFields */);
}
final LinkProperties newLp = new LinkProperties(lp);
diff --git a/tests/net/common/java/android/net/LinkPropertiesTest.java b/tests/net/common/java/android/net/LinkPropertiesTest.java
index 2cbe48c..2b5720a 100644
--- a/tests/net/common/java/android/net/LinkPropertiesTest.java
+++ b/tests/net/common/java/android/net/LinkPropertiesTest.java
@@ -1028,7 +1028,8 @@
source.setCaptivePortalApiUrl(CAPPORT_API_URL);
source.setCaptivePortalData((CaptivePortalData) getCaptivePortalData());
source.setDhcpServerAddress((Inet4Address) GATEWAY1);
- assertParcelSane(source.makeSensitiveFieldsParcelingCopy(), 18 /* fieldCount */);
+ assertParcelSane(new LinkProperties(source, true /* parcelSensitiveFields */),
+ 18 /* fieldCount */);
// Verify that without using a sensitiveFieldsParcelingCopy, sensitive fields are cleared.
final LinkProperties sanitized = new LinkProperties(source);