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/terminal.cpp b/gui/terminal.cpp
index 65ad2c0..b1799ce 100644
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -861,9 +861,12 @@
 	return engine->getLinesCount();
 }
 
-void GUITerminal::RenderItem(size_t itemindex, int yPos, bool selected)
+void GUITerminal::RenderItem(size_t itemindex, int yPos, bool selected __unused)
 {
 	const TerminalEngine::Line& line = engine->getLine(itemindex);
+	
+	if (!mFont || !mFont->GetResource())
+		return;
 
 	gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha);
 	// later: handle attributes here
@@ -887,7 +890,7 @@
 	}
 }
 
-void GUITerminal::NotifySelect(size_t item_selected)
+void GUITerminal::NotifySelect(size_t item_selected __unused)
 {
 	// do nothing - terminal ignores selections
 }
@@ -897,8 +900,10 @@
 	// make sure the shell is started
 	engine->initPty();
 	// send window resize
-	int charWidth = gr_ttf_measureEx("N", mFont->GetResource());
-	engine->setSize(mRenderW / charWidth, GetDisplayItemCount(), mRenderW, mRenderH);
+	if (mFont && mFont->GetResource()) {
+		int charWidth = gr_ttf_measureEx("N", mFont->GetResource());
+		engine->setSize(mRenderW / charWidth, GetDisplayItemCount(), mRenderW, mRenderH);
+	}
 }
 
 void GUITerminal::SetPageFocus(int inFocus)