From 01fa481fb39e292c9b07327c561eda99cdca0b20 Mon Sep 17 00:00:00 2001 From: noah-livio <95378272+noah-livio@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:07:21 -0400 Subject: [PATCH] Add multiple checks to supportsSoftButtonImages() (#1801) This commit adds null checks and a List.size() check to PresentAlertOperation.supportsSoftButtonImages() These checks prevent crashes and returns true when soft button capabilities are unavailable This new behavior improves alignment with the other SDL libraries --- .../managers/screen/PresentAlertOperation.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/PresentAlertOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/PresentAlertOperation.java index 2b1f249cb7..a85901d3cf 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/PresentAlertOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/PresentAlertOperation.java @@ -416,6 +416,14 @@ private List getTTSChunksForAlert(AlertView alertView) { * @return True if soft button images are currently supported; false if not. */ private boolean supportsSoftButtonImages() { + if (currentWindowCapability == null || + currentWindowCapability.getSoftButtonCapabilities() == null || + currentWindowCapability.getSoftButtonCapabilities().size() == 0 || + currentWindowCapability.getSoftButtonCapabilities().get(0) == null + ) { + return true; + } + SoftButtonCapabilities softButtonCapabilities = currentWindowCapability.getSoftButtonCapabilities().get(0); return softButtonCapabilities.getImageSupported().booleanValue(); }