From c087f6248276c21f7f89a424f1765b63dba4133c Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Mon, 6 Sep 2021 08:51:21 +0100 Subject: [PATCH] Don't throw for LazyValue in Parcel.hasFileDescriptors() In aosp/1819733 we extracted Parcel.hasFileDescriptor() for types produced by Parcel.writeValue() and consumed by Parcel.readValue() out of Bundle into Parcel. It's supposed to handle LazyValue too. However, we put a check to verify that it was a type supported by readValue()/writeValue() by retrieving the VAL_XXX type of the value via Parcel.getValueType(), however, that method throws for LazyValue since we don't actually write that special type on the wire. However, we still want Parcel.hasFileDescriptor() to support it, so moving the check into a last 'else' statement, making sure we don't throw in case the value is a LazyValue. Bug: 195622897 Bug: 198433827 Test: atest CtsNetTestCases android.net.cts.CaptivePortalTest#testCaptivePortalIsNotDefaultNetwork Change-Id: I1e6ec122557c12e74db6890e1631fec3cefe31f6 --- core/java/android/os/Parcel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 575eb375abc66..00db972bf709c 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -665,7 +665,6 @@ public final class Parcel { * @hide */ public static boolean hasFileDescriptors(Object value) { - getValueType(value); // Will throw if value is not supported if (value instanceof LazyValue) { return ((LazyValue) value).hasFileDescriptors(); } else if (value instanceof Parcelable) { @@ -706,6 +705,8 @@ public final class Parcel { } } } + } else { + getValueType(value); // Will throw if value is not supported } return false; }