Merge "Allow "android" package name."
diff --git a/libs/vr/libdisplay/Android.mk b/libs/vr/libdisplay/Android.mk
index 6a9458c..05e1bab 100644
--- a/libs/vr/libdisplay/Android.mk
+++ b/libs/vr/libdisplay/Android.mk
@@ -15,7 +15,6 @@
LOCAL_PATH := $(call my-dir)
sourceFiles := \
- native_window.cpp \
native_buffer_queue.cpp \
display_client.cpp \
display_manager_client.cpp \
diff --git a/libs/vr/libdisplay/graphics.cpp b/libs/vr/libdisplay/graphics.cpp
index d0557a9..61f6fea 100644
--- a/libs/vr/libdisplay/graphics.cpp
+++ b/libs/vr/libdisplay/graphics.cpp
@@ -483,25 +483,6 @@
return 0;
}
-extern "C" int dvrGetDisplaySurfaceInfo(EGLNativeWindowType win, int* width,
- int* height, int* format) {
- ANativeWindow* nwin = reinterpret_cast<ANativeWindow*>(win);
- int w, h, f;
-
- nwin->query(nwin, NATIVE_WINDOW_DEFAULT_WIDTH, &w);
- nwin->query(nwin, NATIVE_WINDOW_DEFAULT_HEIGHT, &h);
- nwin->query(nwin, NATIVE_WINDOW_FORMAT, &f);
-
- if (width)
- *width = w;
- if (height)
- *height = h;
- if (format)
- *format = f;
-
- return 0;
-}
-
struct DvrGraphicsContext : public android::ANativeObjectBase<
ANativeWindow, DvrGraphicsContext,
android::LightRefBase<DvrGraphicsContext>> {
diff --git a/libs/vr/libdisplay/include/dvr/graphics.h b/libs/vr/libdisplay/include/dvr/graphics.h
index 50d2754..19deec3 100644
--- a/libs/vr/libdisplay/include/dvr/graphics.h
+++ b/libs/vr/libdisplay/include/dvr/graphics.h
@@ -21,11 +21,6 @@
__BEGIN_DECLS
-// Create a stereo surface that will be lens-warped by the system.
-EGLNativeWindowType dvrCreateWarpedDisplaySurface(int* display_width,
- int* display_height);
-EGLNativeWindowType dvrCreateDisplaySurface(void);
-
// Display surface parameters used to specify display surface options.
enum {
DVR_SURFACE_PARAMETER_NONE = 0,
@@ -163,9 +158,16 @@
float right_fov[4];
};
-// Creates a display surface with the given parameters. The list of parameters
-// is terminated with an entry where key == DVR_SURFACE_PARAMETER_NONE.
-// For example, the parameters array could be built as follows:
+int dvrGetNativeDisplayDimensions(int* native_width, int* native_height);
+
+// Opaque struct that represents a graphics context, the texture swap chain,
+// and surfaces.
+typedef struct DvrGraphicsContext DvrGraphicsContext;
+
+// Create the graphics context. with the given parameters. The list of
+// parameters is terminated with an entry where key ==
+// DVR_SURFACE_PARAMETER_NONE. For example, the parameters array could be built
+// as follows:
// int display_width = 0, display_height = 0;
// int surface_width = 0, surface_height = 0;
// float inter_lens_meters = 0.0f;
@@ -183,38 +185,6 @@
// DVR_SURFACE_PARAMETER_OUT(RIGHT_FOV_LRBT, right_fov),
// DVR_SURFACE_PARAMETER_LIST_END,
// };
-EGLNativeWindowType dvrCreateDisplaySurfaceExtended(
- struct DvrSurfaceParameter* parameters);
-
-int dvrGetNativeDisplayDimensions(int* native_width, int* native_height);
-
-int dvrGetDisplaySurfaceInfo(EGLNativeWindowType win, int* width, int* height,
- int* format);
-
-// NOTE: Only call the functions below on windows created with the API above.
-
-// Sets the display surface visible based on the boolean evaluation of
-// |visible|.
-void dvrDisplaySurfaceSetVisible(EGLNativeWindowType window, int visible);
-
-// Sets the application z-order of the display surface. Higher values display on
-// top of lower values.
-void dvrDisplaySurfaceSetZOrder(EGLNativeWindowType window, int z_order);
-
-// Post the next buffer early. This allows the application to race with either
-// the async EDS process or the scanline for applications that are not using
-// system distortion. When this is called, the next buffer in the queue is
-// posted for display. It is up to the application to kick its GPU rendering
-// work in time. If the rendering is incomplete there will be significant,
-// undesirable tearing artifacts.
-// It is not recommended to use this feature with system distortion.
-void dvrDisplayPostEarly(EGLNativeWindowType window);
-
-// Opaque struct that represents a graphics context, the texture swap chain,
-// and surfaces.
-typedef struct DvrGraphicsContext DvrGraphicsContext;
-
-// Create the graphics context.
int dvrGraphicsContextCreate(struct DvrSurfaceParameter* parameters,
DvrGraphicsContext** return_graphics_context);
diff --git a/libs/vr/libdisplay/native_window.cpp b/libs/vr/libdisplay/native_window.cpp
deleted file mode 100644
index 24ecd8a..0000000
--- a/libs/vr/libdisplay/native_window.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-#include <EGL/egl.h>
-
-#include <android/native_window.h>
-#include <cutils/native_handle.h>
-#include <errno.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/timerfd.h>
-#include <system/window.h>
-#include <time.h>
-#include <ui/ANativeObjectBase.h>
-#include <utils/Errors.h>
-
-#define ATRACE_TAG ATRACE_TAG_GRAPHICS
-#include <utils/Trace.h>
-
-#include <log/log.h>
-
-#include <memory>
-#include <mutex>
-
-#include <dvr/graphics.h>
-#include <private/dvr/clock_ns.h>
-#include <private/dvr/display_client.h>
-#include <private/dvr/native_buffer.h>
-#include <private/dvr/native_buffer_queue.h>
-
-namespace {
-
-constexpr int kDefaultDisplaySurfaceUsage =
- GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
-constexpr int kDefaultDisplaySurfaceFormat = HAL_PIXEL_FORMAT_RGBA_8888;
-constexpr int kWarpedDisplaySurfaceFlags = 0;
-constexpr int kUnwarpedDisplaySurfaceFlags =
- DVR_DISPLAY_SURFACE_FLAGS_DISABLE_SYSTEM_EDS |
- DVR_DISPLAY_SURFACE_FLAGS_DISABLE_SYSTEM_DISTORTION |
- DVR_DISPLAY_SURFACE_FLAGS_DISABLE_SYSTEM_CAC;
-constexpr int kDefaultBufferCount = 4;
-
-} // anonymous namespace
-
-namespace android {
-namespace dvr {
-
-// NativeWindow is an implementation of ANativeWindow. This class interacts with
-// displayd through the DisplaySurfaceClient and NativeBufferQueue.
-class NativeWindow : public ANativeObjectBase<ANativeWindow, NativeWindow,
- LightRefBase<NativeWindow> > {
- public:
- explicit NativeWindow(const std::shared_ptr<DisplaySurfaceClient>& surface);
-
- void SetVisible(bool visible);
- void SetZOrder(int z_order);
- void PostEarly();
-
- private:
- friend class LightRefBase<NativeWindow>;
-
- void Post(sp<NativeBufferProducer> buffer, int fence_fd);
-
- static int SetSwapInterval(ANativeWindow* window, int interval);
- static int DequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer,
- int* fence_fd);
- static int QueueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer,
- int fence_fd);
- static int CancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer,
- int fence_fd);
- static int Query(const ANativeWindow* window, int what, int* value);
- static int Perform(ANativeWindow* window, int operation, ...);
-
- static int DequeueBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer** buffer);
- static int CancelBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer* buffer);
- static int QueueBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer* buffer);
- static int LockBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer* buffer);
-
- std::shared_ptr<DisplaySurfaceClient> surface_;
-
- std::mutex lock_;
- NativeBufferQueue buffer_queue_;
- sp<NativeBufferProducer> next_post_buffer_;
- bool next_buffer_already_posted_;
-
- NativeWindow(const NativeWindow&) = delete;
- void operator=(NativeWindow&) = delete;
-};
-
-NativeWindow::NativeWindow(const std::shared_ptr<DisplaySurfaceClient>& surface)
- : surface_(surface),
- buffer_queue_(surface, kDefaultBufferCount),
- next_post_buffer_(nullptr),
- next_buffer_already_posted_(false) {
- ANativeWindow::setSwapInterval = SetSwapInterval;
- ANativeWindow::dequeueBuffer = DequeueBuffer;
- ANativeWindow::cancelBuffer = CancelBuffer;
- ANativeWindow::queueBuffer = QueueBuffer;
- ANativeWindow::query = Query;
- ANativeWindow::perform = Perform;
-
- ANativeWindow::dequeueBuffer_DEPRECATED = DequeueBuffer_DEPRECATED;
- ANativeWindow::cancelBuffer_DEPRECATED = CancelBuffer_DEPRECATED;
- ANativeWindow::lockBuffer_DEPRECATED = LockBuffer_DEPRECATED;
- ANativeWindow::queueBuffer_DEPRECATED = QueueBuffer_DEPRECATED;
-}
-
-void NativeWindow::SetVisible(bool visible) { surface_->SetVisible(visible); }
-
-void NativeWindow::SetZOrder(int z_order) { surface_->SetZOrder(z_order); }
-
-void NativeWindow::PostEarly() {
- ATRACE_NAME("NativeWindow::PostEarly");
- ALOGI_IF(TRACE, "NativeWindow::PostEarly");
-
- std::lock_guard<std::mutex> autolock(lock_);
-
- if (!next_buffer_already_posted_) {
- next_buffer_already_posted_ = true;
-
- if (!next_post_buffer_.get()) {
- next_post_buffer_ = buffer_queue_.Dequeue();
- }
- ATRACE_ASYNC_BEGIN("BufferPost", next_post_buffer_->buffer()->id());
- Post(next_post_buffer_, -1);
- }
-}
-
-void NativeWindow::Post(sp<NativeBufferProducer> buffer, int fence_fd) {
- ATRACE_NAME(__PRETTY_FUNCTION__);
- ALOGI_IF(TRACE, "NativeWindow::Post: buffer_id=%d, fence_fd=%d",
- buffer->buffer()->id(), fence_fd);
- ALOGW_IF(!surface_->visible(),
- "NativeWindow::Post: Posting buffer on invisible surface!!!");
- buffer->Post(fence_fd, 0);
-}
-
-int NativeWindow::SetSwapInterval(ANativeWindow* window, int interval) {
- ALOGI_IF(TRACE, "SetSwapInterval: window=%p interval=%d", window, interval);
- return 0;
-}
-
-int NativeWindow::DequeueBuffer(ANativeWindow* window,
- ANativeWindowBuffer** buffer, int* fence_fd) {
- ATRACE_NAME(__PRETTY_FUNCTION__);
-
- NativeWindow* self = getSelf(window);
- std::lock_guard<std::mutex> autolock(self->lock_);
-
- if (!self->next_post_buffer_.get()) {
- self->next_post_buffer_ = self->buffer_queue_.Dequeue();
- }
- ATRACE_ASYNC_BEGIN("BufferDraw", self->next_post_buffer_->buffer()->id());
- *fence_fd = self->next_post_buffer_->ClaimReleaseFence().Release();
- *buffer = self->next_post_buffer_.get();
-
- ALOGI_IF(TRACE, "NativeWindow::DequeueBuffer: fence_fd=%d", *fence_fd);
- return 0;
-}
-
-int NativeWindow::QueueBuffer(ANativeWindow* window,
- ANativeWindowBuffer* buffer, int fence_fd) {
- ATRACE_NAME("NativeWindow::QueueBuffer");
- ALOGI_IF(TRACE, "NativeWindow::QueueBuffer: fence_fd=%d", fence_fd);
-
- NativeWindow* self = getSelf(window);
- std::lock_guard<std::mutex> autolock(self->lock_);
-
- NativeBufferProducer* native_buffer =
- static_cast<NativeBufferProducer*>(buffer);
- ATRACE_ASYNC_END("BufferDraw", native_buffer->buffer()->id());
- bool do_post = true;
- if (self->next_buffer_already_posted_) {
- // Check that the buffer is the one we expect, but handle it if this happens
- // in production by allowing this buffer to post on top of the previous one.
- LOG_FATAL_IF(native_buffer != self->next_post_buffer_.get());
- if (native_buffer == self->next_post_buffer_.get()) {
- do_post = false;
- if (fence_fd >= 0)
- close(fence_fd);
- }
- }
- if (do_post) {
- ATRACE_ASYNC_BEGIN("BufferPost", native_buffer->buffer()->id());
- self->Post(native_buffer, fence_fd);
- }
- self->next_buffer_already_posted_ = false;
- self->next_post_buffer_ = nullptr;
-
- return NO_ERROR;
-}
-
-int NativeWindow::CancelBuffer(ANativeWindow* window,
- ANativeWindowBuffer* buffer, int fence_fd) {
- ATRACE_NAME("NativeWindow::CancelBuffer");
- ALOGI_IF(TRACE, "NativeWindow::CancelBuffer: fence_fd: %d", fence_fd);
-
- NativeWindow* self = getSelf(window);
- std::lock_guard<std::mutex> autolock(self->lock_);
-
- NativeBufferProducer* native_buffer =
- static_cast<NativeBufferProducer*>(buffer);
- ATRACE_ASYNC_END("BufferDraw", native_buffer->buffer()->id());
- ATRACE_INT("CancelBuffer", native_buffer->buffer()->id());
- bool do_enqueue = true;
- if (self->next_buffer_already_posted_) {
- // Check that the buffer is the one we expect, but handle it if this happens
- // in production by returning this buffer to the buffer queue.
- LOG_FATAL_IF(native_buffer != self->next_post_buffer_.get());
- if (native_buffer == self->next_post_buffer_.get()) {
- do_enqueue = false;
- }
- }
- if (do_enqueue) {
- self->buffer_queue_.Enqueue(native_buffer);
- }
- if (fence_fd >= 0)
- close(fence_fd);
- self->next_buffer_already_posted_ = false;
- self->next_post_buffer_ = nullptr;
-
- return NO_ERROR;
-}
-
-int NativeWindow::Query(const ANativeWindow* window, int what, int* value) {
- NativeWindow* self = getSelf(const_cast<ANativeWindow*>(window));
- std::lock_guard<std::mutex> autolock(self->lock_);
-
- switch (what) {
- case NATIVE_WINDOW_WIDTH:
- *value = self->surface_->width();
- return NO_ERROR;
- case NATIVE_WINDOW_HEIGHT:
- *value = self->surface_->height();
- return NO_ERROR;
- case NATIVE_WINDOW_FORMAT:
- *value = self->surface_->format();
- return NO_ERROR;
- case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
- *value = 1;
- return NO_ERROR;
- case NATIVE_WINDOW_CONCRETE_TYPE:
- *value = NATIVE_WINDOW_SURFACE;
- return NO_ERROR;
- case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
- *value = 1;
- return NO_ERROR;
- case NATIVE_WINDOW_DEFAULT_WIDTH:
- *value = self->surface_->width();
- return NO_ERROR;
- case NATIVE_WINDOW_DEFAULT_HEIGHT:
- *value = self->surface_->height();
- return NO_ERROR;
- case NATIVE_WINDOW_TRANSFORM_HINT:
- *value = 0;
- return NO_ERROR;
- }
-
- *value = 0;
- return BAD_VALUE;
-}
-
-int NativeWindow::Perform(ANativeWindow* window, int operation, ...) {
- NativeWindow* self = getSelf(window);
- std::lock_guard<std::mutex> autolock(self->lock_);
-
- va_list args;
- va_start(args, operation);
-
- // TODO(eieio): The following operations are not used at this time. They are
- // included here to help document which operations may be useful and what
- // parameters they take.
- switch (operation) {
- case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: {
- int w = va_arg(args, int);
- int h = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: w=%d h=%d", w, h);
- return NO_ERROR;
- }
-
- case NATIVE_WINDOW_SET_BUFFERS_FORMAT: {
- int format = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_BUFFERS_FORMAT: format=%d", format);
- return NO_ERROR;
- }
-
- case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: {
- int transform = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: transform=%d",
- transform);
- return NO_ERROR;
- }
-
- case NATIVE_WINDOW_SET_USAGE: {
- int usage = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_USAGE: usage=%d", usage);
- return NO_ERROR;
- }
-
- case NATIVE_WINDOW_CONNECT:
- case NATIVE_WINDOW_DISCONNECT:
- case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY:
- case NATIVE_WINDOW_API_CONNECT:
- case NATIVE_WINDOW_API_DISCONNECT:
- // TODO(eieio): we should implement these
- return NO_ERROR;
-
- case NATIVE_WINDOW_SET_BUFFER_COUNT: {
- int buffer_count = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_BUFFER_COUNT: bufferCount=%d",
- buffer_count);
- return NO_ERROR;
- }
- case NATIVE_WINDOW_SET_BUFFERS_DATASPACE: {
- android_dataspace_t data_space =
- static_cast<android_dataspace_t>(va_arg(args, int));
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_BUFFERS_DATASPACE: dataSpace=%d",
- data_space);
- return NO_ERROR;
- }
- case NATIVE_WINDOW_SET_SCALING_MODE: {
- int mode = va_arg(args, int);
- ALOGD_IF(TRACE, "NATIVE_WINDOW_SET_SCALING_MODE: mode=%d", mode);
- return NO_ERROR;
- }
-
- case NATIVE_WINDOW_LOCK:
- case NATIVE_WINDOW_UNLOCK_AND_POST:
- case NATIVE_WINDOW_SET_CROP:
- case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP:
- return INVALID_OPERATION;
- }
-
- return NAME_NOT_FOUND;
-}
-
-int NativeWindow::DequeueBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer** buffer) {
- int fence_fd = -1;
- int ret = DequeueBuffer(window, buffer, &fence_fd);
-
- // wait for fence
- if (ret == NO_ERROR && fence_fd != -1)
- close(fence_fd);
-
- return ret;
-}
-
-int NativeWindow::CancelBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer* buffer) {
- return CancelBuffer(window, buffer, -1);
-}
-
-int NativeWindow::QueueBuffer_DEPRECATED(ANativeWindow* window,
- ANativeWindowBuffer* buffer) {
- return QueueBuffer(window, buffer, -1);
-}
-
-int NativeWindow::LockBuffer_DEPRECATED(ANativeWindow* /*window*/,
- ANativeWindowBuffer* /*buffer*/) {
- return NO_ERROR;
-}
-
-} // namespace dvr
-} // namespace android
-
-static EGLNativeWindowType CreateDisplaySurface(int* display_width,
- int* display_height, int format,
- int usage, int flags) {
- auto client = android::dvr::DisplayClient::Create();
- if (!client) {
- ALOGE("Failed to create display client!");
- return nullptr;
- }
-
- // TODO(eieio,jbates): Consider passing flags and other parameters to get
- // metrics based on specific surface requirements.
- android::dvr::SystemDisplayMetrics metrics;
- const int ret = client->GetDisplayMetrics(&metrics);
- if (ret < 0) {
- ALOGE("Failed to get display metrics: %s", strerror(-ret));
- return nullptr;
- }
-
- int width, height;
-
- if (flags & DVR_DISPLAY_SURFACE_FLAGS_DISABLE_SYSTEM_DISTORTION) {
- width = metrics.display_native_width;
- height = metrics.display_native_height;
- } else {
- width = metrics.distorted_width;
- height = metrics.distorted_height;
- }
-
- std::shared_ptr<android::dvr::DisplaySurfaceClient> surface =
- client->CreateDisplaySurface(width, height, format, usage, flags);
-
- if (display_width)
- *display_width = metrics.display_native_width;
- if (display_height)
- *display_height = metrics.display_native_height;
-
- // Set the surface visible by default.
- // TODO(eieio,jbates): Remove this from here and set visible somewhere closer
- // to the application to account for situations where the application wants to
- // create surfaces that will be used later or shouldn't be visible yet.
- surface->SetVisible(true);
-
- return new android::dvr::NativeWindow(surface);
-}
-
-std::shared_ptr<android::dvr::DisplaySurfaceClient> CreateDisplaySurfaceClient(
- struct DvrSurfaceParameter* parameters,
- /*out*/ android::dvr::SystemDisplayMetrics* metrics);
-
-extern "C" EGLNativeWindowType dvrCreateDisplaySurfaceExtended(
- struct DvrSurfaceParameter* parameters) {
- android::dvr::SystemDisplayMetrics metrics;
- auto surface = CreateDisplaySurfaceClient(parameters, &metrics);
- if (!surface) {
- ALOGE("Failed to create display surface client");
- return nullptr;
- }
- return new android::dvr::NativeWindow(surface);
-}
-
-extern "C" EGLNativeWindowType dvrCreateDisplaySurface() {
- return CreateDisplaySurface(NULL, NULL, kDefaultDisplaySurfaceFormat,
- kDefaultDisplaySurfaceUsage,
- kUnwarpedDisplaySurfaceFlags);
-}
-
-extern "C" EGLNativeWindowType dvrCreateWarpedDisplaySurface(
- int* display_width, int* display_height) {
- return CreateDisplaySurface(
- display_width, display_height, kDefaultDisplaySurfaceFormat,
- kDefaultDisplaySurfaceUsage, kWarpedDisplaySurfaceFlags);
-}
-
-extern "C" void dvrDisplaySurfaceSetVisible(EGLNativeWindowType window,
- int visible) {
- auto native_window = reinterpret_cast<android::dvr::NativeWindow*>(window);
- native_window->SetVisible(visible);
-}
-
-extern "C" void dvrDisplaySurfaceSetZOrder(EGLNativeWindowType window,
- int z_order) {
- auto native_window = reinterpret_cast<android::dvr::NativeWindow*>(window);
- native_window->SetZOrder(z_order);
-}
-
-extern "C" void dvrDisplayPostEarly(EGLNativeWindowType window) {
- auto native_window = reinterpret_cast<android::dvr::NativeWindow*>(window);
- native_window->PostEarly();
-}
diff --git a/libs/vr/libdisplay/native_window_test.cpp b/libs/vr/libdisplay/native_window_test.cpp
deleted file mode 100644
index 2f3bc33..0000000
--- a/libs/vr/libdisplay/native_window_test.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <iostream>
-#include <memory>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <dvr/graphics.h>
-#include <private/dvr/display_client.h>
-
-#include <cpp_free_mock/cpp_free_mock.h>
-
-// Checks querying the VSync of the device on display surface creation.
-TEST(CreateDisplaySurface, QueryVSyncPeriod) {
- using ::testing::_;
-
- const uint64_t kExpectedVSync = 123456;
-
- // We only care about the expected VSync value
- android::dvr::DisplayMetrics metrics;
- metrics.vsync_period_ns = kExpectedVSync;
-
- uint64_t outPeriod;
-
- DvrSurfaceParameter display_params[] = {
- DVR_SURFACE_PARAMETER_IN(WIDTH, 256),
- DVR_SURFACE_PARAMETER_IN(HEIGHT, 256),
- DVR_SURFACE_PARAMETER_OUT(VSYNC_PERIOD, &outPeriod),
- DVR_SURFACE_PARAMETER_LIST_END,
- };
-
- // inject the mocking code to the target method
- auto mocked_function =
- MOCKER(&android::dvr::DisplayClient::GetDisplayMetrics);
-
- // instrument the mock function to return our custom metrics
- EXPECT_CALL(*mocked_function, MOCK_FUNCTION(_, _))
- .WillOnce(::testing::DoAll(::testing::SetArgPointee<1>(metrics),
- ::testing::Return(0)));
-
- ASSERT_NE(nullptr, dvrCreateDisplaySurfaceExtended(display_params));
-
- EXPECT_EQ(kExpectedVSync, outPeriod);
-}
diff --git a/libs/vr/libdisplay/tests/graphics_app_tests.cpp b/libs/vr/libdisplay/tests/graphics_app_tests.cpp
index 7ea3952..f51dd8a 100644
--- a/libs/vr/libdisplay/tests/graphics_app_tests.cpp
+++ b/libs/vr/libdisplay/tests/graphics_app_tests.cpp
@@ -1,55 +1,6 @@
#include <dvr/graphics.h>
#include <gtest/gtest.h>
-TEST(GraphicsAppTests, CreateWarpedDisplaySurfaceParams) {
- int width = 0, height = 0;
- EGLNativeWindowType window = dvrCreateWarpedDisplaySurface(&width, &height);
- EXPECT_GT(width, 0);
- EXPECT_GT(height, 0);
- EXPECT_NE(window, nullptr);
-}
-
-TEST(GraphicsAppTests, CreateDisplaySurface) {
- EGLNativeWindowType window = dvrCreateDisplaySurface();
- EXPECT_NE(window, nullptr);
-}
-
-TEST(GraphicsAppTests, CreateDisplaySurfaceExtended) {
- int display_width = 0, display_height = 0;
- int surface_width = 0, surface_height = 0;
- float inter_lens_meters = 0.0f;
- float left_fov[4] = {0.0f};
- float right_fov[4] = {0.0f};
- int disable_warp = 0;
- DvrSurfaceParameter surface_params[] = {
- DVR_SURFACE_PARAMETER_IN(DISABLE_DISTORTION, disable_warp),
- DVR_SURFACE_PARAMETER_OUT(DISPLAY_WIDTH, &display_width),
- DVR_SURFACE_PARAMETER_OUT(DISPLAY_HEIGHT, &display_height),
- DVR_SURFACE_PARAMETER_OUT(SURFACE_WIDTH, &surface_width),
- DVR_SURFACE_PARAMETER_OUT(SURFACE_HEIGHT, &surface_height),
- DVR_SURFACE_PARAMETER_OUT(INTER_LENS_METERS, &inter_lens_meters),
- DVR_SURFACE_PARAMETER_OUT(LEFT_FOV_LRBT, left_fov),
- DVR_SURFACE_PARAMETER_OUT(RIGHT_FOV_LRBT, right_fov),
- DVR_SURFACE_PARAMETER_LIST_END,
- };
-
- EGLNativeWindowType window = dvrCreateDisplaySurfaceExtended(surface_params);
- EXPECT_NE(window, nullptr);
- EXPECT_GT(display_width, 0);
- EXPECT_GT(display_height, 0);
- EXPECT_GT(surface_width, 0);
- EXPECT_GT(surface_height, 0);
- EXPECT_GT(inter_lens_meters, 0);
- EXPECT_GT(left_fov[0], 0);
- EXPECT_GT(left_fov[1], 0);
- EXPECT_GT(left_fov[2], 0);
- EXPECT_GT(left_fov[3], 0);
- EXPECT_GT(right_fov[0], 0);
- EXPECT_GT(right_fov[1], 0);
- EXPECT_GT(right_fov[2], 0);
- EXPECT_GT(right_fov[3], 0);
-}
-
TEST(GraphicsAppTests, GetNativeDisplayDimensions) {
int width, height;
dvrGetNativeDisplayDimensions(&width, &height);
@@ -57,17 +8,6 @@
EXPECT_GT(height, 0);
}
-TEST(GraphicsAppTests, GetDisplaySurfaceInfo) {
- int ret, width, height, format;
- EGLNativeWindowType window = dvrCreateDisplaySurface();
- ASSERT_NE(window, nullptr);
- ret = dvrGetDisplaySurfaceInfo(window, &width, &height, &format);
- ASSERT_EQ(0, ret);
- ASSERT_GT(width, 0);
- ASSERT_GT(height, 0);
- ASSERT_NE(0, format);
-}
-
// TODO(jpoichet) How to check it worked?
TEST(GraphicsAppTests, GraphicsSurfaceSetVisible) {
DvrSurfaceParameter surface_params[] = {DVR_SURFACE_PARAMETER_LIST_END};
diff --git a/libs/vr/libdvrcommon/include/private/dvr/matrix_helpers.h b/libs/vr/libdvrcommon/include/private/dvr/matrix_helpers.h
new file mode 100644
index 0000000..aef7146
--- /dev/null
+++ b/libs/vr/libdvrcommon/include/private/dvr/matrix_helpers.h
@@ -0,0 +1,26 @@
+#ifndef ANDROID_DVR_MATRIX_HELPERS_H_
+#define ANDROID_DVR_MATRIX_HELPERS_H_
+
+#include <private/dvr/eigen.h>
+#include <private/dvr/types.h>
+
+namespace android {
+namespace dvr {
+
+// A helper function for creating a mat4 directly.
+inline mat4 MakeMat4(float m00, float m01, float m02, float m03, float m10,
+ float m11, float m12, float m13, float m20, float m21,
+ float m22, float m23, float m30, float m31, float m32,
+ float m33) {
+ Eigen::Matrix4f matrix;
+
+ matrix << m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30,
+ m31, m32, m33;
+
+ return mat4(matrix);
+}
+
+} // namespace dvr
+} // namespace android
+
+#endif // ANDROID_DVR_LOG_HELPERS_H_
diff --git a/libs/vr/libdvrcommon/include/private/dvr/numeric.h b/libs/vr/libdvrcommon/include/private/dvr/numeric.h
index 584236a..4545893 100644
--- a/libs/vr/libdvrcommon/include/private/dvr/numeric.h
+++ b/libs/vr/libdvrcommon/include/private/dvr/numeric.h
@@ -126,12 +126,9 @@
Derived1 RandomInRange(
const Eigen::MatrixBase<Derived1>& lo,
const Eigen::MatrixBase<Derived2>& hi) {
- using Matrix1_t = Eigen::MatrixBase<Derived1>;
- using Matrix2_t = Eigen::MatrixBase<Derived2>;
+ EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived1, Derived2);
- EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Matrix1_t, Matrix2_t);
-
- Derived1 result = Matrix1_t::Zero();
+ Derived1 result = Eigen::MatrixBase<Derived1>::Zero();
for (int row = 0; row < result.rows(); ++row) {
for (int col = 0; col < result.cols(); ++col) {
diff --git a/libs/vr/libdvrcommon/tests/numeric_test.cpp b/libs/vr/libdvrcommon/tests/numeric_test.cpp
index a6a2182..1ee1447 100644
--- a/libs/vr/libdvrcommon/tests/numeric_test.cpp
+++ b/libs/vr/libdvrcommon/tests/numeric_test.cpp
@@ -1,6 +1,5 @@
#include <gtest/gtest.h>
-#define EIGEN_NO_STATIC_ASSERT
#include <private/dvr/numeric.h>
using TestTypes = ::testing::Types<float, double, int>;
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadClient.cpp b/services/vr/virtual_touchpad/VirtualTouchpadClient.cpp
index 23a2e31..175173f 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadClient.cpp
+++ b/services/vr/virtual_touchpad/VirtualTouchpadClient.cpp
@@ -12,19 +12,20 @@
public:
VirtualTouchpadClientImpl(sp<IVirtualTouchpadService> service)
: service_(service) {}
- ~VirtualTouchpadClientImpl() {}
+ ~VirtualTouchpadClientImpl() override {}
- status_t Touch(float x, float y, float pressure) override {
+ status_t Touch(int touchpad,
+ float x, float y, float pressure) override {
if (service_ == nullptr) {
return NO_INIT;
}
- return service_->touch(x, y, pressure).transactionError();
+ return service_->touch(touchpad, x, y, pressure).transactionError();
}
- status_t ButtonState(int buttons) override {
+ status_t ButtonState(int touchpad, int buttons) override {
if (service_ == nullptr) {
return NO_INIT;
}
- return service_->buttonState(buttons).transactionError();
+ return service_->buttonState(touchpad, buttons).transactionError();
}
private:
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
index ae31156..f25a2ad 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
+++ b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
@@ -56,15 +56,17 @@
return injector_->GetError();
}
-int VirtualTouchpadEvdev::Touch(float x, float y, float pressure) {
+int VirtualTouchpadEvdev::Touch(int touchpad, float x, float y,
+ float pressure) {
+ (void)touchpad; // TODO(b/35992608) Support multiple virtual touchpad devices.
if ((x < 0.0f) || (x >= 1.0f) || (y < 0.0f) || (y >= 1.0f)) {
return EINVAL;
}
int32_t device_x = x * kWidth;
int32_t device_y = y * kHeight;
touches_ = ((touches_ & 1) << 1) | (pressure > 0);
- ALOGV("(%f,%f) %f -> (%" PRId32 ",%" PRId32 ") %d",
- x, y, pressure, device_x, device_y, touches_);
+ ALOGV("(%f,%f) %f -> (%" PRId32 ",%" PRId32 ") %d", x, y, pressure, device_x,
+ device_y, touches_);
if (!injector_) {
return EvdevInjector::ERROR_SEQUENCING;
@@ -101,7 +103,8 @@
return injector_->GetError();
}
-int VirtualTouchpadEvdev::ButtonState(int buttons) {
+int VirtualTouchpadEvdev::ButtonState(int touchpad, int buttons) {
+ (void)touchpad; // TODO(b/35992608) Support multiple virtual touchpad devices.
const int changes = last_motion_event_buttons_ ^ buttons;
if (!changes) {
return 0;
@@ -117,10 +120,9 @@
}
injector_->ResetError();
if (changes & AMOTION_EVENT_BUTTON_BACK) {
- injector_->SendKey(BTN_BACK,
- (buttons & AMOTION_EVENT_BUTTON_BACK)
- ? EvdevInjector::KEY_PRESS
- : EvdevInjector::KEY_RELEASE);
+ injector_->SendKey(BTN_BACK, (buttons & AMOTION_EVENT_BUTTON_BACK)
+ ? EvdevInjector::KEY_PRESS
+ : EvdevInjector::KEY_RELEASE);
}
last_motion_event_buttons_ = buttons;
return injector_->GetError();
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.h b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.h
index c763529..ec8006b 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.h
+++ b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.h
@@ -18,12 +18,12 @@
static sp<VirtualTouchpad> Create();
// VirtualTouchpad implementation:
- status_t Touch(float x, float y, float pressure) override;
- status_t ButtonState(int buttons) override;
+ status_t Touch(int touchpad, float x, float y, float pressure) override;
+ status_t ButtonState(int touchpad, int buttons) override;
protected:
VirtualTouchpadEvdev() {}
- ~VirtualTouchpadEvdev() {}
+ ~VirtualTouchpadEvdev() override {}
status_t Initialize();
// Must be called only between construction and Initialize().
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadService.cpp b/services/vr/virtual_touchpad/VirtualTouchpadService.cpp
index 3fcb8fc..a1f281c 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadService.cpp
+++ b/services/vr/virtual_touchpad/VirtualTouchpadService.cpp
@@ -8,16 +8,15 @@
namespace android {
namespace dvr {
-binder::Status VirtualTouchpadService::touch(float x, float y, float pressure) {
- const status_t error = touchpad_->Touch(x, y, pressure);
- return error ? binder::Status::fromStatusT(error)
- : binder::Status::ok();
+binder::Status VirtualTouchpadService::touch(int touchpad,
+ float x, float y, float pressure) {
+ const status_t error = touchpad_->Touch(touchpad, x, y, pressure);
+ return error ? binder::Status::fromStatusT(error) : binder::Status::ok();
}
-binder::Status VirtualTouchpadService::buttonState(int buttons) {
- const status_t error = touchpad_->ButtonState(buttons);
- return error ? binder::Status::fromStatusT(error)
- : binder::Status::ok();
+binder::Status VirtualTouchpadService::buttonState(int touchpad, int buttons) {
+ const status_t error = touchpad_->ButtonState(touchpad, buttons);
+ return error ? binder::Status::fromStatusT(error) : binder::Status::ok();
}
} // namespace dvr
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadService.h b/services/vr/virtual_touchpad/VirtualTouchpadService.h
index b832c8f..9b880b2 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadService.h
+++ b/services/vr/virtual_touchpad/VirtualTouchpadService.h
@@ -15,11 +15,12 @@
public:
VirtualTouchpadService(sp<VirtualTouchpad> touchpad)
: touchpad_(touchpad) {}
+ ~VirtualTouchpadService() override {}
protected:
// Implements IVirtualTouchpadService.
- binder::Status touch(float x, float y, float pressure) override;
- binder::Status buttonState(int buttons) override;
+ binder::Status touch(int touchpad, float x, float y, float pressure) override;
+ binder::Status buttonState(int touchpad, int buttons) override;
private:
sp<VirtualTouchpad> touchpad_;
diff --git a/services/vr/virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl b/services/vr/virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl
index c2044da..496c5e2 100644
--- a/services/vr/virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl
+++ b/services/vr/virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl
@@ -8,18 +8,20 @@
/**
* Generate a simulated touch event.
*
+ * @param touchpad Selects touchpad.
* @param x Horizontal touch position.
* @param y Vertical touch position.
* @param pressure Touch pressure; use 0.0 for no touch (lift or hover).
*
* Position values in the range [0.0, 1.0) map to the screen.
*/
- void touch(float x, float y, float pressure);
+ void touch(int touchpad, float x, float y, float pressure);
/**
* Generate a simulated touchpad button state event.
*
+ * @param touchpad Selects touchpad.
* @param buttons A union of MotionEvent BUTTON_* values.
*/
- void buttonState(int buttons);
+ void buttonState(int touchpad, int buttons);
}
diff --git a/services/vr/virtual_touchpad/include/VirtualTouchpad.h b/services/vr/virtual_touchpad/include/VirtualTouchpad.h
index bbaf69b..d24d121 100644
--- a/services/vr/virtual_touchpad/include/VirtualTouchpad.h
+++ b/services/vr/virtual_touchpad/include/VirtualTouchpad.h
@@ -12,6 +12,11 @@
//
class VirtualTouchpad : public RefBase {
public:
+ enum : int {
+ PRIMARY = 0,
+ VIRTUAL = 1,
+ };
+
// Create a virtual touchpad.
// Implementations should provide this, and hide their constructors.
// For the user, switching implementations should be as simple as changing
@@ -22,6 +27,7 @@
// Generate a simulated touch event.
//
+ // @param touchpad Touchpad selector index.
// @param x Horizontal touch position.
// @param y Vertical touch position.
// Values must be in the range [0.0, 1.0).
@@ -30,21 +36,22 @@
// is binary. Use 0.0f for no contact.
// @returns OK on success.
//
- virtual status_t Touch(float x, float y, float pressure) = 0;
+ virtual status_t Touch(int touchpad, float x, float y, float pressure) = 0;
// Generate a simulated touchpad button state.
//
+ // @param touchpad Touchpad selector index.
// @param buttons A union of MotionEvent BUTTON_* values.
// @returns OK on success.
//
// Currently only BUTTON_BACK is supported, as the implementation
// restricts itself to operations actually required by VrWindowManager.
//
- virtual status_t ButtonState(int buttons) = 0;
+ virtual status_t ButtonState(int touchpad, int buttons) = 0;
protected:
VirtualTouchpad() {}
- virtual ~VirtualTouchpad() {}
+ ~VirtualTouchpad() override {}
private:
VirtualTouchpad(const VirtualTouchpad&) = delete;
diff --git a/services/vr/virtual_touchpad/include/VirtualTouchpadClient.h b/services/vr/virtual_touchpad/include/VirtualTouchpadClient.h
index 46bec0e..dd9c265 100644
--- a/services/vr/virtual_touchpad/include/VirtualTouchpadClient.h
+++ b/services/vr/virtual_touchpad/include/VirtualTouchpadClient.h
@@ -13,12 +13,12 @@
public:
// VirtualTouchpad implementation:
static sp<VirtualTouchpad> Create();
- status_t Touch(float x, float y, float pressure) override;
- status_t ButtonState(int buttons) override;
+ status_t Touch(int touchpad, float x, float y, float pressure) override;
+ status_t ButtonState(int touchpad, int buttons) override;
protected:
VirtualTouchpadClient() {}
- virtual ~VirtualTouchpadClient() {}
+ ~VirtualTouchpadClient() override {}
private:
VirtualTouchpadClient(const VirtualTouchpadClient&) = delete;
diff --git a/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp b/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
index b448fd1..469a2d0 100644
--- a/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
+++ b/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
@@ -15,6 +15,7 @@
class UInputForTesting : public EvdevInjector::UInput {
public:
+ ~UInputForTesting() override {}
void WriteInputEvent(uint16_t type, uint16_t code, int32_t value) {
struct input_event event;
memset(&event, 0, sizeof(event));
@@ -30,7 +31,7 @@
class UInputRecorder : public UInputForTesting {
public:
UInputRecorder() {}
- virtual ~UInputRecorder() {}
+ ~UInputRecorder() override {}
const std::string& GetString() const { return s_; }
void Reset() { s_.clear(); }
@@ -157,7 +158,7 @@
expect.Reset();
record.Reset();
- int touch_status = touchpad->Touch(0, 0, 0);
+ int touch_status = touchpad->Touch(VirtualTouchpad::PRIMARY, 0, 0, 0);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_ABS, ABS_MT_SLOT, 0);
expect.WriteInputEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
@@ -168,7 +169,7 @@
expect.Reset();
record.Reset();
- touch_status = touchpad->Touch(0.25f, 0.75f, 0.5f);
+ touch_status = touchpad->Touch(VirtualTouchpad::PRIMARY, 0.25f, 0.75f, 0.5f);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
expect.WriteInputEvent(EV_ABS, ABS_MT_POSITION_X, 0.25f * width);
@@ -179,7 +180,7 @@
expect.Reset();
record.Reset();
- touch_status = touchpad->Touch(1.0f, 1.0f, 1.0f);
+ touch_status = touchpad->Touch(VirtualTouchpad::PRIMARY, 1.0f, 1.0f, 1.0f);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
expect.WriteInputEvent(EV_ABS, ABS_MT_POSITION_X, width);
@@ -189,7 +190,8 @@
expect.Reset();
record.Reset();
- touch_status = touchpad->Touch(0.25f, 0.75f, -0.01f);
+ touch_status =
+ touchpad->Touch(VirtualTouchpad::PRIMARY, 0.25f, 0.75f, -0.01f);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_KEY, BTN_TOUCH, EvdevInjector::KEY_RELEASE);
expect.WriteInputEvent(EV_ABS, ABS_MT_TRACKING_ID, -1);
@@ -198,7 +200,8 @@
expect.Reset();
record.Reset();
- touch_status = touchpad->ButtonState(AMOTION_EVENT_BUTTON_BACK);
+ touch_status = touchpad->ButtonState(VirtualTouchpad::PRIMARY,
+ AMOTION_EVENT_BUTTON_BACK);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_KEY, BTN_BACK, EvdevInjector::KEY_PRESS);
expect.WriteInputEvent(EV_SYN, SYN_REPORT, 0);
@@ -206,13 +209,14 @@
expect.Reset();
record.Reset();
- touch_status = touchpad->ButtonState(AMOTION_EVENT_BUTTON_BACK);
+ touch_status = touchpad->ButtonState(VirtualTouchpad::PRIMARY,
+ AMOTION_EVENT_BUTTON_BACK);
EXPECT_EQ(0, touch_status);
EXPECT_EQ(expect.GetString(), record.GetString());
expect.Reset();
record.Reset();
- touch_status = touchpad->ButtonState(0);
+ touch_status = touchpad->ButtonState(VirtualTouchpad::PRIMARY, 0);
EXPECT_EQ(0, touch_status);
expect.WriteInputEvent(EV_KEY, BTN_BACK, EvdevInjector::KEY_RELEASE);
expect.WriteInputEvent(EV_SYN, SYN_REPORT, 0);
@@ -226,20 +230,21 @@
UInputRecorder expect;
UInputRecorder record;
EvdevInjectorForTesting injector(record);
- sp<VirtualTouchpad> touchpad(
- VirtualTouchpadForTesting::Create(injector));
+ sp<VirtualTouchpad> touchpad(VirtualTouchpadForTesting::Create(injector));
// Touch off-screen should return an error,
// and should not result in any system calls.
expect.Reset();
record.Reset();
- status_t touch_status = touchpad->Touch(-0.25f, 0.75f, 1.0f);
+ status_t touch_status =
+ touchpad->Touch(VirtualTouchpad::PRIMARY, -0.25f, 0.75f, 1.0f);
EXPECT_NE(OK, touch_status);
- touch_status = touchpad->Touch(0.25f, -0.75f, 1.0f);
+ touch_status =
+ touchpad->Touch(VirtualTouchpad::PRIMARY, 0.25f, -0.75f, 1.0f);
EXPECT_NE(OK, touch_status);
- touch_status = touchpad->Touch(1.25f, 0.75f, 1.0f);
+ touch_status = touchpad->Touch(VirtualTouchpad::PRIMARY, 1.25f, 0.75f, 1.0f);
EXPECT_NE(OK, touch_status);
- touch_status = touchpad->Touch(0.25f, 1.75f, 1.0f);
+ touch_status = touchpad->Touch(VirtualTouchpad::PRIMARY, 0.25f, 1.75f, 1.0f);
EXPECT_NE(OK, touch_status);
EXPECT_EQ(expect.GetString(), record.GetString());
@@ -247,7 +252,8 @@
// and should not result in any system calls.
expect.Reset();
record.Reset();
- touch_status = touchpad->ButtonState(AMOTION_EVENT_BUTTON_FORWARD);
+ touch_status = touchpad->ButtonState(VirtualTouchpad::PRIMARY,
+ AMOTION_EVENT_BUTTON_FORWARD);
EXPECT_NE(OK, touch_status);
EXPECT_EQ(expect.GetString(), record.GetString());
}
diff --git a/services/vr/vr_window_manager/shell_view.cpp b/services/vr/vr_window_manager/shell_view.cpp
index 7321ed0..fae1dd9 100644
--- a/services/vr/vr_window_manager/shell_view.cpp
+++ b/services/vr/vr_window_manager/shell_view.cpp
@@ -721,6 +721,7 @@
}
const android::status_t status = virtual_touchpad_->Touch(
+ VirtualTouchpad::PRIMARY,
hit_location_in_window_coord_.x() / size_.x(),
hit_location_in_window_coord_.y() / size_.y(),
is_touching_ ? 1.0f : 0.0f);
@@ -747,8 +748,8 @@
return false;
}
- const android::status_t status =
- virtual_touchpad_->ButtonState(touchpad_buttons_);
+ const android::status_t status = virtual_touchpad_->ButtonState(
+ VirtualTouchpad::PRIMARY, touchpad_buttons_);
if (status != OK) {
ALOGE("touchpad button failed: %d %d", touchpad_buttons_, status);
}