From 1b9ea1594acdc6547b8d0d569cb76ba238ba898b Mon Sep 17 00:00:00 2001 From: Noah Stanford Date: Wed, 30 Mar 2022 13:35:28 -0400 Subject: [PATCH] Add multiple checks to supportsSoftButtonImages() 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(); }