Merge AOSP android-9.0.0_r3

Fix conflicts and make it build in 5.1, 6.0, 7.1, 8.1, and 9.0

Change-Id: Ida0a64c29ff27d339b7f42a18d820930964ac6e4
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 05276e8..9d36bae 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -44,8 +44,17 @@
 		mIconSelected = LoadAttrImage(child, "selected");
 		mIconUnselected = LoadAttrImage(child, "unselected");
 	}
-	int iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
-	int iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+	int iconWidth = 0, iconHeight = 0;
+	if (mIconSelected && mIconSelected->GetResource() && mIconUnselected && mIconUnselected->GetResource()) {
+		iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
+		iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+	} else if (mIconSelected && mIconSelected->GetResource()) {
+		iconWidth = mIconSelected->GetWidth();
+		iconHeight = mIconSelected->GetHeight();
+	} else if (mIconUnselected && mIconUnselected->GetResource()) {
+		iconWidth = mIconUnselected->GetWidth();
+		iconHeight = mIconUnselected->GetHeight();
+	}
 	SetMaxIconSize(iconWidth, iconHeight);
 
 	// Handle the result variable