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/services/inputflinger/tests/Android.bp b/services/inputflinger/tests/Android.bp
index 918e1be..e686924 100644
--- a/services/inputflinger/tests/Android.bp
+++ b/services/inputflinger/tests/Android.bp
@@ -52,6 +52,7 @@
],
aidl: {
include_dirs: [
+ "frameworks/native/libs/gui",
"frameworks/native/libs/input",
],
},
diff --git a/services/inputflinger/tests/FocusResolver_test.cpp b/services/inputflinger/tests/FocusResolver_test.cpp
index 9051ff1..8c0edca 100644
--- a/services/inputflinger/tests/FocusResolver_test.cpp
+++ b/services/inputflinger/tests/FocusResolver_test.cpp
@@ -26,9 +26,12 @@
// atest inputflinger_tests:FocusResolverTest
+using android::gui::FocusRequest;
+using android::gui::WindowInfoHandle;
+
namespace android::inputdispatcher {
-class FakeWindowHandle : public InputWindowHandle {
+class FakeWindowHandle : public WindowInfoHandle {
public:
FakeWindowHandle(const std::string& name, const sp<IBinder>& token, bool focusable,
bool visible) {
@@ -47,7 +50,7 @@
sp<IBinder> focusableWindowToken = new BBinder();
sp<IBinder> invisibleWindowToken = new BBinder();
sp<IBinder> unfocusableWindowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
windows.push_back(new FakeWindowHandle("Focusable", focusableWindowToken, true /* focusable */,
true /* visible */));
windows.push_back(new FakeWindowHandle("Invisible", invisibleWindowToken, true /* focusable */,
@@ -82,7 +85,7 @@
sp<IBinder> focusableWindowToken = new BBinder();
sp<IBinder> invisibleWindowToken = new BBinder();
sp<IBinder> unfocusableWindowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
windows.push_back(new FakeWindowHandle("Mirror1", focusableWindowToken, true /* focusable */,
true /* visible */));
windows.push_back(new FakeWindowHandle("Mirror1", focusableWindowToken, true /* focusable */,
@@ -120,7 +123,7 @@
TEST(FocusResolverTest, SetInputWindows) {
sp<IBinder> focusableWindowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
sp<FakeWindowHandle> window = new FakeWindowHandle("Focusable", focusableWindowToken,
true /* focusable */, true /* visible */);
windows.push_back(window);
@@ -142,7 +145,7 @@
TEST(FocusResolverTest, FocusRequestsCanBePending) {
sp<IBinder> invisibleWindowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
sp<FakeWindowHandle> invisibleWindow =
new FakeWindowHandle("Invisible", invisibleWindowToken, true /* focusable */,
@@ -166,7 +169,7 @@
TEST(FocusResolverTest, FocusRequestsArePersistent) {
sp<IBinder> windowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
sp<FakeWindowHandle> window = new FakeWindowHandle("Test Window", windowToken,
false /* focusable */, true /* visible */);
@@ -207,7 +210,7 @@
TEST(FocusResolverTest, ConditionalFocusRequestsAreNotPersistent) {
sp<IBinder> hostWindowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
sp<FakeWindowHandle> hostWindow =
new FakeWindowHandle("Host Window", hostWindowToken, true /* focusable */,
@@ -258,7 +261,7 @@
}
TEST(FocusResolverTest, FocusRequestsAreClearedWhenWindowIsRemoved) {
sp<IBinder> windowToken = new BBinder();
- std::vector<sp<InputWindowHandle>> windows;
+ std::vector<sp<WindowInfoHandle>> windows;
sp<FakeWindowHandle> window = new FakeWindowHandle("Test Window", windowToken,
true /* focusable */, true /* visible */);
diff --git a/services/inputflinger/tests/IInputFlingerQuery.aidl b/services/inputflinger/tests/IInputFlingerQuery.aidl
index 5c8a8da..aff03bf 100644
--- a/services/inputflinger/tests/IInputFlingerQuery.aidl
+++ b/services/inputflinger/tests/IInputFlingerQuery.aidl
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-import android.FocusRequest;
import android.InputChannel;
-import android.InputWindowInfo;
+import android.gui.FocusRequest;
+import android.gui.WindowInfo;
import android.os.ISetInputWindowsListener;
/** @hide */
interface IInputFlingerQuery
{
/* Test interfaces */
- void getInputWindows(out InputWindowInfo[] inputHandles);
+ void getInputWindows(out WindowInfo[] inputHandles);
void getInputChannels(out InputChannel[] channels);
void getLastFocusRequest(out FocusRequest request);
void resetInputManager();
diff --git a/services/inputflinger/tests/InputClassifierConverter_test.cpp b/services/inputflinger/tests/InputClassifierConverter_test.cpp
index c0ada9d..f626d56 100644
--- a/services/inputflinger/tests/InputClassifierConverter_test.cpp
+++ b/services/inputflinger/tests/InputClassifierConverter_test.cpp
@@ -17,9 +17,9 @@
#include "../InputClassifierConverter.h"
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <utils/BitSet.h>
-
using namespace android::hardware::input;
namespace android {
diff --git a/services/inputflinger/tests/InputClassifier_test.cpp b/services/inputflinger/tests/InputClassifier_test.cpp
index a72df01..3a9994e 100644
--- a/services/inputflinger/tests/InputClassifier_test.cpp
+++ b/services/inputflinger/tests/InputClassifier_test.cpp
@@ -16,6 +16,7 @@
#include "../InputClassifier.h"
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include "TestInputListener.h"
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 09b6a79..86a1515 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -29,9 +29,12 @@
#include <vector>
using android::base::StringPrintf;
+using android::gui::FocusRequest;
+using android::gui::TouchOcclusionMode;
+using android::gui::WindowInfo;
+using android::gui::WindowInfoHandle;
using android::os::InputEventInjectionResult;
using android::os::InputEventInjectionSync;
-using android::os::TouchOcclusionMode;
using namespace android::flag_operators;
namespace android::inputdispatcher {
@@ -469,8 +472,8 @@
}
}
- void setFocusedWindow(const sp<InputWindowHandle>& window,
- const sp<InputWindowHandle>& focusedWindow = nullptr) {
+ void setFocusedWindow(const sp<WindowInfoHandle>& window,
+ const sp<WindowInfoHandle>& focusedWindow = nullptr) {
FocusRequest request;
request.token = window->getToken();
request.windowName = window->getName();
@@ -527,8 +530,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
/*action*/ -1, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -541,9 +544,8 @@
(1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, edgeFlags, metaState, 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,
- ARBITRARY_TIME, ARBITRARY_TIME, /*pointerCount*/ 1, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
+ /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
InputEventInjectionSync::NONE, 0ms, 0))
@@ -554,9 +556,8 @@
(~0U << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, edgeFlags, metaState, 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,
- ARBITRARY_TIME, ARBITRARY_TIME, /*pointerCount*/ 1, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
+ /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
InputEventInjectionSync::NONE, 0ms, 0))
@@ -568,9 +569,8 @@
(1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, edgeFlags, metaState, 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,
- ARBITRARY_TIME, ARBITRARY_TIME, /*pointerCount*/ 1, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
+ /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
InputEventInjectionSync::NONE, 0ms, 0))
@@ -581,9 +581,8 @@
(~0U << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, edgeFlags, metaState, 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,
- ARBITRARY_TIME, ARBITRARY_TIME, /*pointerCount*/ 1, pointerProperties,
- pointerCoords);
+ INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
+ /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
InputEventInjectionSync::NONE, 0ms, 0))
@@ -593,8 +592,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
AMOTION_EVENT_ACTION_DOWN, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 0, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -604,8 +603,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
AMOTION_EVENT_ACTION_DOWN, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ MAX_POINTERS + 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -617,8 +616,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
AMOTION_EVENT_ACTION_DOWN, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -629,8 +628,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
AMOTION_EVENT_ACTION_DOWN, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -643,8 +642,8 @@
event.initialize(InputEvent::nextId(), DEVICE_ID, source, DISPLAY_ID, INVALID_HMAC,
AMOTION_EVENT_ACTION_DOWN, 0, 0, edgeFlags, metaState, 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, ARBITRARY_TIME, ARBITRARY_TIME,
+ AMOTION_EVENT_INVALID_CURSOR_POSITION, INVALID_DISPLAY_SIZE,
+ INVALID_DISPLAY_SIZE, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 2, pointerProperties, pointerCoords);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, INJECTOR_PID, INJECTOR_UID,
@@ -892,7 +891,7 @@
std::string mName;
};
-class FakeWindowHandle : public InputWindowHandle {
+class FakeWindowHandle : public WindowInfoHandle {
public:
static const int32_t WIDTH = 600;
static const int32_t HEIGHT = 800;
@@ -914,7 +913,7 @@
mInfo.token = *token;
mInfo.id = sId++;
mInfo.name = name;
- mInfo.type = InputWindowInfo::Type::APPLICATION;
+ mInfo.type = WindowInfo::Type::APPLICATION;
mInfo.dispatchingTimeout = DISPATCHING_TIMEOUT;
mInfo.alpha = 1.0;
mInfo.frameLeft = 0;
@@ -948,9 +947,7 @@
void setAlpha(float alpha) { mInfo.alpha = alpha; }
- void setTouchOcclusionMode(android::os::TouchOcclusionMode mode) {
- mInfo.touchOcclusionMode = mode;
- }
+ void setTouchOcclusionMode(TouchOcclusionMode mode) { mInfo.touchOcclusionMode = mode; }
void setApplicationToken(sp<IBinder> token) { mInfo.applicationInfo.token = token; }
@@ -964,11 +961,11 @@
mInfo.addTouchableRegion(frame);
}
- void addFlags(Flags<InputWindowInfo::Flag> flags) { mInfo.flags |= flags; }
+ void addFlags(Flags<WindowInfo::Flag> flags) { mInfo.flags |= flags; }
- void setFlags(Flags<InputWindowInfo::Flag> flags) { mInfo.flags = flags; }
+ void setFlags(Flags<WindowInfo::Flag> flags) { mInfo.flags = flags; }
- void setInputFeatures(InputWindowInfo::Feature features) { mInfo.inputFeatures = features; }
+ void setInputFeatures(WindowInfo::Feature features) { mInfo.inputFeatures = features; }
void setWindowTransform(float dsdx, float dtdx, float dtdy, float dsdy) {
mInfo.transform.set(dsdx, dtdx, dtdy, dsdy);
@@ -1102,7 +1099,7 @@
void assertNoEvents() {
if (mInputReceiver == nullptr &&
- mInfo.inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL)) {
+ mInfo.inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL)) {
return; // Can't receive events if the window does not have input channel
}
ASSERT_NE(nullptr, mInputReceiver)
@@ -1283,8 +1280,8 @@
int32_t mFlags{0};
float mRawXCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
float mRawYCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
- int32_t mDisplayWidth{AMOTION_EVENT_INVALID_DISPLAY_SIZE};
- int32_t mDisplayHeight{AMOTION_EVENT_INVALID_DISPLAY_SIZE};
+ int32_t mDisplayWidth{INVALID_DISPLAY_SIZE};
+ int32_t mDisplayHeight{INVALID_DISPLAY_SIZE};
std::vector<PointerBuilder> mPointers;
};
@@ -1410,7 +1407,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
- window->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -1433,7 +1430,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
- window->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
@@ -1469,11 +1466,11 @@
sp<FakeWindowHandle> windowLeft =
new FakeWindowHandle(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- windowLeft->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowLeft->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
sp<FakeWindowHandle> windowRight =
new FakeWindowHandle(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- windowRight->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowRight->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -1580,7 +1577,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 1200, 800));
- window->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -1662,11 +1659,11 @@
sp<FakeWindowHandle> windowLeft =
new FakeWindowHandle(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- windowLeft->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowLeft->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
sp<FakeWindowHandle> windowRight =
new FakeWindowHandle(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- windowRight->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowRight->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -1860,15 +1857,13 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Create a non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -1934,15 +1929,13 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Create a non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -2060,15 +2053,13 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Create second non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -2736,8 +2727,7 @@
sp<FakeWindowHandle> slipperyExitWindow =
new FakeWindowHandle(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
- slipperyExitWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SLIPPERY);
+ slipperyExitWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SLIPPERY);
// Make sure this one overlaps the bottom window
slipperyExitWindow->setFrame(Rect(25, 25, 75, 75));
// Change the owner uid/pid of the window so that it is considered to be occluding the bottom
@@ -3221,12 +3211,12 @@
mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30));
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
- mUnfocusedWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ mUnfocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mFocusedWindow =
new FakeWindowHandle(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
- mFocusedWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ mFocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -3335,14 +3325,12 @@
ADISPLAY_ID_DEFAULT);
// Adding FLAG_NOT_TOUCH_MODAL otherwise all taps will go to the top most window.
// We also need FLAG_SPLIT_TOUCH or we won't be able to get touches for both windows.
- mWindow1->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ mWindow1->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
mWindow1->setFrame(Rect(0, 0, 100, 100));
mWindow2 = new FakeWindowHandle(application, mDispatcher, "Fake Window 2",
ADISPLAY_ID_DEFAULT, mWindow1->getToken());
- mWindow2->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ mWindow2->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
mWindow2->setFrame(Rect(100, 100, 200, 200));
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow1, mWindow2}}});
@@ -3353,7 +3341,7 @@
sp<FakeWindowHandle> mWindow2;
// Helper function to convert the point from screen coordinates into the window's space
- static PointF getPointInWindow(const InputWindowInfo* windowInfo, const PointF& point) {
+ static PointF getPointInWindow(const WindowInfo* windowInfo, const PointF& point) {
vec2 vals = windowInfo->transform.transform(point.x, point.y);
return {vals.x, vals.y};
}
@@ -3541,7 +3529,7 @@
mWindow->setFocusable(true);
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
- mWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ mWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
@@ -3942,16 +3930,15 @@
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
// Adding FLAG_WATCH_OUTSIDE_TOUCH to receive ACTION_OUTSIDE when another window is tapped
- mUnfocusedWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::WATCH_OUTSIDE_TOUCH |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ mUnfocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL |
+ WindowInfo::Flag::WATCH_OUTSIDE_TOUCH |
+ WindowInfo::Flag::SPLIT_TOUCH);
mFocusedWindow =
new FakeWindowHandle(mApplication, mDispatcher, "Focused", ADISPLAY_ID_DEFAULT);
mFocusedWindow->setDispatchingTimeout(30ms);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
- mFocusedWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL |
- InputWindowInfo::Flag::SPLIT_TOUCH);
+ mFocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
@@ -4319,7 +4306,7 @@
"Window without input channel", ADISPLAY_ID_DEFAULT,
std::make_optional<sp<IBinder>>(nullptr) /*token*/);
- mNoInputWindow->setInputFeatures(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
+ mNoInputWindow->setInputFeatures(WindowInfo::Feature::NO_INPUT_CHANNEL);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
// It's perfectly valid for this window to not have an associated input channel
@@ -4361,7 +4348,7 @@
"Window with input channel and NO_INPUT_CHANNEL",
ADISPLAY_ID_DEFAULT);
- mNoInputWindow->setInputFeatures(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
+ mNoInputWindow->setInputFeatures(WindowInfo::Feature::NO_INPUT_CHANNEL);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mNoInputWindow, mBottomWindow}}});
@@ -4661,10 +4648,10 @@
mTouchWindow.clear();
}
- sp<FakeWindowHandle> getOccludingWindow(int32_t uid, std::string name,
- os::TouchOcclusionMode mode, float alpha = 1.0f) {
+ sp<FakeWindowHandle> getOccludingWindow(int32_t uid, std::string name, TouchOcclusionMode mode,
+ float alpha = 1.0f) {
sp<FakeWindowHandle> window = getWindow(uid, name);
- window->setFlags(InputWindowInfo::Flag::NOT_TOUCHABLE);
+ window->setFlags(WindowInfo::Flag::NOT_TOUCHABLE);
window->setTouchOcclusionMode(mode);
window->setAlpha(alpha);
return window;
@@ -4778,7 +4765,7 @@
WindowWithZeroOpacityAndWatchOutside_ReceivesOutsideEvent) {
const sp<FakeWindowHandle>& w =
getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.0f);
- w->addFlags(InputWindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
+ w->addFlags(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
touch();
@@ -4789,7 +4776,7 @@
TEST_F(InputDispatcherUntrustedTouchesTest, OutsideEvent_HasZeroCoordinates) {
const sp<FakeWindowHandle>& w =
getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.0f);
- w->addFlags(InputWindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
+ w->addFlags(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
touch();
@@ -5043,11 +5030,11 @@
mApp = std::make_shared<FakeApplicationHandle>();
mWindow = new FakeWindowHandle(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
mWindow->setFrame(Rect(0, 0, 100, 100));
- mWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ mWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mSecondWindow = new FakeWindowHandle(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT);
mSecondWindow->setFrame(Rect(100, 0, 200, 100));
- mSecondWindow->setFlags(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ mSecondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow, mSecondWindow}}});
diff --git a/services/inputflinger/tests/InputFlingerService_test.cpp b/services/inputflinger/tests/InputFlingerService_test.cpp
index c368e79..d2a98df 100644
--- a/services/inputflinger/tests/InputFlingerService_test.cpp
+++ b/services/inputflinger/tests/InputFlingerService_test.cpp
@@ -28,9 +28,9 @@
#include <binder/Parcel.h>
#include <binder/ProcessState.h>
+#include <gui/WindowInfo.h>
#include <input/Input.h>
#include <input/InputTransport.h>
-#include <input/InputWindow.h>
#include <gtest/gtest.h>
#include <inttypes.h>
@@ -44,6 +44,9 @@
#define TAG "InputFlingerServiceTest"
+using android::gui::FocusRequest;
+using android::gui::WindowInfo;
+using android::gui::WindowInfoHandle;
using android::os::BnInputFlinger;
using android::os::BnSetInputWindowsListener;
using android::os::IInputFlinger;
@@ -58,8 +61,8 @@
static const sp<IBinder> FocusedTestInfoToken = new BBinder();
static constexpr int32_t TestInfoId = 1;
static const std::string TestInfoName = "InputFlingerServiceTestInputWindowInfo";
-static constexpr Flags<InputWindowInfo::Flag> TestInfoFlags = InputWindowInfo::Flag::NOT_FOCUSABLE;
-static constexpr InputWindowInfo::Type TestInfoType = InputWindowInfo::Type::INPUT_METHOD;
+static constexpr Flags<WindowInfo::Flag> TestInfoFlags = WindowInfo::Flag::NOT_FOCUSABLE;
+static constexpr WindowInfo::Type TestInfoType = WindowInfo::Type::INPUT_METHOD;
static constexpr std::chrono::duration TestInfoDispatchingTimeout = 2532ms;
static constexpr int32_t TestInfoFrameLeft = 93;
static constexpr int32_t TestInfoFrameTop = 34;
@@ -79,8 +82,7 @@
static constexpr bool TestInfoPaused = false;
static constexpr int32_t TestInfoOwnerPid = 19;
static constexpr int32_t TestInfoOwnerUid = 24;
-static constexpr InputWindowInfo::Feature TestInfoInputFeatures =
- InputWindowInfo::Feature::NO_INPUT_CHANNEL;
+static constexpr WindowInfo::Feature TestInfoInputFeatures = WindowInfo::Feature::NO_INPUT_CHANNEL;
static constexpr int32_t TestInfoDisplayId = 34;
static constexpr int32_t TestInfoPortalToDisplayId = 2;
static constexpr bool TestInfoReplaceTouchableRegionWithCrop = true;
@@ -102,13 +104,13 @@
protected:
void InitializeInputFlinger();
- void setInputWindowsByInfos(const std::vector<InputWindowInfo>& infos);
+ void setInputWindowsByInfos(const std::vector<WindowInfo>& infos);
void setFocusedWindow(const sp<IBinder> token, const sp<IBinder> focusedToken,
nsecs_t timestampNanos);
void setInputWindowsFinished();
- void verifyInputWindowInfo(const InputWindowInfo& info) const;
- InputWindowInfo& getInfo() const { return const_cast<InputWindowInfo&>(mInfo); }
+ void verifyInputWindowInfo(const WindowInfo& info) const;
+ WindowInfo& getInfo() const { return const_cast<WindowInfo&>(mInfo); }
sp<IInputFlinger> mService;
sp<IInputFlingerQuery> mQuery;
@@ -116,7 +118,7 @@
private:
sp<SetInputWindowsListener> mSetInputWindowsListener;
std::unique_ptr<InputChannel> mServerChannel, mClientChannel;
- InputWindowInfo mInfo;
+ WindowInfo mInfo;
std::mutex mLock;
std::condition_variable mSetInputWindowsFinishedCondition;
};
@@ -136,14 +138,14 @@
public:
TestInputManager(){};
- binder::Status getInputWindows(std::vector<::android::InputWindowInfo>* inputHandles);
+ binder::Status getInputWindows(std::vector<WindowInfo>* inputHandles);
binder::Status getInputChannels(std::vector<::android::InputChannel>* channels);
binder::Status getLastFocusRequest(FocusRequest*);
status_t dump(int fd, const Vector<String16>& args) override;
binder::Status setInputWindows(
- const std::vector<InputWindowInfo>& handles,
+ const std::vector<WindowInfo>& handles,
const sp<ISetInputWindowsListener>& setInputWindowsListener) override;
binder::Status createInputChannel(const std::string& name, InputChannel* outChannel) override;
@@ -154,7 +156,7 @@
private:
mutable Mutex mLock;
- std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mHandlesPerDisplay;
+ std::unordered_map<int32_t, std::vector<sp<WindowInfoHandle>>> mHandlesPerDisplay;
std::vector<std::shared_ptr<InputChannel>> mInputChannels;
FocusRequest mFocusRequest;
};
@@ -162,7 +164,7 @@
class TestInputQuery : public BnInputFlingerQuery {
public:
TestInputQuery(sp<android::TestInputManager> manager) : mManager(manager){};
- binder::Status getInputWindows(std::vector<::android::InputWindowInfo>* inputHandles) override;
+ binder::Status getInputWindows(std::vector<WindowInfo>* inputHandles) override;
binder::Status getInputChannels(std::vector<::android::InputChannel>* channels) override;
binder::Status getLastFocusRequest(FocusRequest*) override;
binder::Status resetInputManager() override;
@@ -171,8 +173,7 @@
sp<android::TestInputManager> mManager;
};
-binder::Status TestInputQuery::getInputWindows(
- std::vector<::android::InputWindowInfo>* inputHandles) {
+binder::Status TestInputQuery::getInputWindows(std::vector<WindowInfo>* inputHandles) {
return mManager->getInputWindows(inputHandles);
}
@@ -197,13 +198,13 @@
}
binder::Status TestInputManager::setInputWindows(
- const std::vector<InputWindowInfo>& infos,
+ const std::vector<WindowInfo>& infos,
const sp<ISetInputWindowsListener>& setInputWindowsListener) {
AutoMutex _l(mLock);
for (const auto& info : infos) {
- mHandlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>());
- mHandlesPerDisplay[info.displayId].push_back(new InputWindowHandle(info));
+ mHandlesPerDisplay.emplace(info.displayId, std::vector<sp<WindowInfoHandle>>());
+ mHandlesPerDisplay[info.displayId].push_back(new WindowInfoHandle(info));
}
if (setInputWindowsListener) {
setInputWindowsListener->onSetInputWindowsFinished();
@@ -248,8 +249,7 @@
return NO_ERROR;
}
-binder::Status TestInputManager::getInputWindows(
- std::vector<::android::InputWindowInfo>* inputInfos) {
+binder::Status TestInputManager::getInputWindows(std::vector<WindowInfo>* inputInfos) {
for (auto& [displayId, inputHandles] : mHandlesPerDisplay) {
for (auto& inputHandle : inputHandles) {
inputInfos->push_back(*inputHandle->getInfo());
@@ -331,7 +331,7 @@
mQuery->resetInputManager();
}
-void InputFlingerServiceTest::verifyInputWindowInfo(const InputWindowInfo& info) const {
+void InputFlingerServiceTest::verifyInputWindowInfo(const WindowInfo& info) const {
EXPECT_EQ(mInfo, info);
}
@@ -345,7 +345,7 @@
mQuery = interface_cast<IInputFlingerQuery>(input);
}
-void InputFlingerServiceTest::setInputWindowsByInfos(const std::vector<InputWindowInfo>& infos) {
+void InputFlingerServiceTest::setInputWindowsByInfos(const std::vector<WindowInfo>& infos) {
std::unique_lock<std::mutex> lock(mLock);
mService->setInputWindows(infos, mSetInputWindowsListener);
// Verify listener call
@@ -361,20 +361,20 @@
request.timestamp = timestampNanos;
mService->setFocusedWindow(request);
// call set input windows and wait for the callback to drain the queue.
- setInputWindowsByInfos(std::vector<InputWindowInfo>());
+ setInputWindowsByInfos(std::vector<WindowInfo>());
}
/**
* Test InputFlinger service interface SetInputWindows
*/
TEST_F(InputFlingerServiceTest, InputWindow_SetInputWindows) {
- std::vector<InputWindowInfo> infos = {getInfo()};
+ std::vector<WindowInfo> infos = {getInfo()};
setInputWindowsByInfos(infos);
// Verify input windows from service
- std::vector<::android::InputWindowInfo> windowInfos;
+ std::vector<WindowInfo> windowInfos;
mQuery->getInputWindows(&windowInfos);
- for (const ::android::InputWindowInfo& windowInfo : windowInfos) {
+ for (const WindowInfo& windowInfo : windowInfos) {
verifyInputWindowInfo(windowInfo);
}
}
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 73198bc..02423c4 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -32,6 +32,7 @@
#include <VibratorInputMapper.h>
#include <android-base/thread_annotations.h>
#include <gtest/gtest.h>
+#include <gui/constants.h>
#include <inttypes.h>
#include <math.h>