Skip to content

Commit

Permalink
Add multiple checks to supportsSoftButtonImages() (#1801)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
noah-livio authored Apr 8, 2022
1 parent a624a06 commit 01fa481
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ private List<TTSChunk> 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();
}
Expand Down

0 comments on commit 01fa481

Please sign in to comment.