Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a01c1e34 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove Java and gvr references from vr window manager."

parents 52eb3c9f 46481aa3
Loading
Loading
Loading
Loading
+0 −58
Original line number Original line Diff line number Diff line
@@ -37,33 +37,18 @@ LOCAL_MODULE := libvrwm_binder
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)
include $(BUILD_STATIC_LIBRARY)



native_src := \
native_src := \
  application.cpp \
  application.cpp \
  controller_mesh.cpp \
  controller_mesh.cpp \
  elbow_model.cpp \
  elbow_model.cpp \
  hwc_callback.cpp \
  hwc_callback.cpp \
  reticle.cpp \
  reticle.cpp \
  render_thread.cpp \
  shell_view.cpp \
  shell_view.cpp \
  surface_flinger_view.cpp \
  surface_flinger_view.cpp \
  texture.cpp \
  texture.cpp \
  vr_window_manager.cpp \
  vr_window_manager.cpp \
  ../virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl \
  ../virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl \


src := \
  vr_window_manager_jni.cpp \
  application.cpp \
  controller_mesh.cpp \
  elbow_model.cpp \
  hwc_callback.cpp \
  reticle.cpp \
  render_thread.cpp \
  shell_view.cpp \
  surface_flinger_view.cpp \
  texture.cpp \
  ../virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl \

static_libs := \
static_libs := \
  libdisplay \
  libdisplay \
  libbufferhub \
  libbufferhub \
@@ -97,62 +82,19 @@ shared_libs := \
  libhidlbase \
  libhidlbase \
  libhidltransport
  libhidltransport



include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(src)
LOCAL_STATIC_LIBRARIES := $(static_libs)
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES += libgvr
LOCAL_STATIC_LIBRARIES += libgvr_ext
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\"
LOCAL_LDLIBS := -llog
LOCAL_MODULE := libvr_window_manager_jni
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TARGET_ARCH := arm arm64 x86 x86_64
LOCAL_MULTILIB := 64
LOCAL_CXX_STL := libc++_static
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(native_src)
LOCAL_SRC_FILES := $(native_src)
LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder
LOCAL_STATIC_LIBRARIES := $(static_libs) libvrwm_binder
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES := $(shared_libs)
LOCAL_SHARED_LIBRARIES += libgvr
LOCAL_STATIC_LIBRARIES += libgvr_ext
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\"
LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\"
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -llog
LOCAL_MODULE := vr_wm
LOCAL_MODULE := vr_wm
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TARGET_ARCH := arm arm64 x86 x86_64
LOCAL_INIT_RC := vr_wm.rc
LOCAL_INIT_RC := vr_wm.rc
include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)


include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := VrWindowManager

# We need to be priveleged to run as the system user, which is necessary for
# getting hmd input events and doing input injection.
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true

LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, java)
LOCAL_JNI_SHARED_LIBRARIES := libvr_window_manager_jni
LOCAL_STATIC_JAVA_AAR_LIBRARIES := gvr_common_library_aar
# gvr_common_library_aar depends on nano version of libprotobuf
LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-nano
# Make sure that libgvr's resources are loaded
LOCAL_AAPT_FLAGS += --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages com.google.vr.cardboard
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_MODULE_TARGET_ARCH := arm arm64 x86 x86_64
include $(BUILD_PACKAGE)


cmd_src := \
cmd_src := \
  vr_wm_ctl.cpp \
  vr_wm_ctl.cpp \
  aidl/android/service/vr/IVrWindowManager.aidl
  aidl/android/service/vr/IVrWindowManager.aidl
+0 −34
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.google.vr.windowmanager"
          coreApp="true"
          android:sharedUserId="android.uid.system"
          android:versionCode="1"
          android:versionName="1.0" >

  <!-- The GVR SDK requires API 19+ and OpenGL ES 2+. -->
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="24" />
  <uses-feature android:glEsVersion="0x00020000" android:required="true" />

  <!-- We need the DIAGNOSTIC permission to read HMD button events. DIAGNOSTIC
       ensures our process runs with the "input" group, so we can access
       /dev/input. See frameworks/base/data/etc/platform.xml for the permission
       to group mappings.

       TODO(steventhomas): We shouldn't use this DIAGNOSTIC permission. Figure
       out the correct way to get access to the HMD buttons.
       Bug: b/33253485. -->
  <uses-permission android:name="android.permission.DIAGNOSTIC"/>
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

  <application
      android:label="vr_window_manager"
      android:theme="@style/AppStyle">
    <service android:name=".VrWindowManagerService" />
    <receiver android:name="com.google.vr.windowmanager.BootCompletedReceiver">
      <intent-filter>
        <!-- action android:name="android.intent.action.BOOT_COMPLETED" / -->
      </intent-filter>
    </receiver>
  </application>
</manifest>
+2 −88
Original line number Original line Diff line number Diff line
@@ -16,25 +16,18 @@
namespace android {
namespace android {
namespace dvr {
namespace dvr {


Application::Application()
Application::Application() {}
    : controller_api_status_logged_(false),
      controller_connection_state_logged_(false) {}


Application::~Application() {
Application::~Application() {
}
}


int Application::Initialize(JNIEnv* env, jobject app_context,
int Application::Initialize() {
                            jobject class_loader) {
  dvrSetCpuPartition(0, "/application/performance");
  dvrSetCpuPartition(0, "/application/performance");


  bool is_right_handed = true;  // TODO: retrieve setting from system
  bool is_right_handed = true;  // TODO: retrieve setting from system
  elbow_model_.Enable(ElbowModel::kDefaultNeckPosition, is_right_handed);
  elbow_model_.Enable(ElbowModel::kDefaultNeckPosition, is_right_handed);
  last_frame_time_ = std::chrono::system_clock::now();
  last_frame_time_ = std::chrono::system_clock::now();


  java_env_ = env;
  app_context_ = app_context;
  class_loader_ = class_loader;

  return 0;
  return 0;
}
}


@@ -100,42 +93,10 @@ int Application::AllocateResources() {
  fov_[1] = FieldOfView(lens_info.right_fov[0], lens_info.right_fov[1],
  fov_[1] = FieldOfView(lens_info.right_fov[0], lens_info.right_fov[1],
                        lens_info.right_fov[2], lens_info.right_fov[3]);
                        lens_info.right_fov[2], lens_info.right_fov[3]);


  if (java_env_) {
    int ret = InitializeController();
    if (ret)
      return ret;
  }

  return 0;
}

int Application::InitializeController() {
  gvr_context_ = gvr::GvrApi::Create(java_env_, app_context_, class_loader_);
  if (gvr_context_ == nullptr) {
    ALOGE("Gvr context creation failed");
    return 1;
  }

  int32_t options = gvr_controller_get_default_options();
  options |= GVR_CONTROLLER_ENABLE_GYRO | GVR_CONTROLLER_ENABLE_ACCEL;

  controller_.reset(new gvr::ControllerApi);
  if (!controller_->Init(java_env_, app_context_, class_loader_, options,
                         gvr_context_->cobj())) {
    ALOGE("Gvr controller init failed");
    return 1;
  }

  controller_state_.reset(new gvr::ControllerState);

  return 0;
  return 0;
}
}


void Application::DeallocateResources() {
void Application::DeallocateResources() {
  gvr_context_.reset();
  controller_.reset();
  controller_state_.reset();

  if (graphics_context_)
  if (graphics_context_)
    dvrGraphicsContextDestroy(graphics_context_);
    dvrGraphicsContextDestroy(graphics_context_);


@@ -309,47 +270,6 @@ void Application::ProcessControllerInput() {
      return;
      return;
    }
    }
  }
  }

  if (!controller_)
    return;

  controller_state_->Update(*controller_);
  gvr::ControllerApiStatus new_api_status = controller_state_->GetApiStatus();
  gvr::ControllerConnectionState new_connection_state =
      controller_state_->GetConnectionState();

  if (!controller_api_status_logged_) {
    controller_api_status_logged_ = true;
    ALOGI("Controller api status: %s",
          gvr::ControllerApi::ToString(new_api_status));
  } else if (new_api_status != controller_api_status_) {
    ALOGI("Controller api status changed: %s --> %s",
          gvr::ControllerApi::ToString(controller_api_status_),
          gvr::ControllerApi::ToString(new_api_status));
  }

  if (new_api_status == gvr::kControllerApiOk) {
    if (!controller_connection_state_logged_) {
      controller_connection_state_logged_ = true;
      ALOGI("Controller connection state: %s",
            gvr::ControllerApi::ToString(new_connection_state));
    } else if (new_connection_state != controller_connection_state_) {
      ALOGI("Controller connection state changed: %s --> %s",
            gvr::ControllerApi::ToString(controller_connection_state_),
            gvr::ControllerApi::ToString(new_connection_state));
    }
  } else {
    controller_connection_state_logged_ = false;
  }

  if (new_api_status == gvr::kControllerApiOk) {
    gvr_quatf orientation = controller_state_->GetOrientation();
    controller_orientation_ =
        quat(orientation.qw, orientation.qx, orientation.qy, orientation.qz);
  }

  controller_api_status_ = new_api_status;
  controller_connection_state_ = new_connection_state;
}
}


void Application::SetVisibility(bool visible) {
void Application::SetVisibility(bool visible) {
@@ -357,12 +277,6 @@ void Application::SetVisibility(bool visible) {
  if (changed) {
  if (changed) {
    is_visible_ = visible;
    is_visible_ = visible;
    dvrGraphicsSurfaceSetVisible(graphics_context_, is_visible_);
    dvrGraphicsSurfaceSetVisible(graphics_context_, is_visible_);
    if (controller_) {
      if (is_visible_)
        controller_->Resume();
      else
        controller_->Pause();
    }
    OnVisibilityChanged(is_visible_);
    OnVisibilityChanged(is_visible_);
  }
  }
}
}
+2 −19
Original line number Original line Diff line number Diff line
#ifndef VR_WINDOW_MANAGER_APPLICATION_H_
#ifndef VR_WINDOW_MANAGER_APPLICATION_H_
#define VR_WINDOW_MANAGER_APPLICATION_H_
#define VR_WINDOW_MANAGER_APPLICATION_H_


#include <jni.h>
#include <memory>
#include <memory>
#include <private/dvr/types.h>
#include <private/dvr/types.h>
#include <stdint.h>
#include <stdint.h>
#include <vr/gvr/capi/include/gvr.h>
#include <vr/gvr/capi/include/gvr_controller.h>


#include <chrono>
#include <chrono>
#include <mutex>
#include <mutex>
#include <vector>


#include "controller_data_provider.h"
#include "controller_data_provider.h"
#include "elbow_model.h"
#include "elbow_model.h"
@@ -25,8 +23,7 @@ class Application {
  Application();
  Application();
  virtual ~Application();
  virtual ~Application();


  virtual int Initialize(JNIEnv* env, jobject app_context,
  virtual int Initialize();
                         jobject class_loader);


  virtual int AllocateResources();
  virtual int AllocateResources();
  virtual void DeallocateResources();
  virtual void DeallocateResources();
@@ -59,8 +56,6 @@ class Application {


  void QueueTask(MainThreadTask task);
  void QueueTask(MainThreadTask task);


  int InitializeController();

  DvrGraphicsContext* graphics_context_ = nullptr;
  DvrGraphicsContext* graphics_context_ = nullptr;
  DvrPose* pose_client_ = nullptr;
  DvrPose* pose_client_ = nullptr;


@@ -69,15 +64,8 @@ class Application {
  FieldOfView fov_[2];
  FieldOfView fov_[2];
  Posef last_pose_;
  Posef last_pose_;


  std::unique_ptr<gvr::GvrApi> gvr_context_;
  std::unique_ptr<gvr::ControllerApi> controller_;
  std::unique_ptr<gvr::ControllerState> controller_state_;
  gvr::ControllerApiStatus controller_api_status_;
  gvr::ControllerConnectionState controller_connection_state_;
  quat controller_orientation_;
  quat controller_orientation_;
  bool shmem_controller_active_ = false;
  bool shmem_controller_active_ = false;
  bool controller_api_status_logged_;
  bool controller_connection_state_logged_;
  uint64_t shmem_controller_buttons_;
  uint64_t shmem_controller_buttons_;


  bool is_visible_ = false;
  bool is_visible_ = false;
@@ -95,11 +83,6 @@ class Application {
  bool initialized_ = false;
  bool initialized_ = false;
  std::vector<MainThreadTask> main_thread_tasks_;
  std::vector<MainThreadTask> main_thread_tasks_;


  // Java Resources.
  JNIEnv* java_env_;
  jobject app_context_;
  jobject class_loader_;

  // Controller data provider from shared memory buffer.
  // Controller data provider from shared memory buffer.
  ControllerDataProvider* controller_data_provider_ = nullptr;
  ControllerDataProvider* controller_data_provider_ = nullptr;


+0 −17
Original line number Original line Diff line number Diff line
package com.google.vr.windowmanager;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class BootCompletedReceiver extends BroadcastReceiver {
  private static final String TAG = BootCompletedReceiver.class.getSimpleName();

  @Override
  public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "Starting VRWindowManager");
    Intent vrWindowManagerIntent = new Intent(context, VrWindowManagerService.class);
    context.startService(vrWindowManagerIntent);
  }
}
Loading