Merge "Apply correct SELinux labels to PDX endpoint and channel sockets." into oc-dev
diff --git a/cmds/atrace/Android.bp b/cmds/atrace/Android.bp
index 4f1065f..6c5869a 100644
--- a/cmds/atrace/Android.bp
+++ b/cmds/atrace/Android.bp
@@ -16,9 +16,6 @@
"libz",
"libbase",
],
- static_libs: [
- "libpdx_default_transport",
- ],
init_rc: ["atrace.rc"],
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index f8e0ad5..6cfbed9 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -41,7 +41,6 @@
#include <hidl/ServiceManagement.h>
#include <cutils/properties.h>
-#include <pdx/default_transport/service_utility.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/Tokenizer.h>
@@ -49,7 +48,6 @@
#include <android-base/file.h>
using namespace android;
-using pdx::default_transport::ServiceUtility;
using std::string;
#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
@@ -816,7 +814,6 @@
ok &= setAppCmdlineProperty(&packageList[0]);
ok &= pokeBinderServices();
pokeHalServices();
- ok &= ServiceUtility::PokeServices();
// Disable all the sysfs enables. This is done as a separate loop from
// the enables to allow the same enable to exist in multiple categories.
@@ -854,7 +851,6 @@
setTagsProperty(0);
clearAppProperties();
pokeBinderServices();
- ServiceUtility::PokeServices();
// Set the options back to their defaults.
setTraceOverwriteEnable(true);
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 6472a0f..3bbe3a1 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -190,7 +190,7 @@
static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vdex_fd, int image_fd,
const char* input_file_name, const char* output_file_name, int swap_fd,
- const char* instruction_set, const char* compiler_filter, bool vm_safe_mode,
+ const char* instruction_set, const char* compiler_filter,
bool debuggable, bool post_bootcomplete, int profile_fd, const char* shared_libraries) {
static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
@@ -240,7 +240,7 @@
dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags);
ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);
- // If we booting without the real /data, don't spend time compiling.
+ // If we are booting without the real /data, don't spend time compiling.
char vold_decrypt[kPropertyValueMax];
bool have_vold_decrypt = get_property("vold.decrypt", vold_decrypt, "") > 0;
bool skip_compilation = (have_vold_decrypt &&
@@ -319,20 +319,24 @@
// Compute compiler filter.
- bool have_dex2oat_compiler_filter_flag;
+ bool have_dex2oat_compiler_filter_flag = false;
if (skip_compilation) {
strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=extract");
have_dex2oat_compiler_filter_flag = true;
have_dex2oat_relocation_skip_flag = true;
- } else if (vm_safe_mode) {
- strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=quicken");
- have_dex2oat_compiler_filter_flag = true;
- } else if (compiler_filter != nullptr &&
- strlen(compiler_filter) + strlen("--compiler-filter=") <
+ } else if (compiler_filter != nullptr) {
+ if (strlen(compiler_filter) + strlen("--compiler-filter=") <
arraysize(dex2oat_compiler_filter_arg)) {
- sprintf(dex2oat_compiler_filter_arg, "--compiler-filter=%s", compiler_filter);
- have_dex2oat_compiler_filter_flag = true;
- } else {
+ sprintf(dex2oat_compiler_filter_arg, "--compiler-filter=%s", compiler_filter);
+ have_dex2oat_compiler_filter_flag = true;
+ } else {
+ ALOGW("Compiler filter name '%s' is too large (max characters is %zu)",
+ compiler_filter,
+ kPropertyValueMax);
+ }
+ }
+
+ if (!have_dex2oat_compiler_filter_flag) {
char dex2oat_compiler_filter_flag[kPropertyValueMax];
have_dex2oat_compiler_filter_flag = get_property("dalvik.vm.dex2oat-filter",
dex2oat_compiler_filter_flag, NULL) > 0;
@@ -1479,7 +1483,6 @@
}
bool is_public = (dexopt_flags & DEXOPT_PUBLIC) != 0;
- bool vm_safe_mode = (dexopt_flags & DEXOPT_SAFEMODE) != 0;
bool debuggable = (dexopt_flags & DEXOPT_DEBUGGABLE) != 0;
bool boot_complete = (dexopt_flags & DEXOPT_BOOTCOMPLETE) != 0;
bool profile_guided = (dexopt_flags & DEXOPT_PROFILE_GUIDED) != 0;
@@ -1577,7 +1580,6 @@
swap_fd.get(),
instruction_set,
compiler_filter,
- vm_safe_mode,
debuggable,
boot_complete,
reference_profile_fd.get(),
diff --git a/cmds/installd/installd_constants.h b/cmds/installd/installd_constants.h
index d8a754c..6a81cfc 100644
--- a/cmds/installd/installd_constants.h
+++ b/cmds/installd/installd_constants.h
@@ -38,23 +38,21 @@
* frameworks/base/services/core/java/com/android/server/pm/Installer.java
***************************************************************************/
constexpr int DEXOPT_PUBLIC = 1 << 1;
-constexpr int DEXOPT_SAFEMODE = 1 << 2;
-constexpr int DEXOPT_DEBUGGABLE = 1 << 3;
-constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4;
-constexpr int DEXOPT_PROFILE_GUIDED = 1 << 5;
-constexpr int DEXOPT_SECONDARY_DEX = 1 << 6;
+constexpr int DEXOPT_DEBUGGABLE = 1 << 2;
+constexpr int DEXOPT_BOOTCOMPLETE = 1 << 3;
+constexpr int DEXOPT_PROFILE_GUIDED = 1 << 4;
+constexpr int DEXOPT_SECONDARY_DEX = 1 << 5;
// DEXOPT_FORCE, DEXOPT_STORAGE_CE, DEXOPT_STORAGE_DE are exposed for secondary
// dex files only. Primary apks are analyzed in PackageManager and installd
// does not need to know if the compilation is forced or on what kind of storage
// the dex files are.
-constexpr int DEXOPT_FORCE = 1 << 7;
-constexpr int DEXOPT_STORAGE_CE = 1 << 8;
-constexpr int DEXOPT_STORAGE_DE = 1 << 9;
+constexpr int DEXOPT_FORCE = 1 << 6;
+constexpr int DEXOPT_STORAGE_CE = 1 << 7;
+constexpr int DEXOPT_STORAGE_DE = 1 << 8;
/* all known values for dexopt flags */
constexpr int DEXOPT_MASK =
DEXOPT_PUBLIC
- | DEXOPT_SAFEMODE
| DEXOPT_DEBUGGABLE
| DEXOPT_BOOTCOMPLETE
| DEXOPT_PROFILE_GUIDED
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index ff838ce..43d0780 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -472,7 +472,8 @@
case 6: {
// Version 1 had:
constexpr int OLD_DEXOPT_PUBLIC = 1 << 1;
- constexpr int OLD_DEXOPT_SAFEMODE = 1 << 2;
+ // Note: DEXOPT_SAFEMODE has been removed.
+ // constexpr int OLD_DEXOPT_SAFEMODE = 1 << 2;
constexpr int OLD_DEXOPT_DEBUGGABLE = 1 << 3;
constexpr int OLD_DEXOPT_BOOTCOMPLETE = 1 << 4;
constexpr int OLD_DEXOPT_PROFILE_GUIDED = 1 << 5;
@@ -480,7 +481,6 @@
int input = atoi(param);
package_parameters_.dexopt_flags =
ReplaceMask(input, OLD_DEXOPT_PUBLIC, DEXOPT_PUBLIC) |
- ReplaceMask(input, OLD_DEXOPT_SAFEMODE, DEXOPT_SAFEMODE) |
ReplaceMask(input, OLD_DEXOPT_DEBUGGABLE, DEXOPT_DEBUGGABLE) |
ReplaceMask(input, OLD_DEXOPT_BOOTCOMPLETE, DEXOPT_BOOTCOMPLETE) |
ReplaceMask(input, OLD_DEXOPT_PROFILE_GUIDED, DEXOPT_PROFILE_GUIDED) |
@@ -734,6 +734,10 @@
}
static const char* ParseNull(const char* arg) {
+ // b/38186355. Revert soon.
+ if (strcmp(arg, "!null") == 0) {
+ return nullptr;
+ }
return (strcmp(arg, "!") == 0) ? nullptr : arg;
}
diff --git a/include/input/DisplayViewport.h b/include/input/DisplayViewport.h
new file mode 100644
index 0000000..86da4d3
--- /dev/null
+++ b/include/input/DisplayViewport.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LIBINPUT_DISPLAY_VIEWPORT_H
+#define _LIBINPUT_DISPLAY_VIEWPORT_H
+
+#include <ui/DisplayInfo.h>
+#include <input/Input.h>
+
+namespace android {
+
+/*
+ * Describes how coordinates are mapped on a physical display.
+ * See com.android.server.display.DisplayViewport.
+ */
+struct DisplayViewport {
+ int32_t displayId; // -1 if invalid
+ int32_t orientation;
+ int32_t logicalLeft;
+ int32_t logicalTop;
+ int32_t logicalRight;
+ int32_t logicalBottom;
+ int32_t physicalLeft;
+ int32_t physicalTop;
+ int32_t physicalRight;
+ int32_t physicalBottom;
+ int32_t deviceWidth;
+ int32_t deviceHeight;
+ String8 uniqueId;
+
+ DisplayViewport() :
+ displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
+ logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
+ physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
+ deviceWidth(0), deviceHeight(0) {
+ }
+
+ bool operator==(const DisplayViewport& other) const {
+ return displayId == other.displayId
+ && orientation == other.orientation
+ && logicalLeft == other.logicalLeft
+ && logicalTop == other.logicalTop
+ && logicalRight == other.logicalRight
+ && logicalBottom == other.logicalBottom
+ && physicalLeft == other.physicalLeft
+ && physicalTop == other.physicalTop
+ && physicalRight == other.physicalRight
+ && physicalBottom == other.physicalBottom
+ && deviceWidth == other.deviceWidth
+ && deviceHeight == other.deviceHeight
+ && uniqueId == other.uniqueId;
+ }
+
+ bool operator!=(const DisplayViewport& other) const {
+ return !(*this == other);
+ }
+
+ inline bool isValid() const {
+ return displayId >= 0;
+ }
+
+ void setNonDisplayViewport(int32_t width, int32_t height) {
+ displayId = ADISPLAY_ID_NONE;
+ orientation = DISPLAY_ORIENTATION_0;
+ logicalLeft = 0;
+ logicalTop = 0;
+ logicalRight = width;
+ logicalBottom = height;
+ physicalLeft = 0;
+ physicalTop = 0;
+ physicalRight = width;
+ physicalBottom = height;
+ deviceWidth = width;
+ deviceHeight = height;
+ uniqueId.clear();
+ }
+};
+
+/**
+ * Describes the different type of viewports supported by input flinger.
+ * Keep in sync with values in InputManagerService.java.
+ */
+enum class ViewportType : int32_t {
+ VIEWPORT_INTERNAL = 1,
+ VIEWPORT_EXTERNAL = 2,
+ VIEWPORT_VIRTUAL = 3,
+};
+
+} // namespace android
+
+#endif // _LIBINPUT_DISPLAY_VIEWPORT_H
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index aec8f10..6fefb38 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -2547,8 +2547,16 @@
objectsSize = 0;
} else {
while (objectsSize > 0) {
- if (mObjects[objectsSize-1] < desired)
+ if (mObjects[objectsSize-1] < desired) {
+ // Check for an object being sliced
+ if (desired < mObjects[objectsSize-1] + sizeof(flat_binder_object)) {
+ ALOGE("Attempt to shrink Parcel would slice an objects allocated memory");
+ return UNKNOWN_ERROR + 0xBADF10;
+ }
break;
+ }
+ // STOPSHIP: Above code to be replaced with following commented code:
+ // if (mObjects[objectsSize-1] + sizeof(flat_binder_object) <= desired) break;
objectsSize--;
}
}
diff --git a/libs/nativewindow/include/android/native_window.h b/libs/nativewindow/include/android/native_window.h
index a12bdd7..5290dd5 100644
--- a/libs/nativewindow/include/android/native_window.h
+++ b/libs/nativewindow/include/android/native_window.h
@@ -21,6 +21,7 @@
/**
* @file native_window.h
+ * @brief API for accessing a native window.
*/
#ifndef ANDROID_NATIVE_WINDOW_H
@@ -71,16 +72,16 @@
struct ANativeWindow;
/**
- * {@link ANativeWindow} is opaque type that provides access to a native window.
+ * Opaque type that provides access to a native window.
*
- * A pointer can be obtained using ANativeWindow_fromSurface().
+ * A pointer can be obtained using {@link ANativeWindow_fromSurface()}.
*/
typedef struct ANativeWindow ANativeWindow;
/**
- * {@link ANativeWindow} is a struct that represents a windows buffer.
+ * Struct that represents a windows buffer.
*
- * A pointer can be obtained using ANativeWindow_lock().
+ * A pointer can be obtained using {@link ANativeWindow_lock()}.
*/
typedef struct ANativeWindow_Buffer {
// The number of pixels that are show horizontally.
@@ -90,10 +91,10 @@
int32_t height;
// The number of *pixels* that a line in the buffer takes in
- // memory. This may be >= width.
+ // memory. This may be >= width.
int32_t stride;
- // The format of the buffer. One of AHARDWAREBUFFER_FORMAT_*
+ // The format of the buffer. One of AHARDWAREBUFFER_FORMAT_*
int32_t format;
// The actual bits.
@@ -104,49 +105,53 @@
} ANativeWindow_Buffer;
/**
- * Acquire a reference on the given ANativeWindow object. This prevents the object
+ * Acquire a reference on the given {@link ANativeWindow} object. This prevents the object
* from being deleted until the reference is removed.
*/
void ANativeWindow_acquire(ANativeWindow* window);
/**
- * Remove a reference that was previously acquired with ANativeWindow_acquire().
+ * Remove a reference that was previously acquired with {@link ANativeWindow_acquire()}.
*/
void ANativeWindow_release(ANativeWindow* window);
/**
- * Return the current width in pixels of the window surface. Returns a
- * negative value on error.
+ * Return the current width in pixels of the window surface.
+ *
+ * \return negative value on error.
*/
int32_t ANativeWindow_getWidth(ANativeWindow* window);
/**
- * Return the current height in pixels of the window surface. Returns a
- * negative value on error.
+ * Return the current height in pixels of the window surface.
+ *
+ * \return a negative value on error.
*/
int32_t ANativeWindow_getHeight(ANativeWindow* window);
/**
- * Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface. Returns a
- * negative value on error.
+ * Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface.
+ *
+ * \return a negative value on error.
*/
int32_t ANativeWindow_getFormat(ANativeWindow* window);
/**
* Change the format and size of the window buffers.
*
- * format: one of AHARDWAREBUFFER_FORMAT_ constants
- *
* The width and height control the number of pixels in the buffers, not the
- * dimensions of the window on screen. If these are different than the
- * window's physical size, then it buffer will be scaled to match that size
- * when compositing it to the screen.
+ * dimensions of the window on screen. If these are different than the
+ * window's physical size, then its buffer will be scaled to match that size
+ * when compositing it to the screen. The width and height must be either both zero
+ * or both non-zero.
*
* For all of these parameters, if 0 is supplied then the window's base
* value will come back in force.
*
- * width and height must be either both zero or both non-zero.
- *
+ * \param width width of the buffers in pixels.
+ * \param height height of the buffers in pixels.
+ * \param format one of AHARDWAREBUFFER_FORMAT_* constants.
+ * \return 0 for success, or a negative value on error.
*/
int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window,
int32_t width, int32_t height, int32_t format);
@@ -157,7 +162,9 @@
* function, it contains the dirty region, that is, the region the caller
* intends to redraw. When the function returns, inOutDirtyBounds is updated
* with the actual area the caller needs to redraw -- this region is often
- * extended by ANativeWindow_lock.
+ * extended by {@link ANativeWindow_lock}.
+ *
+ * \return 0 for success, or a negative value on error.
*/
int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
ARect* inOutDirtyBounds);
@@ -165,6 +172,8 @@
/**
* Unlock the window's drawing surface after previously locking it,
* posting the new buffer to the display.
+ *
+ * \return 0 for success, or a negative value on error.
*/
int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
@@ -173,9 +182,8 @@
/**
* Set a transform that will be applied to future buffers posted to the window.
*
- * @param transform combination of {@link ANativeWindowTransform} flags
- * @return 0 if successful
- * @return -EINVAL if @param transform is invalid
+ * \param transform combination of {@link ANativeWindowTransform} flags
+ * \return 0 for success, or -EINVAL if \p transform is invalid
*/
int32_t ANativeWindow_setBuffersTransform(ANativeWindow* window, int32_t transform);
diff --git a/libs/vr/libdvr/Android.bp b/libs/vr/libdvr/Android.bp
index 3876745..fa78b1c 100644
--- a/libs/vr/libdvr/Android.bp
+++ b/libs/vr/libdvr/Android.bp
@@ -19,47 +19,69 @@
export_include_dirs: ["include"],
}
-cc_library_static {
+cflags = [
+ "-DLOG_TAG=\"libdvr\"",
+]
+
+srcs = [
+ "dvr_api.cpp",
+ "dvr_buffer.cpp",
+ "dvr_buffer_queue.cpp",
+ "dvr_display_manager.cpp",
+ "dvr_hardware_composer_client.cpp",
+ "dvr_surface.cpp",
+ "dvr_vsync.cpp",
+]
+
+static_libs = [
+ "libbufferhub",
+ "libbufferhubqueue",
+ "libdisplay",
+ "libvrsensor",
+ "libvirtualtouchpadclient",
+ "libvr_hwc-impl",
+ "libvr_hwc-binder",
+ "libgrallocusage",
+ "libpdx_default_transport",
+]
+
+shared_libs = [
+ "android.hardware.graphics.bufferqueue@1.0",
+ "android.hidl.token@1.0-utils",
+ "libbase",
+ "libbinder",
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libnativewindow",
+ "libgui",
+ "libui",
+]
+
+cc_library_shared {
name: "libdvr",
owner: "google",
-
- cflags: [
- "-fvisibility=hidden",
- "-DLOG_TAG=\"libdvr\"",
- "-DDVR_EXPORT=__attribute__((visibility(\"default\")))",
- ],
-
+ cflags: cflags,
header_libs: ["libdvr_headers"],
export_header_lib_headers: ["libdvr_headers"],
+ srcs: srcs,
+ static_libs: static_libs,
+ shared_libs: shared_libs,
+ version_script: "exported_apis.lds",
+}
- srcs: [
- "dvr_api.cpp",
- "dvr_buffer.cpp",
- "dvr_buffer_queue.cpp",
- "dvr_display_manager.cpp",
- "dvr_hardware_composer_client.cpp",
- "dvr_surface.cpp",
- "dvr_vsync.cpp",
- ],
-
- static_libs: [
- "libbufferhub",
- "libbufferhubqueue",
- "libdisplay",
- "libvrsensor",
- "libvirtualtouchpadclient",
- "libvr_hwc-impl",
- "libvr_hwc-binder",
- "libgrallocusage",
- ],
-
- shared_libs: [
- "android.hardware.graphics.bufferqueue@1.0",
- "android.hidl.token@1.0-utils",
- "libbase",
- "libnativewindow",
- ],
-
+// Also build a static libdvr for linking into tests. The linker script
+// restricting function access in the shared lib makes it inconvenient to use in
+// test code.
+cc_library_static {
+ name: "libdvr_static",
+ owner: "google",
+ cflags: cflags,
+ header_libs: ["libdvr_headers"],
+ export_header_lib_headers: ["libdvr_headers"],
+ srcs: srcs,
+ static_libs: static_libs,
+ shared_libs: shared_libs,
}
subdirs = [
diff --git a/libs/vr/libdvr/dvr_api.cpp b/libs/vr/libdvr/dvr_api.cpp
index 4d7e1a6..2c95583 100644
--- a/libs/vr/libdvr/dvr_api.cpp
+++ b/libs/vr/libdvr/dvr_api.cpp
@@ -18,7 +18,7 @@
extern "C" {
-DVR_EXPORT int dvrGetApi(void* api, size_t struct_size, int version) {
+int dvrGetApi(void* api, size_t struct_size, int version) {
ALOGI("dvrGetApi: api=%p struct_size=%zu version=%d", api, struct_size,
version);
if (version == 1) {
diff --git a/libs/vr/libdvr/exported_apis.lds b/libs/vr/libdvr/exported_apis.lds
new file mode 100644
index 0000000..5ecb498
--- /dev/null
+++ b/libs/vr/libdvr/exported_apis.lds
@@ -0,0 +1,9 @@
+{
+ global:
+ # Whitelist the function to load the dvr api.
+ dvrGetApi;
+
+ local:
+ # Hide everything else.
+ *;
+};
diff --git a/libs/vr/libdvr/tests/Android.bp b/libs/vr/libdvr/tests/Android.bp
index af202b4..ef746e2 100644
--- a/libs/vr/libdvr/tests/Android.bp
+++ b/libs/vr/libdvr/tests/Android.bp
@@ -25,7 +25,7 @@
]
static_libraries = [
- "libdvr",
+ "libdvr_static",
"libbufferhubqueue",
"libbufferhub",
"libchrome",
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index 2705e13..73255dd 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -227,18 +227,65 @@
// --- InputReaderConfiguration ---
-bool InputReaderConfiguration::getDisplayInfo(bool external, DisplayViewport* outViewport) const {
- const DisplayViewport& viewport = external ? mExternalDisplay : mInternalDisplay;
- if (viewport.displayId >= 0) {
- *outViewport = viewport;
+bool InputReaderConfiguration::getDisplayViewport(ViewportType viewportType,
+ const String8* uniqueDisplayId, DisplayViewport* outViewport) const {
+ const DisplayViewport* viewport = NULL;
+ if (viewportType == ViewportType::VIEWPORT_VIRTUAL && uniqueDisplayId != NULL) {
+ for (DisplayViewport currentViewport : mVirtualDisplays) {
+ if (currentViewport.uniqueId == *uniqueDisplayId) {
+ viewport = ¤tViewport;
+ break;
+ }
+ }
+ } else if (viewportType == ViewportType::VIEWPORT_EXTERNAL) {
+ viewport = &mExternalDisplay;
+ } else if (viewportType == ViewportType::VIEWPORT_INTERNAL) {
+ viewport = &mInternalDisplay;
+ }
+
+ if (viewport != NULL && viewport->displayId >= 0) {
+ *outViewport = *viewport;
return true;
}
return false;
}
-void InputReaderConfiguration::setDisplayInfo(bool external, const DisplayViewport& viewport) {
- DisplayViewport& v = external ? mExternalDisplay : mInternalDisplay;
- v = viewport;
+void InputReaderConfiguration::setPhysicalDisplayViewport(ViewportType viewportType,
+ const DisplayViewport& viewport) {
+ if (viewportType == ViewportType::VIEWPORT_EXTERNAL) {
+ mExternalDisplay = viewport;
+ } else if (viewportType == ViewportType::VIEWPORT_INTERNAL) {
+ mInternalDisplay = viewport;
+ }
+}
+
+void InputReaderConfiguration::setVirtualDisplayViewports(
+ const Vector<DisplayViewport>& viewports) {
+ mVirtualDisplays = viewports;
+}
+
+void InputReaderConfiguration::dump(String8& dump) const {
+ dump.append(INDENT4 "ViewportInternal:\n");
+ dumpViewport(dump, mInternalDisplay);
+ dump.append(INDENT4 "ViewportExternal:\n");
+ dumpViewport(dump, mExternalDisplay);
+ dump.append(INDENT4 "ViewportVirtual:\n");
+ for (const DisplayViewport& viewport : mVirtualDisplays) {
+ dumpViewport(dump, viewport);
+ }
+}
+
+void InputReaderConfiguration::dumpViewport(String8& dump, const DisplayViewport& viewport) const {
+ dump.appendFormat(INDENT5 "Viewport: displayId=%d, orientation=%d, uniqueId='%s', "
+ "logicalFrame=[%d, %d, %d, %d], "
+ "physicalFrame=[%d, %d, %d, %d], "
+ "deviceSize=[%d, %d]\n",
+ viewport.displayId, viewport.orientation, viewport.uniqueId.c_str(),
+ viewport.logicalLeft, viewport.logicalTop,
+ viewport.logicalRight, viewport.logicalBottom,
+ viewport.physicalLeft, viewport.physicalTop,
+ viewport.physicalRight, viewport.physicalBottom,
+ viewport.deviceWidth, viewport.deviceHeight);
}
@@ -851,6 +898,9 @@
mConfig.pointerGestureMovementSpeedRatio);
dump.appendFormat(INDENT3 "ZoomSpeedRatio: %0.1f\n",
mConfig.pointerGestureZoomSpeedRatio);
+
+ dump.append(INDENT3 "Viewports:\n");
+ mConfig.dump(dump);
}
void InputReader::monitor() {
@@ -2161,7 +2211,7 @@
if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
DisplayViewport v;
- if (config->getDisplayInfo(false /*external*/, &v)) {
+ if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, NULL, &v)) {
mOrientation = v.orientation;
} else {
mOrientation = DISPLAY_ORIENTATION_0;
@@ -2534,7 +2584,7 @@
if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
DisplayViewport v;
- if (config->getDisplayInfo(false /*external*/, &v)) {
+ if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, NULL, &v)) {
mOrientation = v.orientation;
} else {
mOrientation = DISPLAY_ORIENTATION_0;
@@ -2979,7 +3029,7 @@
}
void TouchInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Touch Input Mapper:\n");
+ dump.appendFormat(INDENT2 "Touch Input Mapper (mode - %s):\n", modeToString(mDeviceMode));
dumpParameters(dump);
dumpVirtualKeys(dump);
dumpRawPointerAxes(dump);
@@ -3071,6 +3121,22 @@
}
}
+const char* TouchInputMapper::modeToString(DeviceMode deviceMode) {
+ switch (deviceMode) {
+ case DEVICE_MODE_DISABLED:
+ return "disabled";
+ case DEVICE_MODE_DIRECT:
+ return "direct";
+ case DEVICE_MODE_UNSCALED:
+ return "unscaled";
+ case DEVICE_MODE_NAVIGATION:
+ return "navigation";
+ case DEVICE_MODE_POINTER:
+ return "pointer";
+ }
+ return "unknown";
+}
+
void TouchInputMapper::configure(nsecs_t when,
const InputReaderConfiguration* config, uint32_t changes) {
InputMapper::configure(when, config, changes);
@@ -3196,9 +3262,11 @@
|| mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
|| mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER) {
mParameters.hasAssociatedDisplay = true;
- mParameters.associatedDisplayIsExternal =
- mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
- && getDevice()->isExternal();
+ if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN) {
+ mParameters.associatedDisplayIsExternal = getDevice()->isExternal();
+ getDevice()->getConfiguration().tryGetProperty(String8("touch.displayId"),
+ mParameters.uniqueDisplayId);
+ }
}
// Initial downs on external touch devices should wake the device.
@@ -3240,9 +3308,11 @@
ALOG_ASSERT(false);
}
- dump.appendFormat(INDENT4 "AssociatedDisplay: hasAssociatedDisplay=%s, isExternal=%s\n",
+ dump.appendFormat(
+ INDENT4 "AssociatedDisplay: hasAssociatedDisplay=%s, isExternal=%s, displayId='%s'\n",
toString(mParameters.hasAssociatedDisplay),
- toString(mParameters.associatedDisplayIsExternal));
+ toString(mParameters.associatedDisplayIsExternal),
+ mParameters.uniqueDisplayId.c_str());
dump.appendFormat(INDENT4 "OrientationAware: %s\n",
toString(mParameters.orientationAware));
}
@@ -3318,7 +3388,21 @@
// Get associated display dimensions.
DisplayViewport newViewport;
if (mParameters.hasAssociatedDisplay) {
- if (!mConfig.getDisplayInfo(mParameters.associatedDisplayIsExternal, &newViewport)) {
+ const String8* uniqueDisplayId = NULL;
+ ViewportType viewportTypeToUse;
+
+ if (mParameters.associatedDisplayIsExternal) {
+ viewportTypeToUse = ViewportType::VIEWPORT_EXTERNAL;
+ } else if (!mParameters.uniqueDisplayId.isEmpty()) {
+ // If the IDC file specified a unique display Id, then it expects to be linked to a
+ // virtual display with the same unique ID.
+ uniqueDisplayId = &mParameters.uniqueDisplayId;
+ viewportTypeToUse = ViewportType::VIEWPORT_VIRTUAL;
+ } else {
+ viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL;
+ }
+
+ if (!mConfig.getDisplayViewport(viewportTypeToUse, uniqueDisplayId, &newViewport)) {
ALOGI(INDENT "Touch device '%s' could not query the properties of its associated "
"display. The device will be inoperable until the display size "
"becomes available.",
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 3171526..edb6fcc 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -21,6 +21,7 @@
#include "PointerControllerInterface.h"
#include "InputListener.h"
+#include <input/DisplayViewport.h>
#include <input/Input.h>
#include <input/VelocityControl.h>
#include <input/VelocityTracker.h>
@@ -49,70 +50,6 @@
class InputMapper;
/*
- * Describes how coordinates are mapped on a physical display.
- * See com.android.server.display.DisplayViewport.
- */
-struct DisplayViewport {
- int32_t displayId; // -1 if invalid
- int32_t orientation;
- int32_t logicalLeft;
- int32_t logicalTop;
- int32_t logicalRight;
- int32_t logicalBottom;
- int32_t physicalLeft;
- int32_t physicalTop;
- int32_t physicalRight;
- int32_t physicalBottom;
- int32_t deviceWidth;
- int32_t deviceHeight;
-
- DisplayViewport() :
- displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
- logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
- physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
- deviceWidth(0), deviceHeight(0) {
- }
-
- bool operator==(const DisplayViewport& other) const {
- return displayId == other.displayId
- && orientation == other.orientation
- && logicalLeft == other.logicalLeft
- && logicalTop == other.logicalTop
- && logicalRight == other.logicalRight
- && logicalBottom == other.logicalBottom
- && physicalLeft == other.physicalLeft
- && physicalTop == other.physicalTop
- && physicalRight == other.physicalRight
- && physicalBottom == other.physicalBottom
- && deviceWidth == other.deviceWidth
- && deviceHeight == other.deviceHeight;
- }
-
- bool operator!=(const DisplayViewport& other) const {
- return !(*this == other);
- }
-
- inline bool isValid() const {
- return displayId >= 0;
- }
-
- void setNonDisplayViewport(int32_t width, int32_t height) {
- displayId = ADISPLAY_ID_NONE;
- orientation = DISPLAY_ORIENTATION_0;
- logicalLeft = 0;
- logicalTop = 0;
- logicalRight = width;
- logicalBottom = height;
- physicalLeft = 0;
- physicalTop = 0;
- physicalRight = width;
- physicalBottom = height;
- deviceWidth = width;
- deviceHeight = height;
- }
-};
-
-/*
* Input reader configuration.
*
* Specifies various options that modify the behavior of the input reader.
@@ -255,12 +192,19 @@
pointerGestureZoomSpeedRatio(0.3f),
showTouches(false) { }
- bool getDisplayInfo(bool external, DisplayViewport* outViewport) const;
- void setDisplayInfo(bool external, const DisplayViewport& viewport);
+ bool getDisplayViewport(ViewportType viewportType, const String8* displayId,
+ DisplayViewport* outViewport) const;
+ void setPhysicalDisplayViewport(ViewportType viewportType, const DisplayViewport& viewport);
+ void setVirtualDisplayViewports(const Vector<DisplayViewport>& viewports);
+
+
+ void dump(String8& dump) const;
+ void dumpViewport(String8& dump, const DisplayViewport& viewport) const;
private:
DisplayViewport mInternalDisplay;
DisplayViewport mExternalDisplay;
+ Vector<DisplayViewport> mVirtualDisplays;
};
@@ -1341,6 +1285,7 @@
bool associatedDisplayIsExternal;
bool orientationAware;
bool hasButtonUnderPad;
+ String8 uniqueDisplayId;
enum GestureMode {
GESTURE_MODE_SINGLE_TOUCH,
@@ -1889,6 +1834,8 @@
const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y);
static void assignPointerIds(const RawState* last, RawState* current);
+
+ const char* modeToString(DeviceMode deviceMode);
};
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 2e0bcd1..dcfe114 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -29,6 +29,10 @@
static const int32_t DISPLAY_ID = 0;
static const int32_t DISPLAY_WIDTH = 480;
static const int32_t DISPLAY_HEIGHT = 800;
+static const int32_t VIRTUAL_DISPLAY_ID = 1;
+static const int32_t VIRTUAL_DISPLAY_WIDTH = 400;
+static const int32_t VIRTUAL_DISPLAY_HEIGHT = 500;
+static const char* VIRTUAL_DISPLAY_UNIQUE_ID = "Vr-display-unique-ID";
// Error tolerance for floating point assertions.
static const float EPSILON = 0.001f;
@@ -136,25 +140,19 @@
FakeInputReaderPolicy() {
}
- void setDisplayInfo(int32_t displayId, int32_t width, int32_t height, int32_t orientation) {
+ void setDisplayViewport(int32_t displayId, int32_t width, int32_t height, int32_t orientation,
+ const String8& uniqueId) {
+ DisplayViewport v = createDisplayViewport(displayId, width, height, orientation, uniqueId);
// Set the size of both the internal and external display at the same time.
- bool isRotated = (orientation == DISPLAY_ORIENTATION_90
- || orientation == DISPLAY_ORIENTATION_270);
- DisplayViewport v;
- v.displayId = displayId;
- v.orientation = orientation;
- v.logicalLeft = 0;
- v.logicalTop = 0;
- v.logicalRight = isRotated ? height : width;
- v.logicalBottom = isRotated ? width : height;
- v.physicalLeft = 0;
- v.physicalTop = 0;
- v.physicalRight = isRotated ? height : width;
- v.physicalBottom = isRotated ? width : height;
- v.deviceWidth = isRotated ? height : width;
- v.deviceHeight = isRotated ? width : height;
- mConfig.setDisplayInfo(false /*external*/, v);
- mConfig.setDisplayInfo(true /*external*/, v);
+ mConfig.setPhysicalDisplayViewport(ViewportType::VIEWPORT_INTERNAL, v);
+ mConfig.setPhysicalDisplayViewport(ViewportType::VIEWPORT_EXTERNAL, v);
+ }
+
+ void setVirtualDisplayViewport(int32_t displayId, int32_t width, int32_t height, int32_t orientation,
+ const String8& uniqueId) {
+ Vector<DisplayViewport> viewports;
+ viewports.push_back(createDisplayViewport(displayId, width, height, orientation, uniqueId));
+ mConfig.setVirtualDisplayViewports(viewports);
}
void addExcludedDeviceName(const String8& deviceName) {
@@ -187,6 +185,27 @@
}
private:
+ DisplayViewport createDisplayViewport(int32_t displayId, int32_t width, int32_t height,
+ int32_t orientation, const String8& uniqueId) {
+ bool isRotated = (orientation == DISPLAY_ORIENTATION_90
+ || orientation == DISPLAY_ORIENTATION_270);
+ DisplayViewport v;
+ v.displayId = displayId;
+ v.orientation = orientation;
+ v.logicalLeft = 0;
+ v.logicalTop = 0;
+ v.logicalRight = isRotated ? height : width;
+ v.logicalBottom = isRotated ? width : height;
+ v.physicalLeft = 0;
+ v.physicalTop = 0;
+ v.physicalRight = isRotated ? height : width;
+ v.physicalBottom = isRotated ? width : height;
+ v.deviceWidth = isRotated ? height : width;
+ v.deviceHeight = isRotated ? width : height;
+ v.uniqueId = uniqueId;
+ return v;
+ }
+
virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) {
*outConfig = mConfig;
}
@@ -1445,7 +1464,13 @@
void setDisplayInfoAndReconfigure(int32_t displayId, int32_t width, int32_t height,
int32_t orientation) {
- mFakePolicy->setDisplayInfo(displayId, width, height, orientation);
+ mFakePolicy->setDisplayViewport(displayId, width, height, orientation, String8::empty());
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ }
+
+ void setVirtualDisplayInfoAndReconfigure(int32_t displayId, int32_t width, int32_t height,
+ int32_t orientation, const String8& uniqueId) {
+ mFakePolicy->setVirtualDisplayViewport(displayId, width, height, orientation, uniqueId);
configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
}
@@ -2751,6 +2776,8 @@
static const int32_t RAW_SLOT_MAX;
static const float X_PRECISION;
static const float Y_PRECISION;
+ static const float X_PRECISION_VIRTUAL;
+ static const float Y_PRECISION_VIRTUAL;
static const float GEOMETRIC_SCALE;
static const TouchAffineTransformation AFFINE_TRANSFORM;
@@ -2772,6 +2799,7 @@
};
void prepareDisplay(int32_t orientation);
+ void prepareVirtualDisplay(int32_t orientation);
void prepareVirtualKeys();
void prepareLocationCalibration();
int32_t toRawX(float displayX);
@@ -2779,7 +2807,10 @@
float toCookedX(float rawX, float rawY);
float toCookedY(float rawX, float rawY);
float toDisplayX(int32_t rawX);
+ float toDisplayX(int32_t rawX, int32_t displayWidth);
float toDisplayY(int32_t rawY);
+ float toDisplayY(int32_t rawY, int32_t displayHeight);
+
};
const int32_t TouchInputMapperTest::RAW_X_MIN = 25;
@@ -2804,6 +2835,10 @@
const int32_t TouchInputMapperTest::RAW_SLOT_MAX = 9;
const float TouchInputMapperTest::X_PRECISION = float(RAW_X_MAX - RAW_X_MIN + 1) / DISPLAY_WIDTH;
const float TouchInputMapperTest::Y_PRECISION = float(RAW_Y_MAX - RAW_Y_MIN + 1) / DISPLAY_HEIGHT;
+const float TouchInputMapperTest::X_PRECISION_VIRTUAL =
+ float(RAW_X_MAX - RAW_X_MIN + 1) / VIRTUAL_DISPLAY_WIDTH;
+const float TouchInputMapperTest::Y_PRECISION_VIRTUAL =
+ float(RAW_Y_MAX - RAW_Y_MIN + 1) / VIRTUAL_DISPLAY_HEIGHT;
const TouchAffineTransformation TouchInputMapperTest::AFFINE_TRANSFORM =
TouchAffineTransformation(1, -2, 3, -4, 5, -6);
@@ -2820,6 +2855,11 @@
setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, orientation);
}
+void TouchInputMapperTest::prepareVirtualDisplay(int32_t orientation) {
+ setVirtualDisplayInfoAndReconfigure(VIRTUAL_DISPLAY_ID, VIRTUAL_DISPLAY_WIDTH,
+ VIRTUAL_DISPLAY_HEIGHT, orientation, String8(VIRTUAL_DISPLAY_UNIQUE_ID));
+}
+
void TouchInputMapperTest::prepareVirtualKeys() {
mFakeEventHub->addVirtualKeyDefinition(DEVICE_ID, VIRTUAL_KEYS[0]);
mFakeEventHub->addVirtualKeyDefinition(DEVICE_ID, VIRTUAL_KEYS[1]);
@@ -2850,11 +2890,19 @@
}
float TouchInputMapperTest::toDisplayX(int32_t rawX) {
- return float(rawX - RAW_X_MIN) * DISPLAY_WIDTH / (RAW_X_MAX - RAW_X_MIN + 1);
+ return toDisplayX(rawX, DISPLAY_WIDTH);
+}
+
+float TouchInputMapperTest::toDisplayX(int32_t rawX, int32_t displayWidth) {
+ return float(rawX - RAW_X_MIN) * displayWidth / (RAW_X_MAX - RAW_X_MIN + 1);
}
float TouchInputMapperTest::toDisplayY(int32_t rawY) {
- return float(rawY - RAW_Y_MIN) * DISPLAY_HEIGHT / (RAW_Y_MAX - RAW_Y_MIN + 1);
+ return toDisplayY(rawY, DISPLAY_HEIGHT);
+}
+
+float TouchInputMapperTest::toDisplayY(int32_t rawY, int32_t displayHeight) {
+ return float(rawY - RAW_Y_MIN) * displayHeight / (RAW_Y_MAX - RAW_Y_MIN + 1);
}
@@ -3314,6 +3362,105 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
}
+TEST_F(SingleTouchInputMapperTest, Process_NormalSingleTouchGesture_VirtualDisplay) {
+ SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+ addConfigurationProperty("touch.deviceType", "touchScreen");
+ addConfigurationProperty("touch.displayId", VIRTUAL_DISPLAY_UNIQUE_ID);
+
+ prepareVirtualDisplay(DISPLAY_ORIENTATION_0);
+ prepareButtons();
+ prepareAxes(POSITION);
+ prepareVirtualKeys();
+ addMapperAndConfigure(mapper);
+
+ mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+ NotifyMotionArgs motionArgs;
+
+ // Down.
+ int32_t x = 100;
+ int32_t y = 125;
+ processDown(mapper, x, y);
+ processSync(mapper);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+ ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+ ASSERT_EQ(VIRTUAL_DISPLAY_ID, motionArgs.displayId);
+ ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+ ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+ ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+ ASSERT_EQ(0, motionArgs.flags);
+ ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+ ASSERT_EQ(0, motionArgs.buttonState);
+ ASSERT_EQ(0, motionArgs.edgeFlags);
+ ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+ ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+ toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
+ 1, 0, 0, 0, 0, 0, 0, 0));
+ ASSERT_NEAR(X_PRECISION_VIRTUAL, motionArgs.xPrecision, EPSILON);
+ ASSERT_NEAR(Y_PRECISION_VIRTUAL, motionArgs.yPrecision, EPSILON);
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+ // Move.
+ x += 50;
+ y += 75;
+ processMove(mapper, x, y);
+ processSync(mapper);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+ ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+ ASSERT_EQ(VIRTUAL_DISPLAY_ID, motionArgs.displayId);
+ ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+ ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(0, motionArgs.flags);
+ ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+ ASSERT_EQ(0, motionArgs.buttonState);
+ ASSERT_EQ(0, motionArgs.edgeFlags);
+ ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+ ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+ toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
+ 1, 0, 0, 0, 0, 0, 0, 0));
+ ASSERT_NEAR(X_PRECISION_VIRTUAL, motionArgs.xPrecision, EPSILON);
+ ASSERT_NEAR(Y_PRECISION_VIRTUAL, motionArgs.yPrecision, EPSILON);
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+ // Up.
+ processUp(mapper);
+ processSync(mapper);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+ ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+ ASSERT_EQ(VIRTUAL_DISPLAY_ID, motionArgs.displayId);
+ ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+ ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+ ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+ ASSERT_EQ(0, motionArgs.flags);
+ ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+ ASSERT_EQ(0, motionArgs.buttonState);
+ ASSERT_EQ(0, motionArgs.edgeFlags);
+ ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+ ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+ toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
+ 1, 0, 0, 0, 0, 0, 0, 0));
+ ASSERT_NEAR(X_PRECISION_VIRTUAL, motionArgs.xPrecision, EPSILON);
+ ASSERT_NEAR(Y_PRECISION_VIRTUAL, motionArgs.yPrecision, EPSILON);
+ ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+ // Should not have sent any more keys or motions.
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
TEST_F(SingleTouchInputMapperTest, Process_NormalSingleTouchGesture) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index d33d370..06a0765 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -697,7 +697,16 @@
mName.string(), z, to_string(error).c_str(),
static_cast<int32_t>(error));
- error = hwcLayer->setInfo(s.type, s.appId);
+ int type = s.type;
+ int appId = s.appId;
+ sp<Layer> parent = mParent.promote();
+ if (parent.get()) {
+ auto& parentState = parent->getDrawingState();
+ type = parentState.type;
+ appId = parentState.appId;
+ }
+
+ error = hwcLayer->setInfo(type, appId);
ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)",
mName.string(), static_cast<int32_t>(error));
#else
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fec1f1e..29a8292 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1116,9 +1116,14 @@
void SurfaceFlinger::resyncWithRateLimit() {
static constexpr nsecs_t kIgnoreDelay = ms2ns(500);
- if (systemTime() - mLastSwapTime > kIgnoreDelay) {
+
+ // No explicit locking is needed here since EventThread holds a lock while calling this method
+ static nsecs_t sLastResyncAttempted = 0;
+ const nsecs_t now = systemTime();
+ if (now - sLastResyncAttempted > kIgnoreDelay) {
resyncToHardwareVsync(false);
}
+ sLastResyncAttempted = now;
}
void SurfaceFlinger::onVSyncReceived(HWComposer* composer, int32_t type,
diff --git a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
index ee09d48..f0bdcd9 100644
--- a/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
+++ b/services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp
@@ -18,7 +18,7 @@
// use it to look up device configuration, so it must be unique. Vendor and
// product values must be 0 to indicate an internal device and prevent a
// similar lookup that could conflict with a physical device.
-static const char* const kDeviceNameFormat = "vr virtual touchpad %d";
+static const char* const kDeviceNameFormat = "vr-virtual-touchpad-%d";
static constexpr int16_t kDeviceBusType = BUS_VIRTUAL;
static constexpr int16_t kDeviceVendor = 0;
static constexpr int16_t kDeviceProduct = 0;
diff --git a/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp b/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
index 24cfdf8..564bcd7 100644
--- a/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
+++ b/services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp
@@ -139,7 +139,7 @@
SCOPED_TRACE(t);
uidev = touchpad->injector[t].GetUiDev();
String8 name;
- name.appendFormat("vr virtual touchpad %d", t);
+ name.appendFormat("vr-virtual-touchpad-%d", t);
EXPECT_EQ(name, uidev->name);
for (int i = 0; i < ABS_CNT; ++i) {
EXPECT_EQ(0, uidev->absmin[i]);