Add gvr_is_feature_supported()

A new gvr function gvr_is_feature_supported() was added in
https://critique.corp.google.com/#review/145712807.

Implement the function to bring our gvr library up to date.

Bug: 34742071
Test: Confirmed I can once again load TreasureHunt built from google3.
Change-Id: Ib6a9802812a514ee54564f8572be9f6f4820ed01
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr.h
index 5054ebd..c459eca 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr.h
@@ -338,6 +338,15 @@
                            const gvr_buffer_viewport_list* viewport_list,
                            gvr_mat4f head_space_from_start_space,
                            gvr_clock_time_point target_presentation_time);
+
+/// Queries whether a particular GVR feature is supported by the underlying
+/// platform.
+///
+/// @param gvr The context to query against.
+/// @param feature The gvr_feature type being queried.
+/// @return true if feature is supported, false otherwise.
+bool gvr_is_feature_supported(const gvr_context* gvr, int32_t feature);
+
 /// @}
 
 /////////////////////////////////////////////////////////////////////////////
@@ -743,7 +752,7 @@
 /// scenarios, e.g., when tracking is non-biological.
 ///
 /// @param gvr Pointer to the context instance from which the pose was obtained.
-/// @param head_rotation_in_start_space The head rotation as returned by
+/// @param head_space_from_start_space_rotation The head rotation as returned by
 ///     gvr_get_head_space_from_start_space_rotation().
 /// @param factor A scaling factor for the neck model offset, clamped from 0 to
 ///     1. This should be 1 for most scenarios, while 0 will effectively disable
@@ -1589,6 +1598,11 @@
                           texture_presentation_time);
   }
 
+  /// For more information, see gvr_is_feature_supported().
+  bool IsFeatureSupported(int32_t feature) {
+    return gvr_is_feature_supported(context_, feature);
+  }
+
   /// For more information, see gvr_buffer_spec_create().
   BufferSpec CreateBufferSpec() {
     return BufferSpec(context_);
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_audio.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_audio.h
index eee3d0c..d34c84d 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_audio.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_audio.h
@@ -441,7 +441,7 @@
 /// @return Id of new sound object. Returns kInvalidId if the sound file has not
 ///     been preloaded or if the number of input channels is > 1.
 gvr_audio_source_id gvr_audio_create_sound_object(gvr_audio_context* api,
-                                                 const char* filename);
+                                                  const char* filename);
 
 /// Returns a new ambisonic sound field. Note that the sample needs to be
 /// preloaded and must have 4 separate audio channels. The handle automatically
@@ -453,7 +453,7 @@
 ///     been preloaded or if the number of input channels does not match that
 ///     required.
 gvr_audio_source_id gvr_audio_create_soundfield(gvr_audio_context* api,
-                                               const char* filename);
+                                                const char* filename);
 
 /// Returns a new stereo non-spatialized source, which directly plays back mono
 /// or stereo audio. Note the sample needs to be preloaded and may contain only
@@ -465,7 +465,7 @@
 ///     sound file has not been preloaded or if the number of input channels is
 ///     > 2;
 gvr_audio_source_id gvr_audio_create_stereo_sound(gvr_audio_context* api,
-                                                 const char* filename);
+                                                  const char* filename);
 
 /// Starts the playback of a sound.
 ///
@@ -549,7 +549,6 @@
     gvr_audio_context* api, gvr_audio_source_id sound_object_id,
     int32_t rolloff_model, float min_distance, float max_distance);
 
-
 /// Changes the master volume.
 ///
 /// @param api Pointer to a gvr_audio_context.
@@ -707,7 +706,7 @@
     return gvr_audio_create_soundfield(context_, filename.c_str());
   }
 
-  /// Returns a new stereo soound.
+  /// Returns a new stereo sound.
   /// For more information, see gvr_audio_create_stereo_sound().
   AudioSourceId CreateStereoSound(const std::string& filename) {
     return gvr_audio_create_stereo_sound(context_, filename.c_str());
@@ -824,8 +823,7 @@
   /// @name Wrapper manipulation
   /// @{
   /// Creates a C++ wrapper for a C object and takes ownership.
-  explicit AudioApi(gvr_audio_context* context)
-      : context_(context) {}
+  explicit AudioApi(gvr_audio_context* context) : context_(context) {}
 
   /// Returns the wrapped C object. Does not affect ownership.
   gvr_audio_context* cobj() { return context_; }
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_controller.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_controller.h
index a67502f..8347393 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_controller.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_controller.h
@@ -414,6 +414,27 @@
 int64_t gvr_controller_state_get_last_position_timestamp(
     const gvr_controller_state* state);
 
+/// Returns whether the controller battery is currently charging.
+/// This may not be real time information and may be slow to be updated.
+bool gvr_controller_state_get_battery_charging(
+    const gvr_controller_state* state);
+
+/// Returns the bucketed controller battery level.
+/// Note this is a gvr_controller_battery_level and not a percent.
+int32_t gvr_controller_state_get_battery_level(
+    const gvr_controller_state* state);
+
+/// Returns the timestamp (nanos) when the last battery event was received.
+int64_t gvr_controller_state_get_last_battery_timestamp(
+    const gvr_controller_state* state);
+
+/// Convenience to convert a battery level to string. The returned pointer
+/// is static and valid throughout the lifetime of the application.
+///
+/// @param level The gvr_controller_battery_level to convert to string.
+/// @return A pointer to a string that describes the value.
+const char* gvr_controller_battery_level_to_string(int32_t level);
+
 /// @}
 
 #ifdef __cplusplus
@@ -572,6 +593,10 @@
     return gvr_controller_button_to_string(button);
   }
 
+  static const char* ToString(ControllerBatteryLevel level) {
+    return gvr_controller_battery_level_to_string(level);
+  }
+
   /// @name Wrapper manipulation
   /// @{
   /// Creates a C++ wrapper for a C object and takes ownership.
@@ -724,6 +749,22 @@
     return gvr_controller_state_get_last_position_timestamp(state_);
   }
 
+  /// For more information, see gvr_controller_state_get_battery_charging
+  bool GetBatteryCharging() const {
+    return gvr_controller_state_get_battery_charging(state_);
+  }
+
+  /// For more information, see gvr_controller_state_get_battery_level
+  ControllerBatteryLevel GetBatteryLevel() const {
+    return static_cast<ControllerBatteryLevel>(
+        gvr_controller_state_get_battery_level(state_));
+  }
+
+  /// For more information, see gvr_controller_state_get_last_battery_timestamp
+  int64_t GetLastBatteryTimestamp() const {
+    return gvr_controller_state_get_last_battery_timestamp(state_);
+  }
+
   /// @name Wrapper manipulation
   /// @{
   /// Creates a C++ wrapper for a C object and takes ownership.
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_types.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_types.h
index ff00863..cf81b51 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_types.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/include/gvr_types.h
@@ -50,6 +50,14 @@
   GVR_VIEWER_TYPE_DAYDREAM = 1,
 } gvr_viewer_type;
 
+// Types of VR-specific features which may or may not be supported on the
+// underlying platform.
+typedef enum {
+  // Asynchronous reprojection warps the app's rendered frame using the most
+  // recent head pose just before pushing the frame to the display.
+  GVR_FEATURE_ASYNC_REPROJECTION = 0,
+} gvr_feature;
+
 /// @}
 
 /// Version information for the Google VR API.
@@ -185,6 +193,8 @@
   GVR_CONTROLLER_ENABLE_POSE_PREDICTION = 1 << 5,
   /// Indicates that controller position data should be reported.
   GVR_CONTROLLER_ENABLE_POSITION = 1 << 6,
+  /// Indicates that controller battery data should be reported.
+  GVR_CONTROLLER_ENABLE_BATTERY = 1 << 7,
 };
 
 /// Constants that represent the status of the controller API.
@@ -239,6 +249,21 @@
   GVR_CONTROLLER_BUTTON_COUNT = 6,
 } gvr_controller_button;
 
+/// Controller battery states.
+typedef enum {
+  GVR_CONTROLLER_BATTERY_LEVEL_UNKNOWN = 0,
+  GVR_CONTROLLER_BATTERY_LEVEL_CRITICAL_LOW = 1,
+  GVR_CONTROLLER_BATTERY_LEVEL_LOW = 2,
+  GVR_CONTROLLER_BATTERY_LEVEL_MEDIUM = 3,
+  GVR_CONTROLLER_BATTERY_LEVEL_ALMOST_FULL = 4,
+  GVR_CONTROLLER_BATTERY_LEVEL_FULL = 5,
+
+  /// Note: there are 5 distinct levels, but there are 6 due to the inclusion
+  /// of an UNKNOWN state before any battery information is collected, etc.
+  GVR_CONTROLLER_BATTERY_LEVEL_COUNT = 6,
+} gvr_controller_battery_level;
+
+
 /// @}
 
 /// Opaque handle to controller state.
@@ -322,6 +347,41 @@
 /// Sound object and sound field identifier.
 typedef int32_t gvr_audio_source_id;
 
+/// Supported surround sound formats.
+typedef enum {
+  // Enables to initialize a yet undefined rendering mode.
+  GVR_AUDIO_SURROUND_FORMAT_INVALID = 0,
+
+  // Virtual stereo speakers at -30 degrees and +30 degrees.
+  GVR_AUDIO_SURROUND_FORMAT_SURROUND_STEREO = 1,
+
+  // 5.1 surround sound according to the ITU-R BS 775 speaker configuration
+  // recommendation:
+  //   - Front left (FL) at 30 degrees.
+  //   - Front right (FR) at -30 degrees.
+  //   - Front center (FC) at 0 degrees.
+  //   - Low frequency effects (LFE) at front center at 0 degrees.
+  //   - Left side (LS) at 110 degrees.
+  //   - Right side (RS) at -110 degrees.
+  //
+  // The 5.1 channel input layout must matches AAC: FL, FR, FC, LFE, LS, RS.
+  // Note that this differs from the Vorbis/Opus 5.1 channel layout, which
+  // is: FL, FC, FR, LS, RS, LFE.
+  GVR_AUDIO_SURROUND_FORMAT_SURROUND_FIVE_DOT_ONE = 2,
+
+  // First-order ambisonics (AmbiX format: 4 channels, ACN channel ordering,
+  // SN3D normalization).
+  GVR_AUDIO_SURROUND_FORMAT_FIRST_ORDER_AMBISONICS = 3,
+
+  // Second-order ambisonics (AmbiX format: 9 channels, ACN channel ordering,
+  // SN3D normalization).
+  GVR_AUDIO_SURROUND_FORMAT_SECOND_ORDER_AMBISONICS = 4,
+
+  // Third-order ambisonics (AmbiX format: 16 channels, ACN channel ordering,
+  // SN3D normalization).
+  GVR_AUDIO_SURROUND_FORMAT_THIRD_ORDER_AMBISONICS = 5,
+} gvr_audio_surround_format_type;
+
 /// Valid color formats for swap chain buffers.
 typedef enum {
   /// Equivalent to GL_RGBA8
@@ -400,6 +460,8 @@
     static_cast<int32_t>(GVR_CONTROLLER_ENABLE_POSE_PREDICTION);
 const int32_t kControllerEnablePosition =
     static_cast<int32_t>(GVR_CONTROLLER_ENABLE_POSITION);
+const int32_t kControllerEnableBattery =
+    static_cast<int32_t>(GVR_CONTROLLER_ENABLE_BATTERY);
 
 typedef gvr_controller_api_status ControllerApiStatus;
 const ControllerApiStatus kControllerApiOk =
@@ -443,6 +505,26 @@
 const ControllerButton kControllerButtonCount =
     static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_COUNT);
 
+typedef gvr_controller_battery_level ControllerBatteryLevel;
+const ControllerBatteryLevel kControllerBatteryLevelUnknown =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_UNKNOWN);
+const ControllerBatteryLevel kControllerBatteryLevelCriticalLow =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_CRITICAL_LOW);
+const ControllerBatteryLevel kControllerBatteryLevelLow =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_LOW);
+const ControllerBatteryLevel kControllerBatteryLevelMedium =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_MEDIUM);
+const ControllerBatteryLevel kControllerBatteryLevelAlmostFull =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_ALMOST_FULL);
+const ControllerBatteryLevel kControllerBatteryLevelFull =
+    static_cast<ControllerBatteryLevel>(
+        GVR_CONTROLLER_BATTERY_LEVEL_FULL);
+
 /// An uninitialized external surface ID.
 const int32_t kUninitializedExternalSurface = GVR_BUFFER_INDEX_EXTERNAL_SURFACE;
 /// The default source buffer index for viewports.
@@ -474,6 +556,7 @@
 typedef gvr_audio_material_type AudioMaterialName;
 typedef gvr_audio_distance_rolloff_type AudioRolloffMethod;
 typedef gvr_audio_source_id AudioSourceId;
+typedef gvr_audio_surround_format_type AudioSurroundFormat;
 
 typedef gvr_color_format_type ColorFormat;
 const ColorFormat kColorFormatRgba8888 =
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_experimental.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_experimental.h
index 6bc2b4e..5bd6174 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_experimental.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_experimental.h
@@ -86,15 +86,6 @@
 int32_t gvr_external_surface_get_surface_id(
     const gvr_external_surface* surface);
 
-/// Queries whether a particular GVR feature is supported by the underlying
-/// platform.
-///
-/// @param gvr The context to query against.
-/// @param feature The gvr_feature type being queried.
-/// @return true if feature is supported, false otherwise.
-bool gvr_experimental_is_feature_supported(const gvr_context* gvr,
-                                           int32_t feature);
-
 /// Sets the z order of the layer to be created.
 /// Note that this API is a short-term workaround for SysUI work and is never
 /// meant to graduate as is to either gvr.h or gvr_private.h. The proper
diff --git a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_types_experimental.h b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_types_experimental.h
index 1df2443..f7ae6a5 100644
--- a/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_types_experimental.h
+++ b/libs/vr/libgvr/prebuilt/include/vr/gvr/capi/src/gvr_types_experimental.h
@@ -43,15 +43,13 @@
   GVR_NUM_PERF_EVENT_CALLBACK_TYPES = 3,
 } gvr_perf_event_callback_type;
 
-// Types of VR-specific features which may or may not be supported on the
-// underlying platform.
+// Experimental VR-specific features which may or may not be supported on the
+// underlying platform.  These values should not overlap with current or future
+// gvr_feature values, so we're starting with 1000000 and increasing upward.
 typedef enum {
-  // Asynchronous reprojection warps the app's rendered frame using the most
-  // recent head pose just before pushing the frame to the display.
-  GVR_ASYNC_REPROJECTION = 0,
   // Head tracking with 6 degrees of freedom (position & rotation)
-  GVR_6DOF_HEAD_POSE = 1,
-} gvr_feature;
+  GVR_FEATURE_HEAD_POSE_6DOF = 1000000,
+} gvr_experimental_feature;
 
 // ************************************************************************** //
 // *                    GVR Analytics experimental APIs                     * //
diff --git a/libs/vr/libgvr/shim_gvr.cpp b/libs/vr/libgvr/shim_gvr.cpp
index 4b074e7..264952e 100644
--- a/libs/vr/libgvr/shim_gvr.cpp
+++ b/libs/vr/libgvr/shim_gvr.cpp
@@ -511,6 +511,10 @@
   gvr_set_error(gvr, GVR_ERROR_INTERNAL);
 }
 
+bool gvr_is_feature_supported(const gvr_context* /*gvr*/, int32_t feature) {
+  return feature == GVR_FEATURE_ASYNC_REPROJECTION;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 // Viewports and viewport lists
 /////////////////////////////////////////////////////////////////////////////
@@ -1200,17 +1204,6 @@
   dvrGraphicsSurfaceSetZOrder(swap_chain->graphics_context_, z_order);
 }
 
-bool gvr_experimental_is_feature_supported(const gvr_context* /* gvr */,
-                                           int32_t feature) {
-  switch (feature) {
-    case GVR_ASYNC_REPROJECTION:
-    case GVR_6DOF_HEAD_POSE:
-      return true;
-    default:
-      return false;
-  }
-}
-
 bool gvr_experimental_register_perf_event_callback(
     gvr_context* gvr, int* /* out_handle */, void* /* user_data */,
     void (* /* event_callback */)(void*, int, float)) {