Renamed and moved InputWindow and related files
In preparation for the hierarchy listener interface, moved the
InputWindow structs into libgui and have libinput dependant on libgui.
Also renamed InputWindow to exclude Input since it will be used for more
generic purposes.
Test: Builds and flashes
Bug: 188792659
Change-Id: I24262cbc14d409c00273de0024a672394a959e5f
Merged-In: I24262cbc14d409c00273de0024a672394a959e5f
diff --git a/libs/ftl/Android.bp b/libs/ftl/Android.bp
index 97626be..2524c5f 100644
--- a/libs/ftl/Android.bp
+++ b/libs/ftl/Android.bp
@@ -14,7 +14,9 @@
address: true,
},
srcs: [
+ "Flags_test.cpp",
"future_test.cpp",
+ "NamedEnum_test.cpp",
"small_map_test.cpp",
"small_vector_test.cpp",
"static_vector_test.cpp",
@@ -25,4 +27,12 @@
"-Wextra",
"-Wpedantic",
],
+
+ header_libs: [
+ "libbase_headers",
+ ],
+
+ shared_libs: [
+ "libbase",
+ ],
}
diff --git a/libs/input/tests/Flags_test.cpp b/libs/ftl/Flags_test.cpp
similarity index 99%
rename from libs/input/tests/Flags_test.cpp
rename to libs/ftl/Flags_test.cpp
index 6de030f..8c00b52 100644
--- a/libs/input/tests/Flags_test.cpp
+++ b/libs/ftl/Flags_test.cpp
@@ -15,7 +15,7 @@
*/
#include <gtest/gtest.h>
-#include <input/Flags.h>
+#include <ftl/Flags.h>
#include <type_traits>
diff --git a/libs/input/tests/NamedEnum_test.cpp b/libs/ftl/NamedEnum_test.cpp
similarity index 98%
rename from libs/input/tests/NamedEnum_test.cpp
rename to libs/ftl/NamedEnum_test.cpp
index 74a0044..dff2b8a 100644
--- a/libs/input/tests/NamedEnum_test.cpp
+++ b/libs/ftl/NamedEnum_test.cpp
@@ -15,7 +15,7 @@
*/
#include <gtest/gtest.h>
-#include <input/NamedEnum.h>
+#include <ftl/NamedEnum.h>
namespace android {
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 64203f7..2d8fff9 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -51,6 +51,51 @@
],
}
+// AIDL files that should be exposed to java
+filegroup {
+ name: "guiconstants_aidl",
+ srcs: [
+ "android/**/TouchOcclusionMode.aidl",
+ ],
+}
+
+cc_library_static {
+ name: "libgui_window_info_static",
+ vendor_available: true,
+ host_supported: true,
+ srcs: [
+ ":guiconstants_aidl",
+ "android/gui/FocusRequest.aidl",
+ "android/gui/InputApplicationInfo.aidl",
+ "android/gui/WindowInfo.aidl",
+ "WindowInfo.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ ],
+
+ local_include_dirs: [
+ "include",
+ ],
+
+ export_shared_lib_headers: [
+ "libbinder",
+ ],
+
+ static_libs: [
+ "libui-types",
+ ],
+
+ aidl: {
+ export_aidl_headers: true
+ },
+
+ include_dirs: [
+ "frameworks/native/include",
+ ],
+}
+
filegroup {
name: "libgui_aidl",
srcs: ["aidl/**/*.aidl"],
@@ -77,12 +122,15 @@
"libbinder",
],
+ static_libs: [
+ "libui-types",
+ ],
+
aidl: {
export_aidl_headers: true
}
}
-
cc_library_shared {
name: "libgui",
vendor_available: true,
@@ -96,9 +144,11 @@
static_libs: [
"libgui_aidl_static",
+ "libgui_window_info_static",
],
export_static_lib_headers: [
"libgui_aidl_static",
+ "libgui_window_info_static",
],
srcs: [
@@ -150,13 +200,11 @@
"libbinder",
"libbufferhub",
"libbufferhubqueue", // TODO(b/70046255): Remove this once BufferHub is integrated into libgui.
- "libinput",
"libpdx_default_transport",
],
export_shared_lib_headers: [
"libbinder",
- "libinput",
],
export_header_lib_headers: [
@@ -168,7 +216,6 @@
vendor: {
cflags: [
"-DNO_BUFFERHUB",
- "-DNO_INPUT",
],
exclude_srcs: [
"BufferHubConsumer.cpp",
@@ -178,7 +225,6 @@
"android.frameworks.bufferhub@1.0",
"libbufferhub",
"libbufferhubqueue",
- "libinput",
"libpdx_default_transport",
],
},
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index 2970116..dbb1cb0 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -38,7 +38,7 @@
using namespace std::chrono_literals;
namespace {
-inline const char* toString(bool b) {
+inline const char* boolToString(bool b) {
return b ? "true" : "false";
}
} // namespace
@@ -513,7 +513,7 @@
BQA_LOGV("processNextBufferLocked size=%dx%d mFrameNumber=%" PRIu64
" applyTransaction=%s mTimestamp=%" PRId64 "%s mPendingTransactions.size=%d"
" graphicBufferId=%" PRIu64 "%s",
- mSize.width, mSize.height, bufferItem.mFrameNumber, toString(applyTransaction),
+ mSize.width, mSize.height, bufferItem.mFrameNumber, boolToString(applyTransaction),
bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp ? "(auto)" : "",
static_cast<uint32_t>(mPendingTransactions.size()), bufferItem.mGraphicBuffer->getId(),
bufferItem.mAutoRefresh ? " mAutoRefresh" : "");
@@ -543,7 +543,7 @@
mNumFrameAvailable + mNumAcquired - mPendingRelease.size());
BQA_LOGV("onFrameAvailable framenumber=%" PRIu64 " nextTransactionSet=%s", item.mFrameNumber,
- toString(nextTransactionSet));
+ boolToString(nextTransactionSet));
processNextBufferLocked(nextTransactionSet /* useNextTransaction */);
}
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index d102e07..001570c 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -31,6 +31,9 @@
namespace android {
+using gui::FocusRequest;
+using gui::WindowInfoHandle;
+
layer_state_t::layer_state_t()
: what(0),
x(0),
@@ -94,9 +97,7 @@
SAFE_PARCEL(output.writeFloat, color.r);
SAFE_PARCEL(output.writeFloat, color.g);
SAFE_PARCEL(output.writeFloat, color.b);
-#ifndef NO_INPUT
- SAFE_PARCEL(inputHandle->writeToParcel, &output);
-#endif
+ SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
SAFE_PARCEL(output.write, transparentRegion);
SAFE_PARCEL(output.writeUint32, transform);
SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
@@ -205,9 +206,7 @@
color.g = tmpFloat;
SAFE_PARCEL(input.readFloat, &tmpFloat);
color.b = tmpFloat;
-#ifndef NO_INPUT
- SAFE_PARCEL(inputHandle->readFromParcel, &input);
-#endif
+ SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
SAFE_PARCEL(input.read, transparentRegion);
SAFE_PARCEL(input.readUint32, &transform);
@@ -491,14 +490,10 @@
if (other.what & eHasListenerCallbacksChanged) {
what |= eHasListenerCallbacksChanged;
}
-
-#ifndef NO_INPUT
if (other.what & eInputInfoChanged) {
what |= eInputInfoChanged;
- inputHandle = new InputWindowHandle(*other.inputHandle);
+ windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
}
-#endif
-
if (other.what & eCachedBufferChanged) {
what |= eCachedBufferChanged;
cachedBuffer = other.cachedBuffer;
@@ -589,11 +584,9 @@
bool InputWindowCommands::merge(const InputWindowCommands& other) {
bool changes = false;
-#ifndef NO_INPUT
changes |= !other.focusRequests.empty();
focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
std::make_move_iterator(other.focusRequests.end()));
-#endif
changes |= other.syncInputWindows && !syncInputWindows;
syncInputWindows |= other.syncInputWindows;
return changes;
@@ -601,31 +594,23 @@
bool InputWindowCommands::empty() const {
bool empty = true;
-#ifndef NO_INPUT
empty = focusRequests.empty() && !syncInputWindows;
-#endif
return empty;
}
void InputWindowCommands::clear() {
-#ifndef NO_INPUT
focusRequests.clear();
-#endif
syncInputWindows = false;
}
status_t InputWindowCommands::write(Parcel& output) const {
-#ifndef NO_INPUT
SAFE_PARCEL(output.writeParcelableVector, focusRequests);
-#endif
SAFE_PARCEL(output.writeBool, syncInputWindows);
return NO_ERROR;
}
status_t InputWindowCommands::read(const Parcel& input) {
-#ifndef NO_INPUT
SAFE_PARCEL(input.readParcelableVector, &focusRequests);
-#endif
SAFE_PARCEL(input.readBool, &syncInputWindows);
return NO_ERROR;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index c255303..c52c644 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -39,14 +39,11 @@
#include <gui/LayerState.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
+#include <gui/WindowInfo.h>
#include <private/gui/ParcelUtils.h>
#include <ui/DisplayMode.h>
#include <ui/DynamicDisplayInfo.h>
-#ifndef NO_INPUT
-#include <input/InputWindow.h>
-#endif
-
#include <private/gui/ComposerService.h>
// This server size should always be smaller than the server cache size
@@ -54,6 +51,9 @@
namespace android {
+using gui::FocusRequest;
+using gui::WindowInfo;
+using gui::WindowInfoHandle;
using ui::ColorMode;
// ---------------------------------------------------------------------------
@@ -1491,16 +1491,14 @@
return *this;
}
-#ifndef NO_INPUT
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setInputWindowInfo(
- const sp<SurfaceControl>& sc,
- const InputWindowInfo& info) {
+ const sp<SurfaceControl>& sc, const WindowInfo& info) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->inputHandle = new InputWindowHandle(info);
+ s->windowInfoHandle = new WindowInfoHandle(info);
s->what |= layer_state_t::eInputInfoChanged;
return *this;
}
@@ -1516,8 +1514,6 @@
return *this;
}
-#endif
-
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorTransform(
const sp<SurfaceControl>& sc, const mat3& matrix, const vec3& translation) {
layer_state_t* s = getLayerState(sc);
diff --git a/libs/input/InputWindow.cpp b/libs/gui/WindowInfo.cpp
similarity index 79%
rename from libs/input/InputWindow.cpp
rename to libs/gui/WindowInfo.cpp
index 9947720..ff0bb8a 100644
--- a/libs/input/InputWindow.cpp
+++ b/libs/gui/WindowInfo.cpp
@@ -15,43 +15,40 @@
*/
#include <type_traits>
-#define LOG_TAG "InputWindow"
+#define LOG_TAG "WindowInfo"
#define LOG_NDEBUG 0
#include <android-base/stringprintf.h>
#include <binder/Parcel.h>
-#include <input/InputTransport.h>
-#include <input/InputWindow.h>
+#include <gui/WindowInfo.h>
#include <log/log.h>
-namespace android {
+namespace android::gui {
-
-// --- InputWindowInfo ---
-void InputWindowInfo::addTouchableRegion(const Rect& region) {
+// --- WindowInfo ---
+void WindowInfo::addTouchableRegion(const Rect& region) {
touchableRegion.orSelf(region);
}
-bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
- return touchableRegion.contains(x,y);
+bool WindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
+ return touchableRegion.contains(x, y);
}
-bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
- return x >= frameLeft && x < frameRight
- && y >= frameTop && y < frameBottom;
+bool WindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
+ return x >= frameLeft && x < frameRight && y >= frameTop && y < frameBottom;
}
-bool InputWindowInfo::supportsSplitTouch() const {
+bool WindowInfo::supportsSplitTouch() const {
return flags.test(Flag::SPLIT_TOUCH);
}
-bool InputWindowInfo::overlaps(const InputWindowInfo* other) const {
- return frameLeft < other->frameRight && frameRight > other->frameLeft
- && frameTop < other->frameBottom && frameBottom > other->frameTop;
+bool WindowInfo::overlaps(const WindowInfo* other) const {
+ return frameLeft < other->frameRight && frameRight > other->frameLeft &&
+ frameTop < other->frameBottom && frameBottom > other->frameTop;
}
-bool InputWindowInfo::operator==(const InputWindowInfo& info) const {
+bool WindowInfo::operator==(const WindowInfo& info) const {
return info.token == token && info.id == id && info.name == name && info.flags == flags &&
info.type == type && info.dispatchingTimeout == dispatchingTimeout &&
info.frameLeft == frameLeft && info.frameTop == frameTop &&
@@ -69,7 +66,7 @@
info.applicationInfo == applicationInfo;
}
-status_t InputWindowInfo::writeToParcel(android::Parcel* parcel) const {
+status_t WindowInfo::writeToParcel(android::Parcel* parcel) const {
if (parcel == nullptr) {
ALOGE("%s: Null parcel", __func__);
return BAD_VALUE;
@@ -86,7 +83,7 @@
parcel->writeInt32(id) ?:
parcel->writeUtf8AsUtf16(name) ?:
parcel->writeInt32(flags.get()) ?:
- parcel->writeInt32(static_cast<std::underlying_type_t<InputWindowInfo::Type>>(type)) ?:
+ parcel->writeInt32(static_cast<std::underlying_type_t<WindowInfo::Type>>(type)) ?:
parcel->writeInt32(frameLeft) ?:
parcel->writeInt32(frameTop) ?:
parcel->writeInt32(frameRight) ?:
@@ -122,7 +119,7 @@
return status;
}
-status_t InputWindowInfo::readFromParcel(const android::Parcel* parcel) {
+status_t WindowInfo::readFromParcel(const android::Parcel* parcel) {
if (parcel == nullptr) {
ALOGE("%s: Null parcel", __func__);
return BAD_VALUE;
@@ -176,11 +173,13 @@
touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt);
inputFeatures = Flags<Feature>(parcel->readInt32());
+ // clang-format off
status = parcel->readInt32(&displayId) ?:
parcel->readInt32(&portalToDisplayId) ?:
applicationInfo.readFromParcel(parcel) ?:
parcel->read(touchableRegion) ?:
parcel->readBool(&replaceTouchableRegionWithCrop);
+ // clang-format on
if (status != OK) {
return status;
@@ -192,33 +191,33 @@
return OK;
}
-// --- InputWindowHandle ---
+// --- WindowInfoHandle ---
-InputWindowHandle::InputWindowHandle() {}
+WindowInfoHandle::WindowInfoHandle() {}
-InputWindowHandle::~InputWindowHandle() {}
+WindowInfoHandle::~WindowInfoHandle() {}
-InputWindowHandle::InputWindowHandle(const InputWindowHandle& other) : mInfo(other.mInfo) {}
+WindowInfoHandle::WindowInfoHandle(const WindowInfoHandle& other) : mInfo(other.mInfo) {}
-InputWindowHandle::InputWindowHandle(const InputWindowInfo& other) : mInfo(other) {}
+WindowInfoHandle::WindowInfoHandle(const WindowInfo& other) : mInfo(other) {}
-status_t InputWindowHandle::writeToParcel(android::Parcel* parcel) const {
+status_t WindowInfoHandle::writeToParcel(android::Parcel* parcel) const {
return mInfo.writeToParcel(parcel);
}
-status_t InputWindowHandle::readFromParcel(const android::Parcel* parcel) {
+status_t WindowInfoHandle::readFromParcel(const android::Parcel* parcel) {
return mInfo.readFromParcel(parcel);
}
-void InputWindowHandle::releaseChannel() {
+void WindowInfoHandle::releaseChannel() {
mInfo.token.clear();
}
-sp<IBinder> InputWindowHandle::getToken() const {
+sp<IBinder> WindowInfoHandle::getToken() const {
return mInfo.token;
}
-void InputWindowHandle::updateFrom(sp<InputWindowHandle> handle) {
+void WindowInfoHandle::updateFrom(sp<WindowInfoHandle> handle) {
mInfo = handle->mInfo;
}
-} // namespace android
+} // namespace android::gui
diff --git a/libs/input/android/FocusRequest.aidl b/libs/gui/android/gui/FocusRequest.aidl
similarity index 98%
rename from libs/input/android/FocusRequest.aidl
rename to libs/gui/android/gui/FocusRequest.aidl
index 8812d34..9018635 100644
--- a/libs/input/android/FocusRequest.aidl
+++ b/libs/gui/android/gui/FocusRequest.aidl
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android;
+package android.gui;
/** @hide */
parcelable FocusRequest {
diff --git a/libs/input/android/InputApplicationInfo.aidl b/libs/gui/android/gui/InputApplicationInfo.aidl
similarity index 96%
rename from libs/input/android/InputApplicationInfo.aidl
rename to libs/gui/android/gui/InputApplicationInfo.aidl
index 9336039..c0fd666 100644
--- a/libs/input/android/InputApplicationInfo.aidl
+++ b/libs/gui/android/gui/InputApplicationInfo.aidl
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android;
+package android.gui;
parcelable InputApplicationInfo {
@nullable IBinder token;
diff --git a/libs/input/android/os/TouchOcclusionMode.aidl b/libs/gui/android/gui/TouchOcclusionMode.aidl
similarity index 98%
rename from libs/input/android/os/TouchOcclusionMode.aidl
rename to libs/gui/android/gui/TouchOcclusionMode.aidl
index 106f159..d91d052 100644
--- a/libs/input/android/os/TouchOcclusionMode.aidl
+++ b/libs/gui/android/gui/TouchOcclusionMode.aidl
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.os;
+package android.gui;
/**
diff --git a/libs/input/android/InputWindowInfo.aidl b/libs/gui/android/gui/WindowInfo.aidl
similarity index 81%
rename from libs/input/android/InputWindowInfo.aidl
rename to libs/gui/android/gui/WindowInfo.aidl
index eeaf400..2c85d15 100644
--- a/libs/input/android/InputWindowInfo.aidl
+++ b/libs/gui/android/gui/WindowInfo.aidl
@@ -1,5 +1,4 @@
-/* //device/java/android/android/view/InputChannel.aidl
-**
+/*
** Copyright 2020, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +14,6 @@
** limitations under the License.
*/
-package android;
+package android.gui;
-parcelable InputWindowInfo cpp_header "input/InputWindow.h";
+parcelable WindowInfo cpp_header "gui/WindowInfo.h";
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 2a3f6a4..71b80d3 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -24,9 +24,9 @@
#include <android/gui/ITunnelModeEnabledListener.h>
#include <binder/IBinder.h>
#include <binder/IInterface.h>
+#include <ftl/Flags.h>
#include <gui/FrameTimelineInfo.h>
#include <gui/ITransactionCompletedListener.h>
-#include <input/Flags.h>
#include <math/vec4.h>
#include <stdint.h>
#include <sys/types.h>
diff --git a/libs/gui/include/gui/InputApplication.h b/libs/gui/include/gui/InputApplication.h
new file mode 100644
index 0000000..679c2a1
--- /dev/null
+++ b/libs/gui/include/gui/InputApplication.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011 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 _UI_INPUT_APPLICATION_H
+#define _UI_INPUT_APPLICATION_H
+
+#include <string>
+
+#include <android/gui/InputApplicationInfo.h>
+
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <binder/Parcelable.h>
+
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+
+namespace android {
+
+/*
+ * Handle for an application that can receive input.
+ *
+ * Used by the native input dispatcher as a handle for the window manager objects
+ * that describe an application.
+ */
+class InputApplicationHandle {
+public:
+ inline const gui::InputApplicationInfo* getInfo() const { return &mInfo; }
+
+ inline std::string getName() const { return !mInfo.name.empty() ? mInfo.name : "<invalid>"; }
+
+ inline std::chrono::nanoseconds getDispatchingTimeout(
+ std::chrono::nanoseconds defaultValue) const {
+ return mInfo.token ? std::chrono::milliseconds(mInfo.dispatchingTimeoutMillis)
+ : defaultValue;
+ }
+
+ inline sp<IBinder> getApplicationToken() const { return mInfo.token; }
+
+ bool operator==(const InputApplicationHandle& other) const {
+ return getName() == other.getName() && getApplicationToken() == other.getApplicationToken();
+ }
+
+ bool operator!=(const InputApplicationHandle& other) const { return !(*this == other); }
+
+ /**
+ * Requests that the state of this object be updated to reflect
+ * the most current available information about the application.
+ *
+ * This method should only be called from within the input dispatcher's
+ * critical section.
+ *
+ * Returns true on success, or false if the handle is no longer valid.
+ */
+ virtual bool updateInfo() = 0;
+
+protected:
+ InputApplicationHandle() = default;
+ virtual ~InputApplicationHandle() = default;
+
+ gui::InputApplicationInfo mInfo;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_APPLICATION_H
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 7961f4b..92de74a 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -26,14 +26,12 @@
#include <gui/ITransactionCompletedListener.h>
#include <math/mat4.h>
-#ifndef NO_INPUT
-#include <android/FocusRequest.h>
-#include <input/InputWindow.h>
-#endif
+#include <android/gui/FocusRequest.h>
#include <gui/ISurfaceComposer.h>
#include <gui/LayerMetadata.h>
#include <gui/SurfaceControl.h>
+#include <gui/WindowInfo.h>
#include <math/vec3.h>
#include <ui/BlurRegion.h>
#include <ui/GraphicTypes.h>
@@ -176,9 +174,7 @@
mat4 colorTransform;
std::vector<BlurRegion> blurRegions;
-#ifndef NO_INPUT
- sp<InputWindowHandle> inputHandle = new InputWindowHandle();
-#endif
+ sp<gui::WindowInfoHandle> windowInfoHandle = new gui::WindowInfoHandle();
client_cache_t cachedBuffer;
@@ -288,9 +284,7 @@
};
struct InputWindowCommands {
-#ifndef NO_INPUT
- std::vector<FocusRequest> focusRequests;
-#endif
+ std::vector<gui::FocusRequest> focusRequests;
bool syncInputWindows{false};
// Merges the passed in commands and returns true if there were any changes.
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index eb81483..ff97fe4 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -502,11 +502,9 @@
// Set the framenumber generated by the graphics producer to mimic BufferQueue behaviour.
Transaction& setFrameNumber(const sp<SurfaceControl>& sc, uint64_t frameNumber);
-#ifndef NO_INPUT
- Transaction& setInputWindowInfo(const sp<SurfaceControl>& sc, const InputWindowInfo& info);
- Transaction& setFocusedWindow(const FocusRequest& request);
+ Transaction& setInputWindowInfo(const sp<SurfaceControl>& sc, const gui::WindowInfo& info);
+ Transaction& setFocusedWindow(const gui::FocusRequest& request);
Transaction& syncInputWindows();
-#endif
// Set a color transform matrix on the given layer on the built-in display.
Transaction& setColorTransform(const sp<SurfaceControl>& sc, const mat3& matrix,
diff --git a/libs/gui/include/gui/WindowInfo.h b/libs/gui/include/gui/WindowInfo.h
new file mode 100644
index 0000000..51ddc50
--- /dev/null
+++ b/libs/gui/include/gui/WindowInfo.h
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#pragma once
+
+#include <android/gui/TouchOcclusionMode.h>
+#include <binder/Parcel.h>
+#include <binder/Parcelable.h>
+#include <ftl/Flags.h>
+#include <gui/constants.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
+#include <ui/Transform.h>
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+
+#include "InputApplication.h"
+
+namespace android::gui {
+
+/*
+ * Describes the properties of a window that can receive input.
+ */
+struct WindowInfo : public Parcelable {
+ WindowInfo() = default;
+
+ // Window flags from WindowManager.LayoutParams
+ enum class Flag : uint32_t {
+ ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
+ DIM_BEHIND = 0x00000002,
+ BLUR_BEHIND = 0x00000004,
+ NOT_FOCUSABLE = 0x00000008,
+ NOT_TOUCHABLE = 0x00000010,
+ NOT_TOUCH_MODAL = 0x00000020,
+ TOUCHABLE_WHEN_WAKING = 0x00000040,
+ KEEP_SCREEN_ON = 0x00000080,
+ LAYOUT_IN_SCREEN = 0x00000100,
+ LAYOUT_NO_LIMITS = 0x00000200,
+ FULLSCREEN = 0x00000400,
+ FORCE_NOT_FULLSCREEN = 0x00000800,
+ DITHER = 0x00001000,
+ SECURE = 0x00002000,
+ SCALED = 0x00004000,
+ IGNORE_CHEEK_PRESSES = 0x00008000,
+ LAYOUT_INSET_DECOR = 0x00010000,
+ ALT_FOCUSABLE_IM = 0x00020000,
+ WATCH_OUTSIDE_TOUCH = 0x00040000,
+ SHOW_WHEN_LOCKED = 0x00080000,
+ SHOW_WALLPAPER = 0x00100000,
+ TURN_SCREEN_ON = 0x00200000,
+ DISMISS_KEYGUARD = 0x00400000,
+ SPLIT_TOUCH = 0x00800000,
+ HARDWARE_ACCELERATED = 0x01000000,
+ LAYOUT_IN_OVERSCAN = 0x02000000,
+ TRANSLUCENT_STATUS = 0x04000000,
+ TRANSLUCENT_NAVIGATION = 0x08000000,
+ LOCAL_FOCUS_MODE = 0x10000000,
+ SLIPPERY = 0x20000000,
+ LAYOUT_ATTACHED_IN_DECOR = 0x40000000,
+ DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000,
+ }; // Window types from WindowManager.LayoutParams
+
+ enum class Type : int32_t {
+ UNKNOWN = 0,
+ FIRST_APPLICATION_WINDOW = 1,
+ BASE_APPLICATION = 1,
+ APPLICATION = 2,
+ APPLICATION_STARTING = 3,
+ LAST_APPLICATION_WINDOW = 99,
+ FIRST_SUB_WINDOW = 1000,
+ APPLICATION_PANEL = FIRST_SUB_WINDOW,
+ APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1,
+ APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2,
+ APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3,
+ APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4,
+ LAST_SUB_WINDOW = 1999,
+ FIRST_SYSTEM_WINDOW = 2000,
+ STATUS_BAR = FIRST_SYSTEM_WINDOW,
+ SEARCH_BAR = FIRST_SYSTEM_WINDOW + 1,
+ PHONE = FIRST_SYSTEM_WINDOW + 2,
+ SYSTEM_ALERT = FIRST_SYSTEM_WINDOW + 3,
+ KEYGUARD = FIRST_SYSTEM_WINDOW + 4,
+ TOAST = FIRST_SYSTEM_WINDOW + 5,
+ SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW + 6,
+ PRIORITY_PHONE = FIRST_SYSTEM_WINDOW + 7,
+ SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW + 8,
+ KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW + 9,
+ SYSTEM_ERROR = FIRST_SYSTEM_WINDOW + 10,
+ INPUT_METHOD = FIRST_SYSTEM_WINDOW + 11,
+ INPUT_METHOD_DIALOG = FIRST_SYSTEM_WINDOW + 12,
+ WALLPAPER = FIRST_SYSTEM_WINDOW + 13,
+ STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW + 14,
+ SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW + 15,
+ DRAG = FIRST_SYSTEM_WINDOW + 16,
+ STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW + 17,
+ POINTER = FIRST_SYSTEM_WINDOW + 18,
+ NAVIGATION_BAR = FIRST_SYSTEM_WINDOW + 19,
+ VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW + 20,
+ BOOT_PROGRESS = FIRST_SYSTEM_WINDOW + 21,
+ INPUT_CONSUMER = FIRST_SYSTEM_WINDOW + 22,
+ NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW + 24,
+ MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 27,
+ ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW + 32,
+ DOCK_DIVIDER = FIRST_SYSTEM_WINDOW + 34,
+ ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 39,
+ NOTIFICATION_SHADE = FIRST_SYSTEM_WINDOW + 40,
+ LAST_SYSTEM_WINDOW = 2999,
+ };
+
+ enum class Feature {
+ DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
+ NO_INPUT_CHANNEL = 0x00000002,
+ DISABLE_USER_ACTIVITY = 0x00000004,
+ };
+
+ /* These values are filled in by the WM and passed through SurfaceFlinger
+ * unless specified otherwise.
+ */
+ // This value should NOT be used to uniquely identify the window. There may be different
+ // input windows that have the same token.
+ sp<IBinder> token;
+ // This uniquely identifies the input window.
+ int32_t id = -1;
+ std::string name;
+ Flags<Flag> flags;
+ Type type = Type::UNKNOWN;
+ std::chrono::nanoseconds dispatchingTimeout = std::chrono::seconds(5);
+
+ /* These values are filled in by SurfaceFlinger. */
+ int32_t frameLeft = -1;
+ int32_t frameTop = -1;
+ int32_t frameRight = -1;
+ int32_t frameBottom = -1;
+
+ /*
+ * SurfaceFlinger consumes this value to shrink the computed frame. This is
+ * different from shrinking the touchable region in that it DOES shift the coordinate
+ * space where-as the touchable region does not and is more like "cropping". This
+ * is used for window shadows.
+ */
+ int32_t surfaceInset = 0;
+
+ // A global scaling factor for all windows. Unlike windowScaleX/Y this results
+ // in scaling of the TOUCH_MAJOR/TOUCH_MINOR axis.
+ float globalScaleFactor = 1.0f;
+
+ // The opacity of this window, from 0.0 to 1.0 (inclusive).
+ // An alpha of 1.0 means fully opaque and 0.0 means fully transparent.
+ float alpha;
+
+ // Transform applied to individual windows.
+ ui::Transform transform;
+
+ // Display size in its natural rotation. Used to rotate raw coordinates for compatibility.
+ int32_t displayWidth = 0;
+ int32_t displayHeight = 0;
+
+ /*
+ * This is filled in by the WM relative to the frame and then translated
+ * to absolute coordinates by SurfaceFlinger once the frame is computed.
+ */
+ Region touchableRegion;
+ bool visible = false;
+ bool focusable = false;
+ bool hasWallpaper = false;
+ bool paused = false;
+ /* This flag is set when the window is of a trusted type that is allowed to silently
+ * overlay other windows for the purpose of implementing the secure views feature.
+ * Trusted overlays, such as IME windows, can partly obscure other windows without causing
+ * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
+ */
+ bool trustedOverlay = false;
+ TouchOcclusionMode touchOcclusionMode = TouchOcclusionMode::BLOCK_UNTRUSTED;
+ int32_t ownerPid = -1;
+ int32_t ownerUid = -1;
+ std::string packageName;
+ Flags<Feature> inputFeatures;
+ int32_t displayId = ADISPLAY_ID_NONE;
+ int32_t portalToDisplayId = ADISPLAY_ID_NONE;
+ InputApplicationInfo applicationInfo;
+ bool replaceTouchableRegionWithCrop = false;
+ wp<IBinder> touchableRegionCropHandle;
+
+ void addTouchableRegion(const Rect& region);
+
+ bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
+
+ bool frameContainsPoint(int32_t x, int32_t y) const;
+
+ bool supportsSplitTouch() const;
+
+ bool overlaps(const WindowInfo* other) const;
+
+ bool operator==(const WindowInfo& inputChannel) const;
+
+ status_t writeToParcel(android::Parcel* parcel) const override;
+
+ status_t readFromParcel(const android::Parcel* parcel) override;
+};
+
+/*
+ * Handle for a window that can receive input.
+ *
+ * Used by the native input dispatcher to indirectly refer to the window manager objects
+ * that describe a window.
+ */
+class WindowInfoHandle : public RefBase {
+public:
+ explicit WindowInfoHandle();
+ WindowInfoHandle(const WindowInfoHandle& other);
+ WindowInfoHandle(const WindowInfo& other);
+
+ inline const WindowInfo* getInfo() const { return &mInfo; }
+
+ sp<IBinder> getToken() const;
+
+ int32_t getId() const { return mInfo.id; }
+
+ sp<IBinder> getApplicationToken() { return mInfo.applicationInfo.token; }
+
+ inline std::string getName() const { return !mInfo.name.empty() ? mInfo.name : "<invalid>"; }
+
+ inline std::chrono::nanoseconds getDispatchingTimeout(
+ std::chrono::nanoseconds defaultValue) const {
+ return mInfo.token ? std::chrono::nanoseconds(mInfo.dispatchingTimeout) : defaultValue;
+ }
+
+ /**
+ * Requests that the state of this object be updated to reflect
+ * the most current available information about the application.
+ * As this class is created as RefBase object, no pure virtual function is allowed.
+ *
+ * This method should only be called from within the input dispatcher's
+ * critical section.
+ *
+ * Returns true on success, or false if the handle is no longer valid.
+ */
+ virtual bool updateInfo() { return false; }
+
+ /**
+ * Updates from another input window handle.
+ */
+ void updateFrom(const sp<WindowInfoHandle> handle);
+
+ /**
+ * Releases the channel used by the associated information when it is
+ * no longer needed.
+ */
+ void releaseChannel();
+
+ // Not override since this class is not derrived from Parcelable.
+ status_t readFromParcel(const android::Parcel* parcel);
+ status_t writeToParcel(android::Parcel* parcel) const;
+
+protected:
+ virtual ~WindowInfoHandle();
+
+ WindowInfo mInfo;
+};
+} // namespace android::gui
\ No newline at end of file
diff --git a/libs/gui/include/gui/constants.h b/libs/gui/include/gui/constants.h
new file mode 100644
index 0000000..8eab378
--- /dev/null
+++ b/libs/gui/include/gui/constants.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+namespace android {
+
+/**
+ * Invalid value for display size. Used when display size isn't available.
+ */
+constexpr int32_t INVALID_DISPLAY_SIZE = 0;
+
+enum {
+ /* Used when an event is not associated with any display.
+ * Typically used for non-pointer events. */
+ ADISPLAY_ID_NONE = -1,
+
+ /* The default display id. */
+ ADISPLAY_ID_DEFAULT = 0,
+};
+
+} // namespace android
\ No newline at end of file
diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp
index c801c62..3d26c3d 100644
--- a/libs/gui/tests/Android.bp
+++ b/libs/gui/tests/Android.bp
@@ -43,6 +43,7 @@
"SurfaceTextureMultiContextGL_test.cpp",
"Surface_test.cpp",
"TextureRenderer.cpp",
+ "WindowInfo_test.cpp",
],
shared_libs: [
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 49c44a7..fc84c1b 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -37,9 +37,9 @@
#include <gui/SurfaceControl.h>
#include <android/os/IInputFlinger.h>
+#include <gui/WindowInfo.h>
#include <input/Input.h>
#include <input/InputTransport.h>
-#include <input/InputWindow.h>
#include <ui/DisplayMode.h>
#include <ui/Rect.h>
@@ -49,6 +49,11 @@
using android::hardware::graphics::common::V1_1::BufferUsage;
+using android::gui::FocusRequest;
+using android::gui::InputApplicationInfo;
+using android::gui::TouchOcclusionMode;
+using android::gui::WindowInfo;
+
namespace android::test {
using Transaction = SurfaceComposerClient::Transaction;
@@ -221,8 +226,8 @@
void populateInputInfo(int width, int height) {
mInputInfo.token = mClientChannel->getConnectionToken();
mInputInfo.name = "Test info";
- mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCH_MODAL;
- mInputInfo.type = InputWindowInfo::Type::BASE_APPLICATION;
+ mInputInfo.flags = WindowInfo::Flag::NOT_TOUCH_MODAL;
+ mInputInfo.type = WindowInfo::Type::BASE_APPLICATION;
mInputInfo.dispatchingTimeout = 5s;
mInputInfo.globalScaleFactor = 1.0;
mInputInfo.focusable = true;
@@ -249,7 +254,7 @@
std::shared_ptr<InputChannel> mClientChannel;
sp<IInputFlinger> mInputFlinger;
- InputWindowInfo mInputInfo;
+ WindowInfo mInputInfo;
PreallocatedInputEventFactory mInputEventFactory;
InputConsumer* mInputConsumer;
@@ -686,7 +691,7 @@
// Add non touchable window to fully cover touchable window. Window behind gets touch, but
// with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED
std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100);
- nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
+ nonTouchableSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
nonTouchableSurface->mInputInfo.ownerUid = 22222;
// Overriding occlusion mode otherwise the touch would be discarded at InputDispatcher by
// the default obscured/untrusted touch filter introduced in S.
@@ -706,8 +711,8 @@
// AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED
std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100);
std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100);
- nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
- parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
+ nonTouchableSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
+ parentSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
nonTouchableSurface->mInputInfo.ownerUid = 22222;
parentSurface->mInputInfo.ownerUid = 22222;
nonTouchableSurface->showAt(0, 0);
@@ -730,8 +735,8 @@
// the touchable window. Window behind gets touch with no obscured flags.
std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100);
std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100);
- nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
- parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
+ nonTouchableSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
+ parentSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
nonTouchableSurface->mInputInfo.ownerUid = 22222;
parentSurface->mInputInfo.ownerUid = 22222;
nonTouchableSurface->showAt(0, 0);
@@ -751,7 +756,7 @@
std::unique_ptr<InputSurface> bufferSurface =
InputSurface::makeBufferInputSurface(mComposerClient, 0, 0);
- bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
+ bufferSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
bufferSurface->mInputInfo.ownerUid = 22222;
surface->showAt(10, 10);
@@ -766,7 +771,7 @@
std::unique_ptr<BlastInputSurface> bufferSurface =
BlastInputSurface::makeBlastInputSurface(mComposerClient, 0, 0);
- bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE;
+ bufferSurface->mInputInfo.flags = WindowInfo::Flag::NOT_TOUCHABLE;
bufferSurface->mInputInfo.ownerUid = 22222;
surface->showAt(10, 10);
diff --git a/libs/input/tests/InputWindow_test.cpp b/libs/gui/tests/WindowInfo_test.cpp
similarity index 89%
rename from libs/input/tests/InputWindow_test.cpp
rename to libs/gui/tests/WindowInfo_test.cpp
index 493f2f4..09c02ca 100644
--- a/libs/input/tests/InputWindow_test.cpp
+++ b/libs/gui/tests/WindowInfo_test.cpp
@@ -19,16 +19,20 @@
#include <binder/Binder.h>
#include <binder/Parcel.h>
-#include <input/InputWindow.h>
-#include <input/InputTransport.h>
+#include <gui/WindowInfo.h>
using std::chrono_literals::operator""s;
namespace android {
+
+using gui::InputApplicationInfo;
+using gui::TouchOcclusionMode;
+using gui::WindowInfo;
+
namespace test {
-TEST(InputWindowInfo, ParcellingWithoutToken) {
- InputWindowInfo i, i2;
+TEST(WindowInfo, ParcellingWithoutToken) {
+ WindowInfo i, i2;
i.token = nullptr;
Parcel p;
@@ -38,14 +42,14 @@
ASSERT_TRUE(i2.token == nullptr);
}
-TEST(InputWindowInfo, Parcelling) {
+TEST(WindowInfo, Parcelling) {
sp<IBinder> touchableRegionCropHandle = new BBinder();
- InputWindowInfo i;
+ WindowInfo i;
i.token = new BBinder();
i.id = 1;
i.name = "Foobar";
- i.flags = InputWindowInfo::Flag::SLIPPERY;
- i.type = InputWindowInfo::Type::INPUT_METHOD;
+ i.flags = WindowInfo::Flag::SLIPPERY;
+ i.type = WindowInfo::Type::INPUT_METHOD;
i.dispatchingTimeout = 12s;
i.frameLeft = 93;
i.frameTop = 34;
@@ -65,7 +69,7 @@
i.ownerPid = 19;
i.ownerUid = 24;
i.packageName = "com.example.package";
- i.inputFeatures = InputWindowInfo::Feature::DISABLE_USER_ACTIVITY;
+ i.inputFeatures = WindowInfo::Feature::DISABLE_USER_ACTIVITY;
i.displayId = 34;
i.portalToDisplayId = 2;
i.replaceTouchableRegionWithCrop = true;
@@ -77,7 +81,7 @@
Parcel p;
i.writeToParcel(&p);
p.setDataPosition(0);
- InputWindowInfo i2;
+ WindowInfo i2;
i2.readFromParcel(&p);
ASSERT_EQ(i.token, i2.token);
ASSERT_EQ(i.id, i2.id);
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index a63ec8f..1a142c9 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -30,7 +30,6 @@
"android/os/IInputConstants.aidl",
"android/os/InputEventInjectionResult.aidl",
"android/os/InputEventInjectionSync.aidl",
- "android/os/TouchOcclusionMode.aidl",
],
}
@@ -69,26 +68,24 @@
static_libs: [
"libui-types",
+ "libgui_window_info_static",
],
export_static_lib_headers: [
"libui-types",
+ "libgui_window_info_static",
],
target: {
android: {
srcs: [
"InputTransport.cpp",
- "InputWindow.cpp",
- "android/FocusRequest.aidl",
- "android/InputApplicationInfo.aidl",
"android/os/BlockUntrustedTouchesMode.aidl",
"android/os/IInputConstants.aidl",
"android/os/IInputFlinger.aidl",
"android/os/InputEventInjectionResult.aidl",
"android/os/InputEventInjectionSync.aidl",
"android/os/ISetInputWindowsListener.aidl",
- "android/os/TouchOcclusionMode.aidl",
],
export_shared_lib_headers: ["libbinder"],
@@ -114,13 +111,9 @@
linux_glibc: {
srcs: [
"InputTransport.cpp",
- "InputWindow.cpp",
- "android/FocusRequest.aidl",
- "android/InputApplicationInfo.aidl",
"android/os/IInputConstants.aidl",
"android/os/IInputFlinger.aidl",
"android/os/ISetInputWindowsListener.aidl",
- "android/os/TouchOcclusionMode.aidl",
],
static_libs: [
"libhostgraphics",
@@ -134,6 +127,9 @@
aidl: {
local_include_dirs: ["."],
export_aidl_headers: true,
+ include_dirs: [
+ "frameworks/native/libs/gui",
+ ],
},
}
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 266d7a3..906e3e5 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -24,6 +24,7 @@
#include <string.h>
#include <android-base/stringprintf.h>
+#include <gui/constants.h>
#include <input/Input.h>
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 30c42a3..220c8e1 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -21,9 +21,9 @@
#include <ctype.h>
#include <android-base/stringprintf.h>
+#include <ftl/NamedEnum.h>
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
-#include <input/NamedEnum.h>
using android::base::StringPrintf;
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index dd1c462..d6c1161 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -33,8 +33,8 @@
#include <log/log.h>
#include <utils/Trace.h>
+#include <ftl/NamedEnum.h>
#include <input/InputTransport.h>
-#include <input/NamedEnum.h>
using android::base::StringPrintf;
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp
index 44f3f34..3baeb55 100644
--- a/libs/input/KeyCharacterMap.cpp
+++ b/libs/input/KeyCharacterMap.cpp
@@ -28,10 +28,11 @@
#include <input/KeyCharacterMap.h>
#include <input/Keyboard.h>
-#include <utils/Log.h>
+#include <gui/constants.h>
#include <utils/Errors.h>
-#include <utils/Tokenizer.h>
+#include <utils/Log.h>
#include <utils/Timers.h>
+#include <utils/Tokenizer.h>
// Enables debug output for the parser.
#define DEBUG_PARSER 0
diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp
index fa5a541..c365ab0 100644
--- a/libs/input/KeyLayoutMap.cpp
+++ b/libs/input/KeyLayoutMap.cpp
@@ -19,10 +19,10 @@
#include <stdlib.h>
#include <android/keycodes.h>
+#include <ftl/NamedEnum.h>
#include <input/InputEventLabels.h>
#include <input/KeyLayoutMap.h>
#include <input/Keyboard.h>
-#include <input/NamedEnum.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/Timers.h>
diff --git a/libs/input/android/os/IInputFlinger.aidl b/libs/input/android/os/IInputFlinger.aidl
index 1771d19..43b262f 100644
--- a/libs/input/android/os/IInputFlinger.aidl
+++ b/libs/input/android/os/IInputFlinger.aidl
@@ -16,9 +16,9 @@
package android.os;
-import android.FocusRequest;
import android.InputChannel;
-import android.InputWindowInfo;
+import android.gui.FocusRequest;
+import android.gui.WindowInfo;
import android.os.ISetInputWindowsListener;
/** @hide */
@@ -28,7 +28,7 @@
// ordering when needed.
// SurfaceFlinger calls this only every VSync, so overflow of binder's oneway buffer
// shouldn't be a concern.
- oneway void setInputWindows(in InputWindowInfo[] inputHandles,
+ oneway void setInputWindows(in WindowInfo[] windowInfoHandles,
in @nullable ISetInputWindowsListener setInputWindowsListener);
InputChannel createInputChannel(in @utf8InCpp String name);
void removeInputChannel(in IBinder connectionToken);
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
index 6ffc6a8..18ab1cb 100644
--- a/libs/input/tests/Android.bp
+++ b/libs/input/tests/Android.bp
@@ -11,26 +11,24 @@
cc_test {
name: "libinput_tests",
srcs: [
- "NamedEnum_test.cpp",
- "Flags_test.cpp",
"IdGenerator_test.cpp",
"InputChannel_test.cpp",
"InputDevice_test.cpp",
"InputEvent_test.cpp",
"InputPublisherAndConsumer_test.cpp",
- "InputWindow_test.cpp",
"TouchVideoFrame_test.cpp",
"VelocityTracker_test.cpp",
"VerifiedInputEvent_test.cpp",
],
+ static_libs: [
+ "libgui_window_info_static",
+ "libinput",
+ ],
cflags: [
"-Wall",
"-Wextra",
"-Werror",
],
- static_libs: [
- "libinput",
- ],
shared_libs: [
"libbase",
"libbinder",
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index cfb5986..f1a26ec 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -20,6 +20,7 @@
#include <attestation/HmacKeyManager.h>
#include <binder/Parcel.h>
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <input/Input.h>
namespace android {
@@ -271,9 +272,8 @@
AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_BUTTON_PRIMARY,
MotionClassification::NONE, mTransform, 2.0f, 2.1f,
AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME, 2, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, ARBITRARY_DOWN_TIME,
+ ARBITRARY_EVENT_TIME, 2, pointerProperties, pointerCoords);
pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 110);
pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 111);
@@ -593,9 +593,8 @@
AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, 0 /*buttonState*/,
MotionClassification::NONE, identityTransform, 0 /*xPrecision*/,
0 /*yPrecision*/, 3 + RADIUS /*xCursorPosition*/, 2 /*yCursorPosition*/,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- 0 /*downTime*/, 0 /*eventTime*/, pointerCount, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, 0 /*downTime*/, 0 /*eventTime*/,
+ pointerCount, pointerProperties, pointerCoords);
float originalRawX = 0 + 3;
float originalRawY = -RADIUS + 2;
@@ -795,9 +794,9 @@
DISPLAY_ID, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, 0, 0,
AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, 0, classification,
identityTransform, 0, 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
- AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, 0 /*downTime*/, 0 /*eventTime*/,
- pointerCount, pointerProperties, pointerCoords);
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, 0 /*downTime*/, 0 /*eventTime*/, pointerCount,
+ pointerProperties, pointerCoords);
ASSERT_EQ(classification, event.getClassification());
}
}
@@ -817,10 +816,9 @@
event.initialize(InputEvent::nextId(), 0 /*deviceId*/, AINPUT_SOURCE_MOUSE, DISPLAY_ID,
INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMOTION_EVENT_EDGE_FLAG_NONE,
AMETA_NONE, 0, MotionClassification::NONE, identityTransform, 0, 0,
- 280 /*xCursorPosition*/, 540 /*yCursorPosition*/,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- 0 /*downTime*/, 0 /*eventTime*/, pointerCount, pointerProperties,
- pointerCoords);
+ 280 /*xCursorPosition*/, 540 /*yCursorPosition*/, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, 0 /*downTime*/, 0 /*eventTime*/, pointerCount,
+ pointerProperties, pointerCoords);
event.offsetLocation(20, 60);
ASSERT_EQ(280, event.getRawXCursorPosition());
ASSERT_EQ(540, event.getRawYCursorPosition());
diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp
index a2cfaa1..d0c337c 100644
--- a/libs/input/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp
@@ -23,6 +23,7 @@
#include <attestation/HmacKeyManager.h>
#include <cutils/ashmem.h>
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <input/InputTransport.h>
#include <utils/StopWatch.h>
#include <utils/Timers.h>
diff --git a/libs/input/tests/VelocityTracker_test.cpp b/libs/input/tests/VelocityTracker_test.cpp
index aefc2ec..8ae7dcc 100644
--- a/libs/input/tests/VelocityTracker_test.cpp
+++ b/libs/input/tests/VelocityTracker_test.cpp
@@ -23,6 +23,7 @@
#include <android-base/stringprintf.h>
#include <attestation/HmacKeyManager.h>
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <input/VelocityTracker.h>
using namespace std::chrono_literals;
@@ -183,9 +184,9 @@
AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, 0 /*buttonState*/,
MotionClassification::NONE, identityTransform, 0 /*xPrecision*/,
0 /*yPrecision*/, AMOTION_EVENT_INVALID_CURSOR_POSITION,
- AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, 0 /*downTime*/,
- entry.eventTime.count(), pointerCount, properties, coords);
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, 0 /*downTime*/, entry.eventTime.count(),
+ pointerCount, properties, coords);
events.emplace_back(event);
}
diff --git a/libs/input/tests/VerifiedInputEvent_test.cpp b/libs/input/tests/VerifiedInputEvent_test.cpp
index f79098c..a0c9c17 100644
--- a/libs/input/tests/VerifiedInputEvent_test.cpp
+++ b/libs/input/tests/VerifiedInputEvent_test.cpp
@@ -16,6 +16,7 @@
#include <attestation/HmacKeyManager.h>
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <input/Input.h>
namespace android {
@@ -46,10 +47,9 @@
INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, 0 /*actionButton*/, flags,
AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, 0 /*buttonState*/,
MotionClassification::NONE, transform, 0.1 /*xPrecision*/, 0.2 /*yPrecision*/,
- 280 /*xCursorPosition*/, 540 /*yCursorPosition*/,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- 100 /*downTime*/, 200 /*eventTime*/, pointerCount, pointerProperties,
- pointerCoords);
+ 280 /*xCursorPosition*/, 540 /*yCursorPosition*/, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, 100 /*downTime*/, 200 /*eventTime*/, pointerCount,
+ pointerProperties, pointerCoords);
return event;
}
diff --git a/libs/nativedisplay/AChoreographer.cpp b/libs/nativedisplay/AChoreographer.cpp
index 0edb213..2dd6c4f 100644
--- a/libs/nativedisplay/AChoreographer.cpp
+++ b/libs/nativedisplay/AChoreographer.cpp
@@ -20,7 +20,6 @@
#include <android-base/thread_annotations.h>
#include <gui/DisplayEventDispatcher.h>
#include <gui/ISurfaceComposer.h>
-#include <gui/SurfaceComposerClient.h>
#include <jni.h>
#include <private/android/choreographer.h>
#include <utils/Looper.h>