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/minuitwrp/events.cpp b/minuitwrp/events.cpp
index 04545b6..94b800e 100644
--- a/minuitwrp/events.cpp
+++ b/minuitwrp/events.cpp
@@ -101,7 +101,7 @@
 static struct ev evs[MAX_DEVICES];
 static unsigned ev_count = 0;
 static struct timeval lastInputStat;
-static unsigned long lastInputMTime;
+static time_t lastInputMTime;
 static int has_mouse = 0;
 
 static inline int ABS(int x) {
@@ -360,7 +360,7 @@
 	ev_count = 0;
 }
 
-static int vk_inside_display(__s32 value, struct input_absinfo *info, int screen_size)
+/*static int vk_inside_display(__s32 value, struct input_absinfo *info, int screen_size)
 {
     int screen_pos;
 
@@ -369,7 +369,7 @@
 
     screen_pos = (value - info->minimum) * (screen_size - 1) / (info->maximum - info->minimum);
     return (screen_pos >= 0 && screen_pos < screen_size);
-}
+}*/
 
 static int vk_tp_to_screen(struct position *p, int *x, int *y)
 {
@@ -782,7 +782,7 @@
     return -2;
 }
 
-int ev_wait(int timeout)
+int ev_wait(int timeout __unused)
 {
     return -1;
 }
@@ -792,7 +792,7 @@
     return;
 }
 
-int ev_get_input(int fd, short revents, struct input_event *ev)
+int ev_get_input(int fd __unused, short revents __unused, struct input_event *ev __unused)
 {
     return -1;
 }
diff --git a/minuitwrp/graphics.cpp b/minuitwrp/graphics.cpp
index 3dc88d9..81e77a6 100644
--- a/minuitwrp/graphics.cpp
+++ b/minuitwrp/graphics.cpp
@@ -42,7 +42,6 @@
     int cheight;
 };
 
-static GRFont* gr_font = NULL;
 static minui_backend* gr_backend = NULL;
 
 static int overscan_percent = OVERSCAN_PERCENT;
@@ -52,11 +51,6 @@
 static unsigned char gr_current_r = 255;
 static unsigned char gr_current_g = 255;
 static unsigned char gr_current_b = 255;
-static unsigned char gr_current_a = 255;
-static unsigned char rgb_555[2];
-static unsigned char gr_current_r5 = 31;
-static unsigned char gr_current_g5 = 63;
-static unsigned char gr_current_b5 = 31;
 
 GRSurface* gr_draw = NULL;
 
@@ -64,19 +58,12 @@
 GGLSurface gr_mem_surface;
 static int gr_is_curr_clr_opaque = 0;
 
-static bool outside(int x, int y)
-{
-    return x < 0 || x >= gr_draw->width || y < 0 || y >= gr_draw->height;
-}
-
 int gr_textEx_scaleW(int x, int y, const char *s, void* pFont, int max_width, int placement, int scale)
 {
     GGLContext *gl = gr_context;
     void* vfont = pFont;
     GRFont *font = (GRFont*) pFont;
-    unsigned off;
-    unsigned cwidth;
-    int y_scale = 0, measured_width, measured_height, ret, new_height;
+    int y_scale = 0, measured_width, measured_height, new_height;
 
     if (!s || strlen(s) == 0 || !font)
         return 0;
diff --git a/minuitwrp/truetype.cpp b/minuitwrp/truetype.cpp
index 18635a8..3e5f707 100644
--- a/minuitwrp/truetype.cpp
+++ b/minuitwrp/truetype.cpp
@@ -461,7 +461,7 @@
     int utf_bytes = 0;
     unsigned int unicode = 0;
     int i, x, diff, char_idx, prev_idx = 0;
-    int height, base;
+    int height;
     FT_Vector delta;
     uint8_t *data = NULL;
     const char *text_itr = text;
@@ -547,7 +547,6 @@
 
 static StringCacheEntry *gr_ttf_string_cache_peek(TrueTypeFont *font, const char *text, int max_width)
 {
-    StringCacheEntry *res;
     StringCacheKey k = {
         .text = (char*)text,
         .max_width = max_width
@@ -785,8 +784,8 @@
             "    refcount: %d\n"
             "    max_height: %d\n"
             "    base: %d\n"
-            "    glyph_cache: %d entries\n"
-            "    string_cache: %d entries (%.2f kB)\n",
+            "    glyph_cache: %zu entries\n"
+            "    string_cache: %zu entries (%.2f kB)\n",
             k->path, k->size, k->dpi,
             f->refcount, f->max_height, f->base,
             hashmapSize(f->glyph_cache),
@@ -808,7 +807,7 @@
     else
     {
         int total_string_cache_size = 0;
-        printf("%d fonts loaded.\n", hashmapSize(font_data.fonts));
+        printf("%zu fonts loaded.\n", hashmapSize(font_data.fonts));
         hashmapForEach(font_data.fonts, gr_ttf_dump_stats_font, &total_string_cache_size);
         printf("  Total string cache size: %.2f kB\n", ((double)total_string_cache_size)/1024);
     }