Migrate unsafe parcel APIs in framework-minus-apex
Migrate the following unsafe parcel APIs in framework-minus-apex: * Parcel.readSerializable() * Parcel.readArrayList() * Parcel.readList() * Parcel.readParcelable() * Parcel.readParcelableList() * Parcel.readSparseArray() This CL was generated by applying lint fixes that infer the expected type from the caller code and provide that as the type parameter (ag/16365240). A few observations: * In some classes we couldn't migrate because the class also belonged to another build module whose min SDK wasn't current (as is the case for framework-minus-apex), hence I suppressed the lint check (since I'll eventually submit the lint check to the tree). * In some cases, I needed to do the cast in https://stackoverflow.com/a/1080525/5765705 to make the compiler happy since there isn't another way of providing a class of type Class<MyClassWithGenerics<T>>. * In the readSerializable() case, the new API also requires the class loader, that was inferred to by InferredClass.class.getClassLoader(). * Note that automatic formatting and import rely on running hooked up to the IDE, which wasn't the case here. Bug: 195622897 Test: TH passes Change-Id: I11a27b9bdab7959ee86e90aa1e1cbebd7aaf883c
This commit is contained in:
@@ -75,7 +75,7 @@ public final class DataUsageRequest implements Parcelable {
|
||||
@Override
|
||||
public DataUsageRequest createFromParcel(Parcel in) {
|
||||
int requestId = in.readInt();
|
||||
NetworkTemplate template = in.readParcelable(null);
|
||||
NetworkTemplate template = in.readParcelable(null, android.net.NetworkTemplate.class);
|
||||
long thresholdInBytes = in.readLong();
|
||||
DataUsageRequest result = new DataUsageRequest(requestId, template,
|
||||
thresholdInBytes);
|
||||
|
||||
@@ -267,14 +267,14 @@ public final class IpSecConfig implements Parcelable {
|
||||
mMode = in.readInt();
|
||||
mSourceAddress = in.readString();
|
||||
mDestinationAddress = in.readString();
|
||||
mNetwork = (Network) in.readParcelable(Network.class.getClassLoader());
|
||||
mNetwork = (Network) in.readParcelable(Network.class.getClassLoader(), android.net.Network.class);
|
||||
mSpiResourceId = in.readInt();
|
||||
mEncryption =
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader(), android.net.IpSecAlgorithm.class);
|
||||
mAuthentication =
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader(), android.net.IpSecAlgorithm.class);
|
||||
mAuthenticatedEncryption =
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader());
|
||||
(IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader(), android.net.IpSecAlgorithm.class);
|
||||
mEncapType = in.readInt();
|
||||
mEncapSocketResourceId = in.readInt();
|
||||
mEncapRemotePort = in.readInt();
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class IpSecUdpEncapResponse implements Parcelable {
|
||||
status = in.readInt();
|
||||
resourceId = in.readInt();
|
||||
port = in.readInt();
|
||||
fileDescriptor = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
|
||||
fileDescriptor = in.readParcelable(ParcelFileDescriptor.class.getClassLoader(), android.os.ParcelFileDescriptor.class);
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<IpSecUdpEncapResponse> CREATOR =
|
||||
|
||||
@@ -73,9 +73,9 @@ public final class NetworkStateSnapshot implements Parcelable {
|
||||
|
||||
/** @hide */
|
||||
public NetworkStateSnapshot(@NonNull Parcel in) {
|
||||
mNetwork = in.readParcelable(null);
|
||||
mNetworkCapabilities = in.readParcelable(null);
|
||||
mLinkProperties = in.readParcelable(null);
|
||||
mNetwork = in.readParcelable(null, android.net.Network.class);
|
||||
mNetworkCapabilities = in.readParcelable(null, android.net.NetworkCapabilities.class);
|
||||
mLinkProperties = in.readParcelable(null, android.net.LinkProperties.class);
|
||||
mSubscriberId = in.readString();
|
||||
mLegacyType = in.readInt();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class UnderlyingNetworkInfo implements Parcelable {
|
||||
mOwnerUid = in.readInt();
|
||||
mIface = in.readString();
|
||||
List<String> underlyingIfaces = new ArrayList<>();
|
||||
in.readList(underlyingIfaces, null /*classLoader*/);
|
||||
in.readList(underlyingIfaces, null /*classLoader*/, java.lang.String.class);
|
||||
mUnderlyingIfaces = Collections.unmodifiableList(underlyingIfaces);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user