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
diff --git a/telecomm/java/android/telecom/ParcelableConference.java b/telecomm/java/android/telecom/ParcelableConference.java
index 1f8aafb..e57c833 100644
--- a/telecomm/java/android/telecom/ParcelableConference.java
+++ b/telecomm/java/android/telecom/ParcelableConference.java
@@ -292,24 +292,24 @@
@Override
public ParcelableConference createFromParcel(Parcel source) {
ClassLoader classLoader = ParcelableConference.class.getClassLoader();
- PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
+ PhoneAccountHandle phoneAccount = source.readParcelable(classLoader, android.telecom.PhoneAccountHandle.class);
int state = source.readInt();
int capabilities = source.readInt();
List<String> connectionIds = new ArrayList<>(2);
- source.readList(connectionIds, classLoader);
+ source.readList(connectionIds, classLoader, java.lang.String.class);
long connectTimeMillis = source.readLong();
IVideoProvider videoCallProvider =
IVideoProvider.Stub.asInterface(source.readStrongBinder());
int videoState = source.readInt();
- StatusHints statusHints = source.readParcelable(classLoader);
+ StatusHints statusHints = source.readParcelable(classLoader, android.telecom.StatusHints.class);
Bundle extras = source.readBundle(classLoader);
int properties = source.readInt();
long connectElapsedTimeMillis = source.readLong();
- Uri address = source.readParcelable(classLoader);
+ Uri address = source.readParcelable(classLoader, android.net.Uri.class);
int addressPresentation = source.readInt();
String callerDisplayName = source.readString();
int callerDisplayNamePresentation = source.readInt();
- DisconnectCause disconnectCause = source.readParcelable(classLoader);
+ DisconnectCause disconnectCause = source.readParcelable(classLoader, android.telecom.DisconnectCause.class);
boolean isRingbackRequested = source.readInt() == 1;
int callDirection = source.readInt();