Update the GVR platform library.

This CL renames the target for the GVR platform library and introduces
a new method in it to determine if this is an all-in-one device or a
Daydream-ready smartphone.

Bug: 34713987
Change-Id: I38067cb02fd805f3fbe1925250bddebfe82cce55
(cherry picked from commit 904762bdddd2ea5d386b1cf5fb7a35899fbc7a1e)
diff --git a/libs/vr/libgvr/Android.mk b/libs/vr/libgvr/Android.mk
index be78605..0daf2ea 100644
--- a/libs/vr/libgvr/Android.mk
+++ b/libs/vr/libgvr/Android.mk
@@ -19,10 +19,9 @@
 
 # Java platform library for the system implementation of the GVR API.
 include $(CLEAR_VARS)
-LOCAL_MODULE := gvr_platform
-LOCAL_MODULE_STEM := com.google.vr.gvr.platform
+LOCAL_MODULE := com.google.vr.gvr.platform
 LOCAL_REQUIRED_MODULES := libgvr_system_loader libgvr_system
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SRC_FILES := $(call all-java-files-under, java)
 include $(BUILD_JAVA_LIBRARY)
 
 # Library to perform dlopen on the actual platform library.
diff --git a/libs/vr/libgvr/java/com/google/vr/gvr/platform/Loader.java b/libs/vr/libgvr/java/com/google/vr/gvr/platform/Loader.java
index 5c5cc62..381175c 100644
--- a/libs/vr/libgvr/java/com/google/vr/gvr/platform/Loader.java
+++ b/libs/vr/libgvr/java/com/google/vr/gvr/platform/Loader.java
@@ -1,32 +1,38 @@
 package com.google.vr.gvr.platform;
 
+import android.os.SystemProperties;
+
 /**
  * Auxiliary class to load the system implementation of the GVR API.
+ * @hide
  */
 public class Loader {
 
-  /**
-   * Opens a shared library containing the system implementation for the GVR
-   * API and returns the handle to it.
-   *
-   * @return A Long object describing the handle returned by dlopen.
-   */
-  public static Long loadLibrary() {
-    // Note: we cannot safely do caller verifications here, so instead we do
-    // them in the service side. This means that private API symbols will be
-    // visible to any app adding the appropriate <uses-library> in their
-    // manifest, but any requests to such APIs will fail if not done from a
-    // trusted package like VrCore.
-    //
-    // Trusted packages are defined by (package name, signature) pairs in within
-    // a system service, and both must match.
+    private static final String VR_MODE_BOOT = "ro.boot.vr";
 
-    // Load a thin JNI library that runs dlopen on request.
-    System.loadLibrary("gvr_system_loader");
+    /**
+     * Opens a shared library containing the system implementation for the GVR API and returns the
+     * handle to it.
+     *
+     * @return A Long object describing the handle returned by dlopen.
+     */
+    public static Long loadLibrary() {
+        // Note: caller verifications cannot be safely done here. Any app can find and use this API.
+        // Any sensitive functions must have appropriate checks on the service side.
 
-    // Performs dlopen on the library and returns the handle.
-    return nativeLoadLibrary("libgvr_system.so");
-  }
+        // Load a thin JNI library that runs dlopen on request.
+        System.loadLibrary("gvr_system_loader");
 
-  private static native long nativeLoadLibrary(String library);
+        // Performs dlopen on the library and returns the handle.
+        return nativeLoadLibrary("libgvr_system.so");
+    }
+
+    /**
+     * Returns true if this device boots directly in VR mode.
+     */
+    public static boolean getVrBoot() {
+        return SystemProperties.getBoolean(VR_MODE_BOOT, false);
+    }
+
+    private static native long nativeLoadLibrary(String library);
 }