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/fileselector.cpp b/gui/fileselector.cpp
index c4aaab1..fe378c8 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -112,8 +112,17 @@
 		mFolderIcon = LoadAttrImage(child, "folder");
 		mFileIcon = LoadAttrImage(child, "file");
 	}
-	int iconWidth = std::max(mFolderIcon->GetWidth(), mFileIcon->GetWidth());
-	int iconHeight = std::max(mFolderIcon->GetHeight(), mFileIcon->GetHeight());
+	int iconWidth = 0, iconHeight = 0;
+	if (mFolderIcon && mFolderIcon->GetResource() && mFileIcon && mFileIcon->GetResource()) {
+		iconWidth = std::max(mFolderIcon->GetWidth(), mFileIcon->GetWidth());
+		iconHeight = std::max(mFolderIcon->GetHeight(), mFileIcon->GetHeight());
+	} else if (mFolderIcon && mFolderIcon->GetResource()) {
+		iconWidth = mFolderIcon->GetWidth();
+		iconHeight = mFolderIcon->GetHeight();
+	} else if (mFileIcon && mFileIcon->GetResource()) {
+		iconWidth = mFileIcon->GetWidth();
+		iconHeight = mFileIcon->GetHeight();
+	}
 	SetMaxIconSize(iconWidth, iconHeight);
 
 	// Fetch the file/folder list