summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pranav Madapurmath <pmadapurmath@google.com> 2023-06-09 23:16:13 +0000
committer Pranav Madapurmath <pmadapurmath@google.com> 2023-06-12 17:00:14 +0000
commitf39d60bc710cc242ca57a75df56f4b4b0b2849ab (patch)
tree783a81037d57df01349c4c5d82f0f1ba5abed5ab
parent9a759a9669f31b51cf237aeb82832b2f73d317b7 (diff)
Handle endpoint name nullability in constructor
Throws an IllegalArgumentException when the endpoint name passed into the constructor is null. This will help prevent the error from being invoked later down the line and instead throws it at the first sign of detection. Fixes: 286310499 Test: atest TelecomUnitTests Change-Id: Ic128d0e3577591d54cf9c4309844e4580af220c1
-rw-r--r--telecomm/java/android/telecom/CallEndpoint.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/CallEndpoint.java b/telecomm/java/android/telecom/CallEndpoint.java
index 0b2211ddb94a..ed4bf40061e2 100644
--- a/telecomm/java/android/telecom/CallEndpoint.java
+++ b/telecomm/java/android/telecom/CallEndpoint.java
@@ -61,6 +61,13 @@ public final class CallEndpoint implements Parcelable {
/** Indicates that the type of endpoint through which call media flows is an external. */
public static final int TYPE_STREAMING = 5;
+ /**
+ * Error message attached to IllegalArgumentException when the endpoint name or id is null.
+ * @hide
+ */
+ private static final String CALLENDPOINT_NAME_ID_NULL_ERROR =
+ "CallEndpoint name cannot be null.";
+
private final CharSequence mName;
private final int mType;
private final ParcelUuid mIdentifier;
@@ -81,6 +88,11 @@ public final class CallEndpoint implements Parcelable {
*/
public CallEndpoint(@NonNull CharSequence name, @EndpointType int type,
@NonNull ParcelUuid id) {
+ // Ensure that endpoint name and id are non-null.
+ if (name == null || id == null) {
+ throw new IllegalArgumentException(CALLENDPOINT_NAME_ID_NULL_ERROR);
+ }
+
this.mName = name;
this.mType = type;
this.mIdentifier = id;
@@ -93,6 +105,11 @@ public final class CallEndpoint implements Parcelable {
/** @hide */
public CallEndpoint(CallEndpoint endpoint) {
+ // Ensure that endpoint name and id are non-null.
+ if (endpoint.getEndpointName() == null || endpoint.getIdentifier() == null) {
+ throw new IllegalArgumentException(CALLENDPOINT_NAME_ID_NULL_ERROR);
+ }
+
mName = endpoint.getEndpointName();
mType = endpoint.getEndpointType();
mIdentifier = endpoint.getIdentifier();