Merge "Move sensitive field parceling bool to constructor" am: abc08c2456
Change-Id: Ib5619a2173d838e81091415fe6323370f61c9461
This commit is contained in:
@@ -167,7 +167,19 @@ public final class LinkProperties implements Parcelable {
|
||||
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;
|
||||
@@ -1560,22 +1572,6 @@ public final class LinkProperties implements Parcelable {
|
||||
return mCaptivePortalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -1712,7 +1712,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
if (checkSettingsPermission(callerPid, callerUid)) {
|
||||
return lp.makeSensitiveFieldsParcelingCopy();
|
||||
return new LinkProperties(lp, true /* parcelSensitiveFields */);
|
||||
}
|
||||
|
||||
final LinkProperties newLp = new LinkProperties(lp);
|
||||
|
||||
@@ -1028,7 +1028,8 @@ public class LinkPropertiesTest {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user