Merge "SF: Cleanup creating / destroying virtual display APIs" into main
diff --git a/cmds/cmd/fuzzer/cmd_fuzzer.cpp b/cmds/cmd/fuzzer/cmd_fuzzer.cpp
index ab514a1..72b295b 100644
--- a/cmds/cmd/fuzzer/cmd_fuzzer.cpp
+++ b/cmds/cmd/fuzzer/cmd_fuzzer.cpp
@@ -58,6 +58,12 @@
while (mFDP->remaining_bytes() > 0) {
size_t sizestr = mFDP->ConsumeIntegralInRange<size_t>(1, mFDP->remaining_bytes());
string argument = mFDP->ConsumeBytesAsString(sizestr);
+ /**
+ * Filtering out strings based on "-w" argument. Since it leads to timeout.
+ */
+ if(strcmp(argument.c_str(), "-w") == 0) {
+ continue;
+ }
arguments.emplace_back(argument);
}
}
diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp
index ba0a38a..a8d12a1 100644
--- a/cmds/dumpstate/DumpstateService.cpp
+++ b/cmds/dumpstate/DumpstateService.cpp
@@ -39,6 +39,7 @@
std::string calling_package;
int32_t user_id = -1;
bool keep_bugreport_on_retrieval = false;
+ bool skip_user_consent = false;
};
static binder::Status exception(uint32_t code, const std::string& msg,
@@ -62,7 +63,8 @@
[[noreturn]] static void* dumpstate_thread_retrieve(void* data) {
std::unique_ptr<DumpstateInfo> ds_info(static_cast<DumpstateInfo*>(data));
- ds_info->ds->Retrieve(ds_info->calling_uid, ds_info->calling_package, ds_info->keep_bugreport_on_retrieval);
+ ds_info->ds->Retrieve(ds_info->calling_uid, ds_info->calling_package,
+ ds_info->keep_bugreport_on_retrieval, ds_info->skip_user_consent);
MYLOGD("Finished retrieving a bugreport. Exiting.\n");
exit(0);
}
@@ -116,7 +118,8 @@
int bugreport_mode,
int bugreport_flags,
const sp<IDumpstateListener>& listener,
- bool is_screenshot_requested) {
+ bool is_screenshot_requested,
+ bool skip_user_consent) {
MYLOGI("startBugreport() with mode: %d\n", bugreport_mode);
// Ensure there is only one bugreport in progress at a time.
@@ -151,7 +154,7 @@
std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_flags,
- bugreport_fd, screenshot_fd, is_screenshot_requested);
+ bugreport_fd, screenshot_fd, is_screenshot_requested, skip_user_consent);
if (bugreport_fd.get() == -1 || (options->do_screenshot && screenshot_fd.get() == -1)) {
MYLOGE("Invalid filedescriptor");
@@ -207,6 +210,7 @@
android::base::unique_fd bugreport_fd,
const std::string& bugreport_file,
const bool keep_bugreport_on_retrieval,
+ const bool skip_user_consent,
const sp<IDumpstateListener>& listener) {
ds_ = &(Dumpstate::GetInstance());
@@ -216,6 +220,7 @@
ds_info->calling_package = calling_package;
ds_info->user_id = user_id;
ds_info->keep_bugreport_on_retrieval = keep_bugreport_on_retrieval;
+ ds_info->skip_user_consent = skip_user_consent;
ds_->listener_ = listener;
std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
// Use a /dev/null FD when initializing options since none is provided.
@@ -223,7 +228,7 @@
TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY | O_CLOEXEC)));
options->Initialize(Dumpstate::BugreportMode::BUGREPORT_DEFAULT,
- 0, bugreport_fd, devnull_fd, false);
+ 0, bugreport_fd, devnull_fd, false, skip_user_consent);
if (bugreport_fd.get() == -1) {
MYLOGE("Invalid filedescriptor");
diff --git a/cmds/dumpstate/DumpstateService.h b/cmds/dumpstate/DumpstateService.h
index 7b76c36..c99f70e 100644
--- a/cmds/dumpstate/DumpstateService.h
+++ b/cmds/dumpstate/DumpstateService.h
@@ -44,7 +44,7 @@
android::base::unique_fd bugreport_fd,
android::base::unique_fd screenshot_fd, int bugreport_mode,
int bugreport_flags, const sp<IDumpstateListener>& listener,
- bool is_screenshot_requested) override;
+ bool is_screenshot_requested, bool skip_user_consent) override;
binder::Status retrieveBugreport(int32_t calling_uid,
const std::string& calling_package,
@@ -52,6 +52,7 @@
android::base::unique_fd bugreport_fd,
const std::string& bugreport_file,
const bool keep_bugreport_on_retrieval,
+ const bool skip_user_consent,
const sp<IDumpstateListener>& listener)
override;
diff --git a/cmds/dumpstate/binder/android/os/IDumpstate.aidl b/cmds/dumpstate/binder/android/os/IDumpstate.aidl
index 97c470e..3b8fde9 100644
--- a/cmds/dumpstate/binder/android/os/IDumpstate.aidl
+++ b/cmds/dumpstate/binder/android/os/IDumpstate.aidl
@@ -96,7 +96,8 @@
void startBugreport(int callingUid, @utf8InCpp String callingPackage,
FileDescriptor bugreportFd, FileDescriptor screenshotFd,
int bugreportMode, int bugreportFlags,
- IDumpstateListener listener, boolean isScreenshotRequested);
+ IDumpstateListener listener, boolean isScreenshotRequested,
+ boolean skipUserConsent);
/**
* Cancels the bugreport currently in progress.
@@ -130,5 +131,6 @@
FileDescriptor bugreportFd,
@utf8InCpp String bugreportFile,
boolean keepBugreportOnRetrieval,
+ boolean skipUserConsent,
IDumpstateListener listener);
}
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 6b9a0a0..d5125f0 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2902,9 +2902,11 @@
int bugreport_flags,
const android::base::unique_fd& bugreport_fd_in,
const android::base::unique_fd& screenshot_fd_in,
- bool is_screenshot_requested) {
+ bool is_screenshot_requested,
+ bool skip_user_consent) {
this->use_predumped_ui_data = bugreport_flags & BugreportFlag::BUGREPORT_USE_PREDUMPED_UI_DATA;
this->is_consent_deferred = bugreport_flags & BugreportFlag::BUGREPORT_FLAG_DEFER_CONSENT;
+ this->skip_user_consent = skip_user_consent;
// Duplicate the fds because the passed in fds don't outlive the binder transaction.
bugreport_fd.reset(fcntl(bugreport_fd_in.get(), F_DUPFD_CLOEXEC, 0));
screenshot_fd.reset(fcntl(screenshot_fd_in.get(), F_DUPFD_CLOEXEC, 0));
@@ -2992,46 +2994,52 @@
}
Dumpstate::RunStatus Dumpstate::Retrieve(int32_t calling_uid, const std::string& calling_package,
- const bool keep_bugreport_on_retrieval) {
+ const bool keep_bugreport_on_retrieval,
+ const bool skip_user_consent) {
Dumpstate::RunStatus status = RetrieveInternal(calling_uid, calling_package,
- keep_bugreport_on_retrieval);
+ keep_bugreport_on_retrieval,
+ skip_user_consent);
HandleRunStatus(status);
return status;
}
Dumpstate::RunStatus Dumpstate::RetrieveInternal(int32_t calling_uid,
const std::string& calling_package,
- const bool keep_bugreport_on_retrieval) {
- consent_callback_ = new ConsentCallback();
- const String16 incidentcompanion("incidentcompanion");
- sp<android::IBinder> ics(
- defaultServiceManager()->checkService(incidentcompanion));
- android::String16 package(calling_package.c_str());
- if (ics != nullptr) {
- MYLOGD("Checking user consent via incidentcompanion service\n");
- android::interface_cast<android::os::IIncidentCompanion>(ics)->authorizeReport(
- calling_uid, package, String16(), String16(),
- 0x1 /* FLAG_CONFIRMATION_DIALOG */, consent_callback_.get());
- } else {
- MYLOGD(
- "Unable to check user consent; incidentcompanion service unavailable\n");
- return RunStatus::USER_CONSENT_TIMED_OUT;
- }
- UserConsentResult consent_result = consent_callback_->getResult();
- int timeout_ms = 30 * 1000;
- while (consent_result == UserConsentResult::UNAVAILABLE &&
- consent_callback_->getElapsedTimeMs() < timeout_ms) {
- sleep(1);
- consent_result = consent_callback_->getResult();
- }
- if (consent_result == UserConsentResult::DENIED) {
- return RunStatus::USER_CONSENT_DENIED;
- }
- if (consent_result == UserConsentResult::UNAVAILABLE) {
- MYLOGD("Canceling user consent request via incidentcompanion service\n");
- android::interface_cast<android::os::IIncidentCompanion>(ics)->cancelAuthorization(
- consent_callback_.get());
- return RunStatus::USER_CONSENT_TIMED_OUT;
+ const bool keep_bugreport_on_retrieval,
+ const bool skip_user_consent) {
+ if (!android::app::admin::flags::onboarding_consentless_bugreports() || !skip_user_consent) {
+ consent_callback_ = new ConsentCallback();
+ const String16 incidentcompanion("incidentcompanion");
+ sp<android::IBinder> ics(
+ defaultServiceManager()->checkService(incidentcompanion));
+ android::String16 package(calling_package.c_str());
+ if (ics != nullptr) {
+ MYLOGD("Checking user consent via incidentcompanion service\n");
+
+ android::interface_cast<android::os::IIncidentCompanion>(ics)->authorizeReport(
+ calling_uid, package, String16(), String16(),
+ 0x1 /* FLAG_CONFIRMATION_DIALOG */, consent_callback_.get());
+ } else {
+ MYLOGD(
+ "Unable to check user consent; incidentcompanion service unavailable\n");
+ return RunStatus::USER_CONSENT_TIMED_OUT;
+ }
+ UserConsentResult consent_result = consent_callback_->getResult();
+ int timeout_ms = 30 * 1000;
+ while (consent_result == UserConsentResult::UNAVAILABLE &&
+ consent_callback_->getElapsedTimeMs() < timeout_ms) {
+ sleep(1);
+ consent_result = consent_callback_->getResult();
+ }
+ if (consent_result == UserConsentResult::DENIED) {
+ return RunStatus::USER_CONSENT_DENIED;
+ }
+ if (consent_result == UserConsentResult::UNAVAILABLE) {
+ MYLOGD("Canceling user consent request via incidentcompanion service\n");
+ android::interface_cast<android::os::IIncidentCompanion>(ics)->cancelAuthorization(
+ consent_callback_.get());
+ return RunStatus::USER_CONSENT_TIMED_OUT;
+ }
}
bool copy_succeeded =
@@ -3510,7 +3518,9 @@
void Dumpstate::MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package) {
if (multiuser_get_app_id(calling_uid) == AID_SHELL ||
- !CalledByApi() || options_->is_consent_deferred) {
+ !CalledByApi() || options_->is_consent_deferred ||
+ (android::app::admin::flags::onboarding_consentless_bugreports() &&
+ options_->skip_user_consent)) {
// No need to get consent for shell triggered dumpstates, or not
// through bugreporting API (i.e. no fd to copy back), or when consent
// is deferred.
@@ -3596,7 +3606,8 @@
// If the caller has asked to copy the bugreport over to their directory, we need explicit
// user consent (unless the caller is Shell).
UserConsentResult consent_result;
- if (multiuser_get_app_id(calling_uid) == AID_SHELL) {
+ if (multiuser_get_app_id(calling_uid) == AID_SHELL || (options_->skip_user_consent
+ && android::app::admin::flags::onboarding_consentless_bugreports())) {
consent_result = UserConsentResult::APPROVED;
} else {
consent_result = consent_callback_->getResult();
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 46d949e..fcb8cf3 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -364,7 +364,7 @@
* Initialize() dumpstate before calling this method.
*/
RunStatus Retrieve(int32_t calling_uid, const std::string& calling_package,
- const bool keep_bugreport_on_retrieval);
+ const bool keep_bugreport_on_retrieval, const bool skip_user_consent);
@@ -412,6 +412,7 @@
bool do_screenshot = false;
bool is_screenshot_copied = false;
bool is_consent_deferred = false;
+ bool skip_user_consent = false;
bool is_remote_mode = false;
bool show_header_only = false;
bool telephony_only = false;
@@ -448,7 +449,8 @@
void Initialize(BugreportMode bugreport_mode, int bugreport_flags,
const android::base::unique_fd& bugreport_fd,
const android::base::unique_fd& screenshot_fd,
- bool is_screenshot_requested);
+ bool is_screenshot_requested,
+ bool skip_user_consent);
/* Returns true if the options set so far are consistent. */
bool ValidateOptions() const;
@@ -564,7 +566,8 @@
private:
RunStatus RunInternal(int32_t calling_uid, const std::string& calling_package);
RunStatus RetrieveInternal(int32_t calling_uid, const std::string& calling_package,
- const bool keep_bugreport_on_retrieval);
+ const bool keep_bugreport_on_retrieval,
+ const bool skip_user_consent);
RunStatus DumpstateDefaultAfterCritical();
RunStatus dumpstate();
diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
index ccf64fe..a29923a 100644
--- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
@@ -507,7 +507,7 @@
ds_binder->startBugreport(123, "com.example.package", std::move(bugreport_fd),
std::move(screenshot_fd),
Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE, flags, listener,
- true);
+ true, false);
// startBugreport is an async call. Verify binder call succeeded first, then wait till listener
// gets expected callbacks.
EXPECT_TRUE(status.isOk());
@@ -545,7 +545,7 @@
android::binder::Status status =
ds_binder->startBugreport(123, "com.example.package", std::move(bugreport_fd),
std::move(screenshot_fd), 2000, // invalid bugreport mode
- flags, listener, false);
+ flags, listener, false, false);
EXPECT_EQ(listener->getErrorCode(), IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
// The service should have died, freeing itself up for a new invocation.
@@ -579,7 +579,7 @@
ds_binder->startBugreport(123, "com.example.package", std::move(bugreport_fd),
std::move(screenshot_fd),
Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE, flags, listener1,
- true);
+ true, false);
EXPECT_TRUE(status.isOk());
// try to make another call to startBugreport. This should fail.
@@ -587,7 +587,7 @@
status = ds_binder->startBugreport(123, "com.example.package", std::move(bugreport_fd2),
std::move(screenshot_fd2),
Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE, flags,
- listener2, true);
+ listener2, true, false);
EXPECT_FALSE(status.isOk());
WaitTillExecutionComplete(listener2.get());
EXPECT_EQ(listener2->getErrorCode(),
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index 2afabed..18c2f94 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -239,7 +239,7 @@
}
TEST_F(DumpOptionsTest, InitializeFullBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_FULL, 0, fd, fd, true);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_FULL, 0, fd, fd, true, false);
EXPECT_TRUE(options_.do_screenshot);
// Other options retain default values
@@ -253,7 +253,7 @@
}
TEST_F(DumpOptionsTest, InitializeInteractiveBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE, 0, fd, fd, true);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE, 0, fd, fd, true, false);
EXPECT_TRUE(options_.do_progress_updates);
EXPECT_TRUE(options_.do_screenshot);
@@ -267,7 +267,7 @@
}
TEST_F(DumpOptionsTest, InitializeRemoteBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_REMOTE, 0, fd, fd, false);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_REMOTE, 0, fd, fd, false, false);
EXPECT_TRUE(options_.is_remote_mode);
EXPECT_FALSE(options_.do_vibrate);
EXPECT_FALSE(options_.do_screenshot);
@@ -281,7 +281,7 @@
}
TEST_F(DumpOptionsTest, InitializeWearBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_WEAR, 0, fd, fd, true);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_WEAR, 0, fd, fd, true, false);
EXPECT_TRUE(options_.do_screenshot);
EXPECT_TRUE(options_.do_progress_updates);
@@ -296,7 +296,7 @@
}
TEST_F(DumpOptionsTest, InitializeTelephonyBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_TELEPHONY, 0, fd, fd, false);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_TELEPHONY, 0, fd, fd, false, false);
EXPECT_FALSE(options_.do_screenshot);
EXPECT_TRUE(options_.telephony_only);
EXPECT_TRUE(options_.do_progress_updates);
@@ -311,7 +311,7 @@
}
TEST_F(DumpOptionsTest, InitializeWifiBugReport) {
- options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_WIFI, 0, fd, fd, false);
+ options_.Initialize(Dumpstate::BugreportMode::BUGREPORT_WIFI, 0, fd, fd, false, false);
EXPECT_FALSE(options_.do_screenshot);
EXPECT_TRUE(options_.wifi_only);
@@ -491,12 +491,12 @@
int flags = Dumpstate::BugreportFlag::BUGREPORT_USE_PREDUMPED_UI_DATA |
Dumpstate::BugreportFlag::BUGREPORT_FLAG_DEFER_CONSENT;
options_.Initialize(
- Dumpstate::BugreportMode::BUGREPORT_FULL, flags, fd, fd, true);
+ Dumpstate::BugreportMode::BUGREPORT_FULL, flags, fd, fd, true, false);
EXPECT_TRUE(options_.is_consent_deferred);
EXPECT_TRUE(options_.use_predumped_ui_data);
options_.Initialize(
- Dumpstate::BugreportMode::BUGREPORT_FULL, 0, fd, fd, true);
+ Dumpstate::BugreportMode::BUGREPORT_FULL, 0, fd, fd, true, false);
EXPECT_FALSE(options_.is_consent_deferred);
EXPECT_FALSE(options_.use_predumped_ui_data);
}
diff --git a/cmds/surfacereplayer/replayer/Replayer.cpp b/cmds/surfacereplayer/replayer/Replayer.cpp
deleted file mode 100644
index 44235cc..0000000
--- a/cmds/surfacereplayer/replayer/Replayer.cpp
+++ /dev/null
@@ -1,707 +0,0 @@
-/* Copyright 2016 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.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "SurfaceReplayer"
-
-#include "Replayer.h"
-
-#include <android/native_window.h>
-
-#include <android-base/file.h>
-
-#include <gui/BufferQueue.h>
-#include <gui/ISurfaceComposer.h>
-#include <gui/LayerState.h>
-#include <gui/Surface.h>
-#include <private/gui/ComposerService.h>
-
-#include <utils/Log.h>
-#include <utils/String8.h>
-#include <utils/Trace.h>
-
-#include <chrono>
-#include <cmath>
-#include <condition_variable>
-#include <cstdlib>
-#include <fstream>
-#include <functional>
-#include <iostream>
-#include <mutex>
-#include <sstream>
-#include <string>
-#include <thread>
-#include <vector>
-
-using namespace android;
-
-std::atomic_bool Replayer::sReplayingManually(false);
-
-Replayer::Replayer(const std::string& filename, bool replayManually, int numThreads, bool wait,
- nsecs_t stopHere)
- : mTrace(),
- mLoaded(false),
- mIncrementIndex(0),
- mCurrentTime(0),
- mNumThreads(numThreads),
- mWaitForTimeStamps(wait),
- mStopTimeStamp(stopHere) {
- srand(RAND_COLOR_SEED);
-
- std::string input;
- if (!android::base::ReadFileToString(filename, &input, true)) {
- std::cerr << "Trace did not load. Does " << filename << " exist?" << std::endl;
- abort();
- }
-
- mLoaded = mTrace.ParseFromString(input);
- if (!mLoaded) {
- std::cerr << "Trace did not load." << std::endl;
- abort();
- }
-
- mCurrentTime = mTrace.increment(0).time_stamp();
-
- sReplayingManually.store(replayManually);
-
- if (stopHere < 0) {
- mHasStopped = true;
- }
-}
-
-Replayer::Replayer(const Trace& t, bool replayManually, int numThreads, bool wait, nsecs_t stopHere)
- : mTrace(t),
- mLoaded(true),
- mIncrementIndex(0),
- mCurrentTime(0),
- mNumThreads(numThreads),
- mWaitForTimeStamps(wait),
- mStopTimeStamp(stopHere) {
- srand(RAND_COLOR_SEED);
- mCurrentTime = mTrace.increment(0).time_stamp();
-
- sReplayingManually.store(replayManually);
-
- if (stopHere < 0) {
- mHasStopped = true;
- }
-}
-
-status_t Replayer::replay() {
- signal(SIGINT, Replayer::stopAutoReplayHandler); //for manual control
-
- ALOGV("There are %d increments.", mTrace.increment_size());
-
- status_t status = loadSurfaceComposerClient();
-
- if (status != NO_ERROR) {
- ALOGE("Couldn't create SurfaceComposerClient (%d)", status);
- return status;
- }
-
- SurfaceComposerClient::enableVSyncInjections(true);
-
- initReplay();
-
- ALOGV("Starting actual Replay!");
- while (!mPendingIncrements.empty()) {
- mCurrentIncrement = mTrace.increment(mIncrementIndex);
-
- if (mHasStopped == false && mCurrentIncrement.time_stamp() >= mStopTimeStamp) {
- mHasStopped = true;
- sReplayingManually.store(true);
- }
-
- waitForConsoleCommmand();
-
- if (mWaitForTimeStamps) {
- waitUntilTimestamp(mCurrentIncrement.time_stamp());
- }
-
- auto event = mPendingIncrements.front();
- mPendingIncrements.pop();
-
- event->complete();
-
- if (event->getIncrementType() == Increment::kVsyncEvent) {
- mWaitingForNextVSync = false;
- }
-
- if (mIncrementIndex + mNumThreads < mTrace.increment_size()) {
- status = dispatchEvent(mIncrementIndex + mNumThreads);
-
- if (status != NO_ERROR) {
- SurfaceComposerClient::enableVSyncInjections(false);
- return status;
- }
- }
-
- mIncrementIndex++;
- mCurrentTime = mCurrentIncrement.time_stamp();
- }
-
- SurfaceComposerClient::enableVSyncInjections(false);
-
- return status;
-}
-
-status_t Replayer::initReplay() {
- for (int i = 0; i < mNumThreads && i < mTrace.increment_size(); i++) {
- status_t status = dispatchEvent(i);
-
- if (status != NO_ERROR) {
- ALOGE("Unable to dispatch event (%d)", status);
- return status;
- }
- }
-
- return NO_ERROR;
-}
-
-void Replayer::stopAutoReplayHandler(int /*signal*/) {
- if (sReplayingManually) {
- SurfaceComposerClient::enableVSyncInjections(false);
- exit(0);
- }
-
- sReplayingManually.store(true);
-}
-
-std::vector<std::string> split(const std::string& s, const char delim) {
- std::vector<std::string> elems;
- std::stringstream ss(s);
- std::string item;
- while (getline(ss, item, delim)) {
- elems.push_back(item);
- }
- return elems;
-}
-
-bool isNumber(const std::string& s) {
- return !s.empty() &&
- std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end();
-}
-
-void Replayer::waitForConsoleCommmand() {
- if (!sReplayingManually || mWaitingForNextVSync) {
- return;
- }
-
- while (true) {
- std::string input = "";
- std::cout << "> ";
- getline(std::cin, input);
-
- if (input.empty()) {
- input = mLastInput;
- } else {
- mLastInput = input;
- }
-
- if (mLastInput.empty()) {
- continue;
- }
-
- std::vector<std::string> inputs = split(input, ' ');
-
- if (inputs[0] == "n") { // next vsync
- mWaitingForNextVSync = true;
- break;
-
- } else if (inputs[0] == "ni") { // next increment
- break;
-
- } else if (inputs[0] == "c") { // continue
- if (inputs.size() > 1 && isNumber(inputs[1])) {
- long milliseconds = stoi(inputs[1]);
- std::thread([&] {
- std::cout << "Started!" << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
- sReplayingManually.store(true);
- std::cout << "Should have stopped!" << std::endl;
- }).detach();
- }
- sReplayingManually.store(false);
- mWaitingForNextVSync = false;
- break;
-
- } else if (inputs[0] == "s") { // stop at this timestamp
- if (inputs.size() < 1) {
- std::cout << "No time stamp given" << std::endl;
- continue;
- }
- sReplayingManually.store(false);
- mStopTimeStamp = stol(inputs[1]);
- mHasStopped = false;
- break;
- } else if (inputs[0] == "l") { // list
- std::cout << "Time stamp: " << mCurrentIncrement.time_stamp() << "\n";
- continue;
- } else if (inputs[0] == "q") { // quit
- SurfaceComposerClient::enableVSyncInjections(false);
- exit(0);
-
- } else if (inputs[0] == "h") { // help
- // add help menu
- std::cout << "Manual Replay options:\n";
- std::cout << " n - Go to next VSync\n";
- std::cout << " ni - Go to next increment\n";
- std::cout << " c - Continue\n";
- std::cout << " c [milliseconds] - Continue until specified number of milliseconds\n";
- std::cout << " s [timestamp] - Continue and stop at specified timestamp\n";
- std::cout << " l - List out timestamp of current increment\n";
- std::cout << " h - Display help menu\n";
- std::cout << std::endl;
- continue;
- }
-
- std::cout << "Invalid Command" << std::endl;
- }
-}
-
-status_t Replayer::dispatchEvent(int index) {
- auto increment = mTrace.increment(index);
- std::shared_ptr<Event> event = std::make_shared<Event>(increment.increment_case());
- mPendingIncrements.push(event);
-
- status_t status = NO_ERROR;
- switch (increment.increment_case()) {
- case increment.kTransaction: {
- std::thread(&Replayer::doTransaction, this, increment.transaction(), event).detach();
- } break;
- case increment.kSurfaceCreation: {
- std::thread(&Replayer::createSurfaceControl, this, increment.surface_creation(), event)
- .detach();
- } break;
- case increment.kBufferUpdate: {
- std::lock_guard<std::mutex> lock1(mLayerLock);
- std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock);
-
- Dimensions dimensions(increment.buffer_update().w(), increment.buffer_update().h());
- BufferEvent bufferEvent(event, dimensions);
-
- auto layerId = increment.buffer_update().id();
- if (mBufferQueueSchedulers.count(layerId) == 0) {
- mBufferQueueSchedulers[layerId] = std::make_shared<BufferQueueScheduler>(
- mLayers[layerId], mColors[layerId], layerId);
- mBufferQueueSchedulers[layerId]->addEvent(bufferEvent);
-
- std::thread(&BufferQueueScheduler::startScheduling,
- mBufferQueueSchedulers[increment.buffer_update().id()].get())
- .detach();
- } else {
- auto bqs = mBufferQueueSchedulers[increment.buffer_update().id()];
- bqs->addEvent(bufferEvent);
- }
- } break;
- case increment.kVsyncEvent: {
- std::thread(&Replayer::injectVSyncEvent, this, increment.vsync_event(), event).detach();
- } break;
- case increment.kDisplayCreation: {
- std::thread(&Replayer::createDisplay, this, increment.display_creation(), event)
- .detach();
- } break;
- case increment.kDisplayDeletion: {
- std::thread(&Replayer::deleteDisplay, this, increment.display_deletion(), event)
- .detach();
- } break;
- case increment.kPowerModeUpdate: {
- std::thread(&Replayer::updatePowerMode, this, increment.power_mode_update(), event)
- .detach();
- } break;
- default:
- ALOGE("Unknown Increment Type: %d", increment.increment_case());
- status = BAD_VALUE;
- break;
- }
-
- return status;
-}
-
-status_t Replayer::doTransaction(const Transaction& t, const std::shared_ptr<Event>& event) {
- ALOGV("Started Transaction");
-
- SurfaceComposerClient::Transaction liveTransaction;
-
- status_t status = NO_ERROR;
-
- status = doSurfaceTransaction(liveTransaction, t.surface_change());
- doDisplayTransaction(liveTransaction, t.display_change());
-
- if (t.animation()) {
- liveTransaction.setAnimationTransaction();
- }
-
- event->readyToExecute();
-
- liveTransaction.apply(t.synchronous());
-
- ALOGV("Ended Transaction");
-
- return status;
-}
-
-status_t Replayer::doSurfaceTransaction(
- SurfaceComposerClient::Transaction& transaction,
- const SurfaceChanges& surfaceChanges) {
- status_t status = NO_ERROR;
-
- for (const SurfaceChange& change : surfaceChanges) {
- std::unique_lock<std::mutex> lock(mLayerLock);
- if (mLayers[change.id()] == nullptr) {
- mLayerCond.wait(lock, [&] { return (mLayers[change.id()] != nullptr); });
- }
-
- switch (change.SurfaceChange_case()) {
- case SurfaceChange::SurfaceChangeCase::kPosition:
- setPosition(transaction, change.id(), change.position());
- break;
- case SurfaceChange::SurfaceChangeCase::kSize:
- setSize(transaction, change.id(), change.size());
- break;
- case SurfaceChange::SurfaceChangeCase::kAlpha:
- setAlpha(transaction, change.id(), change.alpha());
- break;
- case SurfaceChange::SurfaceChangeCase::kLayer:
- setLayer(transaction, change.id(), change.layer());
- break;
- case SurfaceChange::SurfaceChangeCase::kCrop:
- setCrop(transaction, change.id(), change.crop());
- break;
- case SurfaceChange::SurfaceChangeCase::kCornerRadius:
- setCornerRadius(transaction, change.id(), change.corner_radius());
- break;
- case SurfaceChange::SurfaceChangeCase::kMatrix:
- setMatrix(transaction, change.id(), change.matrix());
- break;
- case SurfaceChange::SurfaceChangeCase::kTransparentRegionHint:
- setTransparentRegionHint(transaction, change.id(),
- change.transparent_region_hint());
- break;
- case SurfaceChange::SurfaceChangeCase::kLayerStack:
- setLayerStack(transaction, change.id(), change.layer_stack());
- break;
- case SurfaceChange::SurfaceChangeCase::kHiddenFlag:
- setHiddenFlag(transaction, change.id(), change.hidden_flag());
- break;
- case SurfaceChange::SurfaceChangeCase::kOpaqueFlag:
- setOpaqueFlag(transaction, change.id(), change.opaque_flag());
- break;
- case SurfaceChange::SurfaceChangeCase::kSecureFlag:
- setSecureFlag(transaction, change.id(), change.secure_flag());
- break;
- case SurfaceChange::SurfaceChangeCase::kReparent:
- setReparentChange(transaction, change.id(), change.reparent());
- break;
- case SurfaceChange::SurfaceChangeCase::kRelativeParent:
- setRelativeParentChange(transaction, change.id(), change.relative_parent());
- break;
- case SurfaceChange::SurfaceChangeCase::kShadowRadius:
- setShadowRadiusChange(transaction, change.id(), change.shadow_radius());
- break;
- case SurfaceChange::SurfaceChangeCase::kBlurRegions:
- setBlurRegionsChange(transaction, change.id(), change.blur_regions());
- break;
- default:
- status = 1;
- break;
- }
-
- if (status != NO_ERROR) {
- ALOGE("Unknown Transaction Code");
- return status;
- }
- }
- return status;
-}
-
-void Replayer::doDisplayTransaction(SurfaceComposerClient::Transaction& t,
- const DisplayChanges& displayChanges) {
- for (const DisplayChange& change : displayChanges) {
- ALOGV("Doing display transaction");
- std::unique_lock<std::mutex> lock(mDisplayLock);
- if (mDisplays[change.id()] == nullptr) {
- mDisplayCond.wait(lock, [&] { return (mDisplays[change.id()] != nullptr); });
- }
-
- switch (change.DisplayChange_case()) {
- case DisplayChange::DisplayChangeCase::kSurface:
- setDisplaySurface(t, change.id(), change.surface());
- break;
- case DisplayChange::DisplayChangeCase::kLayerStack:
- setDisplayLayerStack(t, change.id(), change.layer_stack());
- break;
- case DisplayChange::DisplayChangeCase::kSize:
- setDisplaySize(t, change.id(), change.size());
- break;
- case DisplayChange::DisplayChangeCase::kProjection:
- setDisplayProjection(t, change.id(), change.projection());
- break;
- default:
- break;
- }
- }
-}
-
-void Replayer::setPosition(SurfaceComposerClient::Transaction& t,
- layer_id id, const PositionChange& pc) {
- ALOGV("Layer %d: Setting Position -- x=%f, y=%f", id, pc.x(), pc.y());
- t.setPosition(mLayers[id], pc.x(), pc.y());
-}
-
-void Replayer::setSize(SurfaceComposerClient::Transaction& t,
- layer_id id, const SizeChange& sc) {
- ALOGV("Layer %d: Setting Size -- w=%u, h=%u", id, sc.w(), sc.h());
-}
-
-void Replayer::setLayer(SurfaceComposerClient::Transaction& t,
- layer_id id, const LayerChange& lc) {
- ALOGV("Layer %d: Setting Layer -- layer=%d", id, lc.layer());
- t.setLayer(mLayers[id], lc.layer());
-}
-
-void Replayer::setAlpha(SurfaceComposerClient::Transaction& t,
- layer_id id, const AlphaChange& ac) {
- ALOGV("Layer %d: Setting Alpha -- alpha=%f", id, ac.alpha());
- t.setAlpha(mLayers[id], ac.alpha());
-}
-
-void Replayer::setCrop(SurfaceComposerClient::Transaction& t,
- layer_id id, const CropChange& cc) {
- ALOGV("Layer %d: Setting Crop -- left=%d, top=%d, right=%d, bottom=%d", id,
- cc.rectangle().left(), cc.rectangle().top(), cc.rectangle().right(),
- cc.rectangle().bottom());
-
- Rect r = Rect(cc.rectangle().left(), cc.rectangle().top(), cc.rectangle().right(),
- cc.rectangle().bottom());
- t.setCrop(mLayers[id], r);
-}
-
-void Replayer::setCornerRadius(SurfaceComposerClient::Transaction& t,
- layer_id id, const CornerRadiusChange& cc) {
- ALOGV("Layer %d: Setting Corner Radius -- cornerRadius=%d", id, cc.corner_radius());
-
- t.setCornerRadius(mLayers[id], cc.corner_radius());
-}
-
-void Replayer::setBackgroundBlurRadius(SurfaceComposerClient::Transaction& t,
- layer_id id, const BackgroundBlurRadiusChange& cc) {
- ALOGV("Layer %d: Setting Background Blur Radius -- backgroundBlurRadius=%d", id,
- cc.background_blur_radius());
-
- t.setBackgroundBlurRadius(mLayers[id], cc.background_blur_radius());
-}
-
-void Replayer::setMatrix(SurfaceComposerClient::Transaction& t,
- layer_id id, const MatrixChange& mc) {
- ALOGV("Layer %d: Setting Matrix -- dsdx=%f, dtdx=%f, dsdy=%f, dtdy=%f", id, mc.dsdx(),
- mc.dtdx(), mc.dsdy(), mc.dtdy());
- t.setMatrix(mLayers[id], mc.dsdx(), mc.dtdx(), mc.dsdy(), mc.dtdy());
-}
-
-void Replayer::setTransparentRegionHint(SurfaceComposerClient::Transaction& t,
- layer_id id, const TransparentRegionHintChange& trhc) {
- ALOGV("Setting Transparent Region Hint");
- Region re = Region();
-
- for (const auto& r : trhc.region()) {
- Rect rect = Rect(r.left(), r.top(), r.right(), r.bottom());
- re.merge(rect);
- }
-
- t.setTransparentRegionHint(mLayers[id], re);
-}
-
-void Replayer::setLayerStack(SurfaceComposerClient::Transaction& t,
- layer_id id, const LayerStackChange& lsc) {
- ALOGV("Layer %d: Setting LayerStack -- layer_stack=%d", id, lsc.layer_stack());
- t.setLayerStack(mLayers[id], ui::LayerStack::fromValue(lsc.layer_stack()));
-}
-
-void Replayer::setHiddenFlag(SurfaceComposerClient::Transaction& t,
- layer_id id, const HiddenFlagChange& hfc) {
- ALOGV("Layer %d: Setting Hidden Flag -- hidden_flag=%d", id, hfc.hidden_flag());
- layer_id flag = hfc.hidden_flag() ? layer_state_t::eLayerHidden : 0;
-
- t.setFlags(mLayers[id], flag, layer_state_t::eLayerHidden);
-}
-
-void Replayer::setOpaqueFlag(SurfaceComposerClient::Transaction& t,
- layer_id id, const OpaqueFlagChange& ofc) {
- ALOGV("Layer %d: Setting Opaque Flag -- opaque_flag=%d", id, ofc.opaque_flag());
- layer_id flag = ofc.opaque_flag() ? layer_state_t::eLayerOpaque : 0;
-
- t.setFlags(mLayers[id], flag, layer_state_t::eLayerOpaque);
-}
-
-void Replayer::setSecureFlag(SurfaceComposerClient::Transaction& t,
- layer_id id, const SecureFlagChange& sfc) {
- ALOGV("Layer %d: Setting Secure Flag -- secure_flag=%d", id, sfc.secure_flag());
- layer_id flag = sfc.secure_flag() ? layer_state_t::eLayerSecure : 0;
-
- t.setFlags(mLayers[id], flag, layer_state_t::eLayerSecure);
-}
-
-void Replayer::setDisplaySurface(SurfaceComposerClient::Transaction& t,
- display_id id, const DispSurfaceChange& /*dsc*/) {
- sp<IGraphicBufferProducer> outProducer;
- sp<IGraphicBufferConsumer> outConsumer;
- BufferQueue::createBufferQueue(&outProducer, &outConsumer);
-
- t.setDisplaySurface(mDisplays[id], outProducer);
-}
-
-void Replayer::setDisplayLayerStack(SurfaceComposerClient::Transaction& t,
- display_id id, const LayerStackChange& lsc) {
- t.setDisplayLayerStack(mDisplays[id], ui::LayerStack::fromValue(lsc.layer_stack()));
-}
-
-void Replayer::setDisplaySize(SurfaceComposerClient::Transaction& t,
- display_id id, const SizeChange& sc) {
- t.setDisplaySize(mDisplays[id], sc.w(), sc.h());
-}
-
-void Replayer::setDisplayProjection(SurfaceComposerClient::Transaction& t,
- display_id id, const ProjectionChange& pc) {
- Rect viewport = Rect(pc.viewport().left(), pc.viewport().top(), pc.viewport().right(),
- pc.viewport().bottom());
- Rect frame = Rect(pc.frame().left(), pc.frame().top(), pc.frame().right(), pc.frame().bottom());
-
- t.setDisplayProjection(mDisplays[id], ui::toRotation(pc.orientation()), viewport, frame);
-}
-
-status_t Replayer::createSurfaceControl(
- const SurfaceCreation& create, const std::shared_ptr<Event>& event) {
- event->readyToExecute();
-
- ALOGV("Creating Surface Control: ID: %d", create.id());
- sp<SurfaceControl> surfaceControl = mComposerClient->createSurface(
- String8(create.name().c_str()), create.w(), create.h(), PIXEL_FORMAT_RGBA_8888, 0);
-
- if (surfaceControl == nullptr) {
- ALOGE("CreateSurfaceControl: unable to create surface control");
- return BAD_VALUE;
- }
-
- std::lock_guard<std::mutex> lock1(mLayerLock);
- auto& layer = mLayers[create.id()];
- layer = surfaceControl;
-
- mColors[create.id()] = HSV(rand() % 360, 1, 1);
-
- mLayerCond.notify_all();
-
- std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock);
- if (mBufferQueueSchedulers.count(create.id()) != 0) {
- mBufferQueueSchedulers[create.id()]->setSurfaceControl(
- mLayers[create.id()], mColors[create.id()]);
- }
-
- return NO_ERROR;
-}
-
-status_t Replayer::injectVSyncEvent(
- const VSyncEvent& vSyncEvent, const std::shared_ptr<Event>& event) {
- ALOGV("Injecting VSync Event");
-
- event->readyToExecute();
-
- SurfaceComposerClient::injectVSync(vSyncEvent.when());
-
- return NO_ERROR;
-}
-
-void Replayer::createDisplay(const DisplayCreation& create, const std::shared_ptr<Event>& event) {
- ALOGV("Creating display");
- event->readyToExecute();
-
- std::lock_guard<std::mutex> lock(mDisplayLock);
- sp<IBinder> display = SurfaceComposerClient::createDisplay(
- String8(create.name().c_str()), create.is_secure());
- mDisplays[create.id()] = display;
-
- mDisplayCond.notify_all();
-
- ALOGV("Done creating display");
-}
-
-void Replayer::deleteDisplay(const DisplayDeletion& delete_, const std::shared_ptr<Event>& event) {
- ALOGV("Delete display");
- event->readyToExecute();
-
- std::lock_guard<std::mutex> lock(mDisplayLock);
- SurfaceComposerClient::destroyDisplay(mDisplays[delete_.id()]);
- mDisplays.erase(delete_.id());
-}
-
-void Replayer::updatePowerMode(const PowerModeUpdate& pmu, const std::shared_ptr<Event>& event) {
- ALOGV("Updating power mode");
- event->readyToExecute();
- SurfaceComposerClient::setDisplayPowerMode(mDisplays[pmu.id()], pmu.mode());
-}
-
-void Replayer::waitUntilTimestamp(int64_t timestamp) {
- ALOGV("Waiting for %lld nanoseconds...", static_cast<int64_t>(timestamp - mCurrentTime));
- std::this_thread::sleep_for(std::chrono::nanoseconds(timestamp - mCurrentTime));
-}
-
-status_t Replayer::loadSurfaceComposerClient() {
- mComposerClient = new SurfaceComposerClient;
- return mComposerClient->initCheck();
-}
-
-void Replayer::setReparentChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const ReparentChange& c) {
- sp<SurfaceControl> newSurfaceControl = nullptr;
- if (mLayers.count(c.parent_id()) != 0 && mLayers[c.parent_id()] != nullptr) {
- newSurfaceControl = mLayers[c.parent_id()];
- }
- t.reparent(mLayers[id], newSurfaceControl);
-}
-
-void Replayer::setRelativeParentChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const RelativeParentChange& c) {
- if (mLayers.count(c.relative_parent_id()) == 0 || mLayers[c.relative_parent_id()] == nullptr) {
- ALOGE("Layer %d not found in set relative parent transaction", c.relative_parent_id());
- return;
- }
- t.setRelativeLayer(mLayers[id], mLayers[c.relative_parent_id()], c.z());
-}
-
-void Replayer::setShadowRadiusChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const ShadowRadiusChange& c) {
- t.setShadowRadius(mLayers[id], c.radius());
-}
-
-void Replayer::setBlurRegionsChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const BlurRegionsChange& c) {
- std::vector<BlurRegion> regions;
- for(size_t i=0; i < c.blur_regions_size(); i++) {
- auto protoRegion = c.blur_regions(i);
- regions.push_back(BlurRegion{
- .blurRadius = protoRegion.blur_radius(),
- .alpha = protoRegion.alpha(),
- .cornerRadiusTL = protoRegion.corner_radius_tl(),
- .cornerRadiusTR = protoRegion.corner_radius_tr(),
- .cornerRadiusBL = protoRegion.corner_radius_bl(),
- .cornerRadiusBR = protoRegion.corner_radius_br(),
- .left = protoRegion.left(),
- .top = protoRegion.top(),
- .right = protoRegion.right(),
- .bottom = protoRegion.bottom()
- });
- }
- t.setBlurRegions(mLayers[id], regions);
-}
diff --git a/include/ftl/concat.h b/include/ftl/concat.h
index e0774d3..7680bed 100644
--- a/include/ftl/concat.h
+++ b/include/ftl/concat.h
@@ -57,7 +57,7 @@
template <std::size_t N>
struct Concat<N> {
static constexpr std::size_t max_size() { return N; }
- constexpr std::size_t size() const { return end_ - buffer_; }
+ constexpr std::size_t size() const { return static_cast<std::size_t>(end_ - buffer_); }
constexpr const char* c_str() const { return buffer_; }
@@ -68,6 +68,8 @@
protected:
constexpr Concat() : end_(buffer_) {}
+ constexpr Concat(const Concat&) = delete;
+
constexpr void append() { *end_ = '\0'; }
char buffer_[N + 1];
diff --git a/include/ftl/expected.h b/include/ftl/expected.h
index 12b6102..57448dc 100644
--- a/include/ftl/expected.h
+++ b/include/ftl/expected.h
@@ -18,9 +18,57 @@
#include <android-base/expected.h>
#include <ftl/optional.h>
+#include <ftl/unit.h>
#include <utility>
+// Given an expression `expr` that evaluates to an ftl::Expected<T, E> result (R for short), FTL_TRY
+// unwraps T out of R, or bails out of the enclosing function F if R has an error E. The return type
+// of F must be R, since FTL_TRY propagates R in the error case. As a special case, ftl::Unit may be
+// used as the error E to allow FTL_TRY expressions when F returns `void`.
+//
+// The non-standard syntax requires `-Wno-gnu-statement-expression-from-macro-expansion` to compile.
+// The UnitToVoid conversion allows the macro to be used for early exit from a function that returns
+// `void`.
+//
+// Example usage:
+//
+// using StringExp = ftl::Expected<std::string, std::errc>;
+//
+// StringExp repeat(StringExp exp) {
+// const std::string str = FTL_TRY(exp);
+// return StringExp(str + str);
+// }
+//
+// assert(StringExp("haha"s) == repeat(StringExp("ha"s)));
+// assert(repeat(ftl::Unexpected(std::errc::bad_message)).has_error([](std::errc e) {
+// return e == std::errc::bad_message;
+// }));
+//
+//
+// FTL_TRY may be used in void-returning functions by using ftl::Unit as the error type:
+//
+// void uppercase(char& c, ftl::Optional<char> opt) {
+// c = std::toupper(FTL_TRY(std::move(opt).ok_or(ftl::Unit())));
+// }
+//
+// char c = '?';
+// uppercase(c, std::nullopt);
+// assert(c == '?');
+//
+// uppercase(c, 'a');
+// assert(c == 'A');
+//
+#define FTL_TRY(expr) \
+ ({ \
+ auto exp_ = (expr); \
+ if (!exp_.has_value()) { \
+ using E = decltype(exp_)::error_type; \
+ return android::ftl::details::UnitToVoid<E>::from(std::move(exp_)); \
+ } \
+ exp_.value(); \
+ })
+
namespace android::ftl {
// Superset of base::expected<T, E> with monadic operations.
diff --git a/include/ftl/optional.h b/include/ftl/optional.h
index 94d8e3d..e245d88 100644
--- a/include/ftl/optional.h
+++ b/include/ftl/optional.h
@@ -20,13 +20,14 @@
#include <optional>
#include <utility>
+#include <android-base/expected.h>
#include <ftl/details/optional.h>
namespace android::ftl {
// Superset of std::optional<T> with monadic operations, as proposed in https://wg21.link/P0798R8.
//
-// TODO: Remove in C++23.
+// TODO: Remove standard APIs in C++23.
//
template <typename T>
struct Optional final : std::optional<T> {
@@ -109,6 +110,13 @@
return std::forward<F>(f)();
}
+ // Maps this Optional<T> to expected<T, E> where nullopt becomes E.
+ template <typename E>
+ constexpr auto ok_or(E&& e) && -> base::expected<T, E> {
+ if (has_value()) return std::move(value());
+ return base::unexpected(std::forward<E>(e));
+ }
+
// Delete new for this class. Its base doesn't have a virtual destructor, and
// if it got deleted via base class pointer, it would cause undefined
// behavior. There's not a good reason to allocate this object on the heap
diff --git a/include/ftl/unit.h b/include/ftl/unit.h
index e38230b..62549a3 100644
--- a/include/ftl/unit.h
+++ b/include/ftl/unit.h
@@ -58,4 +58,22 @@
return {std::forward<F>(f)};
}
+namespace details {
+
+// Identity function for all T except Unit, which maps to void.
+template <typename T>
+struct UnitToVoid {
+ template <typename U>
+ static auto from(U&& value) {
+ return value;
+ }
+};
+
+template <>
+struct UnitToVoid<Unit> {
+ template <typename U>
+ static void from(U&&) {}
+};
+
+} // namespace details
} // namespace android::ftl
diff --git a/include/input/DisplayViewport.h b/include/input/DisplayViewport.h
index 97c2ab8..56294dd 100644
--- a/include/input/DisplayViewport.h
+++ b/include/input/DisplayViewport.h
@@ -46,7 +46,7 @@
* See com.android.server.display.DisplayViewport.
*/
struct DisplayViewport {
- ui::LogicalDisplayId displayId; // ADISPLAY_ID_NONE if invalid
+ ui::LogicalDisplayId displayId;
ui::Rotation orientation;
int32_t logicalLeft;
int32_t logicalTop;
@@ -66,7 +66,7 @@
ViewportType type;
DisplayViewport()
- : displayId(ui::ADISPLAY_ID_NONE),
+ : displayId(ui::LogicalDisplayId::INVALID),
orientation(ui::ROTATION_0),
logicalLeft(0),
logicalTop(0),
@@ -101,7 +101,7 @@
inline bool isValid() const { return displayId.isValid(); }
void setNonDisplayViewport(int32_t width, int32_t height) {
- displayId = ui::ADISPLAY_ID_NONE;
+ displayId = ui::LogicalDisplayId::INVALID;
orientation = ui::ROTATION_0;
logicalLeft = 0;
logicalTop = 0;
diff --git a/include/input/Input.h b/include/input/Input.h
index 092a698..3ca9c19 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -41,13 +41,11 @@
* Additional private constants not defined in ndk/ui/input.h.
*/
enum {
-#ifdef __linux__
+
/* This event was generated or modified by accessibility service. */
AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
-#else
- AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
-#endif
+
/* Signifies that the key is being predispatched */
AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000,
@@ -90,15 +88,11 @@
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE =
android::os::IInputConstants::MOTION_EVENT_FLAG_NO_FOCUS_CHANGE,
-#if defined(__linux__)
/**
* This event was generated or modified by accessibility service.
*/
AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
-#else
- AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
-#endif
AMOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS =
android::os::IInputConstants::MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS,
@@ -204,9 +198,7 @@
namespace android {
-#ifdef __linux__
class Parcel;
-#endif
/*
* Apply the given transform to the point without applying any translation/offset.
@@ -312,12 +304,8 @@
POLICY_FLAG_RAW_MASK = 0x0000ffff,
-#ifdef __linux__
POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY =
android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY,
-#else
- POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000,
-#endif
/* These flags are set by the input dispatcher. */
@@ -486,10 +474,8 @@
vec2 getXYValue() const { return vec2(getX(), getY()); }
-#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
-#endif
bool operator==(const PointerCoords& other) const;
inline bool operator!=(const PointerCoords& other) const {
@@ -567,7 +553,7 @@
int32_t mId;
DeviceId mDeviceId;
uint32_t mSource;
- ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::INVALID};
std::array<uint8_t, 32> mHmac;
};
@@ -912,10 +898,8 @@
// Matrix is in row-major form and compatible with SkMatrix.
void applyTransform(const std::array<float, 9>& matrix);
-#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
-#endif
static bool isTouchEvent(uint32_t source, int32_t action);
inline bool isTouchEvent() const {
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 8783d9c..7d8c19e 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -366,7 +366,7 @@
int32_t mKeyboardType;
std::shared_ptr<KeyCharacterMap> mKeyCharacterMap;
std::optional<InputDeviceUsiVersion> mUsiVersion;
- ui::LogicalDisplayId mAssociatedDisplayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId mAssociatedDisplayId{ui::LogicalDisplayId::INVALID};
bool mEnabled;
bool mHasVibrator;
diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h
index 837e70e..25d35e9 100644
--- a/include/input/InputEventBuilders.h
+++ b/include/input/InputEventBuilders.h
@@ -158,7 +158,7 @@
int32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
int32_t mActionButton{0};
int32_t mButtonState{0};
int32_t mFlags{0};
@@ -247,7 +247,7 @@
uint32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS;
int32_t mFlags{0};
int32_t mKeyCode{AKEYCODE_UNKNOWN};
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index dfcf766..92d5ec4 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -19,9 +19,7 @@
#include <stdint.h>
#include <list>
-#ifdef __linux__
#include <binder/IBinder.h>
-#endif
#include <android-base/result.h>
#include <input/Input.h>
@@ -144,13 +142,11 @@
std::pair<int32_t /*keyCode*/, int32_t /*metaState*/> applyKeyBehavior(int32_t keyCode,
int32_t metaState) const;
-#ifdef __linux__
/* Reads a key map from a parcel. */
static std::unique_ptr<KeyCharacterMap> readFromParcel(Parcel* parcel);
/* Writes a key map to a parcel. */
void writeToParcel(Parcel* parcel) const;
-#endif
bool operator==(const KeyCharacterMap& other) const = default;
diff --git a/libs/binder/rust/binder_tokio/lib.rs b/libs/binder/rust/binder_tokio/lib.rs
index 1dc0b24..71bb95b 100644
--- a/libs/binder/rust/binder_tokio/lib.rs
+++ b/libs/binder/rust/binder_tokio/lib.rs
@@ -34,6 +34,7 @@
/// Retrieve an existing service for a particular interface, sleeping for a few
/// seconds if it doesn't yet exist.
+#[deprecated = "this polls 5s, use wait_for_interface or check_interface"]
pub async fn get_interface<T: FromIBinder + ?Sized + 'static>(
name: &str,
) -> Result<Strong<T>, StatusCode> {
@@ -56,6 +57,32 @@
}
}
+/// Retrieve an existing service for a particular interface. Returns
+/// `Err(StatusCode::NAME_NOT_FOUND)` immediately if the service is not available.
+///
+/// NOTE: "immediately" above does not mean the future will complete the first time it is polled.
+pub async fn check_interface<T: FromIBinder + ?Sized + 'static>(
+ name: &str,
+) -> Result<Strong<T>, StatusCode> {
+ if binder::is_handling_transaction() {
+ // See comment in the BinderAsyncPool impl.
+ return binder::check_interface::<T>(name);
+ }
+
+ let name = name.to_string();
+ let res = tokio::task::spawn_blocking(move || binder::check_interface::<T>(&name)).await;
+
+ // The `is_panic` branch is not actually reachable in Android as we compile
+ // with `panic = abort`.
+ match res {
+ Ok(Ok(service)) => Ok(service),
+ Ok(Err(err)) => Err(err),
+ Err(e) if e.is_panic() => std::panic::resume_unwind(e.into_panic()),
+ Err(e) if e.is_cancelled() => Err(StatusCode::FAILED_TRANSACTION),
+ Err(_) => Err(StatusCode::UNKNOWN_ERROR),
+ }
+}
+
/// Retrieve an existing service for a particular interface, or start it if it
/// is configured as a dynamic service and isn't yet started.
pub async fn wait_for_interface<T: FromIBinder + ?Sized + 'static>(
diff --git a/libs/binder/rust/src/lib.rs b/libs/binder/rust/src/lib.rs
index 0f9c58c..e70f4f0 100644
--- a/libs/binder/rust/src/lib.rs
+++ b/libs/binder/rust/src/lib.rs
@@ -114,9 +114,9 @@
pub use proxy::{DeathRecipient, SpIBinder, WpIBinder};
#[cfg(not(trusty))]
pub use service::{
- add_service, force_lazy_services_persist, get_declared_instances, get_interface, get_service,
- is_declared, is_handling_transaction, register_lazy_service, wait_for_interface,
- wait_for_service, LazyServiceGuard,
+ add_service, check_interface, check_service, force_lazy_services_persist,
+ get_declared_instances, get_interface, get_service, is_declared, is_handling_transaction,
+ register_lazy_service, wait_for_interface, wait_for_service, LazyServiceGuard,
};
#[cfg(not(trusty))]
pub use state::{ProcessState, ThreadState};
diff --git a/libs/binder/rust/src/service.rs b/libs/binder/rust/src/service.rs
index 3ca3b54..29dd8e1 100644
--- a/libs/binder/rust/src/service.rs
+++ b/libs/binder/rust/src/service.rs
@@ -144,6 +144,7 @@
/// Retrieve an existing service, blocking for a few seconds if it doesn't yet
/// exist.
+#[deprecated = "this polls 5s, use wait_for_service or check_service"]
pub fn get_service(name: &str) -> Option<SpIBinder> {
let name = CString::new(name).ok()?;
// Safety: `AServiceManager_getService` returns either a null pointer or a
@@ -152,6 +153,15 @@
unsafe { SpIBinder::from_raw(sys::AServiceManager_getService(name.as_ptr())) }
}
+/// Retrieve an existing service. Returns `None` immediately if the service is not available.
+pub fn check_service(name: &str) -> Option<SpIBinder> {
+ let name = CString::new(name).ok()?;
+ // Safety: `AServiceManager_checkService` returns either a null pointer or
+ // a valid pointer to an owned `AIBinder`. Either of these values is safe to
+ // pass to `SpIBinder::from_raw`.
+ unsafe { SpIBinder::from_raw(sys::AServiceManager_checkService(name.as_ptr())) }
+}
+
/// Retrieve an existing service, or start it if it is configured as a dynamic
/// service and isn't yet started.
pub fn wait_for_service(name: &str) -> Option<SpIBinder> {
@@ -164,10 +174,17 @@
/// Retrieve an existing service for a particular interface, blocking for a few
/// seconds if it doesn't yet exist.
+#[deprecated = "this polls 5s, use wait_for_interface or check_interface"]
pub fn get_interface<T: FromIBinder + ?Sized>(name: &str) -> Result<Strong<T>> {
interface_cast(get_service(name))
}
+/// Retrieve an existing service for a particular interface. Returns
+/// `Err(StatusCode::NAME_NOT_FOUND)` immediately if the service is not available.
+pub fn check_interface<T: FromIBinder + ?Sized>(name: &str) -> Result<Strong<T>> {
+ interface_cast(check_service(name))
+}
+
/// Retrieve an existing service for a particular interface, or start it if it
/// is configured as a dynamic service and isn't yet started.
pub fn wait_for_interface<T: FromIBinder + ?Sized>(name: &str) -> Result<Strong<T>> {
diff --git a/libs/binder/rust/tests/integration.rs b/libs/binder/rust/tests/integration.rs
index c87fa89..15ae56f 100644
--- a/libs/binder/rust/tests/integration.rs
+++ b/libs/binder/rust/tests/integration.rs
@@ -421,7 +421,7 @@
}
#[test]
- fn check_services() {
+ fn check_get_service() {
let mut sm = binder::get_service("manager").expect("Did not get manager binder service");
assert!(sm.is_binder_alive());
assert!(sm.ping_binder().is_ok());
@@ -445,7 +445,7 @@
}
#[tokio::test]
- async fn check_services_async() {
+ async fn check_get_service_async() {
let mut sm = binder::get_service("manager").expect("Did not get manager binder service");
assert!(sm.is_binder_alive());
assert!(sm.ping_binder().is_ok());
@@ -474,6 +474,62 @@
}
#[test]
+ fn check_check_service() {
+ let mut sm = binder::check_service("manager").expect("Did not find manager binder service");
+ assert!(sm.is_binder_alive());
+ assert!(sm.ping_binder().is_ok());
+
+ assert!(binder::check_service("this_service_does_not_exist").is_none());
+ assert_eq!(
+ binder::check_interface::<dyn ITest>("this_service_does_not_exist").err(),
+ Some(StatusCode::NAME_NOT_FOUND)
+ );
+ assert_eq!(
+ binder::check_interface::<dyn IATest<Tokio>>("this_service_does_not_exist").err(),
+ Some(StatusCode::NAME_NOT_FOUND)
+ );
+
+ // The service manager service isn't an ITest, so this must fail.
+ assert_eq!(
+ binder::check_interface::<dyn ITest>("manager").err(),
+ Some(StatusCode::BAD_TYPE)
+ );
+ assert_eq!(
+ binder::check_interface::<dyn IATest<Tokio>>("manager").err(),
+ Some(StatusCode::BAD_TYPE)
+ );
+ }
+
+ #[tokio::test]
+ async fn check_check_service_async() {
+ let mut sm = binder::check_service("manager").expect("Did not find manager binder service");
+ assert!(sm.is_binder_alive());
+ assert!(sm.ping_binder().is_ok());
+
+ assert!(binder::check_service("this_service_does_not_exist").is_none());
+ assert_eq!(
+ binder_tokio::check_interface::<dyn ITest>("this_service_does_not_exist").await.err(),
+ Some(StatusCode::NAME_NOT_FOUND)
+ );
+ assert_eq!(
+ binder_tokio::check_interface::<dyn IATest<Tokio>>("this_service_does_not_exist")
+ .await
+ .err(),
+ Some(StatusCode::NAME_NOT_FOUND)
+ );
+
+ // The service manager service isn't an ITest, so this must fail.
+ assert_eq!(
+ binder_tokio::check_interface::<dyn ITest>("manager").await.err(),
+ Some(StatusCode::BAD_TYPE)
+ );
+ assert_eq!(
+ binder_tokio::check_interface::<dyn IATest<Tokio>>("manager").await.err(),
+ Some(StatusCode::BAD_TYPE)
+ );
+ }
+
+ #[test]
fn check_wait_for_service() {
let mut sm =
binder::wait_for_service("manager").expect("Did not get manager binder service");
diff --git a/libs/binder/tests/binderSafeInterfaceTest.cpp b/libs/binder/tests/binderSafeInterfaceTest.cpp
index 41cb552..0aa678d 100644
--- a/libs/binder/tests/binderSafeInterfaceTest.cpp
+++ b/libs/binder/tests/binderSafeInterfaceTest.cpp
@@ -723,7 +723,7 @@
ASSERT_EQ(a.getValue() + 1, aPlusOne.getValue());
}
-TEST_F(SafeInterfaceTest, TestIncremementParcelableVector) {
+TEST_F(SafeInterfaceTest, TestIncrementParcelableVector) {
const std::vector<TestParcelable> a{TestParcelable{1}, TestParcelable{2}};
std::vector<TestParcelable> aPlusOne;
status_t result = mSafeInterfaceTest->increment(a, &aPlusOne);
diff --git a/libs/ftl/Android.bp b/libs/ftl/Android.bp
index 4b41152..368f5e0 100644
--- a/libs/ftl/Android.bp
+++ b/libs/ftl/Android.bp
@@ -41,5 +41,6 @@
"-Wextra",
"-Wpedantic",
"-Wthread-safety",
+ "-Wno-gnu-statement-expression-from-macro-expansion",
],
}
diff --git a/libs/ftl/expected_test.cpp b/libs/ftl/expected_test.cpp
index 8cb07e4..9b7f017 100644
--- a/libs/ftl/expected_test.cpp
+++ b/libs/ftl/expected_test.cpp
@@ -15,8 +15,11 @@
*/
#include <ftl/expected.h>
+#include <ftl/optional.h>
+#include <ftl/unit.h>
#include <gtest/gtest.h>
+#include <cctype>
#include <string>
#include <system_error>
@@ -74,4 +77,42 @@
}
}
+namespace {
+
+IntExp increment(IntExp exp) {
+ const int i = FTL_TRY(exp);
+ return IntExp(i + 1);
+}
+
+StringExp repeat(StringExp exp) {
+ const std::string str = FTL_TRY(exp);
+ return StringExp(str + str);
+}
+
+void uppercase(char& c, ftl::Optional<char> opt) {
+ c = std::toupper(FTL_TRY(std::move(opt).ok_or(ftl::Unit())));
+}
+
+} // namespace
+
+// Keep in sync with example usage in header file.
+TEST(Expected, Try) {
+ EXPECT_EQ(IntExp(100), increment(IntExp(99)));
+ EXPECT_TRUE(repeat(ftl::Unexpected(std::errc::value_too_large)).has_error([](std::errc e) {
+ return e == std::errc::value_too_large;
+ }));
+
+ EXPECT_EQ(StringExp("haha"s), repeat(StringExp("ha"s)));
+ EXPECT_TRUE(repeat(ftl::Unexpected(std::errc::bad_message)).has_error([](std::errc e) {
+ return e == std::errc::bad_message;
+ }));
+
+ char c = '?';
+ uppercase(c, std::nullopt);
+ EXPECT_EQ(c, '?');
+
+ uppercase(c, 'a');
+ EXPECT_EQ(c, 'A');
+}
+
} // namespace android::test
diff --git a/libs/ftl/optional_test.cpp b/libs/ftl/optional_test.cpp
index 91bf7bc..e7f1f14 100644
--- a/libs/ftl/optional_test.cpp
+++ b/libs/ftl/optional_test.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <ftl/expected.h>
#include <ftl/optional.h>
#include <ftl/static_vector.h>
#include <ftl/string.h>
@@ -23,6 +24,7 @@
#include <cstdlib>
#include <functional>
#include <numeric>
+#include <system_error>
#include <utility>
using namespace std::placeholders;
@@ -204,6 +206,19 @@
.or_else([] { return Optional(-1); }));
}
+TEST(Optional, OkOr) {
+ using CharExp = ftl::Expected<char, std::errc>;
+ using StringExp = ftl::Expected<std::string, std::errc>;
+
+ EXPECT_EQ(CharExp('z'), Optional('z').ok_or(std::errc::broken_pipe));
+ EXPECT_EQ(CharExp(ftl::Unexpected(std::errc::broken_pipe)),
+ Optional<char>().ok_or(std::errc::broken_pipe));
+
+ EXPECT_EQ(StringExp("abc"s), Optional("abc"s).ok_or(std::errc::protocol_error));
+ EXPECT_EQ(StringExp(ftl::Unexpected(std::errc::protocol_error)),
+ Optional<std::string>().ok_or(std::errc::protocol_error));
+}
+
// Comparison.
namespace {
diff --git a/libs/gui/include/gui/DisplayInfo.h b/libs/gui/include/gui/DisplayInfo.h
index 7282b80..7094658 100644
--- a/libs/gui/include/gui/DisplayInfo.h
+++ b/libs/gui/include/gui/DisplayInfo.h
@@ -29,7 +29,7 @@
* This should only be used by InputFlinger to support raw coordinates in logical display space.
*/
struct DisplayInfo : public Parcelable {
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE;
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID;
// Logical display dimensions.
int32_t logicalWidth = 0;
diff --git a/libs/gui/include/gui/LayerMetadata.h b/libs/gui/include/gui/LayerMetadata.h
index 9cf62bc..7ee291d 100644
--- a/libs/gui/include/gui/LayerMetadata.h
+++ b/libs/gui/include/gui/LayerMetadata.h
@@ -74,6 +74,7 @@
} // namespace android::gui
using android::gui::METADATA_ACCESSIBILITY_ID;
+using android::gui::METADATA_CALLING_UID;
using android::gui::METADATA_DEQUEUE_TIME;
using android::gui::METADATA_GAME_MODE;
using android::gui::METADATA_MOUSE_CURSOR;
diff --git a/libs/gui/include/gui/WindowInfo.h b/libs/gui/include/gui/WindowInfo.h
index 3ea3f67..eb3be55 100644
--- a/libs/gui/include/gui/WindowInfo.h
+++ b/libs/gui/include/gui/WindowInfo.h
@@ -234,7 +234,7 @@
Uid ownerUid = Uid::INVALID;
std::string packageName;
ftl::Flags<InputConfig> inputConfig;
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE;
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID;
InputApplicationInfo applicationInfo;
bool replaceTouchableRegionWithCrop = false;
wp<IBinder> touchableRegionCropHandle;
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index b0db396..7d0b512 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -59,8 +59,6 @@
using android::gui::InputApplicationInfo;
using android::gui::TouchOcclusionMode;
using android::gui::WindowInfo;
-using android::ui::ADISPLAY_ID_DEFAULT;
-using android::ui::ADISPLAY_ID_NONE;
namespace android {
namespace {
@@ -313,7 +311,7 @@
reportedListener->wait();
}
- void requestFocus(ui::LogicalDisplayId displayId = ADISPLAY_ID_DEFAULT) {
+ void requestFocus(ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT) {
SurfaceComposerClient::Transaction t;
FocusRequest request;
request.token = mInputInfo.token;
@@ -438,7 +436,7 @@
}
void injectTap(int x, int y) {
- injectTapOnDisplay(x, y, ADISPLAY_ID_DEFAULT);
+ injectTapOnDisplay(x, y, ui::LogicalDisplayId::DEFAULT);
}
void injectKeyOnDisplay(uint32_t keycode, ui::LogicalDisplayId displayId) {
@@ -451,7 +449,7 @@
}
void injectKey(uint32_t keycode) {
- injectKeyOnDisplay(keycode, ADISPLAY_ID_NONE);
+ injectKeyOnDisplay(keycode, ui::LogicalDisplayId::INVALID);
}
TEST_F(InputSurfacesTest, can_receive_input) {
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index cc0649c..8f44b3a 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -289,6 +289,10 @@
"motion_predictor_model_prebuilt",
"motion_predictor_model_config",
],
+ static_libs: [
+ "libstatslog_libinput",
+ "libstatssocket_lazy",
+ ],
},
host: {
include_dirs: [
@@ -299,6 +303,46 @@
},
}
+cc_library_static {
+ name: "libstatslog_libinput",
+ generated_sources: ["statslog_libinput.cpp"],
+ generated_headers: ["statslog_libinput.h"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ export_generated_headers: ["statslog_libinput.h"],
+ shared_libs: [
+ "libcutils",
+ "liblog",
+ "libutils",
+ ],
+ static_libs: [
+ "libstatssocket_lazy",
+ ],
+}
+
+genrule {
+ name: "statslog_libinput.h",
+ tools: ["stats-log-api-gen"],
+ cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_libinput.h " +
+ "--module libinput --namespace android,libinput",
+ out: [
+ "statslog_libinput.h",
+ ],
+}
+
+genrule {
+ name: "statslog_libinput.cpp",
+ tools: ["stats-log-api-gen"],
+ cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_libinput.cpp " +
+ "--module libinput --namespace android,libinput " +
+ "--importHeader statslog_libinput.h",
+ out: [
+ "statslog_libinput.cpp",
+ ],
+}
+
cc_defaults {
name: "libinput_fuzz_defaults",
cpp_std: "c++20",
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index d271563..ee121d5 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -32,9 +32,7 @@
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
-#ifdef __linux__
#include <binder/Parcel.h>
-#endif
#if defined(__ANDROID__)
#include <sys/random.h>
#endif
@@ -483,7 +481,6 @@
scaleAxisValue(*this, AMOTION_EVENT_AXIS_RELATIVE_Y, windowYScale);
}
-#ifdef __linux__
status_t PointerCoords::readFromParcel(Parcel* parcel) {
bits = parcel->readInt64();
@@ -511,7 +508,6 @@
parcel->writeBool(isResampled);
return OK;
}
-#endif
void PointerCoords::tooManyAxes(int axis) {
ALOGW("Could not set value for axis %d because the PointerCoords structure is full and "
@@ -801,7 +797,6 @@
}
}
-#ifdef __linux__
static status_t readFromParcel(ui::Transform& transform, const Parcel& parcel) {
float dsdx, dtdx, tx, dtdy, dsdy, ty;
status_t status = parcel.readFloat(&dsdx);
@@ -948,7 +943,6 @@
}
return OK;
}
-#endif
bool MotionEvent::isTouchEvent(uint32_t source, int32_t action) {
if (isFromSource(source, AINPUT_SOURCE_CLASS_POINTER)) {
@@ -1204,7 +1198,7 @@
void FocusEvent::initialize(int32_t id, bool hasFocus) {
InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC);
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC);
mHasFocus = hasFocus;
}
@@ -1217,7 +1211,7 @@
void CaptureEvent::initialize(int32_t id, bool pointerCaptureEnabled) {
InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC);
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC);
mPointerCaptureEnabled = pointerCaptureEnabled;
}
@@ -1230,7 +1224,7 @@
void DragEvent::initialize(int32_t id, float x, float y, bool isExiting) {
InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC);
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC);
mIsExiting = isExiting;
mX = x;
mY = y;
@@ -1247,7 +1241,7 @@
void TouchModeEvent::initialize(int32_t id, bool isInTouchMode) {
InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC);
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC);
mIsInTouchMode = isInTouchMode;
}
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 50239a1..bc67810 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -169,7 +169,7 @@
// --- InputDeviceInfo ---
InputDeviceInfo::InputDeviceInfo() {
- initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::ADISPLAY_ID_NONE);
+ initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::LogicalDisplayId::INVALID);
}
InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other)
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp
index 41909bf..1cf5612 100644
--- a/libs/input/KeyCharacterMap.cpp
+++ b/libs/input/KeyCharacterMap.cpp
@@ -19,11 +19,9 @@
#include <stdlib.h>
#include <string.h>
-#ifdef __linux__
-#include <binder/Parcel.h>
-#endif
#include <android/keycodes.h>
#include <attestation/HmacKeyManager.h>
+#include <binder/Parcel.h>
#include <input/InputEventLabels.h>
#include <input/KeyCharacterMap.h>
#include <input/Keyboard.h>
@@ -499,9 +497,10 @@
int32_t metaState, bool down, nsecs_t time) {
outEvents.push();
KeyEvent& event = outEvents.editTop();
- event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE,
- INVALID_HMAC, down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, 0, keyCode,
- 0, metaState, 0, time, time);
+ event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC,
+ down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, 0, keyCode, 0, metaState,
+ 0, time, time);
}
void KeyCharacterMap::addMetaKeys(Vector<KeyEvent>& outEvents,
@@ -611,7 +610,6 @@
}
}
-#ifdef __linux__
std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
if (parcel == nullptr) {
ALOGE("%s: Null parcel", __func__);
@@ -744,7 +742,6 @@
parcel->writeInt32(toAndroidKeyCode);
}
}
-#endif // __linux__
// --- KeyCharacterMap::Parser ---
diff --git a/libs/input/MotionPredictorMetricsManager.cpp b/libs/input/MotionPredictorMetricsManager.cpp
index cda39ce..ccf018e 100644
--- a/libs/input/MotionPredictorMetricsManager.cpp
+++ b/libs/input/MotionPredictorMetricsManager.cpp
@@ -21,6 +21,9 @@
#include <algorithm>
#include <android-base/logging.h>
+#ifdef __ANDROID__
+#include <statslog_libinput.h>
+#endif // __ANDROID__
#include "Eigen/Core"
#include "Eigen/Geometry"
@@ -44,9 +47,20 @@
void MotionPredictorMetricsManager::defaultReportAtomFunction(
const MotionPredictorMetricsManager::AtomFields& atomFields) {
- // TODO(b/338106546): Fix bootanimation build dependency issue, then re-add
- // the stats_write function call here.
- (void)atomFields;
+#ifdef __ANDROID__
+ android::libinput::stats_write(android::libinput::STYLUS_PREDICTION_METRICS_REPORTED,
+ /*stylus_vendor_id=*/0,
+ /*stylus_product_id=*/0,
+ atomFields.deltaTimeBucketMilliseconds,
+ atomFields.alongTrajectoryErrorMeanMillipixels,
+ atomFields.alongTrajectoryErrorStdMillipixels,
+ atomFields.offTrajectoryRmseMillipixels,
+ atomFields.pressureRmseMilliunits,
+ atomFields.highVelocityAlongTrajectoryRmse,
+ atomFields.highVelocityOffTrajectoryRmse,
+ atomFields.scaleInvariantAlongTrajectoryRmse,
+ atomFields.scaleInvariantOffTrajectoryRmse);
+#endif // __ANDROID__
}
MotionPredictorMetricsManager::MotionPredictorMetricsManager(
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
index 6e724ac..e9d799e 100644
--- a/libs/input/tests/Android.bp
+++ b/libs/input/tests/Android.bp
@@ -79,6 +79,12 @@
},
test_suites: ["device-tests"],
target: {
+ android: {
+ static_libs: [
+ "libstatslog_libinput",
+ "libstatssocket_lazy",
+ ],
+ },
host: {
sanitize: {
address: true,
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index cc2574d..476b5cf 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -27,7 +27,7 @@
namespace android {
// Default display id.
-static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
static constexpr float EPSILON = MotionEvent::ROUNDING_PRECISION;
@@ -858,11 +858,10 @@
pointerCoords.back().setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, dy);
nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC);
MotionEvent event;
- event.initialize(InputEvent::nextId(), /* deviceId */ 1, source,
- /* displayId */ ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, action,
- /* actionButton */ 0, /* flags */ 0, /* edgeFlags */ 0, AMETA_NONE,
- /* buttonState */ 0, MotionClassification::NONE, transform,
- /* xPrecision */ 0, /* yPrecision */ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ event.initialize(InputEvent::nextId(), /*deviceId=*/1, source, ui::LogicalDisplayId::DEFAULT,
+ INVALID_HMAC, action, /*actionButton=*/0, /*flags=*/0, /*edgeFlags=*/0,
+ AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, transform,
+ /*xPrecision=*/0, /*yPrecision=*/0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, rawTransform, eventTime, eventTime,
pointerCoords.size(), pointerProperties.data(), pointerCoords.data());
return event;
diff --git a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
index 7ae1cd8..70529bb 100644
--- a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp
@@ -55,7 +55,7 @@
const int32_t eventId;
const int32_t deviceId = 1;
const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
- const ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT;
+ const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
const int32_t actionButton = 0;
const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
@@ -445,7 +445,7 @@
int32_t eventId = InputEvent::nextId();
constexpr int32_t deviceId = 1;
constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD;
- constexpr ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT;
+ constexpr ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
constexpr std::array<uint8_t, 32> hmac = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21,
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
@@ -737,10 +737,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -755,10 +755,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -777,10 +777,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp
index d0dbe2a..48512f7 100644
--- a/libs/input/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp
@@ -48,7 +48,7 @@
const int32_t eventId;
const int32_t deviceId = 1;
const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
- const ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT;
+ const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
const int32_t actionButton = 0;
const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
@@ -262,7 +262,7 @@
int32_t eventId = InputEvent::nextId();
constexpr int32_t deviceId = 1;
constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD;
- constexpr ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT;
+ constexpr ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
constexpr std::array<uint8_t, 32> hmac = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21,
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
@@ -622,10 +622,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -639,10 +639,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -661,10 +661,10 @@
ui::Transform identityTransform;
status =
- mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT,
- INVALID_HMAC, 0, 0, 0, 0, 0, 0,
- MotionClassification::NONE, identityTransform, 0, 0,
- AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
+ 0, 0, MotionClassification::NONE, identityTransform, 0,
+ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
0, 0, pointerCount, pointerProperties, pointerCoords);
ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
diff --git a/libs/input/tests/MotionPredictor_test.cpp b/libs/input/tests/MotionPredictor_test.cpp
index 1c9f0c7..d077760 100644
--- a/libs/input/tests/MotionPredictor_test.cpp
+++ b/libs/input/tests/MotionPredictor_test.cpp
@@ -58,9 +58,10 @@
}
ui::Transform identityTransform;
- event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_STYLUS, ui::ADISPLAY_ID_DEFAULT,
- {0}, action, /*actionButton=*/0, /*flags=*/0, AMOTION_EVENT_EDGE_FLAG_NONE,
- AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, identityTransform,
+ event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_STYLUS,
+ ui::LogicalDisplayId::DEFAULT, {0}, action, /*actionButton=*/0, /*flags=*/0,
+ AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, /*buttonState=*/0,
+ MotionClassification::NONE, identityTransform,
/*xPrecision=*/0.1,
/*yPrecision=*/0.2, /*xCursorPosition=*/280, /*yCursorPosition=*/540,
identityTransform, /*downTime=*/100, eventTime.count(), pointerCount,
diff --git a/libs/input/tests/TouchResampling_test.cpp b/libs/input/tests/TouchResampling_test.cpp
index 1694cad..2dc9fdb 100644
--- a/libs/input/tests/TouchResampling_test.cpp
+++ b/libs/input/tests/TouchResampling_test.cpp
@@ -84,11 +84,11 @@
ADD_FAILURE() << "Downtime should be equal to 0 (hardcoded for convenience)";
}
return mPublisher->publishMotionEvent(mSeq++, InputEvent::nextId(), /*deviceId=*/1,
- AINPUT_SOURCE_TOUCHSCREEN,
- /*displayId=*/ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC,
- action, /*actionButton=*/0, /*flags=*/0, /*edgeFlags=*/0,
- AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE,
- identityTransform, /*xPrecision=*/0, /*yPrecision=*/0,
+ AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
+ INVALID_HMAC, action, /*actionButton=*/0, /*flags=*/0,
+ /*edgeFlags=*/0, AMETA_NONE, /*buttonState=*/0,
+ MotionClassification::NONE, identityTransform,
+ /*xPrecision=*/0, /*yPrecision=*/0,
AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
downTime, eventTime, properties.size(), properties.data(),
diff --git a/libs/input/tests/VelocityTracker_test.cpp b/libs/input/tests/VelocityTracker_test.cpp
index b4c4e12..f50a3cd 100644
--- a/libs/input/tests/VelocityTracker_test.cpp
+++ b/libs/input/tests/VelocityTracker_test.cpp
@@ -33,7 +33,7 @@
namespace android {
-constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; // default display id
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; // default display id
constexpr int32_t DEFAULT_POINTER_ID = 0; // pointer ID used for manually defined tests
@@ -155,7 +155,7 @@
MotionEvent event;
ui::Transform identityTransform;
event.initialize(InputEvent::nextId(), /*deviceId=*/5, AINPUT_SOURCE_ROTARY_ENCODER,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC, AMOTION_EVENT_ACTION_SCROLL,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC, AMOTION_EVENT_ACTION_SCROLL,
/*actionButton=*/0, /*flags=*/0, AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE,
/*buttonState=*/0, MotionClassification::NONE, identityTransform,
/*xPrecision=*/0, /*yPrecision=*/0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
diff --git a/libs/input/tests/VerifiedInputEvent_test.cpp b/libs/input/tests/VerifiedInputEvent_test.cpp
index 40cfaae..df5fe9d 100644
--- a/libs/input/tests/VerifiedInputEvent_test.cpp
+++ b/libs/input/tests/VerifiedInputEvent_test.cpp
@@ -23,7 +23,7 @@
static KeyEvent getKeyEventWithFlags(int32_t flags) {
KeyEvent event;
event.initialize(InputEvent::nextId(), /*deviceId=*/2, AINPUT_SOURCE_GAMEPAD,
- ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, flags,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, flags,
AKEYCODE_BUTTON_X, /*scanCode=*/121, AMETA_ALT_ON, /*repeatCount=*/1,
/*downTime=*/1000, /*eventTime=*/2000);
return event;
@@ -44,7 +44,7 @@
transform.set({2, 0, 4, 0, 3, 5, 0, 0, 1});
ui::Transform identity;
event.initialize(InputEvent::nextId(), /*deviceId=*/0, AINPUT_SOURCE_MOUSE,
- ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN,
/*actionButton=*/0, flags, AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE,
/*buttonState=*/0, MotionClassification::NONE, transform, /*xPrecision=*/0.1,
/*yPrecision=*/0.2,
diff --git a/libs/renderengine/skia/SkiaRenderEngine.cpp b/libs/renderengine/skia/SkiaRenderEngine.cpp
index 325a911..b973211 100644
--- a/libs/renderengine/skia/SkiaRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaRenderEngine.cpp
@@ -91,7 +91,6 @@
// Debugging settings
static const bool kPrintLayerSettings = false;
static const bool kGaneshFlushAfterEveryLayer = kPrintLayerSettings;
-static constexpr bool kEnableLayerBrightening = true;
} // namespace
@@ -714,8 +713,7 @@
// ...and compute the dimming ratio if dimming is requested
const float displayDimmingRatio = display.targetLuminanceNits > 0.f &&
- maxLayerWhitePoint > 0.f &&
- (kEnableLayerBrightening || display.targetLuminanceNits > maxLayerWhitePoint)
+ maxLayerWhitePoint > 0.f && display.targetLuminanceNits > maxLayerWhitePoint
? maxLayerWhitePoint / display.targetLuminanceNits
: 1.f;
diff --git a/libs/ui/include/ui/LogicalDisplayId.h b/libs/ui/include/ui/LogicalDisplayId.h
index 3e504e7..fd84b12 100644
--- a/libs/ui/include/ui/LogicalDisplayId.h
+++ b/libs/ui/include/ui/LogicalDisplayId.h
@@ -35,10 +35,13 @@
constexpr bool isValid() const { return val() >= 0; }
std::string toString() const { return std::to_string(val()); }
+
+ static const LogicalDisplayId INVALID;
+ static const LogicalDisplayId DEFAULT;
};
-constexpr LogicalDisplayId ADISPLAY_ID_NONE{-1};
-constexpr LogicalDisplayId ADISPLAY_ID_DEFAULT{0};
+constexpr inline LogicalDisplayId LogicalDisplayId::INVALID{-1};
+constexpr inline LogicalDisplayId LogicalDisplayId::DEFAULT{0};
inline std::ostream& operator<<(std::ostream& stream, LogicalDisplayId displayId) {
return stream << displayId.val();
diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp
index 29b487f..6b2627c 100644
--- a/services/inputflinger/InputReaderBase.cpp
+++ b/services/inputflinger/InputReaderBase.cpp
@@ -68,7 +68,7 @@
if (currentViewport.type == type) {
if (!result ||
(type == ViewportType::INTERNAL &&
- currentViewport.displayId == ui::ADISPLAY_ID_DEFAULT)) {
+ currentViewport.displayId == ui::LogicalDisplayId::DEFAULT)) {
result = std::make_optional(currentViewport);
}
count++;
diff --git a/services/inputflinger/PointerChoreographer.cpp b/services/inputflinger/PointerChoreographer.cpp
index d6c6f93..8a1eed6 100644
--- a/services/inputflinger/PointerChoreographer.cpp
+++ b/services/inputflinger/PointerChoreographer.cpp
@@ -101,8 +101,8 @@
}),
mNextListener(listener),
mPolicy(policy),
- mDefaultMouseDisplayId(ui::ADISPLAY_ID_DEFAULT),
- mNotifiedPointerDisplayId(ui::ADISPLAY_ID_NONE),
+ mDefaultMouseDisplayId(ui::LogicalDisplayId::DEFAULT),
+ mNotifiedPointerDisplayId(ui::LogicalDisplayId::INVALID),
mShowTouchesEnabled(false),
mStylusPointerIconEnabled(false) {}
@@ -236,7 +236,7 @@
}
void PointerChoreographer::processDrawingTabletEventLocked(const android::NotifyMotionArgs& args) {
- if (args.displayId == ui::ADISPLAY_ID_NONE) {
+ if (args.displayId == ui::LogicalDisplayId::INVALID) {
return;
}
@@ -557,7 +557,7 @@
PointerChoreographer::PointerDisplayChange
PointerChoreographer::calculatePointerDisplayChangeToNotify() {
- ui::LogicalDisplayId displayIdToNotify = ui::ADISPLAY_ID_NONE;
+ ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID;
FloatPoint cursorPosition = {0, 0};
if (const auto it = mMousePointersByDisplay.find(mDefaultMouseDisplayId);
it != mMousePointersByDisplay.end()) {
diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h
index fda5f52..12316c0 100644
--- a/services/inputflinger/PointerChoreographer.h
+++ b/services/inputflinger/PointerChoreographer.h
@@ -57,7 +57,7 @@
virtual void setDefaultMouseDisplayId(ui::LogicalDisplayId displayId) = 0;
virtual void setDisplayViewports(const std::vector<DisplayViewport>& viewports) = 0;
virtual std::optional<DisplayViewport> getViewportForPointerDevice(
- ui::LogicalDisplayId associatedDisplayId = ui::ADISPLAY_ID_NONE) = 0;
+ ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0;
virtual FloatPoint getMouseCursorPosition(ui::LogicalDisplayId displayId) = 0;
virtual void setShowTouchesEnabled(bool enabled) = 0;
virtual void setStylusPointerIconEnabled(bool enabled) = 0;
diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
index 66e4a29..96c8640 100644
--- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
+++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
@@ -37,7 +37,7 @@
constexpr DeviceId DEVICE_ID = 1;
// An arbitrary display id
-constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
static constexpr std::chrono::duration INJECT_EVENT_TIMEOUT = 5s;
@@ -62,7 +62,7 @@
ui::Transform identityTransform;
MotionEvent event;
event.initialize(IInputConstants::INVALID_INPUT_EVENT_ID, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
- ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN,
+ ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN,
/* actionButton */ 0, /* flags */ 0,
/* edgeFlags */ 0, AMETA_NONE, /* buttonState */ 0, MotionClassification::NONE,
identityTransform, /* xPrecision */ 0,
@@ -88,7 +88,7 @@
const nsecs_t currentTime = now();
// Define a valid motion event.
NotifyMotionArgs args(IInputConstants::INVALID_INPUT_EVENT_ID, currentTime, currentTime,
- DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, ui::ADISPLAY_ID_DEFAULT,
+ DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
POLICY_FLAG_PASS_TO_USER, AMOTION_EVENT_ACTION_DOWN,
/* actionButton */ 0, /* flags */ 0, AMETA_NONE, /* buttonState */ 0,
MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1,
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 8e0da14..dae2b61 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -918,9 +918,9 @@
mDispatchFrozen(false),
mInputFilterEnabled(false),
mMaximumObscuringOpacityForTouch(1.0f),
- mFocusedDisplayId(ui::ADISPLAY_ID_DEFAULT),
+ mFocusedDisplayId(ui::LogicalDisplayId::DEFAULT),
mWindowTokenWithPointerCapture(nullptr),
- mAwaitedApplicationDisplayId(ui::ADISPLAY_ID_NONE),
+ mAwaitedApplicationDisplayId(ui::LogicalDisplayId::INVALID),
mLatencyAggregator(),
mLatencyTracker(&mLatencyAggregator) {
mLooper = sp<Looper>::make(false);
@@ -2201,7 +2201,7 @@
* Focused display is the display that the user most recently interacted with.
*/
ui::LogicalDisplayId InputDispatcher::getTargetDisplayId(const EventEntry& entry) {
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
switch (entry.type) {
case EventEntry::Type::KEY: {
const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry);
@@ -2221,10 +2221,10 @@
case EventEntry::Type::SENSOR:
case EventEntry::Type::DRAG: {
ALOGE("%s events do not have a target display", ftl::enum_string(entry.type).c_str());
- return ui::ADISPLAY_ID_NONE;
+ return ui::LogicalDisplayId::INVALID;
}
}
- return displayId == ui::ADISPLAY_ID_NONE ? mFocusedDisplayId : displayId;
+ return displayId == ui::LogicalDisplayId::INVALID ? mFocusedDisplayId : displayId;
}
bool InputDispatcher::shouldWaitToSendKeyLocked(nsecs_t currentTime,
@@ -2829,7 +2829,7 @@
// Save changes unless the action was scroll in which case the temporary touch
// state was only valid for this one action.
if (maskedAction != AMOTION_EVENT_ACTION_SCROLL) {
- if (displayId >= ui::ADISPLAY_ID_DEFAULT) {
+ if (displayId >= ui::LogicalDisplayId::DEFAULT) {
tempTouchState.clearWindowsWithoutPointers();
mTouchStatesByDisplay[displayId] = tempTouchState;
} else {
@@ -4862,8 +4862,8 @@
isFromSource(event->getSource(), AINPUT_SOURCE_CLASS_POINTER);
// If a pointer event has no displayId specified, inject it to the default display.
const ui::LogicalDisplayId displayId =
- isPointerEvent && (event->getDisplayId() == ui::ADISPLAY_ID_NONE)
- ? ui::ADISPLAY_ID_DEFAULT
+ isPointerEvent && (event->getDisplayId() == ui::LogicalDisplayId::INVALID)
+ ? ui::LogicalDisplayId::DEFAULT
: event->getDisplayId();
int32_t flags = motionEvent.getFlags();
@@ -4890,9 +4890,9 @@
// events for consistency and print an error. An inconsistent event sent from
// InputFilter could cause a crash in the later stages of dispatching pipeline.
auto [it, _] =
- mInputFilterVerifiersByDisplay
- .try_emplace(displayId,
- StringPrintf("Injection on %" PRId32, displayId));
+ mInputFilterVerifiersByDisplay.try_emplace(displayId,
+ std::string("Injection on ") +
+ displayId.toString());
InputVerifier& verifier = it->second;
Result<void> result =
@@ -5523,7 +5523,7 @@
options(CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS,
"The display which contains this window no longer has focus.",
traceContext.getTracker());
- options.displayId = ui::ADISPLAY_ID_NONE;
+ options.displayId = ui::LogicalDisplayId::INVALID;
synthesizeCancelationEventsForWindowLocked(windowHandle, options);
}
mFocusedDisplayId = displayId;
@@ -5675,7 +5675,7 @@
}
}
}
- return std::make_tuple(nullptr, nullptr, ui::ADISPLAY_ID_DEFAULT);
+ return std::make_tuple(nullptr, nullptr, ui::LogicalDisplayId::DEFAULT);
}
bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken,
@@ -6125,7 +6125,7 @@
{ // acquire lock
std::scoped_lock _l(mLock);
- if (displayId < ui::ADISPLAY_ID_DEFAULT) {
+ if (displayId < ui::LogicalDisplayId::DEFAULT) {
return base::Error(BAD_VALUE) << "Attempted to create input monitor with name " << name
<< " without a specified display.";
}
diff --git a/services/inputflinger/dispatcher/InputState.h b/services/inputflinger/dispatcher/InputState.h
index ab83ef9..2808ba7 100644
--- a/services/inputflinger/dispatcher/InputState.h
+++ b/services/inputflinger/dispatcher/InputState.h
@@ -90,7 +90,7 @@
struct KeyMemento {
DeviceId deviceId;
uint32_t source;
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
int32_t keyCode;
int32_t scanCode;
int32_t metaState;
@@ -102,7 +102,7 @@
struct MotionMemento {
DeviceId deviceId;
uint32_t source;
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
int32_t flags;
float xPrecision;
float yPrecision;
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index e5c3aa0..889ee09 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -106,15 +106,15 @@
// The associations between input ports and display ports.
// Used to determine which DisplayViewport should be tied to which InputDevice.
- std::unordered_map<std::string, uint8_t> portAssociations;
+ std::unordered_map<std::string, uint8_t> inputPortToDisplayPortAssociations;
// The associations between input device ports and display unique ids.
// Used to determine which DisplayViewport should be tied to which InputDevice.
- std::unordered_map<std::string, std::string> uniqueIdAssociationsByPort;
+ std::unordered_map<std::string, std::string> inputPortToDisplayUniqueIdAssociations;
// The associations between input device descriptor and display unique ids.
// Used to determine which DisplayViewport should be tied to which InputDevice.
- std::unordered_map<std::string, std::string> uniqueIdAssociationsByDescriptor;
+ std::unordered_map<std::string, std::string> inputDeviceDescriptorToDisplayUniqueIdAssociations;
// The associations between input device ports device types.
// This is used to determine which device type and source should be tied to which InputDevice.
@@ -243,7 +243,7 @@
InputReaderConfiguration()
: virtualKeyQuietTime(0),
- defaultPointerDisplayId(ui::ADISPLAY_ID_DEFAULT),
+ defaultPointerDisplayId(ui::LogicalDisplayId::DEFAULT),
mousePointerSpeed(0),
displaysWithMousePointerAccelerationDisabled(),
pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
@@ -310,9 +310,6 @@
/* Called by the heartbeat to ensures that the reader has not deadlocked. */
virtual void monitor() = 0;
- /* Returns true if the input device is enabled. */
- virtual bool isInputDeviceEnabled(int32_t deviceId) = 0;
-
/* Makes the reader start processing events from the kernel. */
virtual status_t start() = 0;
@@ -394,6 +391,12 @@
/* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */
virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0;
+
+ /* Get the ID of the InputDevice that was used most recently.
+ *
+ * Returns ReservedInputDeviceId::INVALID_INPUT_DEVICE_ID if no device has been used since boot.
+ */
+ virtual DeviceId getLastUsedInputDeviceId() = 0;
};
// --- TouchAffineTransformation ---
@@ -472,7 +475,7 @@
* be used as the range of possible values for pointing devices, like mice and touchpads.
*/
virtual std::optional<DisplayViewport> getPointerViewportForAssociatedDisplay(
- ui::LogicalDisplayId associatedDisplayId = ui::ADISPLAY_ID_NONE) = 0;
+ ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0;
};
} // namespace android
diff --git a/services/inputflinger/include/NotifyArgs.h b/services/inputflinger/include/NotifyArgs.h
index 865f3d0..db417cf 100644
--- a/services/inputflinger/include/NotifyArgs.h
+++ b/services/inputflinger/include/NotifyArgs.h
@@ -61,7 +61,7 @@
int32_t deviceId;
uint32_t source;
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
uint32_t policyFlags;
int32_t action;
int32_t flags;
@@ -91,7 +91,7 @@
int32_t deviceId;
uint32_t source;
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
uint32_t policyFlags;
int32_t action;
int32_t actionButton;
diff --git a/services/inputflinger/include/NotifyArgsBuilders.h b/services/inputflinger/include/NotifyArgsBuilders.h
index 1ba0cfd..cae638f 100644
--- a/services/inputflinger/include/NotifyArgsBuilders.h
+++ b/services/inputflinger/include/NotifyArgsBuilders.h
@@ -150,7 +150,7 @@
uint32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS;
int32_t mActionButton{0};
int32_t mButtonState{0};
@@ -229,7 +229,7 @@
uint32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS;
int32_t mFlags{0};
int32_t mKeyCode{AKEYCODE_UNKNOWN};
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 15586e2..b807b27 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -281,14 +281,14 @@
const std::string& inputDeviceDescriptor = mIdentifier.descriptor;
if (!inputDeviceDescriptor.empty()) {
const std::unordered_map<std::string, uint8_t>& ports =
- readerConfig.portAssociations;
+ readerConfig.inputPortToDisplayPortAssociations;
const auto& displayPort = ports.find(inputDeviceDescriptor);
if (displayPort != ports.end()) {
mAssociatedDisplayPort = std::make_optional(displayPort->second);
} else {
const std::unordered_map<std::string, std::string>&
displayUniqueIdsByDescriptor =
- readerConfig.uniqueIdAssociationsByDescriptor;
+ readerConfig.inputDeviceDescriptorToDisplayUniqueIdAssociations;
const auto& displayUniqueIdByDescriptor =
displayUniqueIdsByDescriptor.find(inputDeviceDescriptor);
if (displayUniqueIdByDescriptor != displayUniqueIdsByDescriptor.end()) {
@@ -301,13 +301,13 @@
const std::string& inputPort = mIdentifier.location;
if (!inputPort.empty()) {
const std::unordered_map<std::string, uint8_t>& ports =
- readerConfig.portAssociations;
+ readerConfig.inputPortToDisplayPortAssociations;
const auto& displayPort = ports.find(inputPort);
if (displayPort != ports.end()) {
mAssociatedDisplayPort = std::make_optional(displayPort->second);
} else {
const std::unordered_map<std::string, std::string>& displayUniqueIdsByPort =
- readerConfig.uniqueIdAssociationsByPort;
+ readerConfig.inputPortToDisplayUniqueIdAssociations;
const auto& displayUniqueIdByPort = displayUniqueIdsByPort.find(inputPort);
if (displayUniqueIdByPort != displayUniqueIdsByPort.end()) {
mAssociatedDisplayUniqueIdByPort = displayUniqueIdByPort->second;
@@ -442,7 +442,8 @@
InputDeviceInfo InputDevice::getDeviceInfo() {
InputDeviceInfo outDeviceInfo;
outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
- mHasMic, getAssociatedDisplayId().value_or(ui::ADISPLAY_ID_NONE),
+ mHasMic,
+ getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID),
{mShouldSmoothScroll}, isEnabled());
for_each_mapper(
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 12f52b8..b9523ef 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -38,6 +38,8 @@
namespace android {
+namespace {
+
/**
* Determines if the identifiers passed are a sub-devices. Sub-devices are physical devices
* that expose multiple input device paths such a keyboard that also has a touchpad input.
@@ -49,8 +51,8 @@
* inputs versus the same device plugged into multiple ports.
*/
-static bool isSubDevice(const InputDeviceIdentifier& identifier1,
- const InputDeviceIdentifier& identifier2) {
+bool isSubDevice(const InputDeviceIdentifier& identifier1,
+ const InputDeviceIdentifier& identifier2) {
return (identifier1.vendor == identifier2.vendor &&
identifier1.product == identifier2.product && identifier1.bus == identifier2.bus &&
identifier1.version == identifier2.version &&
@@ -58,7 +60,7 @@
identifier1.location == identifier2.location);
}
-static bool isStylusPointerGestureStart(const NotifyMotionArgs& motionArgs) {
+bool isStylusPointerGestureStart(const NotifyMotionArgs& motionArgs) {
const auto actionMasked = MotionEvent::getActionMasked(motionArgs.action);
if (actionMasked != AMOTION_EVENT_ACTION_HOVER_ENTER &&
actionMasked != AMOTION_EVENT_ACTION_DOWN &&
@@ -69,6 +71,28 @@
return isStylusToolType(motionArgs.pointerProperties[actionIndex].toolType);
}
+bool isNewGestureStart(const NotifyMotionArgs& motion) {
+ return motion.action == AMOTION_EVENT_ACTION_DOWN ||
+ motion.action == AMOTION_EVENT_ACTION_HOVER_ENTER;
+}
+
+bool isNewGestureStart(const NotifyKeyArgs& key) {
+ return key.action == AKEY_EVENT_ACTION_DOWN;
+}
+
+// Return the event's device ID if it marks the start of a new gesture.
+std::optional<DeviceId> getDeviceIdOfNewGesture(const NotifyArgs& args) {
+ if (const auto* motion = std::get_if<NotifyMotionArgs>(&args); motion != nullptr) {
+ return isNewGestureStart(*motion) ? std::make_optional(motion->deviceId) : std::nullopt;
+ }
+ if (const auto* key = std::get_if<NotifyKeyArgs>(&args); key != nullptr) {
+ return isNewGestureStart(*key) ? std::make_optional(key->deviceId) : std::nullopt;
+ }
+ return std::nullopt;
+}
+
+} // namespace
+
// --- InputReader ---
InputReader::InputReader(std::shared_ptr<EventHubInterface> eventHub,
@@ -162,6 +186,11 @@
}
std::swap(notifyArgs, mPendingArgs);
+
+ // Keep track of the last used device
+ for (const NotifyArgs& args : notifyArgs) {
+ mLastUsedDeviceId = getDeviceIdOfNewGesture(args).value_or(mLastUsedDeviceId);
+ }
} // release lock
// Flush queued events out to the listener.
@@ -845,17 +874,6 @@
return std::nullopt;
}
-bool InputReader::isInputDeviceEnabled(int32_t deviceId) {
- std::scoped_lock _l(mLock);
-
- InputDevice* device = findInputDeviceLocked(deviceId);
- if (device) {
- return device->isEnabled();
- }
- ALOGW("Ignoring invalid device id %" PRId32 ".", deviceId);
- return false;
-}
-
bool InputReader::canDispatchToDisplay(int32_t deviceId, ui::LogicalDisplayId displayId) {
std::scoped_lock _l(mLock);
@@ -883,6 +901,11 @@
mEventHub->sysfsNodeChanged(sysfsNodePath);
}
+DeviceId InputReader::getLastUsedInputDeviceId() {
+ std::scoped_lock _l(mLock);
+ return mLastUsedDeviceId;
+}
+
void InputReader::dump(std::string& dump) {
std::scoped_lock _l(mLock);
diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h
index d9ac917..7e701c5 100644
--- a/services/inputflinger/reader/include/InputReader.h
+++ b/services/inputflinger/reader/include/InputReader.h
@@ -61,8 +61,6 @@
std::vector<InputDeviceInfo> getInputDevices() const override;
- bool isInputDeviceEnabled(int32_t deviceId) override;
-
int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, int32_t scanCode) override;
int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, int32_t keyCode) override;
int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) override;
@@ -118,6 +116,8 @@
void sysfsNodeChanged(const std::string& sysfsNodePath) override;
+ DeviceId getLastUsedInputDeviceId() override;
+
protected:
// These members are protected so they can be instrumented by test cases.
virtual std::shared_ptr<InputDevice> createDeviceLocked(nsecs_t when, int32_t deviceId,
@@ -200,6 +200,9 @@
// records timestamp of the last key press on the physical keyboard
nsecs_t mLastKeyDownTimestamp GUARDED_BY(mLock){0};
+ // The input device that produced a new gesture most recently.
+ DeviceId mLastUsedDeviceId GUARDED_BY(mLock){ReservedInputDeviceId::INVALID_INPUT_DEVICE_ID};
+
// low-level input event decoding and device management
[[nodiscard]] std::list<NotifyArgs> processEventsLocked(const RawEvent* rawEvents, size_t count)
REQUIRES(mLock);
diff --git a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp
index 21dec6f..09a5f08 100644
--- a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp
+++ b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp
@@ -278,7 +278,7 @@
LOG_ALWAYS_FATAL_IF(coords.size() != properties.size(),
"Mismatched coords and properties arrays.");
return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE,
- ui::ADISPLAY_ID_NONE, /*policyFlags=*/POLICY_FLAG_WAKE, action,
+ ui::LogicalDisplayId::INVALID, /*policyFlags=*/POLICY_FLAG_WAKE, action,
/*actionButton=*/actionButton, flags,
mReaderContext.getGlobalMetaState(), mButtonState,
MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, coords.size(),
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index d5fe040..c67314d 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -488,13 +488,13 @@
if (mEnableNewMousePointerBallistics) {
mNewPointerVelocityControl.setAccelerationEnabled(
config.displaysWithMousePointerAccelerationDisabled.count(
- mDisplayId.value_or(ui::ADISPLAY_ID_NONE)) == 0);
+ mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0);
mNewPointerVelocityControl.setCurve(
createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
} else {
mOldPointerVelocityControl.setParameters(
(config.displaysWithMousePointerAccelerationDisabled.count(
- mDisplayId.value_or(ui::ADISPLAY_ID_NONE)) == 0)
+ mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0)
? config.pointerVelocityControlParameters
: FLAT_VELOCITY_CONTROL_PARAMS);
}
@@ -506,7 +506,7 @@
void CursorInputMapper::configureOnChangeDisplayInfo(const InputReaderConfiguration& config) {
const bool isPointer = mParameters.mode == Parameters::Mode::POINTER;
- mDisplayId = ui::ADISPLAY_ID_NONE;
+ mDisplayId = ui::LogicalDisplayId::INVALID;
std::optional<DisplayViewport> resolvedViewport;
if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) {
// This InputDevice is associated with a viewport.
@@ -518,7 +518,8 @@
// Always use DISPLAY_ID_NONE for mouse events.
// PointerChoreographer will make it target the correct the displayId later.
resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
- mDisplayId = resolvedViewport ? std::make_optional(ui::ADISPLAY_ID_NONE) : std::nullopt;
+ mDisplayId =
+ resolvedViewport ? std::make_optional(ui::LogicalDisplayId::INVALID) : std::nullopt;
}
mOrientation = (mParameters.orientationAware && mParameters.hasAssociatedDisplay) ||
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.h b/services/inputflinger/reader/mapper/CursorInputMapper.h
index e45105a..75ca9c0 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.h
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.h
@@ -113,7 +113,7 @@
SimpleVelocityControl mWheelYVelocityControl;
// The display that events generated by this mapper should target. This can be set to
- // ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e.
+ // LogicalDisplayId::INVALID to target the focused display. If there is no display target (i.e.
// std::nullopt), all events will be ignored.
std::optional<ui::LogicalDisplayId> mDisplayId;
ui::Rotation mOrientation{ui::ROTATION_0};
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index 7fcff95..5ce4d30 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -341,7 +341,7 @@
// button will likely wake the device.
// TODO: Use the input device configuration to control this behavior more finely.
uint32_t policyFlags = 0;
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE;
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID;
if (getDeviceContext().getAssociatedViewport()) {
displayId = getDeviceContext().getAssociatedViewport()->displayId;
}
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index be8d183..2124555 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -114,7 +114,7 @@
if (mViewport) {
return mViewport->displayId;
}
- return ui::ADISPLAY_ID_NONE;
+ return ui::LogicalDisplayId::INVALID;
}
std::optional<KeyboardLayoutInfo> KeyboardInputMapper::getKeyboardLayoutInfo() const {
diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
index a3206c2..0ddbc06 100644
--- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
@@ -125,7 +125,7 @@
if (scrolled) {
int32_t metaState = getContext()->getGlobalMetaState();
// This is not a pointer, so it's not associated with a display.
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE;
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID;
if (mOrientation == ui::ROTATION_180) {
scroll = -scroll;
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 489bea8..8b4b691 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -2646,7 +2646,7 @@
PointerCoords pointerCoords;
pointerCoords.clear();
out.push_back(NotifyMotionArgs(getContext()->getNextId(), when, readTime, getDeviceId(),
- mSource, ui::ADISPLAY_ID_NONE, policyFlags,
+ mSource, ui::LogicalDisplayId::INVALID, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, flags, metaState,
buttonState, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, 1, &pointerProperties,
@@ -3477,7 +3477,8 @@
hovering = false;
}
- return dispatchPointerSimple(when, readTime, policyFlags, down, hovering, ui::ADISPLAY_ID_NONE);
+ return dispatchPointerSimple(when, readTime, policyFlags, down, hovering,
+ ui::LogicalDisplayId::INVALID);
}
std::list<NotifyArgs> TouchInputMapper::abortPointerMouse(nsecs_t when, nsecs_t readTime,
@@ -3684,7 +3685,8 @@
source |= AINPUT_SOURCE_BLUETOOTH_STYLUS;
}
- const ui::LogicalDisplayId displayId = getAssociatedDisplayId().value_or(ui::ADISPLAY_ID_NONE);
+ const ui::LogicalDisplayId displayId =
+ getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID);
float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
@@ -3961,7 +3963,7 @@
std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() {
if (mParameters.hasAssociatedDisplay) {
if (mDeviceMode == DeviceMode::POINTER) {
- return ui::ADISPLAY_ID_NONE;
+ return ui::LogicalDisplayId::INVALID;
} else {
return std::make_optional(mViewport.displayId);
}
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 0c9ffa2..b24f2ff 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -705,7 +705,7 @@
// Values reported for the last pointer event.
uint32_t source;
- ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE};
+ ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
float lastCursorX;
float lastCursorY;
@@ -718,7 +718,7 @@
hovering = false;
downTime = 0;
source = 0;
- displayId = ui::ADISPLAY_ID_NONE;
+ displayId = ui::LogicalDisplayId::INVALID;
lastCursorX = 0.f;
lastCursorY = 0.f;
}
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index e157862..b8911db 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -183,7 +183,6 @@
static AStatsManager_PullAtomCallbackReturn pullAtomCallback(int32_t atomTag,
AStatsEventList* outEventList,
void* cookie) {
- ALOGI("Received pull request for touchpad usage atom");
LOG_ALWAYS_FATAL_IF(atomTag != android::util::TOUCHPAD_USAGE);
MetricsAccumulator& accumulator = MetricsAccumulator::getInstance();
accumulator.produceAtomsAndReset(*outEventList);
@@ -191,14 +190,12 @@
}
void produceAtomsAndReset(AStatsEventList& outEventList) {
- ALOGI("Acquiring lock for touchpad usage metrics...");
std::scoped_lock lock(mLock);
produceAtomsLocked(outEventList);
resetCountersLocked();
}
void produceAtomsLocked(AStatsEventList& outEventList) const REQUIRES(mLock) {
- ALOGI("Producing touchpad usage atoms for %zu counters", mCounters.size());
for (auto& [id, counters] : mCounters) {
auto [busId, vendorId, productId, versionId] = id;
addAStatsEvent(&outEventList, android::util::TOUCHPAD_USAGE, vendorId, productId,
@@ -322,7 +319,7 @@
}
if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
- mDisplayId = ui::ADISPLAY_ID_NONE;
+ mDisplayId = ui::LogicalDisplayId::INVALID;
std::optional<DisplayViewport> resolvedViewport;
std::optional<FloatRect> boundsInLogicalDisplay;
if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) {
@@ -335,7 +332,8 @@
// Always use DISPLAY_ID_NONE for touchpad events.
// PointerChoreographer will make it target the correct the displayId later.
resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
- mDisplayId = resolvedViewport ? std::make_optional(ui::ADISPLAY_ID_NONE) : std::nullopt;
+ mDisplayId = resolvedViewport ? std::make_optional(ui::LogicalDisplayId::INVALID)
+ : std::nullopt;
}
mGestureConverter.setDisplayId(mDisplayId);
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index f27895f..546fa5b 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -107,7 +107,7 @@
std::set<int32_t> mPalmTrackingIds;
// The display that events generated by this mapper should target. This can be set to
- // ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e.
+ // LogicalDisplayId::INVALID to target the focused display. If there is no display target (i.e.
// std::nullopt), all events will be ignored.
std::optional<ui::LogicalDisplayId> mDisplayId;
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index ff95857..e8e7376 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -331,6 +331,7 @@
out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
+ coords.clear();
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
NotifyMotionArgs args =
diff --git a/services/inputflinger/tests/CursorInputMapper_test.cpp b/services/inputflinger/tests/CursorInputMapper_test.cpp
index 72b5573..83074ff 100644
--- a/services/inputflinger/tests/CursorInputMapper_test.cpp
+++ b/services/inputflinger/tests/CursorInputMapper_test.cpp
@@ -50,7 +50,7 @@
constexpr auto BUTTON_RELEASE = AMOTION_EVENT_ACTION_BUTTON_RELEASE;
constexpr auto HOVER_MOVE = AMOTION_EVENT_ACTION_HOVER_MOVE;
constexpr auto INVALID_CURSOR_POSITION = AMOTION_EVENT_INVALID_CURSOR_POSITION;
-constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
constexpr ui::LogicalDisplayId SECONDARY_DISPLAY_ID = ui::LogicalDisplayId{DISPLAY_ID.val() + 1};
constexpr int32_t DISPLAY_WIDTH = 480;
constexpr int32_t DISPLAY_HEIGHT = 800;
@@ -909,7 +909,8 @@
EXPECT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(ui::ADISPLAY_ID_NONE),
+ WithSource(AINPUT_SOURCE_MOUSE),
+ WithDisplayId(ui::LogicalDisplayId::INVALID),
WithCoords(0.0f, 0.0f)))));
}
diff --git a/services/inputflinger/tests/FakeInputReaderPolicy.cpp b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
index 088c7df..d2cb0ac 100644
--- a/services/inputflinger/tests/FakeInputReaderPolicy.cpp
+++ b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
@@ -129,7 +129,7 @@
void FakeInputReaderPolicy::addInputPortAssociation(const std::string& inputPort,
uint8_t displayPort) {
- mConfig.portAssociations.insert({inputPort, displayPort});
+ mConfig.inputPortToDisplayPortAssociations.insert({inputPort, displayPort});
}
void FakeInputReaderPolicy::addDeviceTypeAssociation(const std::string& inputPort,
@@ -139,7 +139,7 @@
void FakeInputReaderPolicy::addInputUniqueIdAssociation(const std::string& inputUniqueId,
const std::string& displayUniqueId) {
- mConfig.uniqueIdAssociationsByPort.insert({inputUniqueId, displayUniqueId});
+ mConfig.inputPortToDisplayUniqueIdAssociations.insert({inputUniqueId, displayUniqueId});
}
void FakeInputReaderPolicy::addKeyboardLayoutAssociation(const std::string& inputUniqueId,
diff --git a/services/inputflinger/tests/FakePointerController.cpp b/services/inputflinger/tests/FakePointerController.cpp
index 731a286..2bb57b3 100644
--- a/services/inputflinger/tests/FakePointerController.cpp
+++ b/services/inputflinger/tests/FakePointerController.cpp
@@ -53,7 +53,7 @@
ui::LogicalDisplayId FakePointerController::getDisplayId() const {
if (!mEnabled || !mDisplayId) {
- return ui::ADISPLAY_ID_NONE;
+ return ui::LogicalDisplayId::INVALID;
}
return *mDisplayId;
}
diff --git a/services/inputflinger/tests/FakeWindows.cpp b/services/inputflinger/tests/FakeWindows.cpp
index c800d6a..b116521 100644
--- a/services/inputflinger/tests/FakeWindows.cpp
+++ b/services/inputflinger/tests/FakeWindows.cpp
@@ -152,7 +152,7 @@
ASSERT_NE(nullptr, event) << mName.c_str() << ": consumer should have returned non-NULL event.";
ASSERT_EQ(InputEventType::FOCUS, event->getType()) << "Instead of FocusEvent, got " << *event;
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId())
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId())
<< mName.c_str() << ": event displayId should always be NONE.";
FocusEvent& focusEvent = static_cast<FocusEvent&>(*event);
@@ -165,7 +165,7 @@
ASSERT_EQ(InputEventType::CAPTURE, event->getType())
<< "Instead of CaptureEvent, got " << *event;
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId())
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId())
<< mName.c_str() << ": event displayId should always be NONE.";
const auto& captureEvent = static_cast<const CaptureEvent&>(*event);
@@ -177,7 +177,7 @@
ASSERT_NE(nullptr, event) << mName.c_str() << ": consumer should have returned non-NULL event.";
ASSERT_EQ(InputEventType::DRAG, event->getType()) << "Instead of DragEvent, got " << *event;
- EXPECT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId())
+ EXPECT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId())
<< mName.c_str() << ": event displayId should always be NONE.";
const auto& dragEvent = static_cast<const DragEvent&>(*event);
@@ -192,7 +192,7 @@
ASSERT_EQ(InputEventType::TOUCH_MODE, event->getType())
<< "Instead of TouchModeEvent, got " << *event;
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId())
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId())
<< mName.c_str() << ": event displayId should always be NONE.";
const auto& touchModeEvent = static_cast<const TouchModeEvent&>(*event);
EXPECT_EQ(inTouchMode, touchModeEvent.isInTouchMode());
diff --git a/services/inputflinger/tests/FakeWindows.h b/services/inputflinger/tests/FakeWindows.h
index 8a40337..36a8f00 100644
--- a/services/inputflinger/tests/FakeWindows.h
+++ b/services/inputflinger/tests/FakeWindows.h
@@ -261,22 +261,24 @@
}
inline void consumeMotionCancel(
- ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
int32_t expectedFlags = 0) {
consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL),
WithDisplayId(expectedDisplayId),
WithFlags(expectedFlags | AMOTION_EVENT_FLAG_CANCELED)));
}
- inline void consumeMotionMove(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
- int32_t expectedFlags = 0) {
+ inline void consumeMotionMove(
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
+ int32_t expectedFlags = 0) {
consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithDisplayId(expectedDisplayId),
WithFlags(expectedFlags)));
}
- inline void consumeMotionDown(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
- int32_t expectedFlags = 0) {
+ inline void consumeMotionDown(
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
+ int32_t expectedFlags = 0) {
consumeAnyMotionDown(expectedDisplayId, expectedFlags);
}
@@ -292,7 +294,8 @@
}
inline void consumeMotionPointerDown(
- int32_t pointerIdx, ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
+ int32_t pointerIdx,
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
int32_t expectedFlags = 0) {
const int32_t action = AMOTION_EVENT_ACTION_POINTER_DOWN |
(pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
@@ -302,7 +305,8 @@
}
inline void consumeMotionPointerUp(
- int32_t pointerIdx, ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
+ int32_t pointerIdx,
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
int32_t expectedFlags = 0) {
const int32_t action = AMOTION_EVENT_ACTION_POINTER_UP |
(pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
@@ -311,15 +315,16 @@
WithFlags(expectedFlags)));
}
- inline void consumeMotionUp(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
- int32_t expectedFlags = 0) {
+ inline void consumeMotionUp(
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
+ int32_t expectedFlags = 0) {
consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithDisplayId(expectedDisplayId),
WithFlags(expectedFlags)));
}
inline void consumeMotionOutside(
- ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT,
int32_t expectedFlags = 0) {
consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_OUTSIDE),
WithDisplayId(expectedDisplayId),
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index 1132e92..d0cd677 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -45,7 +45,6 @@
} // namespace
-using android::ui::ADISPLAY_ID_DEFAULT;
using testing::AllOf;
using testing::Each;
using testing::ElementsAre;
@@ -93,7 +92,7 @@
TEST_F(GestureConverterTest, Move) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
std::list<NotifyArgs> args =
@@ -107,9 +106,9 @@
WithRelativeMotion(-5, 10), WithButtonState(0),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// The same gesture again should only repeat the HOVER_MOVE, not the HOVER_ENTER.
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
@@ -118,14 +117,14 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithCoords(0, 0),
WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
WithButtonState(0), WithPressure(0.0f),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Move_Rotated) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
std::list<NotifyArgs> args =
@@ -139,15 +138,15 @@
WithRelativeMotion(10, 5), WithButtonState(0),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ButtonsChange) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
// Press left and right buttons at once
Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -170,9 +169,9 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
AMOTION_EVENT_BUTTON_SECONDARY)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Then release the left button
Gesture leftUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -185,7 +184,7 @@
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY), WithCoords(0, 0),
WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Finally release the right button
Gesture rightUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -201,15 +200,15 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithButtonState(0), WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ButtonDownAfterMoveExitsHover) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
std::list<NotifyArgs> args =
@@ -223,13 +222,13 @@
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), WithButtonState(0),
WithCoords(0, 0), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT))));
}
TEST_F(GestureConverterTest, DragWithButton) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
// Press the button
Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -246,9 +245,9 @@
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Move
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
@@ -258,7 +257,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, 0),
WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Release the button
Gesture upGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -274,16 +273,16 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithButtonState(0), WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Scroll) {
const nsecs_t downTime = 12345;
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args =
@@ -303,7 +302,7 @@
AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE),
WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
@@ -314,7 +313,7 @@
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(ToolType::FINGER),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
GESTURES_FLING_START);
@@ -332,8 +331,9 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Scroll_Rotated) {
@@ -341,7 +341,7 @@
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args =
@@ -360,7 +360,7 @@
Each(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
@@ -370,7 +370,7 @@
WithGestureScrollDistance(0, 5, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
GESTURES_FLING_START);
@@ -387,14 +387,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Scroll_ClearsClassificationAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args =
@@ -412,13 +413,13 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionClassification(MotionClassification::NONE),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Scroll_ClearsScrollDistanceAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args =
@@ -440,10 +441,47 @@
EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGestureScrollDistance(0, 0, EPSILON));
}
+TEST_F(GestureConverterTest, Scroll_ClearsFakeFingerPositionOnSubsequentScrollGestures) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
+
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 15, -10);
+ std::list<NotifyArgs> args =
+ converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
+
+ Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -2, -5);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
+
+ Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
+ GESTURES_FLING_START);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
+ Gesture flingGestureEnd(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 0,
+ GESTURES_FLING_TAP_DOWN);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGestureEnd);
+
+ // Start a second scoll gesture, and ensure the fake finger is reset to (0, 0), instead of
+ // continuing from the position where the last scroll gesture's fake finger ended.
+ Gesture secondScrollStart(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 2,
+ 14);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, secondScrollStart);
+ ASSERT_THAT(args,
+ ElementsAre(VariantWith<NotifyMotionArgs>(
+ WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT)),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
+ WithCoords(0, 0),
+ WithGestureScrollDistance(0, 0, EPSILON))),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
+ WithCoords(2, 14),
+ WithGestureScrollDistance(-2, -14, EPSILON)))));
+}
+
TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsClassificationAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0,
/*dy=*/0);
@@ -464,7 +502,7 @@
TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsGestureAxesAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/5,
/*dy=*/5);
@@ -491,7 +529,7 @@
// only checks movement in one dimension.
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0,
/* dy= */ 10);
@@ -502,7 +540,7 @@
Each(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
WithGestureSwipeFingerCount(3), WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Three fake fingers should be created. We don't actually care where they are, so long as they
// move appropriately.
@@ -548,7 +586,7 @@
WithGestureOffset(0, -0.005, EPSILON), WithGestureSwipeFingerCount(3),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
WithPointerCount(3u), WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX());
EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX());
EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX());
@@ -589,22 +627,24 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0,
/* dy= */ 10);
std::list<NotifyArgs> args =
converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
ASSERT_EQ(4u, args.size());
- ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::ADISPLAY_ID_DEFAULT))));
+ ASSERT_THAT(args,
+ Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::LogicalDisplayId::DEFAULT))));
// Three fake fingers should be created. We don't actually care where they are, so long as they
// move appropriately.
@@ -648,7 +688,7 @@
ASSERT_THAT(arg,
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithGestureOffset(0, -0.005, EPSILON), WithPointerCount(3u),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 15);
EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 15);
EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 15);
@@ -674,13 +714,14 @@
WithGestureOffset(0, 0, EPSILON), WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))));
- ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT))));
+ ASSERT_THAT(args,
+ Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::LogicalDisplayId::DEFAULT))));
}
TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* dx= */ 10, /* dy= */ 0);
@@ -691,7 +732,7 @@
Each(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
WithGestureSwipeFingerCount(4), WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Four fake fingers should be created. We don't actually care where they are, so long as they
// move appropriately.
@@ -746,7 +787,7 @@
WithGestureOffset(0.005, 0, EPSILON), WithGestureSwipeFingerCount(4),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
WithPointerCount(4u), WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 15);
EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 15);
EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 15);
@@ -798,14 +839,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Pinch_Inwards) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_START);
@@ -825,7 +867,7 @@
AllOf(WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* dz= */ 0.8, GESTURES_ZOOM_UPDATE);
@@ -837,7 +879,7 @@
WithGesturePinchScaleFactor(0.8f, EPSILON),
WithPointerCoords(0, -80, 0), WithPointerCoords(1, 80, 0),
WithPointerCount(2u), WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_END);
@@ -860,14 +902,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Pinch_Outwards) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_START);
@@ -887,7 +930,7 @@
AllOf(WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* dz= */ 1.1, GESTURES_ZOOM_UPDATE);
@@ -899,7 +942,7 @@
WithGesturePinchScaleFactor(1.1f, EPSILON),
WithPointerCoords(0, -110, 0), WithPointerCoords(1, 110, 0),
WithPointerCount(2u), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_END);
@@ -922,14 +965,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Pinch_ClearsClassificationAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
GESTURES_ZOOM_START);
@@ -954,7 +998,7 @@
TEST_F(GestureConverterTest, Pinch_ClearsScaleFactorAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
GESTURES_ZOOM_START);
@@ -981,7 +1025,7 @@
TEST_F(GestureConverterTest, ResetWithButtonPressed) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/*down=*/GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT,
@@ -1005,15 +1049,15 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithButtonState(0)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ResetDuringScroll) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
(void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
@@ -1032,14 +1076,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ResetDuringThreeFingerSwipe) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0,
/*dy=*/10);
@@ -1073,14 +1118,15 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, ResetDuringPinch) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
GESTURES_ZOOM_START);
@@ -1105,14 +1151,15 @@
WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, FlingTapDown) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN);
@@ -1122,14 +1169,15 @@
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0),
WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER),
- WithButtonState(0), WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ WithButtonState(0), WithPressure(0.0f),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
}
TEST_F(GestureConverterTest, FlingTapDownAfterScrollStopsFling) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
input_flags::enable_touchpad_fling_stop(true);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args =
@@ -1153,7 +1201,7 @@
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(
AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE)))));
}
@@ -1161,7 +1209,7 @@
// Tap should produce button press/release events
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
/* vy= */ 0, GESTURES_FLING_TAP_DOWN);
@@ -1198,17 +1246,17 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithButtonState(0), WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F(GestureConverterTest, Click) {
// Click should produce button press/release events
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
/* vy= */ 0, GESTURES_FLING_TAP_DOWN);
@@ -1235,10 +1283,10 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithPressure(1.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* down= */ GESTURES_BUTTON_NONE,
@@ -1257,10 +1305,10 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithButtonState(0), WithCoords(0, 0), WithRelativeMotion(0.f, 0.f),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
}
TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled,
@@ -1273,7 +1321,7 @@
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
/* vy= */ 0, GESTURES_FLING_TAP_DOWN);
@@ -1302,7 +1350,7 @@
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
/* vy= */ 0, GESTURES_FLING_TAP_DOWN);
@@ -1384,7 +1432,7 @@
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
/* vy= */ 0, GESTURES_FLING_TAP_DOWN);
@@ -1411,10 +1459,10 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithPressure(1.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* down= */ GESTURES_BUTTON_NONE,
@@ -1428,18 +1476,20 @@
WithButtonState(0), WithCoords(0, 0),
WithRelativeMotion(0.f, 0.f),
WithToolType(ToolType::FINGER), WithButtonState(0),
- WithPressure(1.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))),
+ WithPressure(1.0f),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithCoords(0, 0), WithRelativeMotion(0.f, 0.f),
WithToolType(ToolType::FINGER), WithButtonState(0),
- WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))),
+ WithPressure(0.0f),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithCoords(0, 0), WithRelativeMotion(0, 0),
WithToolType(ToolType::FINGER), WithButtonState(0),
WithPressure(0.0f),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)))));
// Future taps should be re-enabled
ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
@@ -1452,7 +1502,7 @@
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
std::list<NotifyArgs> args =
@@ -1468,7 +1518,7 @@
const nsecs_t gestureStartTime = 1000;
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
// Start a move gesture at gestureStartTime
Gesture moveGesture(kGestureMove, gestureStartTime, gestureStartTime, -5, 10);
diff --git a/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp b/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp
index 029414b..28699b8 100644
--- a/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp
+++ b/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp
@@ -63,7 +63,7 @@
uint32_t sources = TOUCHSCREEN | STYLUS) {
auto info = InputDeviceInfo();
info.initialize(id, /*generation=*/1, /*controllerNumber=*/1, generateTestIdentifier(id),
- "alias", /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE);
+ "alias", /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID);
info.addSource(sources);
return info;
}
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 184659d..8de28c6 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -53,7 +53,6 @@
using android::gui::WindowInfoHandle;
using android::os::InputEventInjectionResult;
using android::os::InputEventInjectionSync;
-using android::ui::ADISPLAY_ID_DEFAULT;
namespace android::inputdispatcher {
@@ -73,7 +72,7 @@
static constexpr int32_t SECOND_DEVICE_ID = 2;
// An arbitrary display id.
-constexpr ui::LogicalDisplayId DISPLAY_ID = ADISPLAY_ID_DEFAULT;
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
constexpr ui::LogicalDisplayId SECOND_DISPLAY_ID = ui::LogicalDisplayId{1};
// Ensure common actions are interchangeable between keys and motions for convenience.
@@ -129,9 +128,9 @@
static KeyEvent getTestKeyEvent() {
KeyEvent event;
- event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE,
- INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0,
- ARBITRARY_TIME, ARBITRARY_TIME);
+ event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0,
+ AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
return event;
}
@@ -253,8 +252,8 @@
KeyEvent event;
// Rejects undefined key actions.
- event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE,
- INVALID_HMAC,
+ event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC,
/*action=*/-1, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME,
ARBITRARY_TIME);
ASSERT_EQ(InputEventInjectionResult::FAILED,
@@ -263,9 +262,9 @@
<< "Should reject key events with undefined action.";
// Rejects ACTION_MULTIPLE since it is not supported despite being defined in the API.
- event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE,
- INVALID_HMAC, AKEY_EVENT_ACTION_MULTIPLE, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0,
- ARBITRARY_TIME, ARBITRARY_TIME);
+ event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_MULTIPLE, 0,
+ AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
ASSERT_EQ(InputEventInjectionResult::FAILED,
mDispatcher->injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE,
0ms, 0))
@@ -482,7 +481,7 @@
void consumeMotionPointerDown(int32_t pointerIdx) {
int32_t action = AMOTION_EVENT_ACTION_POINTER_DOWN |
(pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
- mInputReceiver.consumeEvent(InputEventType::MOTION, action, ADISPLAY_ID_DEFAULT,
+ mInputReceiver.consumeEvent(InputEventType::MOTION, action, ui::LogicalDisplayId::DEFAULT,
/*expectedFlags=*/0);
}
@@ -500,7 +499,7 @@
static InputEventInjectionResult injectKey(
InputDispatcher& dispatcher, int32_t action, int32_t repeatCount,
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE,
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID,
InputEventInjectionSync syncMode = InputEventInjectionSync::WAIT_FOR_RESULT,
std::chrono::milliseconds injectionTimeout = INJECT_EVENT_TIMEOUT,
bool allowKeyRepeat = true, std::optional<gui::Uid> targetUid = {},
@@ -522,15 +521,17 @@
static void assertInjectedKeyTimesOut(InputDispatcher& dispatcher) {
InputEventInjectionResult result =
- injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ui::ADISPLAY_ID_NONE,
- InputEventInjectionSync::WAIT_FOR_RESULT, CONSUME_TIMEOUT_NO_EVENT_EXPECTED);
+ injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::INVALID, InputEventInjectionSync::WAIT_FOR_RESULT,
+ CONSUME_TIMEOUT_NO_EVENT_EXPECTED);
if (result != InputEventInjectionResult::TIMED_OUT) {
FAIL() << "Injection should have timed out, but got " << ftl::enum_string(result);
}
}
static InputEventInjectionResult injectKeyDown(
- InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+ InputDispatcher& dispatcher,
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
return injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, displayId);
}
@@ -538,14 +539,16 @@
// sending a subsequent key up. When key repeat is enabled, the dispatcher cannot idle because it
// has to be woken up to process the repeating key.
static InputEventInjectionResult injectKeyDownNoRepeat(
- InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+ InputDispatcher& dispatcher,
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
return injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, displayId,
InputEventInjectionSync::WAIT_FOR_RESULT, INJECT_EVENT_TIMEOUT,
/*allowKeyRepeat=*/false);
}
static InputEventInjectionResult injectKeyUp(
- InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+ InputDispatcher& dispatcher,
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
return injectKey(dispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0, displayId);
}
@@ -596,8 +599,8 @@
return injectMotionEvent(dispatcher, AMOTION_EVENT_ACTION_UP, source, displayId, location);
}
-static NotifyKeyArgs generateKeyArgs(int32_t action,
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+static NotifyKeyArgs generateKeyArgs(
+ int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC);
// Define a valid key event.
NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID,
@@ -608,7 +611,7 @@
}
static NotifyKeyArgs generateSystemShortcutArgs(
- int32_t action, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+ int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC);
// Define a valid key event.
NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID,
@@ -619,7 +622,7 @@
}
static NotifyKeyArgs generateAssistantKeyArgs(
- int32_t action, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) {
+ int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) {
nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC);
// Define a valid key event.
NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID,
@@ -686,9 +689,9 @@
*/
TEST_F(InputDispatcherTest, WhenInputChannelBreaks_PolicyIsNotified) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher,
- "Window that breaks its input channel", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
+ "Window that breaks its input channel",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -699,16 +702,18 @@
TEST_F(InputDispatcherTest, SetInputWindow_SingleWindowTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Window should receive motion event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
using InputDispatcherDeathTest = InputDispatcherTest;
@@ -722,8 +727,9 @@
ScopedSilentDeath _silentDeath;
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
ASSERT_DEATH(mDispatcher->onWindowInfosChanged(
{{*window->getInfo(), *window->getInfo()}, {}, 0, 0}),
"Incorrect WindowInfosUpdate provided");
@@ -731,17 +737,19 @@
TEST_F(InputDispatcherTest, WhenDisplayNotSpecified_InjectMotionToDefaultDisplay) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
// Inject a MotionEvent to an unknown display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::ADISPLAY_ID_NONE))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::INVALID))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Window should receive motion event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
/**
@@ -751,18 +759,19 @@
*/
TEST_F(InputDispatcherTest, SetInputWindowOnceWithSingleTouchWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Window should receive motion event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
/**
@@ -770,37 +779,40 @@
*/
TEST_F(InputDispatcherTest, SetInputWindowTwice_SingleWindowTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Window should receive motion event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
// The foreground window should receive the first touch down event.
TEST_F(InputDispatcherTest, SetInputWindow_MultiWindowsTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowTop =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> windowSecond =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged(
{{*windowTop->getInfo(), *windowSecond->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Top window should receive the touch down event. Second window should not receive anything.
- windowTop->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ windowTop->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
windowSecond->assertNoEvents();
}
@@ -814,10 +826,12 @@
TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCanceled) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> foregroundWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
foregroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaperWindow->setIsWallpaper(true);
mDispatcher->onWindowInfosChanged(
@@ -831,7 +845,7 @@
// Both foreground window and its wallpaper should receive the touch down
foregroundWindow->consumeMotionDown();
- wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher,
@@ -841,13 +855,13 @@
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
foregroundWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
- wallpaperWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Now the foreground window goes away, but the wallpaper stays
mDispatcher->onWindowInfosChanged({{*wallpaperWindow->getInfo()}, {}, 0, 0});
foregroundWindow->consumeMotionCancel();
// Since the "parent" window of the wallpaper is gone, wallpaper should receive cancel, too.
- wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
}
/**
@@ -857,8 +871,8 @@
*/
TEST_F(InputDispatcherTest, CancelAfterPointer0Up) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
// First touch pointer down on right window
@@ -897,30 +911,32 @@
TEST_F(InputDispatcherTest, WhenWallpaperDisappears_NoCrash) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> foregroundWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
foregroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaperWindow->setIsWallpaper(true);
mDispatcher->onWindowInfosChanged(
{{*foregroundWindow->getInfo(), *wallpaperWindow->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Both foreground window and its wallpaper should receive the touch down
foregroundWindow->consumeMotionDown();
- wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 200}))
+ ui::LogicalDisplayId::DEFAULT, {110, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
foregroundWindow->consumeMotionMove();
- wallpaperWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Wallpaper closes its channel, but the window remains.
wallpaperWindow->destroyReceiver();
@@ -942,23 +958,23 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftForegroundWindow->setFrame(Rect(0, 0, 100, 100));
leftForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> leftWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100));
leftWallpaperWindow->setIsWallpaper(true);
sp<FakeWindowHandle> rightForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightForegroundWindow->setFrame(Rect(100, 0, 200, 100));
rightForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> rightWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWallpaperWindow->setFrame(Rect(100, 0, 200, 100));
rightWallpaperWindow->setIsWallpaper(true);
@@ -1026,35 +1042,35 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftForegroundWindow->setFrame(Rect(0, 0, 100, 100));
leftForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> leftWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100));
leftWallpaperWindow->setIsWallpaper(true);
sp<FakeWindowHandle> middleForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Middle foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
middleForegroundWindow->setFrame(Rect(100, 0, 200, 100));
middleForegroundWindow->setDupTouchToWallpaper(true);
middleForegroundWindow->setSlippery(true);
sp<FakeWindowHandle> middleWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Middle wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
middleWallpaperWindow->setFrame(Rect(100, 0, 200, 100));
middleWallpaperWindow->setIsWallpaper(true);
sp<FakeWindowHandle> rightForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightForegroundWindow->setFrame(Rect(200, 0, 300, 100));
rightForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> rightWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWallpaperWindow->setFrame(Rect(200, 0, 300, 100));
rightWallpaperWindow->setIsWallpaper(true);
@@ -1132,34 +1148,34 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftForegroundWindow->setFrame(Rect(0, 0, 100, 100));
leftForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> leftWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100));
leftWallpaperWindow->setIsWallpaper(true);
sp<FakeWindowHandle> middleForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Middle foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
middleForegroundWindow->setFrame(Rect(100, 0, 200, 100));
middleForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> middleWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Middle wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
middleWallpaperWindow->setFrame(Rect(100, 0, 200, 100));
middleWallpaperWindow->setIsWallpaper(true);
sp<FakeWindowHandle> rightForegroundWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightForegroundWindow->setFrame(Rect(200, 0, 300, 100));
rightForegroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> rightWallpaperWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWallpaperWindow->setFrame(Rect(200, 0, 300, 100));
rightWallpaperWindow->setIsWallpaper(true);
@@ -1239,12 +1255,14 @@
TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> foregroundWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
foregroundWindow->setDupTouchToWallpaper(true);
foregroundWindow->setPreventSplitting(GetParam());
sp<FakeWindowHandle> wallpaperWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaperWindow->setIsWallpaper(true);
mDispatcher->onWindowInfosChanged(
@@ -1252,13 +1270,13 @@
// Touch down on top window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 100}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Both top window and its wallpaper should receive the touch down
foregroundWindow->consumeMotionDown();
- wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Second finger down on the top window
const MotionEvent secondFingerDownEvent =
@@ -1272,12 +1290,12 @@
InputEventInjectionSync::WAIT_FOR_RESULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
foregroundWindow->consumeMotionPointerDown(/*pointerIndex=*/1);
- wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ADISPLAY_ID_DEFAULT,
+ wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ui::LogicalDisplayId::DEFAULT,
EXPECTED_WALLPAPER_FLAGS);
const MotionEvent secondFingerUpEvent =
MotionEventBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150))
@@ -1287,13 +1305,14 @@
InputEventInjectionSync::WAIT_FOR_RESULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
foregroundWindow->consumeMotionPointerUp(0);
- wallpaperWindow->consumeMotionPointerUp(0, ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionPointerUp(0, ui::LogicalDisplayId::DEFAULT,
+ EXPECTED_WALLPAPER_FLAGS);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_UP,
AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER)
.x(100)
@@ -1301,8 +1320,8 @@
.build(),
INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- foregroundWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
- wallpaperWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ foregroundWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
+ wallpaperWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
}
/**
@@ -1315,18 +1334,19 @@
*/
TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
leftWindow->setDupTouchToWallpaper(true);
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
rightWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaperWindow->setFrame(Rect(0, 0, 400, 200));
wallpaperWindow->setIsWallpaper(true);
@@ -1338,13 +1358,13 @@
// Touch down on left window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 100}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Both foreground window and its wallpaper should receive the touch down
leftWindow->consumeMotionDown();
- wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Second finger down on the right window
const MotionEvent secondFingerDownEvent =
@@ -1360,8 +1380,8 @@
leftWindow->consumeMotionMove();
// Since the touch is split, right window gets ACTION_DOWN
- rightWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ADISPLAY_ID_DEFAULT,
+ rightWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ui::LogicalDisplayId::DEFAULT,
EXPECTED_WALLPAPER_FLAGS);
// Now, leftWindow, which received the first finger, disappears.
@@ -1369,7 +1389,7 @@
{{*rightWindow->getInfo(), *wallpaperWindow->getInfo()}, {}, 0, 0});
leftWindow->consumeMotionCancel();
// Since a "parent" window of the wallpaper is gone, wallpaper should receive cancel, too.
- wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// The pointer that's still down on the right window moves, and goes to the right window only.
// As far as the dispatcher's concerned though, both pointers are still present.
@@ -1396,18 +1416,19 @@
*/
TEST_F(InputDispatcherTest, WallpaperWindowWhenSlippery) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
leftWindow->setDupTouchToWallpaper(true);
leftWindow->setSlippery(true);
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
sp<FakeWindowHandle> wallpaperWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaperWindow->setIsWallpaper(true);
mDispatcher->onWindowInfosChanged(
@@ -1418,23 +1439,23 @@
// Touch down on left window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 100}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Both foreground window and its wallpaper should receive the touch down
leftWindow->consumeMotionDown();
- wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Move to right window, the left window should receive cancel.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {201, 100}))
+ ui::LogicalDisplayId::DEFAULT, {201, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
leftWindow->consumeMotionCancel();
- rightWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ rightWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
}
/**
@@ -1455,14 +1476,14 @@
*/
TEST_F(InputDispatcherTest, TwoPointerCancelInconsistentPolicy) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
@@ -1533,8 +1554,8 @@
TEST_F(InputDispatcherTest, HoverEventInconsistentPolicy) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 300, 300));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -1595,12 +1616,12 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -1703,12 +1724,12 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -1792,8 +1813,8 @@
*/
TEST_F(InputDispatcherTest, HoverWhileWindowAppears) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
// Only a single window is present at first
@@ -1808,7 +1829,7 @@
// Now, an obscuring window appears!
sp<FakeWindowHandle> obscuringWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Obscuring window",
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
/*createInputChannel=*/false);
obscuringWindow->setFrame(Rect(0, 0, 200, 200));
obscuringWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED);
@@ -1841,8 +1862,8 @@
*/
TEST_F(InputDispatcherTest, HoverMoveWhileWindowAppears) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
// Only a single window is present at first
@@ -1857,7 +1878,7 @@
// Now, an obscuring window appears!
sp<FakeWindowHandle> obscuringWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Obscuring window",
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
/*createInputChannel=*/false);
obscuringWindow->setFrame(Rect(0, 0, 200, 200));
obscuringWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED);
@@ -1899,8 +1920,8 @@
*/
TEST_F(InputDispatcherTest, HoverMoveAndScroll) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -1931,8 +1952,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusDownBlocksTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -1978,8 +1999,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusDownDoesNotBlockTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2027,10 +2048,10 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyBlocksTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
@@ -2086,10 +2107,10 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyDoesNotBlockTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
@@ -2148,8 +2169,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusHoverBlocksTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2200,8 +2221,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusHoverDoesNotBlockTouchDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2254,8 +2275,8 @@
TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusHover) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2308,8 +2329,8 @@
TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusHover) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2363,8 +2384,8 @@
TEST_F(InputDispatcherMultiDeviceTest, LatestStylusWins) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2415,8 +2436,8 @@
TEST_F(InputDispatcherMultiDeviceTest, TwoStylusDevicesActiveAtTheSameTime) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2463,8 +2484,8 @@
TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2508,8 +2529,8 @@
TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -2562,12 +2583,12 @@
TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -2647,12 +2668,12 @@
TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -2725,12 +2746,12 @@
*/
TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceHover) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -2784,18 +2805,18 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 400, 400));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
@@ -2860,18 +2881,18 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 400, 400));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
@@ -2939,18 +2960,18 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 400, 400));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -3015,18 +3036,18 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 400, 400));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -3092,8 +3113,8 @@
TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3172,8 +3193,8 @@
TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3247,8 +3268,8 @@
TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3284,8 +3305,8 @@
TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3328,12 +3349,12 @@
TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -3414,12 +3435,12 @@
TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
mDispatcher->onWindowInfosChanged(
@@ -3481,8 +3502,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusHoverIgnoresTouchTap) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3548,8 +3569,8 @@
TEST_F(InputDispatcherMultiDeviceTest, StylusHoverWithTouchTap) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3608,12 +3629,13 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> sbtRightWindow =
sp<FakeWindowHandle>::make(application, mDispatcher,
- "Stylus blocks touch (right) window", ADISPLAY_ID_DEFAULT);
+ "Stylus blocks touch (right) window",
+ ui::LogicalDisplayId::DEFAULT);
sbtRightWindow->setFrame(Rect(100, 100, 200, 200));
sbtRightWindow->setGlobalStylusBlocksTouch(true);
@@ -3680,12 +3702,13 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> sbtRightWindow =
sp<FakeWindowHandle>::make(application, mDispatcher,
- "Stylus blocks touch (right) window", ADISPLAY_ID_DEFAULT);
+ "Stylus blocks touch (right) window",
+ ui::LogicalDisplayId::DEFAULT);
sbtRightWindow->setFrame(Rect(100, 100, 200, 200));
sbtRightWindow->setGlobalStylusBlocksTouch(true);
@@ -3746,13 +3769,13 @@
*/
TEST_F(InputDispatcherTest, StylusHoverAndDownNoInputChannel) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setNoInputChannel(true);
window->setFrame(Rect(0, 0, 200, 200));
@@ -3805,8 +3828,8 @@
TEST_F(InputDispatcherTest, StaleStylusHoverGestureIsComplete) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -3844,13 +3867,13 @@
TEST_F(InputDispatcherTest, TouchPilferAndMouseMove_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
@@ -3947,13 +3970,13 @@
TEST_F(InputDispatcherTest, TouchPilferAndMouseMove) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 200, 200));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
@@ -4171,14 +4194,14 @@
TEST_F(InputDispatcherTest, HoverMoveEnterMouseClickAndHoverMoveExit) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowLeft =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowLeft = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- sp<FakeWindowHandle> windowRight =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowRight = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged(
{{*windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0});
@@ -4238,7 +4261,7 @@
.buttonState(0)
.pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
- windowLeft->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ windowLeft->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
// Move mouse cursor back to right window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -4262,8 +4285,8 @@
TEST_F(InputDispatcherTest, TwoPointersDownMouseClick_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 600, 800));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4322,8 +4345,8 @@
TEST_F(InputDispatcherTest, TwoPointersDownMouseClick) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 600, 800));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4376,16 +4399,16 @@
TEST_F(InputDispatcherTest, HoverWithSpyWindows) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 600, 800));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 600, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
// Send mouse cursor to the window
@@ -4409,16 +4432,16 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 600, 800));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 600, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
// Send mouse cursor to the window
@@ -4516,16 +4539,16 @@
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(0, 0, 600, 800));
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 600, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
// Send mouse cursor to the window
@@ -4612,11 +4635,11 @@
// directly in this test.
TEST_F(InputDispatcherTest, HoverEnterMouseClickAndHoverExit) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 1200, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4663,7 +4686,7 @@
.buttonState(0)
.pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
- window->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
// We already canceled the hovering implicitly by injecting the "DOWN" event without lifting the
// hover first. Therefore, injection of HOVER_EXIT is inconsistent, and should fail.
@@ -4682,11 +4705,11 @@
*/
TEST_F(InputDispatcherTest, HoverExitIsSentToRemovedWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 1200, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4710,11 +4733,11 @@
REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(com::android::input::flags,
a11y_crash_on_inconsistent_event_stream))) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 1200, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4736,8 +4759,8 @@
TEST_F(InputDispatcherTest, TouchDownAfterMouseHover_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4770,8 +4793,8 @@
TEST_F(InputDispatcherTest, TouchDownAfterMouseHover) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4803,8 +4826,8 @@
TEST_F(InputDispatcherTest, MouseHoverAndTouchTap_legacy) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4843,8 +4866,8 @@
TEST_F(InputDispatcherTest, MouseHoverAndTouchTap) {
SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4878,7 +4901,7 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> windowDefaultDisplay =
sp<FakeWindowHandle>::make(application, mDispatcher, "DefaultDisplay",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
windowDefaultDisplay->setFrame(Rect(0, 0, 600, 800));
sp<FakeWindowHandle> windowSecondDisplay =
sp<FakeWindowHandle>::make(application, mDispatcher, "SecondDisplay",
@@ -4894,7 +4917,7 @@
injectMotionEvent(*mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(600))
.build()));
windowDefaultDisplay->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER));
@@ -4913,7 +4936,7 @@
injectMotionEvent(*mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.pointer(PointerBuilder(0, ToolType::MOUSE).x(400).y(700))
.build()));
windowDefaultDisplay->consumeMotionEvent(
@@ -4925,14 +4948,14 @@
TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowLeft =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowLeft = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- sp<FakeWindowHandle> windowRight =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowRight = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged(
{{*windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0});
@@ -4941,15 +4964,16 @@
// left window. This event should be dispatched to the left window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE,
- ADISPLAY_ID_DEFAULT, {610, 400}, {599, 400}));
- windowLeft->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT, {610, 400}, {599, 400}));
+ windowLeft->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
windowRight->assertNoEvents();
}
TEST_F(InputDispatcherTest, NotifyDeviceReset_CancelsKeyStream) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -4957,41 +4981,44 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
// Window should receive key down event.
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
// When device reset happens, that key stream should be terminated with FLAG_CANCELED
// on the app side.
mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT, AKEY_EVENT_FLAG_CANCELED);
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, AKEY_EVENT_FLAG_CANCELED);
}
TEST_F(InputDispatcherTest, NotifyDeviceReset_CancelsMotionStream) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
// Window should receive motion down event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// When device reset happens, that motion stream should be terminated with ACTION_CANCEL
// on the app side.
mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
window->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
}
TEST_F(InputDispatcherTest, NotifyDeviceResetCancelsHoveringStream) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5014,8 +5041,9 @@
TEST_F(InputDispatcherTest, InterceptKeyByPolicy) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5023,13 +5051,14 @@
window->consumeFocusEvent(true);
- const NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
+ const NotifyKeyArgs keyArgs =
+ generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT);
const std::chrono::milliseconds interceptKeyTimeout = 50ms;
const nsecs_t injectTime = keyArgs.eventTime;
mFakePolicy->setInterceptKeyTimeout(interceptKeyTimeout);
mDispatcher->notifyKey(keyArgs);
// The dispatching time should be always greater than or equal to intercept key timeout.
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
ASSERT_TRUE((systemTime(SYSTEM_TIME_MONOTONIC) - injectTime) >=
std::chrono::nanoseconds(interceptKeyTimeout).count());
}
@@ -5039,8 +5068,9 @@
*/
TEST_F(InputDispatcherTest, InterceptKeyIfKeyUp) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5048,15 +5078,15 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
// Set a value that's significantly larger than the default consumption timeout. If the
// implementation is correct, the actual value doesn't matter; it won't slow down the test.
mFakePolicy->setInterceptKeyTimeout(600ms);
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT));
// Window should receive key event immediately when same key up.
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT);
}
/**
@@ -5068,13 +5098,13 @@
*/
TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinates) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect{0, 0, 100, 100});
sp<FakeWindowHandle> outsideWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Outside Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
outsideWindow->setFrame(Rect{100, 100, 200, 200});
outsideWindow->setWatchOutsideTouch(true);
// outsideWindow must be above 'window' to receive ACTION_OUTSIDE events when 'window' is tapped
@@ -5082,8 +5112,8 @@
// Tap on first window.
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{50, 50}}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {PointF{50, 50}}));
window->consumeMotionDown();
// The coordinates of the tap in 'outsideWindow' are relative to its top left corner.
// Therefore, we should offset them by (100, 100) relative to the screen's top left corner.
@@ -5092,7 +5122,7 @@
// Ensure outsideWindow doesn't get any more events for the gesture.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{51, 51}}));
+ ui::LogicalDisplayId::DEFAULT, {PointF{51, 51}}));
window->consumeMotionMove();
outsideWindow->assertNoEvents();
}
@@ -5116,13 +5146,13 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect{0, 0, 100, 100});
leftWindow->setOwnerInfo(gui::Pid{1}, gui::Uid{101});
sp<FakeWindowHandle> outsideWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Outside Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
outsideWindow->setFrame(Rect{100, 100, 200, 200});
outsideWindow->setOwnerInfo(gui::Pid{1}, gui::Uid{101});
outsideWindow->setWatchOutsideTouch(true);
@@ -5131,7 +5161,7 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> rightWindow =
sp<FakeWindowHandle>::make(anotherApplication, mDispatcher, "Right Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect{100, 0, 200, 100});
rightWindow->setOwnerInfo(gui::Pid{2}, gui::Uid{202});
@@ -5195,32 +5225,33 @@
TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) {
// There are three windows that do not overlap. `window` wants to WATCH_OUTSIDE_TOUCH.
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "First Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setWatchOutsideTouch(true);
window->setFrame(Rect{0, 0, 100, 100});
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setFrame(Rect{100, 100, 200, 200});
sp<FakeWindowHandle> thirdWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Third Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
thirdWindow->setFrame(Rect{200, 200, 300, 300});
mDispatcher->onWindowInfosChanged(
{{*window->getInfo(), *secondWindow->getInfo(), *thirdWindow->getInfo()}, {}, 0, 0});
// First pointer lands outside all windows. `window` does not get ACTION_OUTSIDE.
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{-10, -10}}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {PointF{-10, -10}}));
window->assertNoEvents();
secondWindow->assertNoEvents();
// The second pointer lands inside `secondWindow`, which should receive a DOWN event.
// Now, `window` should get ACTION_OUTSIDE.
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{PointF{-10, -10}, PointF{105, 105}}));
const std::map<int32_t, PointF> expectedPointers{{0, PointF{-10, -10}}, {1, PointF{105, 105}}};
window->consumeMotionEvent(
@@ -5231,7 +5262,8 @@
// The third pointer lands inside `thirdWindow`, which should receive a DOWN event. There is
// no ACTION_OUTSIDE sent to `window` because one has already been sent for this gesture.
mDispatcher->notifyMotion(
- generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT,
{PointF{-10, -10}, PointF{105, 105}, PointF{205, 205}}));
window->assertNoEvents();
secondWindow->consumeMotionMove();
@@ -5240,8 +5272,9 @@
TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5249,13 +5282,15 @@
window->consumeFocusEvent(true);
- const NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- const NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
+ const NotifyKeyArgs keyDown =
+ generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT);
+ const NotifyKeyArgs keyUp =
+ generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyKey(keyDown);
mDispatcher->notifyKey(keyUp);
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT);
// All windows are removed from the display. Ensure that we can no longer dispatch to it.
mDispatcher->onWindowInfosChanged({{}, {}, 0, 0});
@@ -5269,22 +5304,23 @@
TEST_F(InputDispatcherTest, NonSplitTouchableWindowReceivesMultiTouch) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
// Ensure window is non-split and have some transform.
window->setPreventSplitting(true);
window->setWindowOffset(20, 40);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(-30).y(-50))
@@ -5315,12 +5351,12 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left splittable Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setPreventSplitting(false);
leftWindow->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> rightWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right non-splittable Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setPreventSplitting(true);
rightWindow->setFrame(Rect(100, 100, 200, 200));
mDispatcher->onWindowInfosChanged(
@@ -5343,12 +5379,12 @@
TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeOnlySentToTrustedOverlays) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
sp<FakeWindowHandle> trustedOverlay =
sp<FakeWindowHandle>::make(application, mDispatcher, "Trusted Overlay",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
trustedOverlay->setSpy(true);
trustedOverlay->setTrustedOverlay(true);
@@ -5411,8 +5447,8 @@
TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeNotSentToSingleWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5468,8 +5504,8 @@
*/
TEST_F(InputDispatcherTest, MultiplePointersWithRotatingWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 400, 400));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -5534,13 +5570,14 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> spyWindowDefaultDisplay =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindowDefaultDisplay->setTrustedOverlay(true);
spyWindowDefaultDisplay->setSpy(true);
sp<FakeWindowHandle> windowDefaultDisplay =
sp<FakeWindowHandle>::make(application, mDispatcher, "DefaultDisplay",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
windowDefaultDisplay->setWindowTransform(1, 0, 0, 1);
sp<FakeWindowHandle> windowSecondDisplay = windowDefaultDisplay->clone(SECOND_DISPLAY_ID);
@@ -5554,10 +5591,10 @@
0,
0});
- // Send down to ADISPLAY_ID_DEFAULT
+ // Send down to ui::LogicalDisplayId::DEFAULT
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 100}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
spyWindowDefaultDisplay->consumeMotionDown();
@@ -5570,10 +5607,10 @@
ASSERT_NE(nullptr, event);
EXPECT_EQ(AMOTION_EVENT_ACTION_CANCEL, event->getAction());
- // The cancel event is sent to windowDefaultDisplay of the ADISPLAY_ID_DEFAULT display, so
- // the coordinates of the cancel are converted by windowDefaultDisplay's transform, the x and y
- // coordinates are both 100, otherwise if the cancel event is sent to windowSecondDisplay of
- // SECOND_DISPLAY_ID, the x and y coordinates are 200
+ // The cancel event is sent to windowDefaultDisplay of the ui::LogicalDisplayId::DEFAULT
+ // display, so the coordinates of the cancel are converted by windowDefaultDisplay's transform,
+ // the x and y coordinates are both 100, otherwise if the cancel event is sent to
+ // windowSecondDisplay of SECOND_DISPLAY_ID, the x and y coordinates are 200
EXPECT_EQ(100, event->getX(0));
EXPECT_EQ(100, event->getY(0));
}
@@ -5617,7 +5654,7 @@
// respectively.
ui::Transform displayTransform;
displayTransform.set(2, 0, 0, 4);
- addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform);
+ addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform);
std::shared_ptr<FakeApplicationHandle> application =
std::make_shared<FakeApplicationHandle>();
@@ -5625,13 +5662,13 @@
// Add two windows to the display. Their frames are represented in the display space.
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setFrame(Rect(0, 0, 100, 200), displayTransform);
addWindow(firstWindow);
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setFrame(Rect(100, 200, 200, 400), displayTransform);
addWindow(secondWindow);
return {std::move(firstWindow), std::move(secondWindow)};
@@ -5648,8 +5685,8 @@
// selected so that if the hit test was performed with the point and the bounds being in
// different coordinate spaces, the event would end up in the incorrect window.
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{75, 55}}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {PointF{75, 55}}));
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
@@ -5662,7 +5699,7 @@
// Send down to the first window. The point is represented in the logical display space. The
// point is selected so that if the hit test was done in logical display space, then it would
// end up in the incorrect window.
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
PointF{75 * 2, 55 * 4});
firstWindow->consumeMotionDown();
@@ -5681,7 +5718,7 @@
const vec2 untransformedPoint = injectedEventTransform.inverse().transform(expectedPoint);
MotionEvent event = MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER)
.x(untransformedPoint.x)
@@ -5700,9 +5737,9 @@
auto [firstWindow, secondWindow] = setupScaledDisplayScenario();
// Send down to the second window.
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{150, 220}}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {PointF{150, 220}}));
firstWindow->assertNoEvents();
std::unique_ptr<MotionEvent> event = secondWindow->consumeMotionEvent();
@@ -5724,17 +5761,17 @@
auto [firstWindow, secondWindow] = setupScaledDisplayScenario();
// The monitor will always receive events in the logical display's coordinate space, because
// it does not have a window.
- FakeMonitorReceiver monitor{*mDispatcher, "Monitor", ADISPLAY_ID_DEFAULT};
+ FakeMonitorReceiver monitor{*mDispatcher, "Monitor", ui::LogicalDisplayId::DEFAULT};
// Send down to the first window.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{50, 100}}));
+ ui::LogicalDisplayId::DEFAULT, {PointF{50, 100}}));
firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400)));
monitor.consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400)));
// Second pointer goes down on second window.
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{PointF{50, 100}, PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 80)));
const std::map<int32_t, PointF> expectedMonitorPointers{{0, PointF{100, 400}},
@@ -5755,7 +5792,7 @@
// Send down to the first window.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{50, 100}}));
+ ui::LogicalDisplayId::DEFAULT, {PointF{50, 100}}));
firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400)));
// The pointer is transferred to the second window, and the second window receives it in the
@@ -5770,13 +5807,15 @@
// Send hover move to the second window, and ensure it shows up as hover enter.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER),
WithCoords(100, 80), WithRawCoords(300, 880)));
// Touch down at the same location and ensure a hover exit is synthesized.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80),
WithRawCoords(300, 880)));
secondWindow->consumeMotionEvent(
@@ -5801,14 +5840,16 @@
// Send hover move to the second window, and ensure it shows up as hover enter.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER),
WithCoords(100, 80), WithRawCoords(300, 880)));
// Touch down at the same location and ensure a hover exit is synthesized for the correct
// display.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80),
WithRawCoords(300, 880)));
secondWindow->consumeMotionEvent(
@@ -5822,7 +5863,8 @@
// Send hover enter to second window
mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER),
WithCoords(100, 80), WithRawCoords(300, 880)));
@@ -5850,17 +5892,18 @@
// Send hover enter to second window
mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}}));
+ ui::LogicalDisplayId::DEFAULT,
+ {PointF{150, 220}}));
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER),
WithCoords(100, 80), WithRawCoords(300, 880),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
mDispatcher->cancelCurrentTouch();
// Ensure the cancelation happens with the correct displayId and the correct coordinates.
secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80),
WithRawCoords(300, 880),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
secondWindow->assertNoEvents();
firstWindow->assertNoEvents();
}
@@ -5887,13 +5930,13 @@
const int32_t logicalDisplayHeight = isRotated ? displayWidth : displayHeight;
const ui::Transform displayTransform(ui::Transform::toRotationFlags(rotation),
logicalDisplayWidth, logicalDisplayHeight);
- addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform);
+ addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform);
// Create a window with its bounds determined in the logical display.
const Rect frameInLogicalDisplay(100, 100, 200, 300);
const Rect frameInDisplay = displayTransform.inverse().transform(frameInLogicalDisplay);
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(frameInDisplay, displayTransform);
addWindow(window);
@@ -5903,14 +5946,14 @@
for (const auto pointInsideWindow : insidePoints) {
const vec2 p = displayTransform.inverse().transform(pointInsideWindow);
const PointF pointInDisplaySpace{p.x, p.y};
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
window->consumeMotionDown();
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
window->consumeMotionUp();
}
@@ -5920,13 +5963,13 @@
for (const auto pointOutsideWindow : outsidePoints) {
const vec2 p = displayTransform.inverse().transform(pointOutsideWindow);
const PointF pointInDisplaySpace{p.x, p.y};
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
}
window->assertNoEvents();
}
@@ -5950,7 +5993,7 @@
const int32_t logicalDisplayHeight = isRotated ? displayWidth : displayHeight;
const ui::Transform displayTransform(ui::Transform::toRotationFlags(rotation),
logicalDisplayWidth, logicalDisplayHeight);
- addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform);
+ addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform);
// Create a window that not trusted.
const Rect untrustedWindowFrameInLogicalDisplay(100, 100, 200, 300);
@@ -5960,7 +6003,7 @@
sp<FakeWindowHandle> untrustedWindow =
sp<FakeWindowHandle>::make(untrustedWindowApplication, mDispatcher, "UntrustedWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
untrustedWindow->setFrame(untrustedWindowFrameInDisplay, displayTransform);
untrustedWindow->setTrustedOverlay(false);
untrustedWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED);
@@ -5976,7 +6019,7 @@
sp<FakeWindowHandle> simpleAppWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "SimpleAppWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
simpleAppWindow->setFrame(simpleAppWindowFrameInDisplay, displayTransform);
simpleAppWindow->setOwnerInfo(gui::Pid{2}, gui::Uid{202});
addWindow(simpleAppWindow);
@@ -5989,12 +6032,12 @@
for (const auto untrustedPoint : untrustedPoints) {
const vec2 p = displayTransform.inverse().transform(untrustedPoint);
const PointF pointInDisplaySpace{p.x, p.y};
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
}
untrustedWindow->assertNoEvents();
simpleAppWindow->assertNoEvents();
@@ -6005,15 +6048,15 @@
for (const auto trustedPoint : trustedPoints) {
const vec2 p = displayTransform.inverse().transform(trustedPoint);
const PointF pointInDisplaySpace{p.x, p.y};
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
- simpleAppWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT,
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
+ simpleAppWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInDisplaySpace}));
- simpleAppWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT,
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace}));
+ simpleAppWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
}
untrustedWindow->assertNoEvents();
@@ -6040,13 +6083,14 @@
// Create a couple of windows
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> wallpaper =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper",
+ ui::LogicalDisplayId::DEFAULT);
wallpaper->setIsWallpaper(true);
// Add the windows to the dispatcher, and ensure the first window is focused
mDispatcher->onWindowInfosChanged(
@@ -6056,12 +6100,13 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
- wallpaper->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaper->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// Dispatcher reports pointer down outside focus for the wallpaper
mFakePolicy->assertOnPointerDownEquals(wallpaper->getToken());
@@ -6071,17 +6116,19 @@
ASSERT_TRUE(success);
// The first window gets cancel and the second gets down
firstWindow->consumeMotionCancel();
- secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
- wallpaper->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ wallpaper->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
// There should not be any changes to the focused window when transferring touch
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertOnPointerDownWasNotCalled());
// Send up event to the second window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets no events and the second gets up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
wallpaper->assertNoEvents();
}
@@ -6101,14 +6148,15 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
// Create a couple of windows + a spy window
- sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setTrustedOverlay(true);
spyWindow->setSpy(true);
- sp<FakeWindowHandle> firstWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "First", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> secondWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
// Add the windows to the dispatcher
mDispatcher->onWindowInfosChanged(
@@ -6116,7 +6164,8 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
// Only the first window and spy should get the down event
spyWindow->consumeMotionDown();
firstWindow->consumeMotionDown();
@@ -6128,15 +6177,17 @@
ASSERT_TRUE(success);
// The first window gets cancel and the second gets down
firstWindow->consumeMotionCancel();
- secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send up event to the second window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets no events and the second+spy get up
firstWindow->assertNoEvents();
spyWindow->consumeMotionUp();
- secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
TEST_P(TransferTouchFixture, TransferTouch_TwoPointersNonSplitTouch) {
@@ -6147,11 +6198,11 @@
// Create a couple of windows
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setPreventSplitting(true);
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setPreventSplitting(true);
// Add the windows to the dispatcher
@@ -6160,15 +6211,16 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {touchPoint}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {touchPoint}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send pointer down to the first window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint}));
+ ui::LogicalDisplayId::DEFAULT,
+ {touchPoint, touchPoint}));
// Only the first window should get the pointer down event
firstWindow->consumeMotionPointerDown(1);
secondWindow->assertNoEvents();
@@ -6179,24 +6231,27 @@
ASSERT_TRUE(success);
// The first window gets cancel and the second gets down and pointer down
firstWindow->consumeMotionCancel();
- secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
- secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT,
+ secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionPointerDown(1, ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send pointer up to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint}));
+ ui::LogicalDisplayId::DEFAULT,
+ {touchPoint, touchPoint}));
// The first window gets nothing and the second gets pointer up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionPointerUp(1, ADISPLAY_ID_DEFAULT,
+ secondWindow->consumeMotionPointerUp(1, ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send up event to the second window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) {
@@ -6205,19 +6260,21 @@
// Create a couple of windows
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaper1 =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper1", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper1",
+ ui::LogicalDisplayId::DEFAULT);
wallpaper1->setIsWallpaper(true);
sp<FakeWindowHandle> wallpaper2 =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper2", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper2",
+ ui::LogicalDisplayId::DEFAULT);
wallpaper2->setIsWallpaper(true);
// Add the windows to the dispatcher
mDispatcher->onWindowInfosChanged({{*firstWindow->getInfo(), *wallpaper1->getInfo(),
@@ -6228,12 +6285,13 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
- wallpaper1->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaper1->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
wallpaper2->assertNoEvents();
// Transfer touch focus to the second window
@@ -6243,19 +6301,21 @@
// The first window gets cancel and the second gets down
firstWindow->consumeMotionCancel();
- secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
- wallpaper1->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS);
- wallpaper2->consumeMotionDown(ADISPLAY_ID_DEFAULT,
+ secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ wallpaper1->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS);
+ wallpaper2->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
EXPECTED_WALLPAPER_FLAGS | AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send up event to the second window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets no events and the second gets up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
wallpaper1->assertNoEvents();
- wallpaper2->consumeMotionUp(ADISPLAY_ID_DEFAULT,
+ wallpaper2->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
EXPECTED_WALLPAPER_FLAGS | AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
@@ -6268,7 +6328,7 @@
[&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/,
sp<IBinder> destChannelToken) {
return dispatcher->transferTouchOnDisplay(destChannelToken,
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
},
[&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from,
sp<IBinder> to) {
@@ -6281,12 +6341,12 @@
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
// Add the windows to the dispatcher
@@ -6298,15 +6358,15 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
@@ -6316,24 +6376,25 @@
mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken());
// The first window gets cancel and the new gets pointer down (it already saw down)
firstWindow->consumeMotionCancel();
- secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT,
+ secondWindow->consumeMotionPointerDown(1, ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send pointer up to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{pointInFirst, pointInSecond}));
// The first window gets nothing and the second gets pointer up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionPointerUp(1, ADISPLAY_ID_DEFAULT,
+ secondWindow->consumeMotionPointerUp(1, ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
// Send up event to the second window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->assertNoEvents();
- secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
// Same as TransferTouch_TwoPointersSplitTouch, but using 'transferTouchOnDisplay' api.
@@ -6345,12 +6406,12 @@
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
// Add the windows to the dispatcher
@@ -6362,23 +6423,23 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
secondWindow->consumeMotionDown();
// Transfer touch focus to the second window
- const bool transferred =
- mDispatcher->transferTouchOnDisplay(secondWindow->getToken(), ADISPLAY_ID_DEFAULT);
+ const bool transferred = mDispatcher->transferTouchOnDisplay(secondWindow->getToken(),
+ ui::LogicalDisplayId::DEFAULT);
// The 'transferTouchOnDisplay' call should not succeed, because there are 2 touched windows
ASSERT_FALSE(transferred);
firstWindow->assertNoEvents();
@@ -6387,7 +6448,7 @@
// The rest of the dispatch should proceed as normal
// Send pointer up to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{pointInFirst, pointInSecond}));
// The first window gets MOVE and the second gets pointer up
firstWindow->consumeMotionMove();
@@ -6395,7 +6456,7 @@
// Send up event to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->consumeMotionUp();
secondWindow->assertNoEvents();
@@ -6407,13 +6468,16 @@
TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> firstWindowInPrimary =
- sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1",
+ ui::LogicalDisplayId::DEFAULT);
firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> secondWindowInPrimary =
- sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2",
+ ui::LogicalDisplayId::DEFAULT);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- sp<FakeWindowHandle> mirrorWindowInPrimary = firstWindowInPrimary->clone(ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> mirrorWindowInPrimary =
+ firstWindowInPrimary->clone(ui::LogicalDisplayId::DEFAULT);
mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200));
sp<FakeWindowHandle> firstWindowInSecondary = firstWindowInPrimary->clone(SECOND_DISPLAY_ID);
@@ -6432,35 +6496,36 @@
0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Window should receive motion event.
- firstWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ firstWindowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// Transfer touch
ASSERT_TRUE(mDispatcher->transferTouchGesture(firstWindowInPrimary->getToken(),
secondWindowInPrimary->getToken()));
// The first window gets cancel.
firstWindowInPrimary->consumeMotionCancel();
- secondWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT,
+ secondWindowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {150, 50}))
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
firstWindowInPrimary->assertNoEvents();
- secondWindowInPrimary->consumeMotionMove(ADISPLAY_ID_DEFAULT,
+ secondWindowInPrimary->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
firstWindowInPrimary->assertNoEvents();
- secondWindowInPrimary->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ secondWindowInPrimary->consumeMotionUp(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
// Same as TransferTouch_CloneSurface, but this touch on the secondary display and use
@@ -6468,13 +6533,16 @@
TEST_F(InputDispatcherTest, TransferTouchOnDisplay_CloneSurface) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> firstWindowInPrimary =
- sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1",
+ ui::LogicalDisplayId::DEFAULT);
firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> secondWindowInPrimary =
- sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2",
+ ui::LogicalDisplayId::DEFAULT);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- sp<FakeWindowHandle> mirrorWindowInPrimary = firstWindowInPrimary->clone(ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> mirrorWindowInPrimary =
+ firstWindowInPrimary->clone(ui::LogicalDisplayId::DEFAULT);
mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200));
sp<FakeWindowHandle> firstWindowInSecondary = firstWindowInPrimary->clone(SECOND_DISPLAY_ID);
@@ -6527,8 +6595,9 @@
TEST_F(InputDispatcherTest, FocusedWindow_ReceivesFocusEventAndKeyEvent) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -6536,10 +6605,10 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
// Window should receive key down event.
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
// Should have poked user activity
mDispatcher->waitForIdle();
@@ -6548,8 +6617,9 @@
TEST_F(InputDispatcherTest, FocusedWindow_DisableUserActivity) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setDisableUserActivity(true);
window->setFocusable(true);
@@ -6558,10 +6628,10 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
// Window should receive key down event.
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
// Should have poked user activity
mDispatcher->waitForIdle();
@@ -6570,8 +6640,9 @@
TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveSystemShortcut) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -6579,7 +6650,8 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(
+ generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
// System key is not passed down
@@ -6591,8 +6663,9 @@
TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveAssistantKey) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -6600,7 +6673,8 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateAssistantKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(
+ generateAssistantKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
// System key is not passed down
@@ -6612,8 +6686,9 @@
TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setDisableUserActivity(true);
window->setFocusable(true);
@@ -6622,7 +6697,8 @@
window->consumeFocusEvent(true);
- mDispatcher->notifyKey(generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(
+ generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
// System key is not passed down
@@ -6634,18 +6710,19 @@
TEST_F(InputDispatcherTest, InjectedTouchesPokeUserActivity) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {100, 100}))
+ ui::LogicalDisplayId::DEFAULT, {100, 100}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
// Should have poked user activity
mDispatcher->waitForIdle();
@@ -6654,12 +6731,13 @@
TEST_F(InputDispatcherTest, UnfocusedWindow_DoesNotReceiveFocusEventOrKeyEvent) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
window->assertNoEvents();
@@ -6668,19 +6746,21 @@
// If a window is touchable, but does not have focus, it should receive motion events, but not keys
TEST_F(InputDispatcherTest, UnfocusedWindow_ReceivesMotionsButNotKeys) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
// Send key
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
// Send motion
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
// Window should receive only the motion event
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents(); // Key event or focus event will not be received
}
@@ -6689,12 +6769,12 @@
sp<FakeWindowHandle> firstWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "First Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
// Add the windows to the dispatcher
@@ -6706,15 +6786,15 @@
// Send down to the first window
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT,
+ ui::LogicalDisplayId::DEFAULT,
{pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
@@ -6722,17 +6802,17 @@
// Send pointer cancel to the second window
NotifyMotionArgs pointerUpMotionArgs =
- generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
+ generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond});
pointerUpMotionArgs.flags |= AMOTION_EVENT_FLAG_CANCELED;
mDispatcher->notifyMotion(pointerUpMotionArgs);
// The first window gets move and the second gets cancel.
- firstWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
- secondWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
+ firstWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
+ secondWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
// Send up event.
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
// The first window gets up and the second gets nothing.
firstWindow->consumeMotionUp();
secondWindow->assertNoEvents();
@@ -6741,8 +6821,8 @@
TEST_F(InputDispatcherTest, SendTimeline_DoesNotCrashDispatcher) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
std::array<nsecs_t, GraphicsTimeline::SIZE> graphicsTimeline;
graphicsTimeline[GraphicsTimeline::GPU_COMPLETED_TIME] = 2;
@@ -6765,28 +6845,29 @@
*/
TEST_F(InputDispatcherMonitorTest, MonitorTouchIsCanceledWhenForegroundWindowDisappears) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
// Both the foreground window and the global monitor should receive the touch down
window->consumeMotionDown();
- monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 200}))
+ ui::LogicalDisplayId::DEFAULT, {110, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionMove();
- monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
// Now the foreground window goes away
mDispatcher->onWindowInfosChanged({{}, {}, 0, 0});
@@ -6797,41 +6878,47 @@
// cause a cancel for the monitor, as well.
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {120, 200}))
+ ui::LogicalDisplayId::DEFAULT, {120, 200}))
<< "Injection should fail because the window was removed";
window->assertNoEvents();
// Global monitor now gets the cancel
- monitor.consumeMotionCancel(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT);
}
TEST_F(InputDispatcherMonitorTest, ReceivesMotionEvents) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
TEST_F(InputDispatcherMonitorTest, MonitorCannotPilferPointers) {
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// Pilfer pointers from the monitor.
// This should not do anything and the window should continue to receive events.
@@ -6839,27 +6926,30 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT))
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
- window->consumeMotionMove(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
+ window->consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
}
TEST_F(InputDispatcherMonitorTest, NoWindowTransform) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
window->setWindowOffset(20, 40);
window->setWindowTransform(0, 1, -1, 0);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
std::unique_ptr<MotionEvent> event = monitor.consumeMotion();
ASSERT_NE(nullptr, event);
// Even though window has transform, gesture monitor must not.
@@ -6868,10 +6958,12 @@
TEST_F(InputDispatcherMonitorTest, InjectionFailsWithNoWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Injection should fail if there is a monitor, but no touchable window";
monitor.assertNoEvents();
}
@@ -6889,20 +6981,21 @@
*/
TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCanceledWhenAnotherEmptyDisplayReceiveEvents) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
FakeMonitorReceiver secondMonitor = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "The down event injected into the first display should succeed";
window->consumeMotionDown();
- monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
@@ -6913,19 +7006,19 @@
// Continue to inject event to first display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 220}))
+ ui::LogicalDisplayId::DEFAULT, {110, 220}))
<< "The move event injected into the first display should succeed";
window->consumeMotionMove();
- monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{110, 220}))
<< "The up event injected into the first display should succeed";
window->consumeMotionUp();
- monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents();
monitor.assertNoEvents();
@@ -6949,24 +7042,25 @@
*/
TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCancelWhenAnotherDisplayMonitorTouchCanceled) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> secondWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "SecondForeground",
SECOND_DISPLAY_ID);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
FakeMonitorReceiver secondMonitor = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID);
// There is a foreground window on both displays.
mDispatcher->onWindowInfosChanged({{*window->getInfo(), *secondWindow->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "The down event injected into the first display should succeed";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
@@ -6994,11 +7088,11 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 200}))
+ ui::LogicalDisplayId::DEFAULT, {110, 200}))
<< "The move event injected into the first display should succeed";
window->consumeMotionMove();
- monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
@@ -7007,12 +7101,12 @@
"touchable window";
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{110, 220}))
<< "The up event injected into the first display should succeed";
- window->consumeMotionUp(ADISPLAY_ID_DEFAULT);
- monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
+ monitor.consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents();
monitor.assertNoEvents();
@@ -7030,22 +7124,23 @@
*/
TEST_F(InputDispatcherMonitorTest, MonitorTouchCancelEventWithDisplayTransform) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground",
+ ui::LogicalDisplayId::DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
ui::Transform transform;
transform.set({1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 0, 0, 1});
gui::DisplayInfo displayInfo;
- displayInfo.displayId = ADISPLAY_ID_DEFAULT;
+ displayInfo.displayId = ui::LogicalDisplayId::DEFAULT;
displayInfo.transform = transform;
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {displayInfo}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "The down event injected should succeed";
window->consumeMotionDown();
@@ -7055,7 +7150,7 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 220}))
+ ui::LogicalDisplayId::DEFAULT, {110, 220}))
<< "The move event injected should succeed";
window->consumeMotionMove();
@@ -7071,19 +7166,19 @@
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 220}))
+ ui::LogicalDisplayId::DEFAULT, {110, 220}))
<< "The move event injected should failed";
// Now foreground should not receive any events, but monitor should receive a cancel event
// with transform that same as display's display.
std::unique_ptr<MotionEvent> cancelMotionEvent = monitor.consumeMotion();
EXPECT_EQ(transform, cancelMotionEvent->getTransform());
- EXPECT_EQ(ADISPLAY_ID_DEFAULT, cancelMotionEvent->getDisplayId());
+ EXPECT_EQ(ui::LogicalDisplayId::DEFAULT, cancelMotionEvent->getDisplayId());
EXPECT_EQ(AMOTION_EVENT_ACTION_CANCEL, cancelMotionEvent->getAction());
// Other event inject to this display should fail.
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 220}))
+ ui::LogicalDisplayId::DEFAULT, {110, 220}))
<< "The up event injected should fail because the touched window was removed";
window->assertNoEvents();
monitor.assertNoEvents();
@@ -7091,18 +7186,19 @@
TEST_F(InputDispatcherTest, TestMoveEvent) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Fake Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
NotifyMotionArgs motionArgs =
generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyMotion(motionArgs);
// Window should receive motion down event.
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
motionArgs.action = AMOTION_EVENT_ACTION_MOVE;
motionArgs.id += 1;
@@ -7111,7 +7207,7 @@
motionArgs.pointerCoords[0].getX() - 10);
mDispatcher->notifyMotion(motionArgs);
- window->consumeMotionMove(ADISPLAY_ID_DEFAULT, /*expectedFlags=*/0);
+ window->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, /*expectedFlags=*/0);
}
/**
@@ -7121,12 +7217,13 @@
*/
TEST_F(InputDispatcherTest, TouchModeState_IsSentToApps) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
const WindowInfo& windowInfo = *window->getInfo();
// Set focused application.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
SCOPED_TRACE("Check default value of touch mode");
@@ -7141,7 +7238,7 @@
SCOPED_TRACE("Disable touch mode");
mDispatcher->setInTouchMode(false, windowInfo.ownerPid, windowInfo.ownerUid,
- /*hasPermission=*/true, ADISPLAY_ID_DEFAULT);
+ /*hasPermission=*/true, ui::LogicalDisplayId::DEFAULT);
window->consumeTouchModeEvent(false);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -7155,7 +7252,7 @@
SCOPED_TRACE("Enable touch mode again");
mDispatcher->setInTouchMode(true, windowInfo.ownerPid, windowInfo.ownerUid,
- /*hasPermission=*/true, ADISPLAY_ID_DEFAULT);
+ /*hasPermission=*/true, ui::LogicalDisplayId::DEFAULT);
window->consumeTouchModeEvent(true);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -7167,10 +7264,11 @@
TEST_F(InputDispatcherTest, VerifyInputEvent_KeyEvent) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -7205,23 +7303,24 @@
TEST_F(InputDispatcherTest, VerifyInputEvent_MotionEvent) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
ui::Transform transform;
transform.set({1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 0, 0, 1});
gui::DisplayInfo displayInfo;
- displayInfo.displayId = ADISPLAY_ID_DEFAULT;
+ displayInfo.displayId = ui::LogicalDisplayId::DEFAULT;
displayInfo.transform = transform;
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {displayInfo}, 0, 0});
const NotifyMotionArgs motionArgs =
generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyMotion(motionArgs);
std::unique_ptr<MotionEvent> event = window->consumeMotionEvent();
@@ -7308,11 +7407,12 @@
TEST_F(InputDispatcherTest, SetFocusedWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowTop =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> windowSecond =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
// Top window is also focusable but is not granted focus.
windowTop->setFocusable(true);
@@ -7326,15 +7426,15 @@
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
// Focused window should receive event.
- windowSecond->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ windowSecond->consumeKeyDown(ui::LogicalDisplayId::INVALID);
windowTop->assertNoEvents();
}
TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestInvalidChannel) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
// Release channel for window is no longer valid.
@@ -7351,10 +7451,10 @@
TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestNoFocusableWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(false);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
setFocusedWindow(window);
@@ -7368,11 +7468,12 @@
TEST_F(InputDispatcherTest, SetFocusedWindow_CheckFocusedToken) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowTop =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> windowSecond =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
windowTop->setFocusable(true);
windowSecond->setFocusable(true);
@@ -7391,16 +7492,17 @@
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
// Focused window should receive event.
- windowSecond->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ windowSecond->consumeKeyDown(ui::LogicalDisplayId::INVALID);
}
TEST_F(InputDispatcherTest, SetFocusedWindow_TransferFocusTokenNotFocusable) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> windowTop =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> windowSecond =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
windowTop->setFocusable(true);
windowSecond->setFocusable(false);
@@ -7414,18 +7516,18 @@
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
// Event should be dropped.
- windowTop->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ windowTop->consumeKeyDown(ui::LogicalDisplayId::INVALID);
windowSecond->assertNoEvents();
}
TEST_F(InputDispatcherTest, SetFocusedWindow_DeferInvisibleWindow) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
sp<FakeWindowHandle> previousFocusedWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "previousFocusedWindow",
- ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
previousFocusedWindow->setFocusable(true);
@@ -7442,7 +7544,7 @@
// Injected key goes to pending queue.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
- ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE));
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE));
// Window does not get focus event or key down.
window->assertNoEvents();
@@ -7454,14 +7556,14 @@
// Window receives focus event.
window->consumeFocusEvent(true);
// Focused window receives key down.
- window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
}
TEST_F(InputDispatcherTest, DisplayRemoved) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "window", ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "window",
+ ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
// window is granted focus.
window->setFocusable(true);
@@ -7470,7 +7572,7 @@
window->consumeFocusEvent(true);
// When a display is removed window loses focus.
- mDispatcher->displayRemoved(ADISPLAY_ID_DEFAULT);
+ mDispatcher->displayRemoved(ui::LogicalDisplayId::DEFAULT);
window->consumeFocusEvent(false);
}
@@ -7502,10 +7604,11 @@
constexpr gui::Uid SLIPPERY_UID{WINDOW_UID.val() + 1};
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
sp<FakeWindowHandle> slipperyExitWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
slipperyExitWindow->setSlippery(true);
// Make sure this one overlaps the bottom window
slipperyExitWindow->setFrame(Rect(25, 25, 75, 75));
@@ -7514,7 +7617,8 @@
slipperyExitWindow->setOwnerInfo(SLIPPERY_PID, SLIPPERY_UID);
sp<FakeWindowHandle> slipperyEnterWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
slipperyExitWindow->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged(
@@ -7522,20 +7626,20 @@
// Use notifyMotion instead of injecting to avoid dealing with injection permissions
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {{50, 50}}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {{50, 50}}));
slipperyExitWindow->consumeMotionDown();
slipperyExitWindow->setFrame(Rect(70, 70, 100, 100));
mDispatcher->onWindowInfosChanged(
{{*slipperyExitWindow->getInfo(), *slipperyEnterWindow->getInfo()}, {}, 0, 0});
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_MOVE,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {{51, 51}}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {{51, 51}}));
slipperyExitWindow->consumeMotionCancel();
- slipperyEnterWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT,
+ slipperyEnterWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
}
@@ -7550,12 +7654,14 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftSlipperyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftSlipperyWindow->setSlippery(true);
leftSlipperyWindow->setFrame(Rect(0, 0, 100, 100));
sp<FakeWindowHandle> rightDropTouchesWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightDropTouchesWindow->setFrame(Rect(100, 0, 200, 100));
rightDropTouchesWindow->setDropInput(true);
@@ -7586,12 +7692,14 @@
TEST_F(InputDispatcherTest, InjectedTouchSlips) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> originalWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Original", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Original",
+ ui::LogicalDisplayId::DEFAULT);
originalWindow->setFrame(Rect(0, 0, 200, 200));
originalWindow->setSlippery(true);
sp<FakeWindowHandle> appearingWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Appearing", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Appearing",
+ ui::LogicalDisplayId::DEFAULT);
appearingWindow->setFrame(Rect(0, 0, 200, 200));
mDispatcher->onWindowInfosChanged({{*originalWindow->getInfo()}, {}, 0, 0});
@@ -7645,17 +7753,18 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 100, 100));
leftWindow->setSlippery(true);
sp<FakeWindowHandle> rightWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(100, 0, 200, 100));
sp<FakeWindowHandle> spyWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window",
+ ui::LogicalDisplayId::DEFAULT);
spyWindow->setFrame(Rect(200, 0, 300, 100));
spyWindow->setSpy(true);
spyWindow->setTrustedOverlay(true);
@@ -7705,21 +7814,22 @@
* If device B reports more ACTION_MOVE events, the middle window should receive remaining events.
*/
TEST_F(InputDispatcherTest, MultiDeviceSlipperyWindowTest) {
+ SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> leftWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Left window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 100, 100));
leftWindow->setSlippery(true);
sp<FakeWindowHandle> middleWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "middle window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
middleWindow->setFrame(Rect(100, 0, 200, 100));
sp<FakeWindowHandle> rightWindow =
sp<FakeWindowHandle>::make(application, mDispatcher, "Right window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(200, 0, 300, 100));
rightWindow->setSlippery(true);
@@ -7778,20 +7888,21 @@
using Uid = gui::Uid;
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> leftWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left",
+ ui::LogicalDisplayId::DEFAULT);
leftWindow->setFrame(Rect(0, 0, 100, 100));
leftWindow->setOwnerInfo(gui::Pid{1}, Uid{101});
sp<FakeWindowHandle> rightSpy =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right spy",
+ ui::LogicalDisplayId::DEFAULT);
rightSpy->setFrame(Rect(100, 0, 200, 100));
rightSpy->setOwnerInfo(gui::Pid{2}, Uid{102});
rightSpy->setSpy(true);
rightSpy->setTrustedOverlay(true);
- sp<FakeWindowHandle> rightWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right",
+ ui::LogicalDisplayId::DEFAULT);
rightWindow->setFrame(Rect(100, 0, 200, 100));
rightWindow->setOwnerInfo(gui::Pid{3}, Uid{103});
@@ -7856,8 +7967,8 @@
TEST_F(InputDispatcherTest, NotifiesDeviceInteractionsWithKeys) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
window->setOwnerInfo(gui::Pid{1}, gui::Uid{101});
@@ -7866,14 +7977,14 @@
ASSERT_NO_FATAL_FAILURE(window->consumeFocusEvent(true));
mDispatcher->notifyKey(KeyArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_KEYBOARD).build());
- ASSERT_NO_FATAL_FAILURE(window->consumeKeyDown(ADISPLAY_ID_DEFAULT));
+ ASSERT_NO_FATAL_FAILURE(window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
ASSERT_NO_FATAL_FAILURE(
mFakePolicy->assertNotifyDeviceInteractionWasCalled(DEVICE_ID, {gui::Uid{101}}));
// The UP actions are not treated as device interaction.
mDispatcher->notifyKey(KeyArgsBuilder(ACTION_UP, AINPUT_SOURCE_KEYBOARD).build());
- ASSERT_NO_FATAL_FAILURE(window->consumeKeyUp(ADISPLAY_ID_DEFAULT));
+ ASSERT_NO_FATAL_FAILURE(window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertNotifyDeviceInteractionWasNotCalled());
}
@@ -7882,13 +7993,14 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
left->setFrame(Rect(0, 0, 100, 100));
- sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Right Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> right =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window",
+ ui::LogicalDisplayId::DEFAULT);
right->setFrame(Rect(100, 0, 200, 100));
- sp<FakeWindowHandle> spy =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window",
+ ui::LogicalDisplayId::DEFAULT);
spy->setFrame(Rect(0, 0, 200, 100));
spy->setTrustedOverlay(true);
spy->setSpy(true);
@@ -7897,8 +8009,9 @@
{{*spy->getInfo(), *left->getInfo(), *right->getInfo()}, {}, 0, 0});
// Send hover move to the left window, and ensure hover enter is synthesized with a new eventId.
- NotifyMotionArgs notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{50, 50}});
+ NotifyMotionArgs notifyArgs =
+ generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS,
+ ui::LogicalDisplayId::DEFAULT, {PointF{50, 50}});
mDispatcher->notifyMotion(notifyArgs);
std::unique_ptr<MotionEvent> leftEnter = left->consumeMotionEvent(
@@ -7911,8 +8024,8 @@
WithEventIdSource(IdGenerator::Source::INPUT_DISPATCHER)));
// Send move to the right window, and ensure hover exit and enter are synthesized with new ids.
- notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT,
- {PointF{150, 50}});
+ notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS,
+ ui::LogicalDisplayId::DEFAULT, {PointF{150, 50}});
mDispatcher->notifyMotion(notifyArgs);
std::unique_ptr<MotionEvent> leftExit = left->consumeMotionEvent(
@@ -7934,8 +8047,8 @@
*/
TEST_F(InputDispatcherMultiDeviceTest, SingleDevicePointerDownEventRetentionWithoutWindowTarget) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -7960,8 +8073,8 @@
*/
TEST_F(InputDispatcherMultiDeviceTest, SecondDeviceDownEventDroppedWithoutWindowTarget) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
@@ -7991,7 +8104,8 @@
mApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Window",
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
@@ -8303,7 +8417,8 @@
void setUpWindow() {
mApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Fake Window",
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
@@ -8312,13 +8427,14 @@
}
void sendAndConsumeKeyDown(int32_t deviceId) {
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
+ NotifyKeyArgs keyArgs =
+ generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT);
keyArgs.deviceId = deviceId;
keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Otherwise it won't generate repeat event
mDispatcher->notifyKey(keyArgs);
// Window should receive key down event.
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
}
void expectKeyRepeatOnce(int32_t repeatCount) {
@@ -8328,19 +8444,21 @@
}
void sendAndConsumeKeyUp(int32_t deviceId) {
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
+ NotifyKeyArgs keyArgs =
+ generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT);
keyArgs.deviceId = deviceId;
keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Unless it won't generate repeat event
mDispatcher->notifyKey(keyArgs);
// Window should receive key down event.
- mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT,
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT,
/*expectedFlags=*/0);
}
void injectKeyRepeat(int32_t repeatCount) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, repeatCount, ADISPLAY_ID_DEFAULT))
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, repeatCount,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
}
};
@@ -8401,7 +8519,7 @@
sendAndConsumeKeyDown(DEVICE_ID);
expectKeyRepeatOnce(/*repeatCount=*/1);
mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
- mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT,
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT,
AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_LONG_PRESS);
mWindow->assertNoEvents();
}
@@ -8433,7 +8551,7 @@
TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_CorrectRepeatCountWhenInjectKeyRepeat) {
injectKeyRepeat(0);
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
for (int32_t repeatCount = 1; repeatCount <= 2; ++repeatCount) {
expectKeyRepeatOnce(repeatCount);
}
@@ -8449,11 +8567,11 @@
InputDispatcherTest::SetUp();
application1 = std::make_shared<FakeApplicationHandle>();
- windowInPrimary =
- sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1", ADISPLAY_ID_DEFAULT);
+ windowInPrimary = sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1",
+ ui::LogicalDisplayId::DEFAULT);
// Set focus window for primary display, but focused display would be second one.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application1);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application1);
windowInPrimary->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*windowInPrimary->getInfo()}, {}, 0, 0});
@@ -8494,9 +8612,10 @@
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) {
// Test touch down on primary display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
windowInSecondary->assertNoEvents();
// Test touch down on second display.
@@ -8510,22 +8629,22 @@
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) {
// Test inject a key down with display id specified.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKeyDownNoRepeat(*mDispatcher, ADISPLAY_ID_DEFAULT))
+ injectKeyDownNoRepeat(*mDispatcher, ui::LogicalDisplayId::DEFAULT))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- windowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ windowInPrimary->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
windowInSecondary->assertNoEvents();
// Test inject a key down without display id specified.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDownNoRepeat(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
windowInPrimary->assertNoEvents();
- windowInSecondary->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ windowInSecondary->consumeKeyDown(ui::LogicalDisplayId::INVALID);
// Remove all windows in secondary display.
mDispatcher->onWindowInfosChanged({{*windowInPrimary->getInfo()}, {}, 0, 0});
// Old focus should receive a cancel event.
- windowInSecondary->consumeKeyUp(ui::ADISPLAY_ID_NONE, AKEY_EVENT_FLAG_CANCELED);
+ windowInSecondary->consumeKeyUp(ui::LogicalDisplayId::INVALID, AKEY_EVENT_FLAG_CANCELED);
// Test inject a key down, should timeout because of no target window.
ASSERT_NO_FATAL_FAILURE(assertInjectedKeyTimesOut(*mDispatcher));
@@ -8537,16 +8656,17 @@
// Test per-display input monitors for motion event.
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) {
FakeMonitorReceiver monitorInPrimary =
- FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
FakeMonitorReceiver monitorInSecondary =
FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID);
// Test touch down on primary display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- monitorInPrimary.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ monitorInPrimary.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
windowInSecondary->assertNoEvents();
monitorInSecondary.assertNoEvents();
@@ -8570,19 +8690,20 @@
// If specific a display, it will dispatch to the focused window of particular display,
// or it will dispatch to the focused window of focused display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ui::ADISPLAY_ID_NONE))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL,
+ ui::LogicalDisplayId::INVALID))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
windowInPrimary->assertNoEvents();
monitorInPrimary.assertNoEvents();
- windowInSecondary->consumeMotionDown(ui::ADISPLAY_ID_NONE);
- monitorInSecondary.consumeMotionDown(ui::ADISPLAY_ID_NONE);
+ windowInSecondary->consumeMotionDown(ui::LogicalDisplayId::INVALID);
+ monitorInSecondary.consumeMotionDown(ui::LogicalDisplayId::INVALID);
}
// Test per-display input monitors for key event.
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorKeyEvent_MultiDisplay) {
// Input monitor per display.
FakeMonitorReceiver monitorInPrimary =
- FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
FakeMonitorReceiver monitorInSecondary =
FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID);
@@ -8591,13 +8712,14 @@
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
windowInPrimary->assertNoEvents();
monitorInPrimary.assertNoEvents();
- windowInSecondary->consumeKeyDown(ui::ADISPLAY_ID_NONE);
- monitorInSecondary.consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ windowInSecondary->consumeKeyDown(ui::LogicalDisplayId::INVALID);
+ monitorInSecondary.consumeKeyDown(ui::LogicalDisplayId::INVALID);
}
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CanFocusWindowOnUnfocusedDisplay) {
sp<FakeWindowHandle> secondWindowInPrimary =
- sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1_W2",
+ ui::LogicalDisplayId::DEFAULT);
secondWindowInPrimary->setFocusable(true);
mDispatcher->onWindowInfosChanged(
{{*windowInPrimary->getInfo(), *secondWindowInPrimary->getInfo(),
@@ -8611,25 +8733,26 @@
// Test inject a key down.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT))
+ injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
windowInPrimary->assertNoEvents();
windowInSecondary->assertNoEvents();
- secondWindowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ secondWindowInPrimary->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
}
TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CancelTouch_MultiDisplay) {
FakeMonitorReceiver monitorInPrimary =
- FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
FakeMonitorReceiver monitorInSecondary =
FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID);
// Test touch down on primary display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- monitorInPrimary.consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ monitorInPrimary.consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// Test touch down on second display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -8640,15 +8763,15 @@
// Trigger cancel touch.
mDispatcher->cancelCurrentTouch();
- windowInPrimary->consumeMotionCancel(ADISPLAY_ID_DEFAULT);
- monitorInPrimary.consumeMotionCancel(ADISPLAY_ID_DEFAULT);
+ windowInPrimary->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT);
+ monitorInPrimary.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT);
windowInSecondary->consumeMotionCancel(SECOND_DISPLAY_ID);
monitorInSecondary.consumeMotionCancel(SECOND_DISPLAY_ID);
// Test inject a move motion event, no window/monitor should receive the event.
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {110, 200}))
+ ui::LogicalDisplayId::DEFAULT, {110, 200}))
<< "Inject motion event should return InputEventInjectionResult::FAILED";
windowInPrimary->assertNoEvents();
monitorInPrimary.assertNoEvents();
@@ -8671,11 +8794,11 @@
// Send a key down on primary display
mDispatcher->notifyKey(
KeyArgsBuilder(AKEY_EVENT_ACTION_DOWN, AINPUT_SOURCE_KEYBOARD)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.policyFlags(DEFAULT_POLICY_FLAGS | POLICY_FLAG_DISABLE_KEY_REPEAT)
.build());
- windowInPrimary->consumeKeyEvent(
- AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ windowInPrimary->consumeKeyEvent(AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
windowInSecondary->assertNoEvents();
// Send a key down on second display
@@ -8691,7 +8814,7 @@
// Send a valid key up event on primary display that will be dropped because it is stale
NotifyKeyArgs staleKeyUp =
KeyArgsBuilder(AKEY_EVENT_ACTION_UP, AINPUT_SOURCE_KEYBOARD)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.policyFlags(DEFAULT_POLICY_FLAGS | POLICY_FLAG_DISABLE_KEY_REPEAT)
.build();
static constexpr std::chrono::duration STALE_EVENT_TIMEOUT = 10ms;
@@ -8703,7 +8826,7 @@
// Therefore, windowInPrimary should get the cancel event and windowInSecondary should not
// receive any events.
windowInPrimary->consumeKeyEvent(AllOf(WithKeyAction(AKEY_EVENT_ACTION_UP),
- WithDisplayId(ADISPLAY_ID_DEFAULT),
+ WithDisplayId(ui::LogicalDisplayId::DEFAULT),
WithFlags(AKEY_EVENT_FLAG_CANCELED)));
windowInSecondary->assertNoEvents();
}
@@ -8716,10 +8839,10 @@
mDispatcher->notifyMotion(
MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.build());
windowInPrimary->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
windowInSecondary->assertNoEvents();
// Send touch down on second display.
@@ -8735,7 +8858,7 @@
// inject a valid MotionEvent on primary display that will be stale when it arrives.
NotifyMotionArgs staleMotionUp =
MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
.build();
static constexpr std::chrono::duration STALE_EVENT_TIMEOUT = 10ms;
@@ -8790,19 +8913,19 @@
// Test InputFilter for MotionEvent
TEST_F(InputFilterTest, MotionEvent_InputFilter) {
// Since the InputFilter is disabled by default, check if touch events aren't filtered.
- testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/false);
+ testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/false);
testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/false);
// Enable InputFilter
mDispatcher->setInputFilterEnabled(true);
// Test touch on both primary and second display, and check if both events are filtered.
- testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/true);
+ testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/true);
testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/true);
// Disable InputFilter
mDispatcher->setInputFilterEnabled(false);
// Test touch on both primary and second display, and check if both events aren't filtered.
- testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/false);
+ testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/false);
testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/false);
}
@@ -8831,7 +8954,7 @@
secondDisplayTransform.set({-6.6, -5.5, -4.4, -3.3, -2.2, -1.1, 0, 0, 1});
std::vector<gui::DisplayInfo> displayInfos(2);
- displayInfos[0].displayId = ADISPLAY_ID_DEFAULT;
+ displayInfos[0].displayId = ui::LogicalDisplayId::DEFAULT;
displayInfos[0].transform = firstDisplayTransform;
displayInfos[1].displayId = SECOND_DISPLAY_ID;
displayInfos[1].transform = secondDisplayTransform;
@@ -8842,7 +8965,8 @@
mDispatcher->setInputFilterEnabled(true);
// Ensure the correct transforms are used for the displays.
- testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/true, firstDisplayTransform);
+ testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/true,
+ firstDisplayTransform);
testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/true, secondDisplayTransform);
}
@@ -8861,9 +8985,9 @@
std::shared_ptr<InputApplicationHandle> application =
std::make_shared<FakeApplicationHandle>();
mWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Test Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mWindow->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
setFocusedWindow(mWindow);
@@ -8876,8 +9000,8 @@
const nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC);
event.initialize(InputEvent::nextId(), injectedDeviceId, AINPUT_SOURCE_KEYBOARD,
- ui::ADISPLAY_ID_NONE, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, AKEYCODE_A,
- KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime);
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0,
+ AKEYCODE_A, KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime);
const int32_t additionalPolicyFlags =
POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_DISABLE_KEY_REPEAT;
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -8957,13 +9081,13 @@
std::make_shared<FakeApplicationHandle>();
application->setDispatchingTimeout(100ms);
mWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFrame(Rect(0, 0, 100, 100));
mWindow->setDispatchingTimeout(100ms);
mWindow->setFocusable(true);
// Set focused application.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
setFocusedWindow(mWindow);
@@ -8991,50 +9115,55 @@
mDispatcher->setMinTimeBetweenUserActivityPokes(50ms);
// First event of type TOUCH. Should poke.
- notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(50));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(50), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(50), USER_ACTIVITY_EVENT_TOUCH,
+ ui::LogicalDisplayId::DEFAULT}});
// 80ns > 50ns has passed since previous TOUCH event. Should poke.
- notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(130));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(130), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(130), USER_ACTIVITY_EVENT_TOUCH,
+ ui::LogicalDisplayId::DEFAULT}});
// First event of type OTHER. Should poke (despite being within 50ns of previous TOUCH event).
- notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT,
- milliseconds_to_nanoseconds(135));
+ notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER,
+ ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(135));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(135), USER_ACTIVITY_EVENT_OTHER, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(135), USER_ACTIVITY_EVENT_OTHER,
+ ui::LogicalDisplayId::DEFAULT}});
// Within 50ns of previous TOUCH event. Should NOT poke.
- notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(140));
mFakePolicy->assertUserActivityNotPoked();
// Within 50ns of previous OTHER event. Should NOT poke.
- notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT,
- milliseconds_to_nanoseconds(150));
+ notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER,
+ ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(150));
mFakePolicy->assertUserActivityNotPoked();
// Within 50ns of previous TOUCH event (which was at time 130). Should NOT poke.
// Note that STYLUS is mapped to TOUCH user activity, since it's a pointer-type source.
- notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_STYLUS, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(160));
mFakePolicy->assertUserActivityNotPoked();
// 65ns > 50ns has passed since previous OTHER event. Should poke.
- notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT,
- milliseconds_to_nanoseconds(200));
+ notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER,
+ ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(200));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_OTHER, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_OTHER,
+ ui::LogicalDisplayId::DEFAULT}});
// 170ns > 50ns has passed since previous TOUCH event. Should poke.
- notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_STYLUS, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(300));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(300), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(300), USER_ACTIVITY_EVENT_TOUCH,
+ ui::LogicalDisplayId::DEFAULT}});
// Assert that there's no more user activity poke event.
mFakePolicy->assertUserActivityNotPoked();
@@ -9044,19 +9173,21 @@
InputDispatcherUserActivityPokeTests, DefaultMinPokeTimeOf100MsUsed,
REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(com::android::input::flags,
rate_limit_user_activity_poke_in_dispatcher))) {
- notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(200));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_TOUCH,
+ ui::LogicalDisplayId::DEFAULT}});
- notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(280));
mFakePolicy->assertUserActivityNotPoked();
- notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
milliseconds_to_nanoseconds(340));
mFakePolicy->assertUserActivityPoked(
- {{milliseconds_to_nanoseconds(340), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}});
+ {{milliseconds_to_nanoseconds(340), USER_ACTIVITY_EVENT_TOUCH,
+ ui::LogicalDisplayId::DEFAULT}});
}
TEST_F_WITH_FLAGS(
@@ -9065,10 +9196,12 @@
rate_limit_user_activity_poke_in_dispatcher))) {
mDispatcher->setMinTimeBetweenUserActivityPokes(0ms);
- notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, 20);
+ notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
+ 20);
mFakePolicy->assertUserActivityPoked();
- notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, 30);
+ notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
+ 30);
mFakePolicy->assertUserActivityPoked();
}
@@ -9078,16 +9211,16 @@
std::shared_ptr<FakeApplicationHandle> application =
std::make_shared<FakeApplicationHandle>();
- mUnfocusedWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
+ mUnfocusedWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Top",
+ ui::LogicalDisplayId::DEFAULT);
mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30));
- mFocusedWindow =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
+ mFocusedWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second",
+ ui::LogicalDisplayId::DEFAULT);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
// Set focused application.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mFocusedWindow->setFocusable(true);
// Expect one focus window exist in display.
@@ -9115,8 +9248,8 @@
// the onPointerDownOutsideFocus callback.
TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_Success) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {20, 20}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {20, 20}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mUnfocusedWindow->consumeMotionDown();
@@ -9129,7 +9262,7 @@
// onPointerDownOutsideFocus callback.
TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonPointerSource) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ADISPLAY_ID_DEFAULT,
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ui::LogicalDisplayId::DEFAULT,
{20, 20}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mFocusedWindow->consumeMotionDown();
@@ -9142,9 +9275,9 @@
// have focus. Ensure no window received the onPointerDownOutsideFocus callback.
TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonMotionFailure) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKeyDownNoRepeat(*mDispatcher, ADISPLAY_ID_DEFAULT))
+ injectKeyDownNoRepeat(*mDispatcher, ui::LogicalDisplayId::DEFAULT))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mFocusedWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mFocusedWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertOnPointerDownWasNotCalled();
@@ -9155,8 +9288,8 @@
// onPointerDownOutsideFocus callback.
TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_OnAlreadyFocusedWindow) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- FOCUSED_WINDOW_TOUCH_POINT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_TOUCH_POINT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mFocusedWindow->consumeMotionDown();
@@ -9175,7 +9308,8 @@
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, event))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mUnfocusedWindow->consumeAnyMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mUnfocusedWindow->consumeAnyMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertOnPointerDownWasNotCalled();
@@ -9192,10 +9326,10 @@
std::shared_ptr<FakeApplicationHandle> application =
std::make_shared<FakeApplicationHandle>();
mWindow1 = sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window 1",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mWindow1->setFrame(Rect(0, 0, 100, 100));
- mWindow2 = mWindow1->clone(ADISPLAY_ID_DEFAULT);
+ mWindow2 = mWindow1->clone(ui::LogicalDisplayId::DEFAULT);
mWindow2->setFrame(Rect(100, 100, 200, 200));
mDispatcher->onWindowInfosChanged({{*mWindow1->getInfo(), *mWindow2->getInfo()}, {}, 0, 0});
@@ -9236,7 +9370,7 @@
const std::vector<PointF>& touchedPoints,
std::vector<PointF> expectedPoints) {
mDispatcher->notifyMotion(generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, touchedPoints));
+ ui::LogicalDisplayId::DEFAULT, touchedPoints));
consumeMotionEvent(touchedWindow, action, expectedPoints);
}
@@ -9383,14 +9517,14 @@
// Touch down in window 1
mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{50, 50}}));
+ ui::LogicalDisplayId::DEFAULT, {{50, 50}}));
consumeMotionEvent(mWindow1, ACTION_DOWN, {{50, 50}});
// Move touch to be above window 2. Even though window 1 is slippery, touch should not slip.
// That means the gesture should continue normally, without any ACTION_CANCEL or ACTION_DOWN
// getting generated.
mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{150, 150}}));
+ ui::LogicalDisplayId::DEFAULT, {{150, 150}}));
consumeMotionEvent(mWindow1, ACTION_MOVE, {{150, 150}});
}
@@ -9425,13 +9559,13 @@
mApplication = std::make_shared<FakeApplicationHandle>();
mApplication->setDispatchingTimeout(100ms);
mWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "TestWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFrame(Rect(0, 0, 30, 30));
mWindow->setDispatchingTimeout(100ms);
mWindow->setFocusable(true);
// Set focused application.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
setFocusedWindow(mWindow);
@@ -9462,8 +9596,8 @@
}
sp<FakeWindowHandle> addSpyWindow() {
- sp<FakeWindowHandle> spy =
- sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Spy",
+ ui::LogicalDisplayId::DEFAULT);
spy->setTrustedOverlay(true);
spy->setFocusable(false);
spy->setSpy(true);
@@ -9485,7 +9619,7 @@
// Send a regular key and respond, which should not cause an ANR.
TEST_F(InputDispatcherSingleWindowAnr, WhenKeyIsConsumed_NoAnr) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDownNoRepeat(*mDispatcher));
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyAnrWasNotCalled();
}
@@ -9496,15 +9630,16 @@
mWindow->consumeFocusEvent(false);
InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::NONE, CONSUME_TIMEOUT_EVENT_EXPECTED,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE,
+ CONSUME_TIMEOUT_EVENT_EXPECTED,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result);
// Key will not go to window because we have no focused window.
// The 'no focused window' ANR timer should start instead.
// Now, the focused application goes away.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, nullptr);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, nullptr);
// The key should get dropped and there should be no ANR.
ASSERT_TRUE(mDispatcher->waitForIdle());
@@ -9516,8 +9651,8 @@
// So InputDispatcher will enqueue ACTION_CANCEL event as well.
TEST_F(InputDispatcherSingleWindowAnr, OnPointerDown_BasicAnr) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION));
const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN
ASSERT_TRUE(sequenceNum);
@@ -9526,7 +9661,7 @@
mWindow->finishEvent(*sequenceNum);
mWindow->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid());
}
@@ -9550,8 +9685,8 @@
// taps on the window work as normal
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION));
ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionDown());
mDispatcher->waitForIdle();
mFakePolicy->assertNotifyAnrWasNotCalled();
@@ -9560,8 +9695,8 @@
// We specify the injection timeout to be smaller than the application timeout, to ensure that
// injection times out (instead of failing).
const InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::WAIT_FOR_RESULT, 50ms,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::WAIT_FOR_RESULT, 50ms,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::TIMED_OUT, result);
const std::chrono::duration timeout = mApplication->getDispatchingTimeout(DISPATCHING_TIMEOUT);
@@ -9585,9 +9720,10 @@
std::chrono::nanoseconds(STALE_EVENT_TIMEOUT).count();
// Define a valid key down event that is stale (too old).
- event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE,
- INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, /*flags=*/0, AKEYCODE_A, KEY_A,
- AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime);
+ event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN,
+ /*flags=*/0, AKEYCODE_A, KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime,
+ eventTime);
const int32_t policyFlags =
POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_DISABLE_KEY_REPEAT;
@@ -9609,7 +9745,7 @@
TEST_F(InputDispatcherSingleWindowAnr, NoFocusedWindow_DoesNotSendDuplicateAnr) {
const std::chrono::duration appTimeout = 400ms;
mApplication->setDispatchingTimeout(appTimeout);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication);
mWindow->setFocusable(false);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
@@ -9621,8 +9757,9 @@
const std::chrono::duration eventInjectionTimeout = 100ms;
ASSERT_LT(eventInjectionTimeout, appTimeout);
const InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::WAIT_FOR_RESULT, eventInjectionTimeout,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::WAIT_FOR_RESULT,
+ eventInjectionTimeout,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::TIMED_OUT, result)
<< "result=" << ftl::enum_string(result);
@@ -9670,20 +9807,20 @@
TEST_F(InputDispatcherSingleWindowAnr, Anr_HandlesEventsWithIdenticalTimestamps) {
nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC);
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, WINDOW_LOCATION,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION,
{AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION},
500ms, InputEventInjectionSync::WAIT_FOR_RESULT, currentTime);
// Now send ACTION_UP, with identical timestamp
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, WINDOW_LOCATION,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION,
{AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION},
500ms, InputEventInjectionSync::WAIT_FOR_RESULT, currentTime);
// We have now sent down and up. Let's consume first event and then ANR on the second.
- mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(timeout, mWindow);
}
@@ -9693,8 +9830,8 @@
sp<FakeWindowHandle> spy = addSpyWindow();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION));
mWindow->consumeMotionDown();
const auto [sequenceNum, _] = spy->receiveEvent(); // ACTION_DOWN
@@ -9704,7 +9841,7 @@
spy->finishEvent(*sequenceNum);
spy->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyWindowResponsiveWasCalled(spy->getToken(), mWindow->getPid());
}
@@ -9715,9 +9852,10 @@
sp<FakeWindowHandle> spy = addSpyWindow();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT));
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
- ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher, ADISPLAY_ID_DEFAULT));
+ injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT));
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
+ ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
+ injectKeyUp(*mDispatcher, ui::LogicalDisplayId::DEFAULT));
// Stuck on the ACTION_UP
const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
@@ -9725,10 +9863,10 @@
// New tap will go to the spy window, but not to the window
tapOnWindow();
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- spy->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
- mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT); // still the previous motion
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); // still the previous motion
mDispatcher->waitForIdle();
mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid());
mWindow->assertNoEvents();
@@ -9741,8 +9879,8 @@
sp<FakeWindowHandle> spy = addSpyWindow();
tapOnWindow();
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- spy->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
mWindow->consumeMotionDown();
// Stuck on the ACTION_UP
@@ -9751,10 +9889,10 @@
// New tap will go to the spy window, but not to the window
tapOnWindow();
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- spy->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
- mWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT); // still the previous motion
+ mWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); // still the previous motion
mDispatcher->waitForIdle();
mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid());
mWindow->assertNoEvents();
@@ -9764,13 +9902,14 @@
TEST_F(InputDispatcherSingleWindowAnr, UnresponsiveMonitorAnr) {
mDispatcher->setMonitorDispatchingTimeoutForTest(SPY_TIMEOUT);
- FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT);
+ FakeMonitorReceiver monitor =
+ FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION));
- mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
const std::optional<uint32_t> consumeSeq = monitor.receiveEvent();
ASSERT_TRUE(consumeSeq);
@@ -9778,7 +9917,7 @@
MONITOR_PID);
monitor.finishEvent(*consumeSeq);
- monitor.consumeMotionCancel(ADISPLAY_ID_DEFAULT);
+ monitor.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT);
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyWindowResponsiveWasCalled(monitor.getToken(), MONITOR_PID);
@@ -9817,8 +9956,8 @@
// it.
TEST_F(InputDispatcherSingleWindowAnr, Policy_DoesNotGetDuplicateAnr) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION));
const std::chrono::duration windowTimeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(windowTimeout, mWindow);
@@ -9828,7 +9967,7 @@
// When the ANR happened, dispatcher should abort the current event stream via ACTION_CANCEL
mWindow->consumeMotionDown();
mWindow->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
mWindow->assertNoEvents();
mDispatcher->waitForIdle();
mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid());
@@ -9865,7 +10004,7 @@
std::this_thread::sleep_for(400ms);
// if we wait long enough though, dispatcher will give up, and still send the key
// to the focused window, even though we have not yet finished the motion event
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
mWindow->finishEvent(*downSequenceNum);
mWindow->finishEvent(*upSequenceNum);
}
@@ -9969,8 +10108,8 @@
// So InputDispatcher will enqueue ACTION_CANCEL event as well.
TEST_F(InputDispatcherSingleWindowAnr, AnrAfterWindowRemoval) {
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {WINDOW_LOCATION}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {WINDOW_LOCATION}));
const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN
ASSERT_TRUE(sequenceNum);
@@ -9987,7 +10126,7 @@
mWindow->finishEvent(*sequenceNum);
// The cancellation was generated when the window was removed, along with the focus event.
mWindow->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
mWindow->consumeFocusEvent(false);
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), /*pid=*/std::nullopt);
@@ -9997,8 +10136,8 @@
// notified of the unresponsive window, then remove the app window.
TEST_F(InputDispatcherSingleWindowAnr, AnrFollowedByWindowRemoval) {
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {WINDOW_LOCATION}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {WINDOW_LOCATION}));
const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN
ASSERT_TRUE(sequenceNum);
@@ -10011,7 +10150,7 @@
mWindow->finishEvent(*sequenceNum);
// The cancellation was generated during the ANR, and the window lost focus when it was removed.
mWindow->consumeMotionEvent(
- AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
+ AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
mWindow->consumeFocusEvent(false);
ASSERT_TRUE(mDispatcher->waitForIdle());
// Since the window was removed, Dispatcher does not know the PID associated with the window
@@ -10026,18 +10165,18 @@
mApplication = std::make_shared<FakeApplicationHandle>();
mApplication->setDispatchingTimeout(100ms);
mUnfocusedWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Unfocused",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30));
// Adding FLAG_WATCH_OUTSIDE_TOUCH to receive ACTION_OUTSIDE when another window is tapped
mUnfocusedWindow->setWatchOutsideTouch(true);
mFocusedWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Focused",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mFocusedWindow->setDispatchingTimeout(100ms);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
// Set focused application.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication);
mFocusedWindow->setFocusable(true);
// Expect one focus window exist in display.
@@ -10069,11 +10208,11 @@
private:
void tap(const PointF& location) {
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- location));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, location));
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- location));
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, location));
}
};
@@ -10098,7 +10237,7 @@
.build()));
mFocusedWindow->consumeMotionDown();
mFocusedWindow->consumeMotionUp();
- mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0);
+ mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0);
// We consumed all events, so no ANR
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyAnrWasNotCalled();
@@ -10174,7 +10313,7 @@
// At the same time, FLAG_WATCH_OUTSIDE_TOUCH targets should not receive any events.
TEST_F(InputDispatcherMultiWindowAnr, DuringAnr_SecondTapIsIgnored) {
tapOnFocusedWindow();
- mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0);
+ mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0);
// Receive the events, but don't respond
const auto [downEventSequenceNum, downEvent] = mFocusedWindow->receiveEvent(); // ACTION_DOWN
ASSERT_TRUE(downEventSequenceNum);
@@ -10187,10 +10326,10 @@
// Tap once again
// We cannot use "tapOnFocusedWindow" because it asserts the injection result to be success
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- FOCUSED_WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_LOCATION));
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
FOCUSED_WINDOW_LOCATION));
// Unfocused window does not receive ACTION_OUTSIDE because the tapped window is not a
// valid touch target
@@ -10211,8 +10350,8 @@
// If you tap outside of all windows, there will not be ANR
TEST_F(InputDispatcherMultiWindowAnr, TapOutsideAllWindows_DoesNotAnr) {
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- LOCATION_OUTSIDE_ALL_WINDOWS));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, LOCATION_OUTSIDE_ALL_WINDOWS));
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyAnrWasNotCalled();
}
@@ -10224,8 +10363,8 @@
{{*mUnfocusedWindow->getInfo(), *mFocusedWindow->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- FOCUSED_WINDOW_LOCATION));
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_LOCATION));
std::this_thread::sleep_for(mFocusedWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT));
ASSERT_TRUE(mDispatcher->waitForIdle());
@@ -10265,8 +10404,8 @@
// window even if motions are still being processed.
InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::NONE,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE,
/*injectionTimeout=*/100ms);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result);
// Key will not be sent to the window, yet, because the window is still processing events
@@ -10293,7 +10432,7 @@
// Now that all queues are cleared and no backlog in the connections, the key event
// can finally go to the newly focused "mUnfocusedWindow".
- mUnfocusedWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mUnfocusedWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
mFocusedWindow->assertNoEvents();
mUnfocusedWindow->assertNoEvents();
mFakePolicy->assertNotifyAnrWasNotCalled();
@@ -10304,14 +10443,15 @@
// The other window should not be affected by that.
TEST_F(InputDispatcherMultiWindowAnr, SplitTouch_SingleWindowAnr) {
// Touch Window 1
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {FOCUSED_WINDOW_LOCATION}));
- mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0);
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {FOCUSED_WINDOW_LOCATION}));
+ mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0);
// Touch Window 2
mDispatcher->notifyMotion(
- generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT,
{FOCUSED_WINDOW_LOCATION, UNFOCUSED_WINDOW_LOCATION}));
const std::chrono::duration timeout =
@@ -10357,7 +10497,7 @@
std::shared_ptr<FakeApplicationHandle> focusedApplication =
std::make_shared<FakeApplicationHandle>();
focusedApplication->setDispatchingTimeout(300ms);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, focusedApplication);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, focusedApplication);
// The application that owns 'mFocusedWindow' and 'mUnfocusedWindow' is not focused.
mFocusedWindow->setFocusable(false);
@@ -10369,8 +10509,8 @@
// 'focusedApplication' will get blamed if this timer completes.
// Key will not be sent anywhere because we have no focused window. It will remain pending.
InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::NONE,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE,
/*injectionTimeout=*/100ms,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result);
@@ -10385,9 +10525,9 @@
std::this_thread::sleep_for(100ms);
// Touch unfocused window. This should force the pending key to get dropped.
- mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {UNFOCUSED_WINDOW_LOCATION}));
+ mDispatcher->notifyMotion(
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {UNFOCUSED_WINDOW_LOCATION}));
// We do not consume the motion right away, because that would require dispatcher to first
// process (== drop) the key event, and by that time, ANR will be raised.
@@ -10440,20 +10580,20 @@
mFakePolicy->setStaleEventTimeout(3000ms);
sp<FakeWindowHandle> navigationBar =
sp<FakeWindowHandle>::make(systemUiApplication, mDispatcher, "NavigationBar",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
navigationBar->setFocusable(false);
navigationBar->setWatchOutsideTouch(true);
navigationBar->setFrame(Rect(0, 0, 100, 100));
mApplication->setDispatchingTimeout(3000ms);
// 'mApplication' is already focused, but we call it again here to make it explicit.
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication);
std::shared_ptr<FakeApplicationHandle> anotherApplication =
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> appWindow =
sp<FakeWindowHandle>::make(anotherApplication, mDispatcher, "Another window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
appWindow->setFocusable(false);
appWindow->setFrame(Rect(100, 100, 200, 200));
@@ -10472,8 +10612,8 @@
// Key will not be sent anywhere because we have no focused window. It will remain pending.
// Pretend we are injecting KEYCODE_BACK, but it doesn't actually matter what key it is.
InputEventInjectionResult result =
- injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::NONE,
+ injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE,
/*injectionTimeout=*/100ms,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result);
@@ -10482,8 +10622,8 @@
mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN)
.pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
.build());
- result = injectKey(*mDispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT,
- InputEventInjectionSync::NONE,
+ result = injectKey(*mDispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0,
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE,
/*injectionTimeout=*/100ms,
/*allowKeyRepeat=*/false);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result);
@@ -10519,16 +10659,16 @@
InputDispatcherTest::SetUp();
mApplication = std::make_shared<FakeApplicationHandle>();
- mNoInputWindow =
- sp<FakeWindowHandle>::make(mApplication, mDispatcher,
- "Window without input channel", ADISPLAY_ID_DEFAULT,
- /*createInputChannel=*/false);
+ mNoInputWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher,
+ "Window without input channel",
+ ui::LogicalDisplayId::DEFAULT,
+ /*createInputChannel=*/false);
mNoInputWindow->setNoInputChannel(true);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
// It's perfectly valid for this window to not have an associated input channel
mBottomWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Bottom window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mBottomWindow->setFrame(Rect(0, 0, 100, 100));
mDispatcher->onWindowInfosChanged(
@@ -10545,8 +10685,8 @@
PointF touchedPoint = {10, 10};
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {touchedPoint}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {touchedPoint}));
mNoInputWindow->assertNoEvents();
// Even though the window 'mNoInputWindow' positioned above 'mBottomWindow' does not have
@@ -10563,7 +10703,7 @@
NoInputChannelFeature_DropsTouchesWithValidChannel) {
mNoInputWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher,
"Window with input channel and NO_INPUT_CHANNEL",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
mNoInputWindow->setNoInputChannel(true);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
@@ -10573,8 +10713,8 @@
PointF touchedPoint = {10, 10};
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {touchedPoint}));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {touchedPoint}));
mNoInputWindow->assertNoEvents();
mBottomWindow->assertNoEvents();
@@ -10589,9 +10729,10 @@
virtual void SetUp() override {
InputDispatcherTest::SetUp();
mApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
- mMirror = mWindow->clone(ADISPLAY_ID_DEFAULT);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
+ mMirror = mWindow->clone(ui::LogicalDisplayId::DEFAULT);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp);
mWindow->setFocusable(true);
mMirror->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0});
@@ -10606,7 +10747,7 @@
mWindow->consumeFocusEvent(true);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
}
// A focused & mirrored window remains focused only if the window and its mirror are both
@@ -10618,10 +10759,10 @@
mWindow->consumeFocusEvent(true);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID);
mMirror->setFocusable(false);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0});
@@ -10643,20 +10784,20 @@
mWindow->consumeFocusEvent(true);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID);
mMirror->setVisible(false);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID);
mWindow->setVisible(false);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0});
@@ -10677,20 +10818,20 @@
mWindow->consumeFocusEvent(true);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID);
// single window is removed but the window token remains focused
mDispatcher->onWindowInfosChanged({{*mMirror->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mMirror->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ mMirror->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mMirror->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ mMirror->consumeKeyUp(ui::LogicalDisplayId::INVALID);
// Both windows are removed
mDispatcher->onWindowInfosChanged({{}, {}, 0, 0});
@@ -10712,7 +10853,7 @@
// Injected key goes to pending queue.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
- ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE));
+ ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE));
mMirror->setVisible(true);
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0});
@@ -10720,7 +10861,7 @@
// window gets focused
mWindow->consumeFocusEvent(true);
// window gets the pending key event
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
}
class InputDispatcherPointerCaptureTests : public InputDispatcherTest {
@@ -10732,13 +10873,14 @@
void SetUp() override {
InputDispatcherTest::SetUp();
mApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFocusable(true);
- mSecondWindow =
- sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT);
+ mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2",
+ ui::LogicalDisplayId::DEFAULT);
mSecondWindow->setFocusable(true);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp);
mDispatcher->onWindowInfosChanged(
{{*mWindow->getInfo(), *mSecondWindow->getInfo()}, {}, 0, 0});
@@ -10977,7 +11119,7 @@
sp<FakeWindowHandle> getWindow(gui::Uid uid, std::string name) {
std::shared_ptr<FakeApplicationHandle> app = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
- sp<FakeWindowHandle>::make(app, mDispatcher, name, ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle>::make(app, mDispatcher, name, ui::LogicalDisplayId::DEFAULT);
// Generate an arbitrary PID based on the UID
window->setOwnerInfo(gui::Pid{static_cast<pid_t>(1777 + (uid.val() % 10000))}, uid);
return window;
@@ -10985,8 +11127,8 @@
void touch(const std::vector<PointF>& points = {PointF{100, 200}}) {
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- points));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, points));
}
};
@@ -11351,20 +11493,21 @@
void SetUp() override {
InputDispatcherTest::SetUp();
mApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFrame(Rect(0, 0, 100, 100));
- mSecondWindow =
- sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT);
+ mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2",
+ ui::LogicalDisplayId::DEFAULT);
mSecondWindow->setFrame(Rect(100, 0, 200, 100));
- mSpyWindow =
- sp<FakeWindowHandle>::make(mApp, mDispatcher, "SpyWindow", ADISPLAY_ID_DEFAULT);
+ mSpyWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "SpyWindow",
+ ui::LogicalDisplayId::DEFAULT);
mSpyWindow->setSpy(true);
mSpyWindow->setTrustedOverlay(true);
mSpyWindow->setFrame(Rect(0, 0, 200, 100));
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp);
mDispatcher->onWindowInfosChanged(
{{*mSpyWindow->getInfo(), *mWindow->getInfo(), *mSecondWindow->getInfo()},
{},
@@ -11377,7 +11520,7 @@
case AINPUT_SOURCE_TOUCHSCREEN:
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
break;
case AINPUT_SOURCE_STYLUS:
@@ -11409,9 +11552,9 @@
}
// Window should receive motion event.
- mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// Spy window should also receive motion event
- mSpyWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mSpyWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
// Start performing drag, we will create a drag window and transfer touch to it.
@@ -11423,8 +11566,8 @@
}
// The drag window covers the entire display
- mDragWindow =
- sp<FakeWindowHandle>::make(mApp, mDispatcher, "DragWindow", ADISPLAY_ID_DEFAULT);
+ mDragWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "DragWindow",
+ ui::LogicalDisplayId::DEFAULT);
mDragWindow->setTouchableRegion(Region{{0, 0, 0, 0}});
mDispatcher->onWindowInfosChanged({{*mDragWindow->getInfo(), *mSpyWindow->getInfo(),
*mWindow->getInfo(), *mSecondWindow->getInfo()},
@@ -11438,7 +11581,8 @@
/*isDragDrop=*/true);
if (transferred) {
mWindow->consumeMotionCancel();
- mDragWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
}
return transferred;
}
@@ -11450,35 +11594,38 @@
// Move on window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
// Move to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {150, 50}))
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(true, 150, 50);
mSecondWindow->consumeDragEvent(false, 50, 50);
// Move back to original window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->consumeDragEvent(true, -50, 50);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
}
@@ -11513,27 +11660,29 @@
// Move on window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
// Move to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {150, 50}))
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(true, 150, 50);
mSecondWindow->consumeDragEvent(false, 50, 50);
// drop to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
@@ -11595,7 +11744,8 @@
.pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
@@ -11607,7 +11757,8 @@
.pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
@@ -11620,7 +11771,7 @@
.pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
}
@@ -11636,27 +11787,29 @@
// Move on window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
// Move to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {150, 50}))
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(true, 150, 50);
mSecondWindow->assertNoEvents();
// drop to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mFakePolicy->assertDropTargetEquals(*mDispatcher, nullptr);
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
@@ -11667,14 +11820,14 @@
mWindow->setPreventSplitting(true);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(75).y(50))
@@ -11692,16 +11845,16 @@
TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) {
// First down on second window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {150, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mSecondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ mSecondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
// Second down on first window.
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
@@ -11710,8 +11863,8 @@
injectMotionEvent(*mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
InputEventInjectionSync::WAIT_FOR_RESULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- mSecondWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ mSecondWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT);
// Perform drag and drop from first window.
ASSERT_TRUE(startDrag(false));
@@ -11726,7 +11879,8 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, secondFingerMoveEvent, INJECT_EVENT_TIMEOUT,
InputEventInjectionSync::WAIT_FOR_RESULT));
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->consumeMotionMove();
@@ -11740,7 +11894,7 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, secondFingerUpEvent, INJECT_EVENT_TIMEOUT,
InputEventInjectionSync::WAIT_FOR_RESULT));
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mFakePolicy->assertDropTargetEquals(*mDispatcher, mWindow->getToken());
mWindow->assertNoEvents();
mSecondWindow->consumeMotionMove();
@@ -11779,27 +11933,29 @@
// Move on window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {50, 50}))
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
// Move to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {150, 50}))
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(true, 150, 50);
mSecondWindow->consumeDragEvent(false, 50, 50);
// drop to another window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
@@ -11817,7 +11973,8 @@
.y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(false, 50, 50);
mSecondWindow->assertNoEvents();
@@ -11831,7 +11988,8 @@
.y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mWindow->consumeDragEvent(true, 150, 50);
mSecondWindow->consumeDragEvent(false, 50, 50);
@@ -11845,7 +12003,7 @@
.y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
+ mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE);
mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
@@ -11858,8 +12016,8 @@
TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) {
// Down on second window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {150, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {150, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
ASSERT_NO_FATAL_FAILURE(mSecondWindow->consumeMotionDown());
@@ -11868,7 +12026,7 @@
// Down on first window
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
@@ -11886,7 +12044,7 @@
// Trigger cancel
mDispatcher->cancelCurrentTouch();
ASSERT_NO_FATAL_FAILURE(mSecondWindow->consumeMotionCancel());
- ASSERT_NO_FATAL_FAILURE(mDragWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT,
+ ASSERT_NO_FATAL_FAILURE(mDragWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT,
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE));
ASSERT_NO_FATAL_FAILURE(mSpyWindow->consumeMotionCancel());
@@ -11899,14 +12057,14 @@
// Inject a simple gesture, ensure dispatcher not crashed
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- PointF{50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, PointF{50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionDown());
const MotionEvent moveEvent =
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -11916,7 +12074,7 @@
ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionMove());
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT,
{50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionUp());
@@ -11926,7 +12084,7 @@
// Start hovering over the window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE,
- ADISPLAY_ID_DEFAULT, {50, 50}));
+ ui::LogicalDisplayId::DEFAULT, {50, 50}));
ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)));
ASSERT_NO_FATAL_FAILURE(mSpyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)));
@@ -11939,23 +12097,25 @@
TEST_F(InputDispatcherDropInputFeatureTest, WindowDropsInput) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
window->setDropInput(true);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
setFocusedWindow(window);
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
window->assertNoEvents();
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
mDispatcher->waitForIdle();
window->assertNoEvents();
@@ -11963,12 +12123,13 @@
window->setDropInput(false);
mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT));
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents();
}
@@ -11977,16 +12138,17 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> obscuringWindow =
sp<FakeWindowHandle>::make(obscuringApplication, mDispatcher, "obscuringWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
obscuringWindow->setFrame(Rect(0, 0, 50, 50));
obscuringWindow->setOwnerInfo(gui::Pid{111}, gui::Uid{111});
obscuringWindow->setTouchable(false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
window->setDropInputIfObscured(true);
window->setOwnerInfo(gui::Pid{222}, gui::Uid{222});
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged(
{{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
@@ -11994,13 +12156,14 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
window->assertNoEvents();
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
window->assertNoEvents();
// With the flag cleared, the window should get input
@@ -12008,12 +12171,14 @@
mDispatcher->onWindowInfosChanged(
{{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT));
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
window->assertNoEvents();
}
@@ -12022,16 +12187,17 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> obscuringWindow =
sp<FakeWindowHandle>::make(obscuringApplication, mDispatcher, "obscuringWindow",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
obscuringWindow->setFrame(Rect(0, 0, 50, 50));
obscuringWindow->setOwnerInfo(gui::Pid{111}, gui::Uid{111});
obscuringWindow->setTouchable(false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Test window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Test window",
+ ui::LogicalDisplayId::DEFAULT);
window->setDropInputIfObscured(true);
window->setOwnerInfo(gui::Pid{222}, gui::Uid{222});
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
window->setFocusable(true);
mDispatcher->onWindowInfosChanged(
{{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0});
@@ -12039,25 +12205,27 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT));
window->assertNoEvents();
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
window->assertNoEvents();
// When the window is no longer obscured because it went on top, it should get input
mDispatcher->onWindowInfosChanged(
{{*window->getInfo(), *obscuringWindow->getInfo()}, {}, 0, 0});
- mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
- window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT));
+ window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT);
mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
- AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT));
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents();
}
@@ -12074,18 +12242,19 @@
mApp = std::make_shared<FakeApplicationHandle>();
mSecondaryApp = std::make_shared<FakeApplicationHandle>();
- mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
+ mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow",
+ ui::LogicalDisplayId::DEFAULT);
mWindow->setFocusable(true);
setFocusedWindow(mWindow);
- mSecondWindow =
- sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT);
+ mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2",
+ ui::LogicalDisplayId::DEFAULT);
mSecondWindow->setFocusable(true);
mThirdWindow =
sp<FakeWindowHandle>::make(mSecondaryApp, mDispatcher,
"TestWindow3_SecondaryDisplay", SECOND_DISPLAY_ID);
mThirdWindow->setFocusable(true);
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp);
mDispatcher->onWindowInfosChanged(
{{*mWindow->getInfo(), *mSecondWindow->getInfo(), *mThirdWindow->getInfo()},
{},
@@ -12096,7 +12265,8 @@
// Set main display initial touch mode to InputDispatcher::kDefaultInTouchMode.
if (mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode, WINDOW_PID,
- WINDOW_UID, /*hasPermission=*/true, ADISPLAY_ID_DEFAULT)) {
+ WINDOW_UID, /*hasPermission=*/true,
+ ui::LogicalDisplayId::DEFAULT)) {
mWindow->consumeTouchModeEvent(InputDispatcher::kDefaultInTouchMode);
mSecondWindow->consumeTouchModeEvent(InputDispatcher::kDefaultInTouchMode);
mThirdWindow->assertNoEvents();
@@ -12115,7 +12285,7 @@
void changeAndVerifyTouchModeInMainDisplayOnly(bool inTouchMode, gui::Pid pid, gui::Uid uid,
bool hasPermission) {
ASSERT_TRUE(mDispatcher->setInTouchMode(inTouchMode, pid, uid, hasPermission,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
mWindow->consumeTouchModeEvent(inTouchMode);
mSecondWindow->consumeTouchModeEvent(inTouchMode);
mThirdWindow->assertNoEvents();
@@ -12136,7 +12306,7 @@
mWindow->setOwnerInfo(gui::Pid::INVALID, gui::Uid::INVALID);
ASSERT_FALSE(mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode, ownerPid,
ownerUid, /*hasPermission=*/false,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
}
@@ -12154,7 +12324,8 @@
const WindowInfo& windowInfo = *mWindow->getInfo();
ASSERT_FALSE(mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode,
windowInfo.ownerPid, windowInfo.ownerUid,
- /*hasPermission=*/true, ADISPLAY_ID_DEFAULT));
+ /*hasPermission=*/true,
+ ui::LogicalDisplayId::DEFAULT));
mWindow->assertNoEvents();
mSecondWindow->assertNoEvents();
}
@@ -12172,9 +12343,9 @@
TEST_F(InputDispatcherTouchModeChangedTests, CanChangeTouchModeWhenOwningLastInteractedWindow) {
// Interact with the window first.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT))
+ injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
+ mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT);
// Then remove focus.
mWindow->setFocusable(false);
@@ -12184,7 +12355,8 @@
const WindowInfo& windowInfo = *mWindow->getInfo();
ASSERT_TRUE(mDispatcher->setInTouchMode(!InputDispatcher::kDefaultInTouchMode,
windowInfo.ownerPid, windowInfo.ownerUid,
- /*hasPermission=*/false, ADISPLAY_ID_DEFAULT));
+ /*hasPermission=*/false,
+ ui::LogicalDisplayId::DEFAULT));
}
class InputDispatcherSpyWindowTest : public InputDispatcherTest {
@@ -12194,8 +12366,9 @@
std::make_shared<FakeApplicationHandle>();
std::string name = "Fake Spy ";
name += std::to_string(mSpyCount++);
- sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher,
- name.c_str(), ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spy =
+ sp<FakeWindowHandle>::make(application, mDispatcher, name.c_str(),
+ ui::LogicalDisplayId::DEFAULT);
spy->setSpy(true);
spy->setTrustedOverlay(true);
return spy;
@@ -12206,7 +12379,7 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
return window;
}
@@ -12237,9 +12410,10 @@
mDispatcher->onWindowInfosChanged({{*spy->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
}
/**
@@ -12277,7 +12451,8 @@
}
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
std::vector<size_t> eventOrder;
@@ -12315,9 +12490,10 @@
mDispatcher->onWindowInfosChanged({{*spy->getInfo(), *window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
spy->assertNoEvents();
}
@@ -12334,20 +12510,22 @@
// Inject an event outside the spy window's touchable region.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy->assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionUp();
spy->assertNoEvents();
// Inject an event inside the spy window's touchable region.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {5, 10}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {5, 10}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy->consumeMotionDown();
@@ -12368,8 +12546,8 @@
// Inject an event outside the spy window's frame and touchable region.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy->consumeMotionOutsideWithZeroedCoords();
@@ -12390,8 +12568,8 @@
{{*spy->getInfo(), *windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
windowLeft->consumeMotionDown();
spy->consumeMotionDown();
@@ -12422,8 +12600,8 @@
mDispatcher->onWindowInfosChanged({{*spyRight->getInfo(), *window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {50, 50}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {50, 50}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spyRight->assertNoEvents();
@@ -12459,16 +12637,16 @@
// First finger down, no window touched.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
window->assertNoEvents();
// Second finger down on window, the window should receive touch down.
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
@@ -12478,7 +12656,7 @@
InputEventInjectionSync::WAIT_FOR_RESULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
spy->consumeMotionPointerDown(/*pointerIndex=*/1);
}
@@ -12497,11 +12675,11 @@
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ window->consumeKeyDown(ui::LogicalDisplayId::INVALID);
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher))
<< "Inject key event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeKeyUp(ui::ADISPLAY_ID_NONE);
+ window->consumeKeyUp(ui::LogicalDisplayId::INVALID);
spy->assertNoEvents();
}
@@ -12520,7 +12698,8 @@
{{*spy1->getInfo(), *spy2->getInfo(), *window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy1->consumeMotionDown();
@@ -12535,7 +12714,7 @@
// The rest of the gesture should only be sent to the second spy window.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT))
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
spy2->consumeMotionMove();
spy1->assertNoEvents();
@@ -12552,19 +12731,21 @@
mDispatcher->onWindowInfosChanged({{*spy->getInfo(), *window->getInfo()}, {}, 0, 0});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
- spy->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+ window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
+ spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT);
window->releaseChannel();
EXPECT_EQ(OK, mDispatcher->pilferPointers(spy->getToken()));
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
- spy->consumeMotionUp(ADISPLAY_ID_DEFAULT);
+ spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT);
}
/**
@@ -12579,8 +12760,8 @@
// First finger down on the window and the spy.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {100, 200}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {100, 200}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
spy->consumeMotionDown();
window->consumeMotionDown();
@@ -12592,7 +12773,7 @@
// Second finger down on the window and spy, but the window should not receive the pointer down.
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
@@ -12607,7 +12788,7 @@
// Third finger goes down outside all windows, so injection should fail.
const MotionEvent thirdFingerDownEvent =
MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
@@ -12635,15 +12816,15 @@
// First finger down on the window only
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {150, 150}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {150, 150}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
// Second finger down on the spy and window
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10))
@@ -12658,7 +12839,7 @@
// Third finger down on the spy and window
const MotionEvent thirdFingerDownEvent =
MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10))
@@ -12673,8 +12854,10 @@
// Spy window pilfers the pointers.
EXPECT_EQ(OK, mDispatcher->pilferPointers(spy->getToken()));
- window->consumeMotionPointerUp(/*idx=*/2, ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
- window->consumeMotionPointerUp(/*idx=*/1, ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
+ window->consumeMotionPointerUp(/*idx=*/2, ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_CANCELED);
+ window->consumeMotionPointerUp(/*idx=*/1, ui::LogicalDisplayId::DEFAULT,
+ AMOTION_EVENT_FLAG_CANCELED);
spy->assertNoEvents();
window->assertNoEvents();
@@ -12695,8 +12878,8 @@
// First finger down on both spy and window
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {10, 10}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {10, 10}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy->consumeMotionDown();
@@ -12704,7 +12887,7 @@
// Second finger down on the spy and window
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
@@ -12738,8 +12921,8 @@
// First finger down on both window and spy
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
- injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {10, 10}))
+ injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN,
+ ui::LogicalDisplayId::DEFAULT, {10, 10}))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
window->consumeMotionDown();
spy->consumeMotionDown();
@@ -12751,7 +12934,7 @@
// Second finger down on the window only
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .displayId(ADISPLAY_ID_DEFAULT)
+ .displayId(ui::LogicalDisplayId::DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10))
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150))
@@ -12936,9 +13119,9 @@
std::pair<sp<FakeWindowHandle>, sp<FakeWindowHandle>> setupStylusOverlayScenario() {
std::shared_ptr<FakeApplicationHandle> overlayApplication =
std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> overlay =
- sp<FakeWindowHandle>::make(overlayApplication, mDispatcher,
- "Stylus interceptor window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> overlay = sp<FakeWindowHandle>::make(overlayApplication, mDispatcher,
+ "Stylus interceptor window",
+ ui::LogicalDisplayId::DEFAULT);
overlay->setFocusable(false);
overlay->setOwnerInfo(gui::Pid{111}, gui::Uid{111});
overlay->setTouchable(false);
@@ -12949,11 +13132,11 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
sp<FakeWindowHandle>::make(application, mDispatcher, "Application window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
window->setFocusable(true);
window->setOwnerInfo(gui::Pid{222}, gui::Uid{222});
- mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
+ mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application);
mDispatcher->onWindowInfosChanged({{*overlay->getInfo(), *window->getInfo()}, {}, 0, 0});
setFocusedWindow(window);
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
@@ -12963,13 +13146,13 @@
void sendFingerEvent(int32_t action) {
mDispatcher->notifyMotion(
generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{20, 20}}));
+ ui::LogicalDisplayId::DEFAULT, {PointF{20, 20}}));
}
void sendStylusEvent(int32_t action) {
NotifyMotionArgs motionArgs =
generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{30, 40}});
+ ui::LogicalDisplayId::DEFAULT, {PointF{30, 40}});
motionArgs.pointerProperties[0].toolType = ToolType::STYLUS;
mDispatcher->notifyMotion(motionArgs);
}
@@ -13073,7 +13256,7 @@
InputEventInjectionResult injectTargetedMotion(int32_t action) const {
return injectMotionEvent(*mDispatcher, action, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {100, 200},
+ ui::LogicalDisplayId::DEFAULT, {100, 200},
{AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION},
INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT,
@@ -13082,7 +13265,7 @@
InputEventInjectionResult injectTargetedKey(int32_t action) const {
return inputdispatcher::injectKey(*mDispatcher, action, /*repeatCount=*/0,
- ui::ADISPLAY_ID_NONE,
+ ui::LogicalDisplayId::INVALID,
InputEventInjectionSync::WAIT_FOR_RESULT,
INJECT_EVENT_TIMEOUT, /*allowKeyRepeat=*/false, {mUid},
mPolicyFlags);
@@ -13091,8 +13274,9 @@
sp<FakeWindowHandle> createWindow(const char* name) const {
std::shared_ptr<FakeApplicationHandle> overlayApplication =
std::make_shared<FakeApplicationHandle>();
- sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(overlayApplication, mDispatcher,
- name, ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> window =
+ sp<FakeWindowHandle>::make(overlayApplication, mDispatcher, name,
+ ui::LogicalDisplayId::DEFAULT);
window->setOwnerInfo(mPid, mUid);
return window;
}
@@ -13114,7 +13298,7 @@
EXPECT_EQ(InputEventInjectionResult::SUCCEEDED,
owner.injectTargetedKey(AKEY_EVENT_ACTION_DOWN));
- window->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ window->consumeKeyDown(ui::LogicalDisplayId::INVALID);
}
TEST_F(InputDispatcherTargetedInjectionTest, CannotInjectIntoUnownedWindow) {
@@ -13179,7 +13363,7 @@
// A user that has injection permission can inject into any window.
EXPECT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT));
+ ui::LogicalDisplayId::DEFAULT));
randosSpy->consumeMotionDown();
window->consumeMotionDown();
@@ -13187,7 +13371,7 @@
randosSpy->consumeFocusEvent(true);
EXPECT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher));
- randosSpy->consumeKeyDown(ui::ADISPLAY_ID_NONE);
+ randosSpy->consumeKeyDown(ui::LogicalDisplayId::INVALID);
window->assertNoEvents();
}
@@ -13214,13 +13398,14 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
left->setFrame(Rect(0, 0, 100, 100));
- sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Right Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> right =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window",
+ ui::LogicalDisplayId::DEFAULT);
right->setFrame(Rect(100, 0, 200, 100));
- sp<FakeWindowHandle> spy =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window",
+ ui::LogicalDisplayId::DEFAULT);
spy->setFrame(Rect(0, 0, 200, 100));
spy->setTrustedOverlay(true);
spy->setSpy(true);
@@ -13237,11 +13422,14 @@
left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Hover move to the right window.
@@ -13254,11 +13442,14 @@
right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_MOVE));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Stop hovering.
@@ -13270,11 +13461,14 @@
right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
}
@@ -13282,13 +13476,14 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
left->setFrame(Rect(0, 0, 100, 100));
- sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Right Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> right =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window",
+ ui::LogicalDisplayId::DEFAULT);
right->setFrame(Rect(100, 0, 200, 100));
- sp<FakeWindowHandle> spy =
- sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window",
+ ui::LogicalDisplayId::DEFAULT);
spy->setFrame(Rect(0, 0, 200, 100));
spy->setTrustedOverlay(true);
spy->setSpy(true);
@@ -13305,11 +13500,14 @@
left->consumeMotionDown();
spy->consumeMotionDown();
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Second pointer down on right window.
@@ -13323,17 +13521,23 @@
right->consumeMotionDown();
spy->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
// Second pointer up.
@@ -13347,17 +13551,23 @@
right->consumeMotionUp();
spy->consumeMotionEvent(WithMotionAction(POINTER_1_UP));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/1));
// First pointer up.
@@ -13369,11 +13579,14 @@
left->consumeMotionUp();
spy->consumeMotionUp();
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
}
@@ -13382,17 +13595,20 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
left->setFrame(Rect(0, 0, 100, 100));
- sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Right Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> right =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window",
+ ui::LogicalDisplayId::DEFAULT);
right->setFrame(Rect(100, 0, 200, 100));
mDispatcher->onWindowInfosChanged({{*left->getInfo(), *right->getInfo()}, {}, 0, 0});
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Hover move into the window.
@@ -13406,7 +13622,8 @@
left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Move the mouse with another device. This cancels the hovering pointer from the first device.
@@ -13423,9 +13640,10 @@
// TODO(b/313689709): InputDispatcher's touch state is not updated, even though the window gets
// a HOVER_EXIT from the first device.
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
SECOND_DEVICE_ID,
/*pointerId=*/0));
@@ -13441,9 +13659,10 @@
left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
SECOND_DEVICE_ID,
/*pointerId=*/0));
}
@@ -13457,17 +13676,20 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window",
- ADISPLAY_ID_DEFAULT);
+ ui::LogicalDisplayId::DEFAULT);
left->setFrame(Rect(0, 0, 100, 100));
- sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher,
- "Right Window", ADISPLAY_ID_DEFAULT);
+ sp<FakeWindowHandle> right =
+ sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window",
+ ui::LogicalDisplayId::DEFAULT);
right->setFrame(Rect(100, 0, 200, 100));
mDispatcher->onWindowInfosChanged({{*left->getInfo(), *right->getInfo()}, {}, 0, 0});
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Hover move into the window.
@@ -13481,7 +13703,8 @@
left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
// Move the mouse with another device
@@ -13496,9 +13719,10 @@
// TODO(b/313689709): InputDispatcher's touch state is not updated, even though the window gets
// a HOVER_EXIT from the first device.
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
SECOND_DEVICE_ID,
/*pointerId=*/0));
@@ -13513,9 +13737,10 @@
.build());
right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
- ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID,
+ ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
+ DEVICE_ID,
/*pointerId=*/0));
- ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT,
+ ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT,
SECOND_DEVICE_ID,
/*pointerId=*/0));
}
diff --git a/services/inputflinger/tests/InputProcessorConverter_test.cpp b/services/inputflinger/tests/InputProcessorConverter_test.cpp
index 1556532..bdf156c 100644
--- a/services/inputflinger/tests/InputProcessorConverter_test.cpp
+++ b/services/inputflinger/tests/InputProcessorConverter_test.cpp
@@ -38,7 +38,7 @@
coords.setAxisValue(AMOTION_EVENT_AXIS_SIZE, 0.5);
static constexpr nsecs_t downTime = 2;
NotifyMotionArgs motionArgs(/*sequenceNum=*/1, /*eventTime=*/downTime, /*readTime=*/2,
- /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::ADISPLAY_ID_DEFAULT,
+ /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::LogicalDisplayId::DEFAULT,
/*policyFlags=*/4, AMOTION_EVENT_ACTION_DOWN, /*actionButton=*/0,
/*flags=*/0, AMETA_NONE, /*buttonState=*/0,
MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
diff --git a/services/inputflinger/tests/InputProcessor_test.cpp b/services/inputflinger/tests/InputProcessor_test.cpp
index 5606a91..f7e5e67 100644
--- a/services/inputflinger/tests/InputProcessor_test.cpp
+++ b/services/inputflinger/tests/InputProcessor_test.cpp
@@ -44,7 +44,7 @@
coords.setAxisValue(AMOTION_EVENT_AXIS_Y, 1);
static constexpr nsecs_t downTime = 2;
NotifyMotionArgs motionArgs(/*sequenceNum=*/1, /*eventTime=*/downTime, /*readTime=*/2,
- /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::ADISPLAY_ID_DEFAULT,
+ /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::LogicalDisplayId::DEFAULT,
/*policyFlags=*/4, AMOTION_EVENT_ACTION_DOWN, /*actionButton=*/0,
/*flags=*/0, AMETA_NONE, /*buttonState=*/0,
MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
@@ -80,7 +80,7 @@
TEST_F(InputProcessorTest, SendToNextStage_NotifyKeyArgs) {
// Create a basic key event and send to processor
NotifyKeyArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*readTime=*/21, /*deviceId=*/3,
- AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT, /*policyFlags=*/0,
+ AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/0,
AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5,
AMETA_NONE, /*downTime=*/6);
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index fcc52a8..8536ff0 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -27,6 +27,7 @@
#include <JoystickInputMapper.h>
#include <KeyboardInputMapper.h>
#include <MultiTouchInputMapper.h>
+#include <NotifyArgsBuilders.h>
#include <PeripheralController.h>
#include <SensorInputMapper.h>
#include <SingleTouchInputMapper.h>
@@ -59,11 +60,10 @@
using std::chrono_literals::operator""s;
// Arbitrary display properties.
-static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
static const std::string DISPLAY_UNIQUE_ID = "local:1";
static constexpr ui::LogicalDisplayId SECONDARY_DISPLAY_ID =
ui::LogicalDisplayId{DISPLAY_ID.val() + 1};
-static const std::string SECONDARY_DISPLAY_UNIQUE_ID = "local:2";
static constexpr int32_t DISPLAY_WIDTH = 480;
static constexpr int32_t DISPLAY_HEIGHT = 800;
static constexpr ui::LogicalDisplayId VIRTUAL_DISPLAY_ID = ui::LogicalDisplayId{1};
@@ -521,12 +521,12 @@
const std::string uniqueId1 = "uniqueId1";
const std::string uniqueId2 = "uniqueId2";
constexpr ui::LogicalDisplayId nonDefaultDisplayId = ui::LogicalDisplayId{2};
- ASSERT_NE(nonDefaultDisplayId, ui::ADISPLAY_ID_DEFAULT)
- << "Test display ID should not be ui::ADISPLAY_ID_DEFAULT ";
+ ASSERT_NE(nonDefaultDisplayId, ui::LogicalDisplayId::DEFAULT)
+ << "Test display ID should not be ui::LogicalDisplayId::DEFAULT ";
// Add the default display first and ensure it gets returned.
mFakePolicy->clearViewports();
- mFakePolicy->addDisplayViewport(ui::ADISPLAY_ID_DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT,
+ mFakePolicy->addDisplayViewport(ui::LogicalDisplayId::DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /*isActive=*/true, uniqueId1, NO_PORT,
ViewportType::INTERNAL);
mFakePolicy->addDisplayViewport(nonDefaultDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT,
@@ -536,7 +536,7 @@
std::optional<DisplayViewport> viewport =
mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
ASSERT_TRUE(viewport);
- ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, viewport->displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, viewport->displayId);
ASSERT_EQ(ViewportType::INTERNAL, viewport->type);
// Add the default display second to make sure order doesn't matter.
@@ -544,13 +544,13 @@
mFakePolicy->addDisplayViewport(nonDefaultDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /*isActive=*/true, uniqueId2, NO_PORT,
ViewportType::INTERNAL);
- mFakePolicy->addDisplayViewport(ui::ADISPLAY_ID_DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT,
+ mFakePolicy->addDisplayViewport(ui::LogicalDisplayId::DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /*isActive=*/true, uniqueId1, NO_PORT,
ViewportType::INTERNAL);
viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
ASSERT_TRUE(viewport);
- ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, viewport->displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, viewport->displayId);
ASSERT_EQ(ViewportType::INTERNAL, viewport->type);
}
@@ -1184,6 +1184,82 @@
mFakeListener->assertNotifyCaptureWasNotCalled();
}
+TEST_F(InputReaderTest, GetLastUsedInputDeviceId) {
+ constexpr int32_t FIRST_DEVICE_ID = END_RESERVED_ID + 1000;
+ constexpr int32_t SECOND_DEVICE_ID = FIRST_DEVICE_ID + 1;
+ FakeInputMapper& firstMapper =
+ addDeviceWithFakeInputMapper(FIRST_DEVICE_ID, FIRST_DEVICE_ID, "first",
+ InputDeviceClass::KEYBOARD, AINPUT_SOURCE_KEYBOARD,
+ /*configuration=*/nullptr);
+ FakeInputMapper& secondMapper =
+ addDeviceWithFakeInputMapper(SECOND_DEVICE_ID, SECOND_DEVICE_ID, "second",
+ InputDeviceClass::TOUCH_MT, AINPUT_SOURCE_STYLUS,
+ /*configuration=*/nullptr);
+
+ ASSERT_EQ(ReservedInputDeviceId::INVALID_INPUT_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+
+ // Start a new key gesture from the first device
+ firstMapper.setProcessResult({KeyArgsBuilder(AKEY_EVENT_ACTION_DOWN, AINPUT_SOURCE_KEYBOARD)
+ .deviceId(FIRST_DEVICE_ID)
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, FIRST_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(firstMapper.getDeviceId(), mReader->getLastUsedInputDeviceId());
+
+ // Start a new touch gesture from the second device
+ secondMapper.setProcessResult(
+ {MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_STYLUS)
+ .deviceId(SECOND_DEVICE_ID)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER))
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, SECOND_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(SECOND_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+
+ // Releasing the key is not a new gesture, so it does not update the last used device
+ firstMapper.setProcessResult({KeyArgsBuilder(AKEY_EVENT_ACTION_UP, AINPUT_SOURCE_KEYBOARD)
+ .deviceId(FIRST_DEVICE_ID)
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, FIRST_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(SECOND_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+
+ // But pressing a new key does start a new gesture
+ firstMapper.setProcessResult({KeyArgsBuilder(AKEY_EVENT_ACTION_DOWN, AINPUT_SOURCE_KEYBOARD)
+ .deviceId(FIRST_DEVICE_ID)
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, FIRST_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(FIRST_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+
+ // Moving or ending a touch gesture does not update the last used device
+ secondMapper.setProcessResult(
+ {MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_STYLUS)
+ .deviceId(SECOND_DEVICE_ID)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::STYLUS))
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, SECOND_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(FIRST_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+ secondMapper.setProcessResult({MotionArgsBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_STYLUS)
+ .deviceId(SECOND_DEVICE_ID)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::STYLUS))
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, SECOND_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(FIRST_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+
+ // Starting a new hover gesture updates the last used device
+ secondMapper.setProcessResult(
+ {MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
+ .deviceId(SECOND_DEVICE_ID)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::STYLUS))
+ .build()});
+ mFakeEventHub->enqueueEvent(ARBITRARY_TIME, ARBITRARY_TIME, SECOND_DEVICE_ID, 0, 0, 0);
+ mReader->loopOnce();
+ ASSERT_EQ(SECOND_DEVICE_ID, mReader->getLastUsedInputDeviceId());
+}
+
class FakeVibratorInputMapper : public FakeInputMapper {
public:
FakeVibratorInputMapper(InputDeviceContext& deviceContext,
@@ -3244,7 +3320,7 @@
void testDPadKeyRotation(KeyboardInputMapper& mapper, int32_t originalScanCode,
int32_t originalKeyCode, int32_t rotatedKeyCode,
- ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE);
+ ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID);
};
/* Similar to setDisplayInfoAndReconfigure, but pre-populates all parameters except for the
@@ -3579,19 +3655,19 @@
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
NotifyKeyArgs args;
- // Display id should be ADISPLAY_ID_NONE without any display configuration.
+ // Display id should be LogicalDisplayId::INVALID without any display configuration.
process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 1);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 0);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, args.displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, args.displayId);
prepareDisplay(ui::ROTATION_0);
process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 1);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 0);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, args.displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, args.displayId);
}
TEST_F(KeyboardInputMapperTest, DisplayIdConfigurationChange_OrientationAware) {
@@ -3605,7 +3681,7 @@
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
NotifyKeyArgs args;
- // Display id should be ADISPLAY_ID_NONE without any display configuration.
+ // Display id should be LogicalDisplayId::INVALID without any display configuration.
// ^--- already checked by the previous test
setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
@@ -8675,7 +8751,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
- ASSERT_EQ(ui::ADISPLAY_ID_NONE, motionArgs.displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::INVALID, motionArgs.displayId);
}
/**
@@ -9572,7 +9648,7 @@
processPosition(mapper, 100, 100);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
- ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, motionArgs.displayId);
+ ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, motionArgs.displayId);
// Expect the event to be sent to the external viewport if it is present.
prepareSecondaryDisplay(ViewportType::EXTERNAL);
diff --git a/services/inputflinger/tests/InputTracingTest.cpp b/services/inputflinger/tests/InputTracingTest.cpp
index dfbbce3..617d67f 100644
--- a/services/inputflinger/tests/InputTracingTest.cpp
+++ b/services/inputflinger/tests/InputTracingTest.cpp
@@ -41,7 +41,7 @@
namespace {
-constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
// Ensure common actions are interchangeable between keys and motions for convenience.
static_assert(static_cast<int32_t>(AMOTION_EVENT_ACTION_DOWN) ==
diff --git a/services/inputflinger/tests/LatencyTracker_test.cpp b/services/inputflinger/tests/LatencyTracker_test.cpp
index 01fd03e..4fcffdd 100644
--- a/services/inputflinger/tests/LatencyTracker_test.cpp
+++ b/services/inputflinger/tests/LatencyTracker_test.cpp
@@ -43,7 +43,7 @@
identifier.product = productId;
auto info = InputDeviceInfo();
info.initialize(deviceId, /*generation=*/1, /*controllerNumber=*/1, identifier, "Test Device",
- /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE);
+ /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID);
return info;
}
diff --git a/services/inputflinger/tests/MultiTouchInputMapper_test.cpp b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
index 437020f..b5f8971 100644
--- a/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
+++ b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
@@ -35,7 +35,7 @@
using testing::SetArgPointee;
using testing::VariantWith;
-static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
static constexpr int32_t DISPLAY_WIDTH = 480;
static constexpr int32_t DISPLAY_HEIGHT = 800;
static constexpr std::optional<uint8_t> NO_PORT = std::nullopt; // no physical port is specified
diff --git a/services/inputflinger/tests/PointerChoreographer_test.cpp b/services/inputflinger/tests/PointerChoreographer_test.cpp
index 33e7277..1689b33 100644
--- a/services/inputflinger/tests/PointerChoreographer_test.cpp
+++ b/services/inputflinger/tests/PointerChoreographer_test.cpp
@@ -203,14 +203,16 @@
TEST_F(PointerChoreographerTest, WhenMouseIsAddedCreatesPointerController) {
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
}
TEST_F(PointerChoreographerTest, WhenMouseIsRemovedRemovesPointerController) {
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
// Remove the mouse.
@@ -221,7 +223,8 @@
TEST_F(PointerChoreographerTest, WhenKeyboardIsAddedDoesNotCreatePointerController) {
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerNotCreated();
}
@@ -256,7 +259,8 @@
// the PointerController.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertViewportSet(DISPLAY_ID);
ASSERT_TRUE(pc->isPointerShown());
@@ -269,7 +273,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE);
firstDisplayPc->assertViewportSet(DISPLAY_ID);
ASSERT_TRUE(firstDisplayPc->isPointerShown());
@@ -289,7 +294,8 @@
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
@@ -299,7 +305,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotNotified();
@@ -312,12 +319,13 @@
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged({/*id=*/1, {}});
- assertPointerDisplayIdNotified(ui::ADISPLAY_ID_NONE);
+ assertPointerDisplayIdNotified(ui::LogicalDisplayId::INVALID);
assertPointerControllerRemoved(pc);
}
@@ -329,7 +337,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
@@ -346,7 +355,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -358,7 +368,7 @@
MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
.pointer(MOUSE_POINTER)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
// Check that the PointerController updated the position and the pointer is shown.
@@ -375,7 +385,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -390,7 +401,7 @@
MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
.pointer(absoluteMousePointer)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
// Check that the PointerController updated the position and the pointer is shown.
@@ -412,7 +423,7 @@
// Add two devices, one unassociated and the other associated with non-default mouse display.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}});
auto unassociatedMousePc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, unassociatedMousePc->getDisplayId());
@@ -449,7 +460,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -460,7 +472,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/1,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE_RELATIVE,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
mChoreographer.notifyPointerCaptureChanged(
NotifyPointerCaptureChangedArgs(/*id=*/2, systemTime(SYSTEM_TIME_MONOTONIC),
PointerCaptureRequest(/*window=*/sp<BBinder>::make(),
@@ -475,7 +487,7 @@
.axis(AMOTION_EVENT_AXIS_RELATIVE_X, 10)
.axis(AMOTION_EVENT_AXIS_RELATIVE_Y, 20))
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
// Check that there's no update on the PointerController.
@@ -485,7 +497,7 @@
// Check x-y coordinates, displayId and cursor position are not changed.
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithCoords(10, 20), WithRelativeMotion(10, 20),
- WithDisplayId(ui::ADISPLAY_ID_NONE),
+ WithDisplayId(ui::LogicalDisplayId::INVALID),
WithCursorPosition(AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION)));
}
@@ -495,7 +507,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
ASSERT_TRUE(pc->isPointerShown());
@@ -515,7 +528,8 @@
// A mouse is connected, and the pointer is shown.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_TRUE(pc->isPointerShown());
@@ -525,9 +539,9 @@
// Add a second mouse is added, the pointer is shown again.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
ASSERT_TRUE(pc->isPointerShown());
// One of the mice is removed, and it does not cause the mouse pointer to fade, because
@@ -535,7 +549,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerNotRemoved(pc);
ASSERT_TRUE(pc->isPointerShown());
@@ -549,7 +563,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_TRUE(pc->isPointerShown());
@@ -559,7 +574,7 @@
// Adding a touchscreen device does not unfade the mouse pointer.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID,
AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
DISPLAY_ID)}});
@@ -576,7 +591,7 @@
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
InputDeviceInfo mouseDeviceInfo =
- generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE);
+ generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID);
// Disable this mouse device.
mouseDeviceInfo.setEnabled(false);
mChoreographer.notifyInputDevicesChanged({/*id=*/0, {mouseDeviceInfo}});
@@ -589,7 +604,7 @@
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
InputDeviceInfo mouseDeviceInfo =
- generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE);
+ generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID);
mChoreographer.notifyInputDevicesChanged({/*id=*/0, {mouseDeviceInfo}});
@@ -608,14 +623,16 @@
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
InputDeviceInfo disabledMouseDeviceInfo =
- generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE);
+ generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID);
disabledMouseDeviceInfo.setEnabled(false);
InputDeviceInfo enabledMouseDeviceInfo =
- generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE);
+ generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID);
InputDeviceInfo anotherEnabledMouseDeviceInfo =
- generateTestDeviceInfo(THIRD_DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE);
+ generateTestDeviceInfo(THIRD_DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
@@ -1177,7 +1194,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
}
@@ -1185,7 +1202,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
// Remove the touchpad.
@@ -1227,7 +1244,8 @@
// the PointerController.
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertViewportSet(DISPLAY_ID);
}
@@ -1240,7 +1258,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE);
firstDisplayPc->assertViewportSet(DISPLAY_ID);
@@ -1258,7 +1276,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
@@ -1269,7 +1287,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotNotified();
@@ -1283,12 +1301,12 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged({/*id=*/1, {}});
- assertPointerDisplayIdNotified(ui::ADISPLAY_ID_NONE);
+ assertPointerDisplayIdNotified(ui::LogicalDisplayId::INVALID);
assertPointerControllerRemoved(pc);
}
@@ -1302,12 +1320,12 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE);
assertPointerDisplayIdNotified(DISPLAY_ID);
- // Set another viewport as a default mouse display ID. ui::ADISPLAY_ID_NONE will be notified
- // before a touchpad event.
+ // Set another viewport as a default mouse display ID. ui::LogicalDisplayId::INVALID will be
+ // notified before a touchpad event.
mChoreographer.setDefaultMouseDisplayId(ANOTHER_DISPLAY_ID);
assertPointerControllerRemoved(firstDisplayPc);
@@ -1321,7 +1339,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -1333,7 +1351,7 @@
MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
.pointer(TOUCHPAD_POINTER)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
// Check that the PointerController updated the position and the pointer is shown.
@@ -1351,7 +1369,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -1365,7 +1383,7 @@
.pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(-100).y(0))
.classification(MotionClassification::MULTI_FINGER_SWIPE)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
@@ -1379,7 +1397,7 @@
.pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(0).y(0))
.classification(MotionClassification::MULTI_FINGER_SWIPE)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
@@ -1396,7 +1414,7 @@
.pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(100).y(0))
.classification(MotionClassification::MULTI_FINGER_SWIPE)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
@@ -1411,7 +1429,7 @@
.pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(110).y(10))
.classification(MotionClassification::MULTI_FINGER_SWIPE)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
@@ -1430,7 +1448,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE),
+ ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
ANOTHER_DISPLAY_ID)}});
auto unassociatedMousePc = assertPointerControllerCreated(ControllerType::MOUSE);
@@ -1469,7 +1487,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
@@ -1486,7 +1504,7 @@
mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHPAD)
.pointer(FIRST_TOUCH_POINTER)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
// Check that there's no update on the PointerController.
@@ -1495,7 +1513,7 @@
// Check x-y coordinates, displayId and cursor position are not changed.
mTestListener.assertNotifyMotionWasCalled(
- AllOf(WithCoords(100, 200), WithDisplayId(ui::ADISPLAY_ID_NONE),
+ AllOf(WithCoords(100, 200), WithDisplayId(ui::LogicalDisplayId::INVALID),
WithCursorPosition(AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION)));
}
@@ -1506,7 +1524,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, pc->getDisplayId());
ASSERT_TRUE(pc->isPointerShown());
@@ -1525,7 +1543,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertPointerIconNotSet();
@@ -1540,7 +1559,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertPointerIconNotSet();
@@ -1556,7 +1576,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertPointerIconNotSet();
@@ -1572,7 +1593,8 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
pc->assertCustomPointerIconNotSet();
@@ -1595,7 +1617,7 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}});
auto firstMousePc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, firstMousePc->getDisplayId());
@@ -1790,14 +1812,14 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, source, DISPLAY_ID)}});
mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
mChoreographer.notifyMotion(
MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
.pointer(MOUSE_POINTER)
.deviceId(DEVICE_ID)
- .displayId(ui::ADISPLAY_ID_NONE)
+ .displayId(ui::LogicalDisplayId::INVALID)
.build());
auto mousePc = assertPointerControllerCreated(ControllerType::MOUSE);
mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, source)
@@ -1825,7 +1847,7 @@
mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}});
auto firstMousePc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, firstMousePc->getDisplayId());
@@ -1882,7 +1904,8 @@
mChoreographer.setPointerIconVisibility(DISPLAY_ID, false);
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
+ ui::LogicalDisplayId::INVALID)}});
auto mousePc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, mousePc->getDisplayId());
@@ -1900,7 +1923,7 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
{generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto touchpadPc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_EQ(DISPLAY_ID, touchpadPc->getDisplayId());
@@ -1945,7 +1968,8 @@
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID)}});
// There should be no controller created when a drawing tablet is connected
assertPointerControllerNotCreated();
@@ -1972,7 +1996,8 @@
// First drawing tablet is added
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerNotCreated();
mChoreographer.notifyMotion(
@@ -1987,9 +2012,10 @@
// Second drawing tablet is added
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, DRAWING_TABLET_SOURCE,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerNotRemoved(pc);
mChoreographer.notifyMotion(
@@ -2002,7 +2028,8 @@
// First drawing tablet is removed
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID)}});
assertPointerControllerNotRemoved(pc);
// Second drawing tablet is removed
@@ -2017,9 +2044,10 @@
// Mouse and drawing tablet connected
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE),
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID),
generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE,
- ui::ADISPLAY_ID_NONE)}});
+ ui::LogicalDisplayId::INVALID)}});
auto pc = assertPointerControllerCreated(ControllerType::MOUSE);
ASSERT_TRUE(pc->isPointerShown());
@@ -2034,7 +2062,8 @@
// Remove the mouse device
mChoreographer.notifyInputDevicesChanged(
{/*id=*/0,
- {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}});
+ {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE,
+ ui::LogicalDisplayId::INVALID)}});
// The mouse controller should not be removed, because the drawing tablet has produced a
// mouse event, so we are treating it as a mouse too.
diff --git a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
index c273e92..a36d526 100644
--- a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
+++ b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
@@ -64,7 +64,7 @@
// Define a valid motion event.
NotifyMotionArgs args(/*id=*/0, eventTime, /*readTime=*/0, deviceId, source,
- /*displayId=*/ui::ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER, action,
+ ui::LogicalDisplayId::DEFAULT, POLICY_FLAG_PASS_TO_USER, action,
/* actionButton */ 0,
/*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, pointerCount, pointerProperties,
@@ -439,7 +439,7 @@
InputDeviceInfo stylusDevice;
stylusDevice.initialize(STYLUS_DEVICE_ID, /*generation=*/1, /*controllerNumber=*/1,
/*identifier=*/{}, "stylus device", /*external=*/false,
- /*hasMic=*/false, ui::ADISPLAY_ID_NONE);
+ /*hasMic=*/false, ui::LogicalDisplayId::INVALID);
notifyInputDevicesChanged({stylusDevice});
// The touchscreen device was removed, so we no longer remember anything about it. We should
// again start blocking touch events from it.
diff --git a/services/inputflinger/tests/TouchpadInputMapper_test.cpp b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
index 245497c..2b62dd1 100644
--- a/services/inputflinger/tests/TouchpadInputMapper_test.cpp
+++ b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
@@ -37,7 +37,7 @@
constexpr auto HOVER_MOVE = AMOTION_EVENT_ACTION_HOVER_MOVE;
constexpr auto HOVER_ENTER = AMOTION_EVENT_ACTION_HOVER_ENTER;
constexpr auto HOVER_EXIT = AMOTION_EVENT_ACTION_HOVER_EXIT;
-constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT;
+constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT;
constexpr int32_t DISPLAY_WIDTH = 480;
constexpr int32_t DISPLAY_HEIGHT = 800;
constexpr std::optional<uint8_t> NO_PORT = std::nullopt; // no physical port is specified
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index 80430d1..853f628 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -88,7 +88,7 @@
// Define a valid motion event.
NotifyMotionArgs args(/*id=*/0, eventTime, /*readTime=*/0, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
- /*displayId=*/ui::ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER, action,
+ ui::LogicalDisplayId::DEFAULT, POLICY_FLAG_PASS_TO_USER, action,
/*actionButton=*/0,
/*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, pointerCount, pointerProperties,
@@ -104,7 +104,7 @@
auto info = InputDeviceInfo();
info.initialize(DEVICE_ID, /*generation=*/1, /*controllerNumber=*/1, identifier, "alias",
- /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE);
+ /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID);
info.addSource(AINPUT_SOURCE_TOUCHSCREEN);
info.addMotionRange(AMOTION_EVENT_AXIS_X, AINPUT_SOURCE_TOUCHSCREEN, 0, 1599, /*flat=*/0,
/*fuzz=*/0, X_RESOLUTION);
@@ -434,7 +434,7 @@
TEST_F(UnwantedInteractionBlockerTest, KeyIsPassedToNextListener) {
// Create a basic key event and send to blocker
NotifyKeyArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*readTime=*/21, /*deviceId=*/3,
- AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT, /*policyFlags=*/0,
+ AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/0,
AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5,
AMETA_NONE, /*downTime=*/6);
diff --git a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
index 0446d76..0b4ac1f 100644
--- a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
@@ -54,7 +54,7 @@
mClassifier->notifyKey({/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(),
eventTime, readTime,
/*deviceId=*/fdp.ConsumeIntegral<int32_t>(),
- AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT,
+ AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT,
/*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(),
AKEY_EVENT_ACTION_DOWN,
/*flags=*/fdp.ConsumeIntegral<int32_t>(), AKEYCODE_HOME,
diff --git a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
index 34ea54c..7d26a43 100644
--- a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
@@ -55,8 +55,6 @@
void monitor() { reader->monitor(); }
- bool isInputDeviceEnabled(int32_t deviceId) { return reader->isInputDeviceEnabled(deviceId); }
-
status_t start() { return reader->start(); }
status_t stop() { return reader->stop(); }
@@ -169,6 +167,8 @@
reader->sysfsNodeChanged(sysfsNodePath);
}
+ DeviceId getLastUsedInputDeviceId() override { return reader->getLastUsedInputDeviceId(); }
+
private:
std::unique_ptr<InputReaderInterface> reader;
};
@@ -204,7 +204,6 @@
},
[&]() -> void { reader->monitor(); },
[&]() -> void { reader->getInputDevices(); },
- [&]() -> void { reader->isInputDeviceEnabled(fdp->ConsumeIntegral<int32_t>()); },
[&]() -> void {
reader->getScanCodeState(fdp->ConsumeIntegral<int32_t>(),
fdp->ConsumeIntegral<uint32_t>(),
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index f62562c..9c4d1ac 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -429,14 +429,18 @@
}
void SensorDevice::onDynamicSensorsDisconnected(
- const std::vector<int32_t>& dynamicSensorHandlesRemoved) {
- if (sensorservice_flags::sensor_device_on_dynamic_sensor_disconnected()) {
- for (auto handle : dynamicSensorHandlesRemoved) {
- auto it = mConnectedDynamicSensors.find(handle);
- if (it != mConnectedDynamicSensors.end()) {
- mConnectedDynamicSensors.erase(it);
- }
- }
+ const std::vector<int32_t>& /*dynamicSensorHandlesRemoved*/) {
+ // This function is currently a no-op has removing data in mConnectedDynamicSensors here will
+ // cause a race condition between when this callback is invoked and when the dynamic sensor meta
+ // event is processed by polling. The clean up should only happen after processing the meta
+ // event. See the call stack of cleanupDisconnectedDynamicSensor.
+}
+
+void SensorDevice::cleanupDisconnectedDynamicSensor(int handle) {
+ std::lock_guard<std::mutex> lock(mDynamicSensorsMutex);
+ auto it = mConnectedDynamicSensors.find(handle);
+ if (it != mConnectedDynamicSensors.end()) {
+ mConnectedDynamicSensors.erase(it);
}
}
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index 52f7cf2..b7b04b5 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -63,6 +63,14 @@
std::vector<int32_t> getDynamicSensorHandles();
void handleDynamicSensorConnection(int handle, bool connected);
+ /**
+ * Removes handle from connected dynamic sensor list. Note that this method must be called after
+ * SensorService has done using sensor data.
+ *
+ * @param handle of the disconnected dynamic sensor.
+ */
+ void cleanupDisconnectedDynamicSensor(int handle);
+
status_t initCheck() const;
int getHalDeviceVersion() const;
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 69e4309..70ca702 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -1273,6 +1273,7 @@
} else {
int handle = mSensorEventBuffer[i].dynamic_sensor_meta.handle;
disconnectDynamicSensor(handle, activeConnections);
+ device.cleanupDisconnectedDynamicSensor(handle);
}
}
}
diff --git a/services/surfaceflinger/Effects/Daltonizer.cpp b/services/surfaceflinger/Effects/Daltonizer.cpp
index a7090c5..65f2605 100644
--- a/services/surfaceflinger/Effects/Daltonizer.cpp
+++ b/services/surfaceflinger/Effects/Daltonizer.cpp
@@ -37,6 +37,18 @@
}
}
+void Daltonizer::setLevel(int32_t level) {
+ if (level < 0 || level > 10) {
+ return;
+ }
+
+ float newLevel = level / 10.0f;
+ if (std::fabs(mLevel - newLevel) > 0.09f) {
+ mDirty = true;
+ }
+ mLevel = newLevel;
+}
+
const mat4& Daltonizer::operator()() {
if (mDirty) {
mDirty = false;
@@ -117,25 +129,24 @@
// a color blind user and "spread" this error onto the healthy cones.
// The matrices below perform this last step and have been chosen arbitrarily.
- // The amount of correction can be adjusted here.
-
+ // Scale 0 represents no change (mColorTransform is identical matrix).
// error spread for protanopia
- const mat4 errp( 1.0, 0.7, 0.7, 0,
- 0.0, 1.0, 0.0, 0,
- 0.0, 0.0, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errp(1.0, mLevel, mLevel, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// error spread for deuteranopia
- const mat4 errd( 1.0, 0.0, 0.0, 0,
- 0.7, 1.0, 0.7, 0,
- 0.0, 0.0, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errd( 1.0, 0.0, 0.0, 0.0,
+ mLevel, 1.0, mLevel, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// error spread for tritanopia
- const mat4 errt( 1.0, 0.0, 0.0, 0,
- 0.0, 1.0, 0.0, 0,
- 0.7, 0.7, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errt( 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ mLevel, mLevel, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// And the magic happens here...
// We construct the matrix that will perform the whole correction.
diff --git a/services/surfaceflinger/Effects/Daltonizer.h b/services/surfaceflinger/Effects/Daltonizer.h
index 2fb60e9..f5eaae7 100644
--- a/services/surfaceflinger/Effects/Daltonizer.h
+++ b/services/surfaceflinger/Effects/Daltonizer.h
@@ -21,6 +21,9 @@
namespace android {
+// Forward declare test class
+class DaltonizerTest;
+
enum class ColorBlindnessType {
None, // Disables the Daltonizer
Protanomaly, // L (red) cone deficient
@@ -37,10 +40,15 @@
public:
void setType(ColorBlindnessType type);
void setMode(ColorBlindnessMode mode);
+ // sets level for correction saturation, [0-10].
+ void setLevel(int32_t level);
// returns the color transform to apply in the shader
const mat4& operator()();
+ // For testing.
+ friend class DaltonizerTest;
+
private:
void update();
@@ -48,6 +56,8 @@
ColorBlindnessMode mMode = ColorBlindnessMode::Simulation;
bool mDirty = true;
mat4 mColorTransform;
+ // level of error spreading, [0.0-1.0].
+ float mLevel = 0.7f;
};
} /* namespace android */
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index d0e2d7a..c9ed157 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -543,12 +543,14 @@
}
void SurfaceFrame::classifyJankLocked(int32_t displayFrameJankType, const Fps& refreshRate,
- Fps displayFrameRenderRate, nsecs_t& deadlineDelta) {
+ Fps displayFrameRenderRate, nsecs_t* outDeadlineDelta) {
if (mActuals.presentTime == Fence::SIGNAL_TIME_INVALID) {
// Cannot do any classification for invalid present time.
mJankType = JankType::Unknown;
mJankSeverityType = JankSeverityType::Unknown;
- deadlineDelta = -1;
+ if (outDeadlineDelta) {
+ *outDeadlineDelta = -1;
+ }
return;
}
@@ -559,7 +561,9 @@
mJankType = mPresentState != PresentState::Presented ? JankType::Dropped
: JankType::AppDeadlineMissed;
mJankSeverityType = JankSeverityType::Unknown;
- deadlineDelta = -1;
+ if (outDeadlineDelta) {
+ *outDeadlineDelta = -1;
+ }
return;
}
@@ -568,11 +572,14 @@
return;
}
- deadlineDelta = mActuals.endTime - mPredictions.endTime;
const nsecs_t presentDelta = mActuals.presentTime - mPredictions.presentTime;
const nsecs_t deltaToVsync = refreshRate.getPeriodNsecs() > 0
? std::abs(presentDelta) % refreshRate.getPeriodNsecs()
: 0;
+ const nsecs_t deadlineDelta = mActuals.endTime - mPredictions.endTime;
+ if (outDeadlineDelta) {
+ *outDeadlineDelta = deadlineDelta;
+ }
if (deadlineDelta > mJankClassificationThresholds.deadlineThreshold) {
mFrameReadyMetadata = FrameReadyMetadata::LateFinish;
@@ -671,7 +678,7 @@
mActuals.presentTime = presentTime;
nsecs_t deadlineDelta = 0;
- classifyJankLocked(displayFrameJankType, refreshRate, displayFrameRenderRate, deadlineDelta);
+ classifyJankLocked(displayFrameJankType, refreshRate, displayFrameRenderRate, &deadlineDelta);
if (mPredictionState != PredictionState::None) {
// Only update janky frames if the app used vsync predictions
@@ -681,6 +688,14 @@
}
}
+void SurfaceFrame::onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate) {
+ std::scoped_lock lock(mMutex);
+
+ mDisplayFrameRenderRate = displayFrameRenderRate;
+ mActuals.presentTime = mPredictions.presentTime;
+ classifyJankLocked(JankType::None, refreshRate, displayFrameRenderRate, nullptr);
+}
+
void SurfaceFrame::tracePredictions(int64_t displayFrameToken, nsecs_t monoBootOffset) const {
int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing();
@@ -912,6 +927,15 @@
finalizeCurrentDisplayFrame();
}
+void FrameTimeline::onCommitNotComposited() {
+ ATRACE_CALL();
+ std::scoped_lock lock(mMutex);
+ mCurrentDisplayFrame->onCommitNotComposited();
+ mCurrentDisplayFrame.reset();
+ mCurrentDisplayFrame = std::make_shared<DisplayFrame>(mTimeStats, mJankClassificationThresholds,
+ &mTraceCookieCounter);
+}
+
void FrameTimeline::DisplayFrame::addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame) {
mSurfaceFrames.push_back(surfaceFrame);
}
@@ -1094,6 +1118,12 @@
}
}
+void FrameTimeline::DisplayFrame::onCommitNotComposited() {
+ for (auto& surfaceFrame : mSurfaceFrames) {
+ surfaceFrame->onCommitNotComposited(mRefreshRate, mRenderRate);
+ }
+}
+
void FrameTimeline::DisplayFrame::tracePredictions(pid_t surfaceFlingerPid,
nsecs_t monoBootOffset) const {
int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing();
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.h b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
index a76f7d4..94cfcb4 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.h
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
@@ -204,6 +204,8 @@
void onPresent(nsecs_t presentTime, int32_t displayFrameJankType, Fps refreshRate,
Fps displayFrameRenderRate, nsecs_t displayDeadlineDelta,
nsecs_t displayPresentDelta);
+ // Sets the frame as none janky as there was no real display frame.
+ void onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate);
// All the timestamps are dumped relative to the baseTime
void dump(std::string& result, const std::string& indent, nsecs_t baseTime) const;
// Dumps only the layer, token, is buffer, jank metadata, prediction and present states.
@@ -235,7 +237,7 @@
void tracePredictions(int64_t displayFrameToken, nsecs_t monoBootOffset) const;
void traceActuals(int64_t displayFrameToken, nsecs_t monoBootOffset) const;
void classifyJankLocked(int32_t displayFrameJankType, const Fps& refreshRate,
- Fps displayFrameRenderRate, nsecs_t& deadlineDelta) REQUIRES(mMutex);
+ Fps displayFrameRenderRate, nsecs_t* outDeadlineDelta) REQUIRES(mMutex);
const int64_t mToken;
const int32_t mInputEventId;
@@ -318,6 +320,10 @@
virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
const std::shared_ptr<FenceTime>& gpuFence) = 0;
+ // Tells FrameTimeline that a frame was committed but not composited. This is used to flush
+ // all the associated surface frames.
+ virtual void onCommitNotComposited() = 0;
+
// Args:
// -jank : Dumps only the Display Frames that are either janky themselves
// or contain janky Surface Frames.
@@ -390,6 +396,8 @@
std::optional<TimelineItem> predictions, nsecs_t wakeUpTime);
// Sets the appropriate metadata and classifies the jank.
void onPresent(nsecs_t signalTime, nsecs_t previousPresentTime);
+ // Flushes all the surface frames as those were not generating any actual display frames.
+ void onCommitNotComposited();
// Adds the provided SurfaceFrame to the current display frame.
void addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame);
@@ -475,6 +483,7 @@
void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate, Fps renderRate) override;
void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
const std::shared_ptr<FenceTime>& gpuFence = FenceTime::NO_FENCE) override;
+ void onCommitNotComposited() override;
void parseArgs(const Vector<String16>& args, std::string& result) override;
void setMaxDisplayFrames(uint32_t size) override;
float computeFps(const std::unordered_set<int32_t>& layerIds) override;
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index e40c79c..f10bb33 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -313,6 +313,21 @@
}
}
+void updateMetadataAndGameMode(LayerSnapshot& snapshot, const RequestedLayerState& requested,
+ const LayerSnapshotBuilder::Args& args,
+ const LayerSnapshot& parentSnapshot) {
+ if (snapshot.changes.test(RequestedLayerState::Changes::GameMode)) {
+ snapshot.gameMode = requested.metadata.has(gui::METADATA_GAME_MODE)
+ ? requested.gameMode
+ : parentSnapshot.gameMode;
+ }
+ updateMetadata(snapshot, requested, args);
+ if (args.includeMetadata) {
+ snapshot.layerMetadata = parentSnapshot.layerMetadata;
+ snapshot.layerMetadata.merge(requested.metadata);
+ }
+}
+
void clearChanges(LayerSnapshot& snapshot) {
snapshot.changes.clear();
snapshot.clientChanges = 0;
@@ -362,6 +377,7 @@
snapshot.gameMode = gui::GameMode::Unsupported;
snapshot.frameRate = {};
snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
+ snapshot.ignoreLocalTransform = false;
return snapshot;
}
@@ -745,6 +761,11 @@
RequestedLayerState::Changes::Input)) {
updateInput(snapshot, requested, parentSnapshot, path, args);
}
+ if (forceUpdate ||
+ (args.includeMetadata &&
+ snapshot.changes.test(RequestedLayerState::Changes::Metadata))) {
+ updateMetadataAndGameMode(snapshot, requested, args, parentSnapshot);
+ }
return;
}
@@ -784,15 +805,8 @@
}
}
- if (forceUpdate || snapshot.changes.test(RequestedLayerState::Changes::GameMode)) {
- snapshot.gameMode = requested.metadata.has(gui::METADATA_GAME_MODE)
- ? requested.gameMode
- : parentSnapshot.gameMode;
- updateMetadata(snapshot, requested, args);
- if (args.includeMetadata) {
- snapshot.layerMetadata = parentSnapshot.layerMetadata;
- snapshot.layerMetadata.merge(requested.metadata);
- }
+ if (forceUpdate || snapshot.changes.test(RequestedLayerState::Changes::Metadata)) {
+ updateMetadataAndGameMode(snapshot, requested, args, parentSnapshot);
}
if (forceUpdate || snapshot.clientChanges & layer_state_t::eFixedTransformHintChanged ||
@@ -1161,6 +1175,15 @@
}
}
+void LayerSnapshotBuilder::forEachSnapshot(const Visitor& visitor,
+ const ConstPredicate& predicate) {
+ for (int i = 0; i < mNumInterestingSnapshots; i++) {
+ std::unique_ptr<LayerSnapshot>& snapshot = mSnapshots.at((size_t)i);
+ if (!predicate(*snapshot)) continue;
+ visitor(snapshot);
+ }
+}
+
void LayerSnapshotBuilder::forEachInputSnapshot(const ConstVisitor& visitor) const {
for (int i = mNumInterestingSnapshots - 1; i >= 0; i--) {
LayerSnapshot& snapshot = *mSnapshots[(size_t)i];
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
index 1cec018..dbbad76 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
@@ -86,6 +86,11 @@
// Visit each visible snapshot in z-order and move the snapshot if needed
void forEachVisibleSnapshot(const Visitor& visitor);
+ typedef std::function<bool(const LayerSnapshot& snapshot)> ConstPredicate;
+ // Visit each snapshot that satisfies the predicate and move the snapshot if needed with visible
+ // snapshots in z-order
+ void forEachSnapshot(const Visitor& visitor, const ConstPredicate& predicate);
+
// Visit each snapshot interesting to input reverse z-order
void forEachInputSnapshot(const ConstVisitor& visitor) const;
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
index 028bd19..5631fac 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
@@ -328,6 +328,7 @@
changes |= RequestedLayerState::Changes::GameMode;
}
}
+ changes |= RequestedLayerState::Changes::Metadata;
}
if (clientState.what & layer_state_t::eFrameRateChanged) {
const auto compatibility =
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.h b/services/surfaceflinger/FrontEnd/RequestedLayerState.h
index 09f33de..48b9640 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.h
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.h
@@ -26,6 +26,7 @@
#include "TransactionState.h"
namespace android::surfaceflinger::frontend {
+using namespace ftl::flag_operators;
// Stores client requested states for a layer.
// This struct does not store any other states or states pertaining to
@@ -58,6 +59,13 @@
GameMode = 1u << 19,
BufferUsageFlags = 1u << 20,
};
+
+ static constexpr ftl::Flags<Changes> kMustComposite = Changes::Created | Changes::Destroyed |
+ Changes::Hierarchy | Changes::Geometry | Changes::Content | Changes::Input |
+ Changes::Z | Changes::Mirror | Changes::Parent | Changes::RelativeParent |
+ Changes::Metadata | Changes::Visibility | Changes::VisibleRegion | Changes::Buffer |
+ Changes::SidebandStream | Changes::Animation | Changes::BufferSize | Changes::GameMode |
+ Changes::BufferUsageFlags;
static Rect reduce(const Rect& win, const Region& exclude);
RequestedLayerState(const LayerCreationArgs&);
void merge(const ResolvedComposerState&);
diff --git a/services/surfaceflinger/LayerRenderArea.cpp b/services/surfaceflinger/LayerRenderArea.cpp
index c25ddb6..f323ce7 100644
--- a/services/surfaceflinger/LayerRenderArea.cpp
+++ b/services/surfaceflinger/LayerRenderArea.cpp
@@ -25,13 +25,14 @@
namespace android {
-LayerRenderArea::LayerRenderArea(sp<Layer> layer, const Rect& crop, ui::Size reqSize,
- ui::Dataspace reqDataSpace, bool allowSecureLayers,
- const ui::Transform& layerTransform, const Rect& layerBufferSize,
- bool hintForSeamlessTransition)
+LayerRenderArea::LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot,
+ const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
+ bool allowSecureLayers, const ui::Transform& layerTransform,
+ const Rect& layerBufferSize, bool hintForSeamlessTransition)
: RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, hintForSeamlessTransition,
allowSecureLayers),
mLayer(std::move(layer)),
+ mLayerSnapshot(std::move(layerSnapshot)),
mLayerBufferSize(layerBufferSize),
mCrop(crop),
mTransform(layerTransform) {}
diff --git a/services/surfaceflinger/LayerRenderArea.h b/services/surfaceflinger/LayerRenderArea.h
index b12afe8..a12bfca 100644
--- a/services/surfaceflinger/LayerRenderArea.h
+++ b/services/surfaceflinger/LayerRenderArea.h
@@ -32,19 +32,22 @@
class LayerRenderArea : public RenderArea {
public:
- LayerRenderArea(sp<Layer> layer, const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
- bool allowSecureLayers, const ui::Transform& layerTransform,
- const Rect& layerBufferSize, bool hintForSeamlessTransition);
+ LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot, const Rect& crop,
+ ui::Size reqSize, ui::Dataspace reqDataSpace, bool allowSecureLayers,
+ const ui::Transform& layerTransform, const Rect& layerBufferSize,
+ bool hintForSeamlessTransition);
const ui::Transform& getTransform() const override;
bool isSecure() const override;
sp<const DisplayDevice> getDisplayDevice() const override;
Rect getSourceCrop() const override;
- virtual sp<Layer> getParentLayer() const { return mLayer; }
+ sp<Layer> getParentLayer() const override { return mLayer; }
+ const frontend::LayerSnapshot* getLayerSnapshot() const override { return &mLayerSnapshot; }
private:
const sp<Layer> mLayer;
+ const frontend::LayerSnapshot mLayerSnapshot;
const Rect mLayerBufferSize;
const Rect mCrop;
diff --git a/services/surfaceflinger/RenderArea.h b/services/surfaceflinger/RenderArea.h
index 18a5304..e8d20af 100644
--- a/services/surfaceflinger/RenderArea.h
+++ b/services/surfaceflinger/RenderArea.h
@@ -4,6 +4,8 @@
#include <ui/Transform.h>
#include <functional>
+
+#include "FrontEnd/LayerSnapshot.h"
#include "Layer.h"
namespace android {
@@ -82,6 +84,10 @@
// capture operation.
virtual sp<Layer> getParentLayer() const { return nullptr; }
+ // If this is a LayerRenderArea, return the layer snapshot
+ // of the root layer of the capture operation
+ virtual const frontend::LayerSnapshot* getLayerSnapshot() const { return nullptr; }
+
// Returns whether the render result may be used for system animations that
// must preserve the exact colors of the display.
bool getHintForSeamlessTransition() const { return mHintForSeamlessTransition; }
diff --git a/services/surfaceflinger/RenderAreaBuilder.h b/services/surfaceflinger/RenderAreaBuilder.h
index 012acd2..a25c6e0 100644
--- a/services/surfaceflinger/RenderAreaBuilder.h
+++ b/services/surfaceflinger/RenderAreaBuilder.h
@@ -83,9 +83,12 @@
layer(layer),
childrenOnly(childrenOnly) {}
- // Layer that the render area will be on
+ // Root layer of the render area
sp<Layer> layer;
+ // Layer snapshot of the root layer
+ frontend::LayerSnapshot layerSnapshot;
+
// Transform to be applied on the layers to transform them
// into the logical render area
ui::Transform layerTransform{ui::Transform()};
@@ -97,17 +100,18 @@
bool childrenOnly;
// Uses parent snapshot to determine layer transform and buffer size
- void setLayerInfo(const frontend::LayerSnapshot* parentSnapshot) {
+ void setLayerSnapshot(const frontend::LayerSnapshot& parentSnapshot) {
+ layerSnapshot = parentSnapshot;
if (!childrenOnly) {
- layerTransform = parentSnapshot->localTransform.inverse();
+ layerTransform = parentSnapshot.localTransform.inverse();
}
- layerBufferSize = parentSnapshot->bufferSize;
+ layerBufferSize = parentSnapshot.bufferSize;
}
std::unique_ptr<RenderArea> build() const override {
- return std::make_unique<LayerRenderArea>(layer, crop, reqSize, reqDataSpace,
- allowSecureLayers, layerTransform, layerBufferSize,
- hintForSeamlessTransition);
+ return std::make_unique<LayerRenderArea>(layer, std::move(layerSnapshot), crop, reqSize,
+ reqDataSpace, allowSecureLayers, layerTransform,
+ layerBufferSize, hintForSeamlessTransition);
}
};
diff --git a/services/surfaceflinger/Scheduler/ISchedulerCallback.h b/services/surfaceflinger/Scheduler/ISchedulerCallback.h
index 9f4f5b6..43cdb5e 100644
--- a/services/surfaceflinger/Scheduler/ISchedulerCallback.h
+++ b/services/surfaceflinger/Scheduler/ISchedulerCallback.h
@@ -32,6 +32,7 @@
virtual void onChoreographerAttached() = 0;
virtual void onExpectedPresentTimePosted(TimePoint, ftl::NonNull<DisplayModePtr>,
Fps renderRate) = 0;
+ virtual void onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) = 0;
protected:
~ISchedulerCallback() = default;
diff --git a/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp b/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
index a37fb96..2c66492 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp
@@ -1590,7 +1590,8 @@
std::lock_guard lock(mLock);
const auto activeMode = getActiveModeLocked();
- dumper.dump("activeMode"sv, to_string(activeMode));
+ dumper.dump("renderRate"sv, to_string(activeMode.fps));
+ dumper.dump("activeMode"sv, to_string(*activeMode.modePtr));
dumper.dump("displayModes"sv);
{
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 005ec05..60681a2 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -221,6 +221,7 @@
if (FlagManager::getInstance().vrr_config()) {
compositor.sendNotifyExpectedPresentHint(pacesetterPtr->displayId);
}
+ mSchedulerCallback.onCommitNotComposited(pacesetterPtr->displayId);
return;
}
}
@@ -1152,8 +1153,10 @@
return pacesetterFps;
}();
+ // Choose a mode for powered-on follower displays.
for (const auto& [id, display] : mDisplays) {
if (id == *mPacesetterDisplayId) continue;
+ if (display.powerMode != hal::PowerMode::ON) continue;
auto rankedFrameRates =
display.selectorPtr->getRankedFrameRates(mPolicy.contentRequirements, globalSignals,
diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
index 0b47924..85ce713 100644
--- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
+++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp
@@ -650,29 +650,33 @@
const auto threshold = model.slope / 2;
const auto lastFrameMissed =
lastVsyncOpt && std::abs(*lastVsyncOpt - missedVsync.vsync.ns()) < threshold;
- if (FlagManager::getInstance().vrr_config() && lastFrameMissed) {
- // If the last frame missed is the last vsync, we already shifted the timeline. Depends on
- // whether we skipped the frame (onFrameMissed) or not (onFrameBegin) we apply a different
- // fixup. There is no need to to shift the vsync timeline again.
- vsyncTime += missedVsync.fixup.ns();
- ATRACE_FORMAT_INSTANT("lastFrameMissed");
- } else if (FlagManager::getInstance().vrr_config() && minFramePeriodOpt && mRenderRateOpt &&
- lastVsyncOpt) {
- // lastVsyncOpt is based on the old timeline before we shifted it. we should correct it
- // first before trying to use it.
- lastVsyncOpt = snapToVsyncAlignedWithRenderRate(model, *lastVsyncOpt);
- const auto vsyncDiff = vsyncTime - *lastVsyncOpt;
- if (vsyncDiff <= minFramePeriodOpt->ns() - threshold) {
- // avoid a duplicate vsync
- ATRACE_FORMAT_INSTANT("skipping a vsync to avoid duplicate frame. next in %.2f which "
- "is %.2f "
- "from "
- "prev. "
- "adjust by %.2f",
- static_cast<float>(vsyncTime - TimePoint::now().ns()) / 1e6f,
- static_cast<float>(vsyncDiff) / 1e6f,
- static_cast<float>(mRenderRateOpt->getPeriodNsecs()) / 1e6f);
- vsyncTime += mRenderRateOpt->getPeriodNsecs();
+ const auto mightBackpressure = minFramePeriodOpt && mRenderRateOpt &&
+ mRenderRateOpt->getPeriod() < 2 * (*minFramePeriodOpt);
+ if (FlagManager::getInstance().vrr_config()) {
+ if (lastFrameMissed) {
+ // If the last frame missed is the last vsync, we already shifted the timeline. Depends
+ // on whether we skipped the frame (onFrameMissed) or not (onFrameBegin) we apply a
+ // different fixup. There is no need to to shift the vsync timeline again.
+ vsyncTime += missedVsync.fixup.ns();
+ ATRACE_FORMAT_INSTANT("lastFrameMissed");
+ } else if (mightBackpressure && lastVsyncOpt) {
+ // lastVsyncOpt is based on the old timeline before we shifted it. we should correct it
+ // first before trying to use it.
+ lastVsyncOpt = snapToVsyncAlignedWithRenderRate(model, *lastVsyncOpt);
+ const auto vsyncDiff = vsyncTime - *lastVsyncOpt;
+ if (vsyncDiff <= minFramePeriodOpt->ns() - threshold) {
+ // avoid a duplicate vsync
+ ATRACE_FORMAT_INSTANT("skipping a vsync to avoid duplicate frame. next in %.2f "
+ "which "
+ "is %.2f "
+ "from "
+ "prev. "
+ "adjust by %.2f",
+ static_cast<float>(vsyncTime - TimePoint::now().ns()) / 1e6f,
+ static_cast<float>(vsyncDiff) / 1e6f,
+ static_cast<float>(mRenderRateOpt->getPeriodNsecs()) / 1e6f);
+ vsyncTime += mRenderRateOpt->getPeriodNsecs();
+ }
}
}
diff --git a/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h b/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
index 59a6df2..f2be316 100644
--- a/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
+++ b/services/surfaceflinger/Scheduler/include/scheduler/FrameRateMode.h
@@ -36,8 +36,11 @@
};
inline std::string to_string(const FrameRateMode& mode) {
- return to_string(mode.fps) + " (" + to_string(mode.modePtr->getPeakFps()) + "(" +
- to_string(mode.modePtr->getVsyncRate()) + "))";
+ return base::StringPrintf("{fps=%s, modePtr={id=%d, vsyncRate=%s, peakRefreshRate=%s}}",
+ to_string(mode.fps).c_str(),
+ ftl::to_underlying(mode.modePtr->getId()),
+ to_string(mode.modePtr->getVsyncRate()).c_str(),
+ to_string(mode.modePtr->getPeakFps()).c_str());
}
} // namespace android::scheduler
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9a575ca..b2ca572 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1414,11 +1414,12 @@
}
}
-void SurfaceFlinger::initiateDisplayModeChanges() {
+bool SurfaceFlinger::initiateDisplayModeChanges() {
ATRACE_CALL();
std::optional<PhysicalDisplayId> displayToUpdateImmediately;
+ bool mustComposite = false;
for (const auto& [id, physical] : mPhysicalDisplays) {
const auto display = getDisplayDeviceLocked(id);
if (!display) continue;
@@ -1428,11 +1429,6 @@
continue;
}
- if (!shouldApplyRefreshRateSelectorPolicy(*display)) {
- dropModeRequest(display);
- continue;
- }
-
const auto desiredModeId = desiredModeOpt->mode.modePtr->getId();
const auto displayModePtrOpt = physical.snapshot().displayModes().get(desiredModeId);
@@ -1475,7 +1471,11 @@
mScheduler->onNewVsyncPeriodChangeTimeline(outTimeline);
if (outTimeline.refreshRequired) {
- scheduleComposite(FrameHint::kNone);
+ if (FlagManager::getInstance().vrr_bugfix_24q4()) {
+ mustComposite = true;
+ } else {
+ scheduleComposite(FrameHint::kNone);
+ }
} else {
// TODO(b/255635711): Remove `displayToUpdateImmediately` to `finalizeDisplayModeChange`
// for all displays. This was only needed when the loop iterated over `mDisplays` rather
@@ -1493,6 +1493,8 @@
applyActiveMode(display);
}
}
+
+ return mustComposite;
}
void SurfaceFlinger::disableExpensiveRendering() {
@@ -2442,7 +2444,12 @@
mUpdateAttachedChoreographer = true;
}
outTransactionsAreEmpty = mLayerLifecycleManager.getGlobalChanges().get() == 0;
- mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;
+ if (FlagManager::getInstance().vrr_bugfix_24q4()) {
+ mustComposite |= mLayerLifecycleManager.getGlobalChanges().any(
+ frontend::RequestedLayerState::kMustComposite);
+ } else {
+ mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;
+ }
bool newDataLatched = false;
ATRACE_NAME("DisplayCallbackAndStatsUpdates");
@@ -2667,7 +2674,7 @@
? &mLayerHierarchyBuilder.getHierarchy()
: nullptr,
updateAttachedChoreographer);
- initiateDisplayModeChanges();
+ mustComposite |= initiateDisplayModeChanges();
}
updateCursorAsync();
@@ -4231,12 +4238,6 @@
if (!display) continue;
- if (ftl::FakeGuard guard(kMainThreadContext);
- !shouldApplyRefreshRateSelectorPolicy(*display)) {
- ALOGV("%s(%s): Skipped applying policy", __func__, to_string(displayId).c_str());
- continue;
- }
-
if (display->refreshRateSelector().isModeAllowed(request.mode)) {
setDesiredMode(std::move(request));
} else {
@@ -4408,6 +4409,12 @@
scheduleNotifyExpectedPresentHint(displayId);
}
+void SurfaceFlinger::onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) {
+ if (FlagManager::getInstance().commit_not_composited()) {
+ mFrameTimeline->onCommitNotComposited();
+ }
+}
+
void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) {
using namespace scheduler;
@@ -7141,6 +7148,7 @@
Mutex::Autolock _l(mStateLock);
// daltonize
n = data.readInt32();
+ mDaltonizer.setLevel(data.readInt32());
switch (n % 10) {
case 1:
mDaltonizer.setType(ColorBlindnessType::Protanomaly);
@@ -7504,14 +7512,11 @@
auto future = mScheduler->schedule(
[&]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(kMainThreadContext) {
n = data.readInt32();
- mHdrSdrRatioOverlay = n != 0;
- switch (n) {
- case 0:
- case 1:
- enableHdrSdrRatioOverlay(mHdrSdrRatioOverlay);
- break;
- default:
- reply->writeBool(isHdrSdrRatioOverlayEnabled());
+ if (n == 0 || n == 1) {
+ mHdrSdrRatioOverlay = n != 0;
+ enableHdrSdrRatioOverlay(mHdrSdrRatioOverlay);
+ } else {
+ reply->writeBool(isHdrSdrRatioOverlayEnabled());
}
});
future.wait();
@@ -8211,7 +8216,7 @@
ALOGW("Couldn't find layer snapshot for %d",
layerRenderAreaBuilder->layer->getSequence());
} else {
- layerRenderAreaBuilder->setLayerInfo(snapshot);
+ layerRenderAreaBuilder->setLayerSnapshot(*snapshot);
}
}
@@ -8306,9 +8311,8 @@
Mutex::Autolock lock(mStateLock);
const DisplayDevice* display = nullptr;
if (parent) {
- const frontend::LayerSnapshot* snapshot = mLayerLifecycleManagerEnabled
- ? mLayerSnapshotBuilder.getSnapshot(parent->sequence)
- : parent->getLayerSnapshot();
+ const frontend::LayerSnapshot* snapshot =
+ mLayerSnapshotBuilder.getSnapshot(parent->sequence);
if (snapshot) {
display = findDisplay([layerStack = snapshot->outputFilter.layerStack](
const auto& display) {
@@ -8332,10 +8336,7 @@
renderArea->getHintForSeamlessTransition());
sdrWhitePointNits = state.sdrWhitePointNits;
- // TODO(b/298219334): Clean this up once we verify this doesn't break anything
- static constexpr bool kScreenshotsDontDim = true;
-
- if (kScreenshotsDontDim && !captureResults.capturedHdrLayers) {
+ if (!captureResults.capturedHdrLayers) {
displayBrightnessNits = sdrWhitePointNits;
} else {
displayBrightnessNits = state.displayBrightnessNits;
@@ -8567,35 +8568,11 @@
break;
}
- if (!shouldApplyRefreshRateSelectorPolicy(*display)) {
- ALOGV("%s(%s): Skipped applying policy", __func__, to_string(displayId).c_str());
- return NO_ERROR;
- }
-
return applyRefreshRateSelectorPolicy(displayId, selector);
}
-bool SurfaceFlinger::shouldApplyRefreshRateSelectorPolicy(const DisplayDevice& display) const {
- if (display.isPoweredOn() || mPhysicalDisplays.size() == 1) return true;
-
- LOG_ALWAYS_FATAL_IF(display.isVirtual());
- const auto displayId = display.getPhysicalId();
-
- // The display is powered off, and this is a multi-display device. If the display is the
- // inactive internal display of a dual-display foldable, then the policy will be applied
- // when it becomes active upon powering on.
- //
- // TODO(b/255635711): Remove this function (i.e. returning `false` as a special case) once
- // concurrent mode setting across multiple (potentially powered off) displays is supported.
- //
- return displayId == mActiveDisplayId ||
- !mPhysicalDisplays.get(displayId)
- .transform(&PhysicalDisplay::isInternal)
- .value_or(false);
-}
-
status_t SurfaceFlinger::applyRefreshRateSelectorPolicy(
- PhysicalDisplayId displayId, const scheduler::RefreshRateSelector& selector, bool force) {
+ PhysicalDisplayId displayId, const scheduler::RefreshRateSelector& selector) {
const scheduler::RefreshRateSelector::Policy currentPolicy = selector.getCurrentPolicy();
ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str());
@@ -8626,7 +8603,7 @@
return INVALID_OPERATION;
}
- setDesiredMode({std::move(preferredMode), .emitEvent = true, .force = force});
+ setDesiredMode({std::move(preferredMode), .emitEvent = true});
// Update the frameRateOverride list as the display render rate might have changed
if (mScheduler->updateFrameRateOverrides(scheduler::GlobalSignals{}, preferredFps)) {
@@ -8984,13 +8961,8 @@
const DisplayDevice& activeDisplay) {
ATRACE_CALL();
- // For the first display activated during boot, there is no need to force setDesiredMode,
- // because DM is about to send its policy via setDesiredDisplayModeSpecs.
- bool forceApplyPolicy = false;
-
if (inactiveDisplayPtr) {
inactiveDisplayPtr->getCompositionDisplay()->setLayerCachingTexturePoolEnabled(false);
- forceApplyPolicy = true;
}
mActiveDisplayId = activeDisplay.getPhysicalId();
@@ -9007,12 +8979,11 @@
mActiveDisplayTransformHint = activeDisplay.getTransformHint();
sActiveDisplayRotationFlags = ui::Transform::toRotationFlags(activeDisplay.getOrientation());
- // The policy of the new active/pacesetter display may have changed while it was inactive. In
- // that case, its preferred mode has not been propagated to HWC (via setDesiredMode). In either
- // case, the Scheduler's cachedModeChangedParams must be initialized to the newly active mode,
- // and the kernel idle timer of the newly active display must be toggled.
- applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay.refreshRateSelector(),
- forceApplyPolicy);
+ // Whether or not the policy of the new active/pacesetter display changed while it was inactive
+ // (in which case its preferred mode has already been propagated to HWC via setDesiredMode), the
+ // Scheduler's cachedModeChangedParams must be initialized to the newly active mode, and the
+ // kernel idle timer of the newly active display must be toggled.
+ applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay.refreshRateSelector());
}
status_t SurfaceFlinger::addWindowInfosListener(const sp<IWindowInfosListener>& windowInfosListener,
@@ -9231,7 +9202,9 @@
std::vector<std::pair<Layer*, LayerFE*>> layers;
if (mLayerLifecycleManagerEnabled) {
nsecs_t currentTime = systemTime();
- mLayerSnapshotBuilder.forEachVisibleSnapshot(
+ const bool needsMetadata = mCompositionEngine->getFeatureFlags().test(
+ compositionengine::Feature::kSnapshotLayerMetadata);
+ mLayerSnapshotBuilder.forEachSnapshot(
[&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) FTL_FAKE_GUARD(
kMainThreadContext) {
if (cursorOnly &&
@@ -9254,6 +9227,12 @@
layerFE->mSnapshot = std::move(snapshot);
refreshArgs.layers.push_back(layerFE);
layers.emplace_back(legacyLayer.get(), layerFE.get());
+ },
+ [needsMetadata](const frontend::LayerSnapshot& snapshot) {
+ return snapshot.isVisible ||
+ (needsMetadata &&
+ snapshot.changes.test(
+ frontend::RequestedLayerState::Changes::Metadata));
});
}
if (!mLayerLifecycleManagerEnabled) {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 2363cd7..d56072a 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -701,6 +701,8 @@
void onChoreographerAttached() override;
void onExpectedPresentTimePosted(TimePoint expectedPresentTime, ftl::NonNull<DisplayModePtr>,
Fps renderRate) override;
+ void onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) override
+ REQUIRES(kMainThreadContext);
// ICEPowerCallback overrides:
void notifyCpuLoadUp() override;
@@ -735,7 +737,7 @@
status_t setActiveModeFromBackdoor(const sp<display::DisplayToken>&, DisplayModeId, Fps minFps,
Fps maxFps);
- void initiateDisplayModeChanges() REQUIRES(mStateLock, kMainThreadContext);
+ bool initiateDisplayModeChanges() REQUIRES(mStateLock, kMainThreadContext);
void finalizeDisplayModeChange(DisplayDevice&) REQUIRES(mStateLock, kMainThreadContext);
// TODO(b/241285191): Replace DisplayDevice with DisplayModeRequest, and move to Scheduler.
@@ -755,13 +757,9 @@
const sp<DisplayDevice>&, const scheduler::RefreshRateSelector::PolicyVariant&)
EXCLUDES(mStateLock) REQUIRES(kMainThreadContext);
- bool shouldApplyRefreshRateSelectorPolicy(const DisplayDevice&) const
- REQUIRES(mStateLock, kMainThreadContext);
-
// TODO(b/241285191): Look up RefreshRateSelector on Scheduler to remove redundant parameter.
status_t applyRefreshRateSelectorPolicy(PhysicalDisplayId,
- const scheduler::RefreshRateSelector&,
- bool force = false)
+ const scheduler::RefreshRateSelector&)
REQUIRES(mStateLock, kMainThreadContext);
void commitTransactionsLegacy() EXCLUDES(mStateLock) REQUIRES(kMainThreadContext);
diff --git a/services/surfaceflinger/TransactionState.h b/services/surfaceflinger/TransactionState.h
index 89a8f92..e5d6481 100644
--- a/services/surfaceflinger/TransactionState.h
+++ b/services/surfaceflinger/TransactionState.h
@@ -23,6 +23,7 @@
#include "FrontEnd/LayerCreationArgs.h"
#include "renderengine/ExternalTexture.h"
+#include <common/FlagManager.h>
#include <gui/LayerState.h>
#include <system/window.h>
@@ -108,9 +109,22 @@
for (const auto& state : states) {
const bool frameRateChanged = state.state.what & layer_state_t::eFrameRateChanged;
- if (!frameRateChanged ||
- state.state.frameRateCompatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE) {
- return true;
+ if (FlagManager::getInstance().vrr_bugfix_24q4()) {
+ const bool frameRateIsNoVote = frameRateChanged &&
+ state.state.frameRateCompatibility == ANATIVEWINDOW_FRAME_RATE_NO_VOTE;
+ const bool frameRateCategoryChanged =
+ state.state.what & layer_state_t::eFrameRateCategoryChanged;
+ const bool frameRateCategoryIsNoPreference = frameRateCategoryChanged &&
+ state.state.frameRateCategory ==
+ ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE;
+ if (!frameRateIsNoVote && !frameRateCategoryIsNoPreference) {
+ return true;
+ }
+ } else {
+ if (!frameRateChanged ||
+ state.state.frameRateCompatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE) {
+ return true;
+ }
}
}
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index 45b3290..121629f 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -134,6 +134,7 @@
DUMP_READ_ONLY_FLAG(screenshot_fence_preservation);
DUMP_READ_ONLY_FLAG(vulkan_renderengine);
DUMP_READ_ONLY_FLAG(renderable_buffer_usage);
+ DUMP_READ_ONLY_FLAG(vrr_bugfix_24q4);
DUMP_READ_ONLY_FLAG(restore_blur_step);
DUMP_READ_ONLY_FLAG(dont_skip_on_early_ro);
DUMP_READ_ONLY_FLAG(protected_if_client);
@@ -144,6 +145,8 @@
DUMP_READ_ONLY_FLAG(deprecate_vsync_sf);
DUMP_READ_ONLY_FLAG(allow_n_vsyncs_in_targeter);
DUMP_READ_ONLY_FLAG(detached_mirror);
+ DUMP_READ_ONLY_FLAG(commit_not_composited);
+ DUMP_READ_ONLY_FLAG(local_tonemap_screenshots);
#undef DUMP_READ_ONLY_FLAG
#undef DUMP_SERVER_FLAG
@@ -232,12 +235,15 @@
FLAG_MANAGER_READ_ONLY_FLAG(restore_blur_step, "debug.renderengine.restore_blur_step")
FLAG_MANAGER_READ_ONLY_FLAG(dont_skip_on_early_ro, "")
FLAG_MANAGER_READ_ONLY_FLAG(protected_if_client, "")
+FLAG_MANAGER_READ_ONLY_FLAG(vrr_bugfix_24q4, "");
FLAG_MANAGER_READ_ONLY_FLAG(ce_fence_promise, "");
FLAG_MANAGER_READ_ONLY_FLAG(graphite_renderengine, "debug.renderengine.graphite")
FLAG_MANAGER_READ_ONLY_FLAG(latch_unsignaled_with_auto_refresh_changed, "");
FLAG_MANAGER_READ_ONLY_FLAG(deprecate_vsync_sf, "");
FLAG_MANAGER_READ_ONLY_FLAG(allow_n_vsyncs_in_targeter, "");
FLAG_MANAGER_READ_ONLY_FLAG(detached_mirror, "");
+FLAG_MANAGER_READ_ONLY_FLAG(commit_not_composited, "");
+FLAG_MANAGER_READ_ONLY_FLAG(local_tonemap_screenshots, "debug.sf.local_tonemap_screenshots");
/// Trunk stable server flags ///
FLAG_MANAGER_SERVER_FLAG(refresh_rate_overlay_on_external_display, "")
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index 592e774..4cf4453 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -72,6 +72,7 @@
bool enable_layer_command_batching() const;
bool screenshot_fence_preservation() const;
bool vulkan_renderengine() const;
+ bool vrr_bugfix_24q4() const;
bool renderable_buffer_usage() const;
bool restore_blur_step() const;
bool dont_skip_on_early_ro() const;
@@ -83,6 +84,8 @@
bool deprecate_vsync_sf() const;
bool allow_n_vsyncs_in_targeter() const;
bool detached_mirror() const;
+ bool commit_not_composited() const;
+ bool local_tonemap_screenshots() const;
protected:
// overridden for unit tests
diff --git a/services/surfaceflinger/surfaceflinger_flags_new.aconfig b/services/surfaceflinger/surfaceflinger_flags_new.aconfig
index 4d3195d..5b94f07 100644
--- a/services/surfaceflinger/surfaceflinger_flags_new.aconfig
+++ b/services/surfaceflinger/surfaceflinger_flags_new.aconfig
@@ -22,6 +22,17 @@
} # ce_fence_promise
flag {
+ name: "commit_not_composited"
+ namespace: "core_graphics"
+ description: "mark frames as non janky if the transaction resulted in no composition"
+ bug: "340633280"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+ } # commit_not_composited
+
+ flag {
name: "deprecate_vsync_sf"
namespace: "core_graphics"
description: "Depracate eVsyncSourceSurfaceFlinger and use vsync_app everywhere"
@@ -65,4 +76,23 @@
}
} # latch_unsignaled_with_auto_refresh_changed
+flag {
+ name: "local_tonemap_screenshots"
+ namespace: "core_graphics"
+ description: "Enables local tonemapping when capturing screenshots"
+ bug: "329464641"
+ is_fixed_read_only: true
+} # local_tonemap_screenshots
+
+flag {
+ name: "vrr_bugfix_24q4"
+ namespace: "core_graphics"
+ description: "bug fixes for VRR"
+ bug: "331513837"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+} # vrr_bugfix_24q4
+
# IMPORTANT - please keep alphabetize to reduce merge conflicts
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index 0ea0824..d97d433 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -19,6 +19,7 @@
#pragma clang diagnostic ignored "-Wconversion"
#include <android-base/properties.h>
+#include <common/FlagManager.h>
#include <private/android_filesystem_config.h>
#include "LayerTransactionTest.h"
#include "utils/TransactionUtils.h"
@@ -78,6 +79,10 @@
.show(mirrorLayer)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
+
{
SCOPED_TRACE("Initial Mirror");
auto shot = screenshot();
@@ -172,6 +177,9 @@
.show(mirrorLayer)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
{
SCOPED_TRACE("Initial Mirror BufferQueueLayer");
auto shot = screenshot();
@@ -263,6 +271,9 @@
.setLayer(mirrorLayer, INT32_MAX - 1)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
{
SCOPED_TRACE("Offscreen Mirror");
auto shot = screenshot();
@@ -313,8 +324,15 @@
ASSERT_NE(mirrorLayer, nullptr);
}
+ sp<SurfaceControl> mirrorParent =
+ createLayer("Grandchild layer", 50, 50, ISurfaceComposerClient::eFXSurfaceBufferState);
+
// Show the mirror layer, but don't reparent to a layer on screen.
- Transaction().show(mirrorLayer).apply();
+ Transaction().reparent(mirrorLayer, mirrorParent).show(mirrorLayer).apply();
+
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 50, 50).apply();
+ }
{
SCOPED_TRACE("Offscreen Mirror");
@@ -331,7 +349,7 @@
SCOPED_TRACE("Capture Mirror");
// Capture just the mirror layer and child.
LayerCaptureArgs captureArgs;
- captureArgs.layerHandle = mirrorLayer->getHandle();
+ captureArgs.layerHandle = mirrorParent->getHandle();
captureArgs.sourceCrop = childBounds;
std::unique_ptr<ScreenCapture> shot;
ScreenCapture::captureLayers(&shot, captureArgs);
diff --git a/services/surfaceflinger/tests/unittests/Android.bp b/services/surfaceflinger/tests/unittests/Android.bp
index 0c13db3..5145e11 100644
--- a/services/surfaceflinger/tests/unittests/Android.bp
+++ b/services/surfaceflinger/tests/unittests/Android.bp
@@ -66,6 +66,7 @@
"BackgroundExecutorTest.cpp",
"CommitTest.cpp",
"CompositionTest.cpp",
+ "DaltonizerTest.cpp",
"DisplayIdGeneratorTest.cpp",
"DisplayTransactionTest.cpp",
"DisplayDevice_GetBestColorModeTest.cpp",
diff --git a/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp b/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp
new file mode 100644
index 0000000..9f632a1
--- /dev/null
+++ b/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2018 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.
+ */
+
+#include <gtest/gtest.h>
+#include <math/mat4.h>
+#include <cmath>
+#include "Effects/Daltonizer.h"
+
+namespace android {
+
+class DaltonizerTest {
+private:
+ Daltonizer& mDaltonizer;
+
+public:
+ DaltonizerTest(Daltonizer& daltonizer) : mDaltonizer(daltonizer) {}
+
+ bool isDirty() const { return mDaltonizer.mDirty; }
+
+ float getLevel() const { return mDaltonizer.mLevel; }
+
+ ColorBlindnessType getType() const { return mDaltonizer.mType; }
+};
+
+constexpr float TOLERANCE = 0.01f;
+
+static bool isIdentityMatrix(mat4& matrix) {
+ for (size_t i = 0; i < 4; ++i) {
+ for (size_t j = 0; j < 4; ++j) {
+ if (i == j) {
+ // Check diagonal elements
+ if (std::fabs(matrix[i][j] - 1.0f) > TOLERANCE) {
+ return false;
+ }
+ } else {
+ // Check off-diagonal elements
+ if (std::fabs(matrix[i][j]) > TOLERANCE) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+// Test Suite Name : DaltonizerTest, Test name: ConstructionDefaultValues
+TEST(DaltonizerTest, ConstructionDefaultValues) {
+ Daltonizer daltonizer;
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_TRUE(test.isDirty());
+ EXPECT_EQ(test.getType(), ColorBlindnessType::None);
+ mat4 matrix = daltonizer();
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, NotDirtyAfterColorMatrixReturned) {
+ Daltonizer daltonizer;
+
+ mat4 matrix = daltonizer();
+ DaltonizerTest test(daltonizer);
+
+ ASSERT_FALSE(test.isDirty());
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, LevelOutOfRangeTooLowIgnored) {
+ Daltonizer daltonizer;
+ // Get matrix to reset isDirty == false.
+ mat4 matrix = daltonizer();
+
+ daltonizer.setLevel(-1);
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_FALSE(test.isDirty());
+}
+
+TEST(DaltonizerTest, LevelOutOfRangeTooHighIgnored) {
+ Daltonizer daltonizer;
+ // Get matrix to reset isDirty == false.
+ mat4 matrix = daltonizer();
+
+ daltonizer.setLevel(11);
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_FALSE(test.isDirty());
+}
+
+TEST(DaltonizerTest, ColorCorrectionMatrixNonIdentical) {
+ Daltonizer daltonizer;
+ daltonizer.setType(ColorBlindnessType::Protanomaly);
+ daltonizer.setMode(ColorBlindnessMode::Correction);
+
+ mat4 matrix = daltonizer();
+
+ ASSERT_FALSE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, LevelZeroColorMatrixEqIdentityMatrix) {
+ Daltonizer daltonizer;
+ daltonizer.setType(ColorBlindnessType::Protanomaly);
+ daltonizer.setMode(ColorBlindnessMode::Correction);
+ daltonizer.setLevel(0);
+
+ mat4 matrix = daltonizer();
+
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+} /* namespace android */
diff --git a/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp b/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
index ddc3967..9fd687c 100644
--- a/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
+++ b/services/surfaceflinger/tests/unittests/FrameTimelineTest.cpp
@@ -341,6 +341,57 @@
EXPECT_NE(surfaceFrame2->getJankSeverityType(), std::nullopt);
}
+TEST_F(FrameTimelineTest, displayFrameSkippedComposition) {
+ // Layer specific increment
+ EXPECT_CALL(*mTimeStats, incrementJankyFrames(_)).Times(1);
+ auto presentFence1 = fenceFactory.createFenceTimeForTest(Fence::NO_FENCE);
+ int64_t surfaceFrameToken1 = mTokenManager->generateTokenForPredictions({10, 20, 30});
+ int64_t sfToken1 = mTokenManager->generateTokenForPredictions({22, 26, 30});
+ FrameTimelineInfo ftInfo;
+ ftInfo.vsyncId = surfaceFrameToken1;
+ ftInfo.inputEventId = sInputEventId;
+ auto surfaceFrame1 =
+ mFrameTimeline->createSurfaceFrameForToken(ftInfo, sPidOne, sUidOne, sLayerIdOne,
+ sLayerNameOne, sLayerNameOne,
+ /*isBuffer*/ true, sGameMode);
+ auto surfaceFrame2 =
+ mFrameTimeline->createSurfaceFrameForToken(ftInfo, sPidOne, sUidOne, sLayerIdTwo,
+ sLayerNameTwo, sLayerNameTwo,
+ /*isBuffer*/ true, sGameMode);
+
+ mFrameTimeline->setSfWakeUp(sfToken1, 22, RR_11, RR_11);
+ surfaceFrame1->setPresentState(SurfaceFrame::PresentState::Presented);
+ mFrameTimeline->addSurfaceFrame(surfaceFrame1);
+ mFrameTimeline->onCommitNotComposited();
+
+ EXPECT_EQ(surfaceFrame1->getActuals().presentTime, 30);
+ ASSERT_NE(surfaceFrame1->getJankType(), std::nullopt);
+ EXPECT_EQ(*surfaceFrame1->getJankType(), JankType::None);
+ ASSERT_NE(surfaceFrame1->getJankSeverityType(), std::nullopt);
+ EXPECT_EQ(*surfaceFrame1->getJankSeverityType(), JankSeverityType::None);
+
+ mFrameTimeline->setSfWakeUp(sfToken1, 22, RR_11, RR_11);
+ surfaceFrame2->setPresentState(SurfaceFrame::PresentState::Presented);
+ mFrameTimeline->addSurfaceFrame(surfaceFrame2);
+ mFrameTimeline->setSfPresent(26, presentFence1);
+
+ auto displayFrame = getDisplayFrame(0);
+ auto& presentedSurfaceFrame2 = getSurfaceFrame(0, 0);
+ presentFence1->signalForTest(42);
+
+ // Fences haven't been flushed yet, so it should be 0
+ EXPECT_EQ(displayFrame->getActuals().presentTime, 0);
+ EXPECT_EQ(presentedSurfaceFrame2.getActuals().presentTime, 0);
+
+ addEmptyDisplayFrame();
+
+ // Fences have flushed, so the present timestamps should be updated
+ EXPECT_EQ(displayFrame->getActuals().presentTime, 42);
+ EXPECT_EQ(presentedSurfaceFrame2.getActuals().presentTime, 42);
+ EXPECT_NE(surfaceFrame2->getJankType(), std::nullopt);
+ EXPECT_NE(surfaceFrame2->getJankSeverityType(), std::nullopt);
+}
+
TEST_F(FrameTimelineTest, displayFramesSlidingWindowMovesAfterLimit) {
// Insert kMaxDisplayFrames' count of DisplayFrames to fill the deque
int frameTimeFactor = 0;
diff --git a/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp b/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp
index 867ff55..cfc8e99 100644
--- a/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp
@@ -461,8 +461,8 @@
HAL_PIXEL_FORMAT_RGBA_8888,
GRALLOC_USAGE_PROTECTED /*usage*/));
EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(),
- ftl::Flags<RequestedLayerState::Changes>(RequestedLayerState::Changes::Buffer |
- RequestedLayerState::Changes::Content)
+ ftl::Flags<RequestedLayerState::Changes>(
+ RequestedLayerState::Changes::Buffer | RequestedLayerState::Changes::Content)
.get());
mLifecycleManager.commitChanges();
@@ -493,10 +493,10 @@
HAL_PIXEL_FORMAT_RGB_888,
GRALLOC_USAGE_PROTECTED /*usage*/));
EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(),
- ftl::Flags<RequestedLayerState::Changes>(RequestedLayerState::Changes::Buffer |
- RequestedLayerState::Changes::Content |
- RequestedLayerState::Changes::VisibleRegion |
- RequestedLayerState::Changes::Visibility)
+ ftl::Flags<RequestedLayerState::Changes>(
+ RequestedLayerState::Changes::Buffer | RequestedLayerState::Changes::Content |
+ RequestedLayerState::Changes::VisibleRegion |
+ RequestedLayerState::Changes::Visibility)
.get());
mLifecycleManager.commitChanges();
}
@@ -580,8 +580,8 @@
HAL_PIXEL_FORMAT_RGBA_8888,
GRALLOC_USAGE_SW_READ_NEVER /*usage*/));
EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(),
- ftl::Flags<RequestedLayerState::Changes>(RequestedLayerState::Changes::Buffer |
- RequestedLayerState::Changes::Content)
+ ftl::Flags<RequestedLayerState::Changes>(
+ RequestedLayerState::Changes::Buffer | RequestedLayerState::Changes::Content)
.get());
mLifecycleManager.commitChanges();
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 82adadc..23b6851 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -254,7 +254,8 @@
TEST_F(LayerSnapshotTest, FastPathClearsPreviousChangeStates) {
setColor(11, {1._hf, 0._hf, 0._hf});
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
- EXPECT_EQ(getSnapshot(11)->changes, RequestedLayerState::Changes::Content);
+ EXPECT_EQ(getSnapshot(11)->changes,
+ RequestedLayerState::Changes::Content);
EXPECT_EQ(getSnapshot(11)->clientChanges, layer_state_t::eColorChanged);
EXPECT_EQ(getSnapshot(1)->changes.get(), 0u);
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
@@ -264,7 +265,8 @@
TEST_F(LayerSnapshotTest, FastPathSetsChangeFlagToContent) {
setColor(1, {1._hf, 0._hf, 0._hf});
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
- EXPECT_EQ(getSnapshot(1)->changes, RequestedLayerState::Changes::Content);
+ EXPECT_EQ(getSnapshot(1)->changes,
+ RequestedLayerState::Changes::Content);
EXPECT_EQ(getSnapshot(1)->clientChanges, layer_state_t::eColorChanged);
}
@@ -278,13 +280,106 @@
transactions.back().states.front().layerId = 1;
transactions.back().states.front().state.layerId = static_cast<int32_t>(1);
mLifecycleManager.applyTransactions(transactions);
- EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::GameMode);
+ EXPECT_EQ(mLifecycleManager.getGlobalChanges(),
+ RequestedLayerState::Changes::GameMode | RequestedLayerState::Changes::Metadata);
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
EXPECT_EQ(getSnapshot(1)->clientChanges, layer_state_t::eMetadataChanged);
EXPECT_EQ(static_cast<int32_t>(getSnapshot(1)->gameMode), 42);
EXPECT_EQ(static_cast<int32_t>(getSnapshot(11)->gameMode), 42);
}
+TEST_F(LayerSnapshotTest, UpdateMetadata) {
+ std::vector<TransactionState> transactions;
+ transactions.emplace_back();
+ transactions.back().states.push_back({});
+ transactions.back().states.front().state.what = layer_state_t::eMetadataChanged;
+ // This test focuses on metadata used by ARC++ to ensure LayerMetadata is updated correctly,
+ // and not using stale data.
+ transactions.back().states.front().state.metadata = LayerMetadata();
+ transactions.back().states.front().state.metadata.setInt32(METADATA_OWNER_UID, 123);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_WINDOW_TYPE, 234);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_TASK_ID, 345);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_MOUSE_CURSOR, 456);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_ACCESSIBILITY_ID, 567);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_OWNER_PID, 678);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_CALLING_UID, 789);
+
+ transactions.back().states.front().layerId = 1;
+ transactions.back().states.front().state.layerId = static_cast<int32_t>(1);
+
+ mLifecycleManager.applyTransactions(transactions);
+ EXPECT_EQ(mLifecycleManager.getGlobalChanges(), RequestedLayerState::Changes::Metadata);
+
+ // Setting includeMetadata=true to ensure metadata update is applied to LayerSnapshot
+ LayerSnapshotBuilder::Args args{.root = mHierarchyBuilder.getHierarchy(),
+ .layerLifecycleManager = mLifecycleManager,
+ .includeMetadata = true,
+ .displays = mFrontEndDisplayInfos,
+ .globalShadowSettings = globalShadowSettings,
+ .supportsBlur = true,
+ .supportedLayerGenericMetadata = {},
+ .genericLayerMetadataKeyMap = {}};
+ update(mSnapshotBuilder, args);
+
+ EXPECT_EQ(getSnapshot(1)->clientChanges, layer_state_t::eMetadataChanged);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_OWNER_UID, -1), 123);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_WINDOW_TYPE, -1), 234);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_TASK_ID, -1), 345);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_MOUSE_CURSOR, -1), 456);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_ACCESSIBILITY_ID, -1), 567);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_OWNER_PID, -1), 678);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_CALLING_UID, -1), 789);
+}
+
+TEST_F(LayerSnapshotTest, UpdateMetadataOfHiddenLayers) {
+ hideLayer(1);
+
+ std::vector<TransactionState> transactions;
+ transactions.emplace_back();
+ transactions.back().states.push_back({});
+ transactions.back().states.front().state.what = layer_state_t::eMetadataChanged;
+ // This test focuses on metadata used by ARC++ to ensure LayerMetadata is updated correctly,
+ // and not using stale data.
+ transactions.back().states.front().state.metadata = LayerMetadata();
+ transactions.back().states.front().state.metadata.setInt32(METADATA_OWNER_UID, 123);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_WINDOW_TYPE, 234);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_TASK_ID, 345);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_MOUSE_CURSOR, 456);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_ACCESSIBILITY_ID, 567);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_OWNER_PID, 678);
+ transactions.back().states.front().state.metadata.setInt32(METADATA_CALLING_UID, 789);
+
+ transactions.back().states.front().layerId = 1;
+ transactions.back().states.front().state.layerId = static_cast<int32_t>(1);
+
+ mLifecycleManager.applyTransactions(transactions);
+ EXPECT_EQ(mLifecycleManager.getGlobalChanges(),
+ RequestedLayerState::Changes::Metadata | RequestedLayerState::Changes::Visibility |
+ RequestedLayerState::Changes::VisibleRegion |
+ RequestedLayerState::Changes::AffectsChildren);
+
+ // Setting includeMetadata=true to ensure metadata update is applied to LayerSnapshot
+ LayerSnapshotBuilder::Args args{.root = mHierarchyBuilder.getHierarchy(),
+ .layerLifecycleManager = mLifecycleManager,
+ .includeMetadata = true,
+ .displays = mFrontEndDisplayInfos,
+ .globalShadowSettings = globalShadowSettings,
+ .supportsBlur = true,
+ .supportedLayerGenericMetadata = {},
+ .genericLayerMetadataKeyMap = {}};
+ update(mSnapshotBuilder, args);
+
+ EXPECT_EQ(static_cast<int64_t>(getSnapshot(1)->clientChanges),
+ layer_state_t::eMetadataChanged | layer_state_t::eFlagsChanged);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_OWNER_UID, -1), 123);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_WINDOW_TYPE, -1), 234);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_TASK_ID, -1), 345);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_MOUSE_CURSOR, -1), 456);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_ACCESSIBILITY_ID, -1), 567);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_OWNER_PID, -1), 678);
+ EXPECT_EQ(getSnapshot(1)->layerMetadata.getInt32(METADATA_CALLING_UID, -1), 789);
+}
+
TEST_F(LayerSnapshotTest, NoLayerVoteForParentWithChildVotes) {
// ROOT
// ├── 1
@@ -1281,6 +1376,17 @@
EXPECT_TRUE(foundInputLayer);
}
+TEST_F(LayerSnapshotTest, ForEachSnapshotsWithPredicate) {
+ std::vector<uint32_t> visitedUniqueSequences;
+ mSnapshotBuilder.forEachSnapshot(
+ [&](const std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
+ visitedUniqueSequences.push_back(snapshot->uniqueSequence);
+ },
+ [](const frontend::LayerSnapshot& snapshot) { return snapshot.uniqueSequence == 111; });
+ EXPECT_EQ(visitedUniqueSequences.size(), 1u);
+ EXPECT_EQ(visitedUniqueSequences[0], 111u);
+}
+
TEST_F(LayerSnapshotTest, canOccludePresentation) {
setFlags(12, layer_state_t::eCanOccludePresentation, layer_state_t::eCanOccludePresentation);
LayerSnapshotBuilder::Args args{.root = mHierarchyBuilder.getHierarchy(),
diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
index 7479a4f..4fb0690 100644
--- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
@@ -350,6 +350,9 @@
std::make_shared<RefreshRateSelector>(kDisplay2Modes,
kDisplay2Mode60->getId()));
+ mScheduler->setDisplayPowerMode(kDisplayId1, hal::PowerMode::ON);
+ mScheduler->setDisplayPowerMode(kDisplayId2, hal::PowerMode::ON);
+
using DisplayModeChoice = TestableScheduler::DisplayModeChoice;
TestableScheduler::DisplayModeChoiceMap expectedChoices;
@@ -412,6 +415,7 @@
->registerDisplay(kDisplayId3,
std::make_shared<RefreshRateSelector>(kDisplay3Modes,
kDisplay3Mode60->getId()));
+ mScheduler->setDisplayPowerMode(kDisplayId3, hal::PowerMode::ON);
const GlobalSignals globalSignals = {.touch = true};
mScheduler->replaceTouchTimer(10);
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp
index 15a6db6..078b4fe 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp
@@ -327,7 +327,9 @@
return false;
}
- if (!flinger->scheduler()->vsyncModulator().isVsyncConfigEarly()) {
+ // VsyncModulator should react to mode switches on the pacesetter display.
+ if (arg->getPhysicalId() == flinger->scheduler()->pacesetterDisplayId() &&
+ !flinger->scheduler()->vsyncModulator().isVsyncConfigEarly()) {
*result_listener << "VsyncModulator did not shift to early phase";
return false;
}
@@ -368,8 +370,8 @@
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
- // Only the inner display is powered on.
- mFlinger.onActiveDisplayChanged(nullptr, *innerDisplay);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::OFF);
+ mFlinger.setPowerModeInternal(innerDisplay, hal::PowerMode::ON);
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
@@ -385,41 +387,45 @@
0.f, 120.f)));
EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
- EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
+ EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
const VsyncPeriodChangeTimeline timeline{.refreshRequired = true};
EXPECT_SET_ACTIVE_CONFIG(kInnerDisplayHwcId, kModeId90);
-
- mFlinger.commit();
-
- EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
- EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
-
- mFlinger.commit();
-
- EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
- EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
-
- innerDisplay->setPowerMode(hal::PowerMode::OFF);
- outerDisplay->setPowerMode(hal::PowerMode::ON);
-
- // Only the outer display is powered on.
- mFlinger.onActiveDisplayChanged(innerDisplay.get(), *outerDisplay);
-
- EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
- EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
-
EXPECT_SET_ACTIVE_CONFIG(kOuterDisplayHwcId, kModeId60);
mFlinger.commit();
- EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
+ EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
mFlinger.commit();
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId60));
+
+ mFlinger.setPowerModeInternal(innerDisplay, hal::PowerMode::OFF);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::ON);
+
+ EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
+ EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId60));
+
+ EXPECT_EQ(NO_ERROR,
+ mFlinger.setDesiredDisplayModeSpecs(innerDisplay->getDisplayToken().promote(),
+ mock::createDisplayModeSpecs(kModeId60, false,
+ 0.f, 120.f)));
+
+ EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
+ EXPECT_SET_ACTIVE_CONFIG(kInnerDisplayHwcId, kModeId60);
+
+ mFlinger.commit();
+
+ EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
+ EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId60));
+
+ mFlinger.commit();
+
+ EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
+ EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId60));
}
TEST_F(DisplayModeSwitchingTest, innerAndOuterDisplay) {
@@ -437,10 +443,8 @@
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
- outerDisplay->setPowerMode(hal::PowerMode::ON);
-
- // Both displays are powered on.
- mFlinger.onActiveDisplayChanged(nullptr, *innerDisplay);
+ mFlinger.setPowerModeInternal(innerDisplay, hal::PowerMode::ON);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::ON);
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
@@ -485,7 +489,7 @@
EXPECT_THAT(mDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
// Power off the display before the mode has been set.
- mDisplay->setPowerMode(hal::PowerMode::OFF);
+ mFlinger.setPowerModeInternal(mDisplay, hal::PowerMode::OFF);
const VsyncPeriodChangeTimeline timeline{.refreshRequired = true};
EXPECT_SET_ACTIVE_CONFIG(kInnerDisplayHwcId, kModeId90);
@@ -517,10 +521,8 @@
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
- outerDisplay->setPowerMode(hal::PowerMode::ON);
-
- // Both displays are powered on.
- mFlinger.onActiveDisplayChanged(nullptr, *innerDisplay);
+ mFlinger.setPowerModeInternal(innerDisplay, hal::PowerMode::ON);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::ON);
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId60));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
@@ -539,40 +541,42 @@
EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
// Power off the outer display before the mode has been set.
- outerDisplay->setPowerMode(hal::PowerMode::OFF);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::OFF);
const VsyncPeriodChangeTimeline timeline{.refreshRequired = true};
EXPECT_SET_ACTIVE_CONFIG(kInnerDisplayHwcId, kModeId90);
-
- mFlinger.commit();
-
- // Powering off the inactive display should abort the mode set.
- EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
- EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
-
- mFlinger.commit();
-
- EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
- EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
-
- innerDisplay->setPowerMode(hal::PowerMode::OFF);
- outerDisplay->setPowerMode(hal::PowerMode::ON);
-
- // Only the outer display is powered on.
- mFlinger.onActiveDisplayChanged(innerDisplay.get(), *outerDisplay);
-
EXPECT_SET_ACTIVE_CONFIG(kOuterDisplayHwcId, kModeId60);
mFlinger.commit();
- // The mode set should resume once the display becomes active.
- EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
+ // Powering off the inactive display should not abort the mode set.
+ EXPECT_THAT(innerDisplay, ModeSwitchingTo(&mFlinger, kModeId90));
EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId60));
mFlinger.commit();
EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId60));
+
+ mFlinger.setPowerModeInternal(innerDisplay, hal::PowerMode::OFF);
+ mFlinger.setPowerModeInternal(outerDisplay, hal::PowerMode::ON);
+
+ EXPECT_EQ(NO_ERROR,
+ mFlinger.setDesiredDisplayModeSpecs(outerDisplay->getDisplayToken().promote(),
+ mock::createDisplayModeSpecs(kModeId120, false,
+ 0.f, 120.f)));
+
+ EXPECT_SET_ACTIVE_CONFIG(kOuterDisplayHwcId, kModeId120);
+
+ mFlinger.commit();
+
+ EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
+ EXPECT_THAT(outerDisplay, ModeSwitchingTo(&mFlinger, kModeId120));
+
+ mFlinger.commit();
+
+ EXPECT_THAT(innerDisplay, ModeSettledTo(kModeId90));
+ EXPECT_THAT(outerDisplay, ModeSettledTo(kModeId120));
}
} // namespace
diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index 1e02c67..198a5de 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -111,6 +111,11 @@
Scheduler::unregisterDisplay(displayId);
}
+ void setDisplayPowerMode(PhysicalDisplayId displayId, hal::PowerMode powerMode) {
+ ftl::FakeGuard guard(kMainThreadContext);
+ Scheduler::setDisplayPowerMode(displayId, powerMode);
+ }
+
std::optional<PhysicalDisplayId> pacesetterDisplayId() const NO_THREAD_SAFETY_ANALYSIS {
return mPacesetterDisplayId;
}
diff --git a/services/surfaceflinger/tests/unittests/mock/MockSchedulerCallback.h b/services/surfaceflinger/tests/unittests/mock/MockSchedulerCallback.h
index 4ca0542..dec5fa5 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockSchedulerCallback.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockSchedulerCallback.h
@@ -30,6 +30,7 @@
MOCK_METHOD(void, onChoreographerAttached, (), (override));
MOCK_METHOD(void, onExpectedPresentTimePosted, (TimePoint, ftl::NonNull<DisplayModePtr>, Fps),
(override));
+ MOCK_METHOD(void, onCommitNotComposited, (PhysicalDisplayId), (override));
};
struct NoOpSchedulerCallback final : ISchedulerCallback {
@@ -39,6 +40,7 @@
void triggerOnFrameRateOverridesChanged() override {}
void onChoreographerAttached() override {}
void onExpectedPresentTimePosted(TimePoint, ftl::NonNull<DisplayModePtr>, Fps) override {}
+ void onCommitNotComposited(PhysicalDisplayId) override {}
};
} // namespace android::scheduler::mock