Add HAL version check, with fallback to CPU reference driver on failure.

libRS_internal and the vendor driver (or CPU reference driver) must
agree on HAL version.

Bug: 27298560
Change-Id: Ie4886af9c9cf6a91a164b8cfedb5c010ffbf9cb0
diff --git a/rsDriverLoader.cpp b/rsDriverLoader.cpp
index 426c519..83c6cf6 100644
--- a/rsDriverLoader.cpp
+++ b/rsDriverLoader.cpp
@@ -201,6 +201,12 @@
         goto error;
     }
 
+    if (version_major != RS_HAL_VERSION) {
+        ALOGE("Mismatched RS HAL versions: %s is version %u but version %u is expected",
+              filename, version_major, RS_HAL_VERSION);
+        goto error;
+    }
+
     if (!LoadHalTable(this, fnQueryHal, mIsGraphicsContext)) {
         ALOGE("Error loading RS HAL table, %s", filename);
         goto error;