Loading libs/gui/LayerState.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ #define LOG_TAG "LayerState" #include <apex/window.h> #include <inttypes.h> #include <cinttypes> #include <cmath> #include <android/native_window.h> #include <binder/Parcel.h> Loading @@ -25,10 +25,9 @@ #include <gui/ISurfaceComposerClient.h> #include <gui/LayerState.h> #include <private/gui/ParcelUtils.h> #include <system/window.h> #include <utils/Errors.h> #include <cmath> namespace android { using gui::FocusRequest; Loading Loading @@ -679,7 +678,9 @@ bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrame if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT && compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE && (!privileged || compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT)) { (!privileged || (compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT && compatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE))) { ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName, compatibility, privileged ? "yes" : "no"); return false; Loading libs/nativewindow/include/apex/window.h +0 −13 Original line number Diff line number Diff line Loading @@ -39,19 +39,6 @@ enum ANativeWindowPerform { // clang-format on }; /* * Internal extension of compatibility value for ANativeWindow_setFrameRate. */ enum ANativeWindow_FrameRateCompatibilityInternal { /** * This surface belongs to an app on the High Refresh Rate Deny list, and needs the display * to operate at the exact frame rate. * * This is used internally by the platform and should not be used by apps. * @hide */ ANATIVEWINDOW_FRAME_RATE_EXACT = 100, }; /** * Prototype of the function that an ANativeWindow implementation would call * when ANativeWindow_cancelBuffer is called. Loading libs/nativewindow/include/system/window.h +18 −0 Original line number Diff line number Diff line Loading @@ -1018,6 +1018,24 @@ static inline int native_window_set_auto_prerotation(struct ANativeWindow* windo return window->perform(window, NATIVE_WINDOW_SET_AUTO_PREROTATION, autoPrerotation); } /* * Internal extension of ANativeWindow_FrameRateCompatibility. */ enum { /** * This surface belongs to an app on the High Refresh Rate Deny list, and needs the display * to operate at the exact frame rate. * * Keep in sync with Surface.java constant. */ ANATIVEWINDOW_FRAME_RATE_EXACT = 100, /** * This surface is ignored while choosing the refresh rate. */ ANATIVEWINDOW_FRAME_RATE_NO_VOTE, }; static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) { return window->perform(window, NATIVE_WINDOW_SET_FRAME_RATE, (double)frameRate, Loading services/inputflinger/dispatcher/InputDispatcher.cpp +39 −13 Original line number Diff line number Diff line Loading @@ -5146,28 +5146,54 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp< return true; } /** * Get the touched foreground window on the given display. * Return null if there are no windows touched on that display, or if more than one foreground * window is being touched. */ sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(int32_t displayId) const { auto stateIt = mTouchStatesByDisplay.find(displayId); if (stateIt == mTouchStatesByDisplay.end()) { ALOGI("No touch state on display %" PRId32, displayId); return nullptr; } const TouchState& state = stateIt->second; sp<WindowInfoHandle> touchedForegroundWindow; // If multiple foreground windows are touched, return nullptr for (const TouchedWindow& window : state.windows) { if (window.targetFlags & InputTarget::FLAG_FOREGROUND) { if (touchedForegroundWindow != nullptr) { ALOGI("Two or more foreground windows: %s and %s", touchedForegroundWindow->getName().c_str(), window.windowHandle->getName().c_str()); return nullptr; } touchedForegroundWindow = window.windowHandle; } } return touchedForegroundWindow; } // Binder call bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken) { bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) { sp<IBinder> fromToken; { // acquire lock std::scoped_lock _l(mLock); auto it = std::find_if(mTouchStatesByDisplay.begin(), mTouchStatesByDisplay.end(), [](const auto& pair) { return pair.second.windows.size() == 1; }); if (it == mTouchStatesByDisplay.end()) { ALOGW("Cannot transfer touch state because there is no exact window being touched"); return false; } const int32_t displayId = it->first; sp<WindowInfoHandle> toWindowHandle = getWindowHandleLocked(destChannelToken, displayId); if (toWindowHandle == nullptr) { ALOGW("Could not find window associated with token=%p", destChannelToken.get()); ALOGW("Could not find window associated with token=%p on display %" PRId32, destChannelToken.get(), displayId); return false; } sp<WindowInfoHandle> from = findTouchedForegroundWindowLocked(displayId); if (from == nullptr) { ALOGE("Could not find a source window in %s for %p", __func__, destChannelToken.get()); return false; } TouchState& state = it->second; const TouchedWindow& touchedWindow = state.windows[0]; fromToken = touchedWindow.windowHandle->getToken(); fromToken = from->getToken(); } // release lock return transferTouchFocus(fromToken, destChannelToken); Loading services/inputflinger/dispatcher/InputDispatcher.h +4 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public: bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop = false) override; bool transferTouch(const sp<IBinder>& destChannelToken) override; bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) override; base::Result<std::unique_ptr<InputChannel>> createInputChannel( const std::string& name) override; Loading Loading @@ -245,6 +245,9 @@ private: std::vector<sp<android::gui::WindowInfoHandle>> findTouchedSpyWindowsAtLocked( int32_t displayId, int32_t x, int32_t y, bool isStylus) const REQUIRES(mLock); sp<android::gui::WindowInfoHandle> findTouchedForegroundWindowLocked(int32_t displayId) const REQUIRES(mLock); sp<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const REQUIRES(mLock); Loading Loading
libs/gui/LayerState.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ #define LOG_TAG "LayerState" #include <apex/window.h> #include <inttypes.h> #include <cinttypes> #include <cmath> #include <android/native_window.h> #include <binder/Parcel.h> Loading @@ -25,10 +25,9 @@ #include <gui/ISurfaceComposerClient.h> #include <gui/LayerState.h> #include <private/gui/ParcelUtils.h> #include <system/window.h> #include <utils/Errors.h> #include <cmath> namespace android { using gui::FocusRequest; Loading Loading @@ -679,7 +678,9 @@ bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrame if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT && compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE && (!privileged || compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT)) { (!privileged || (compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT && compatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE))) { ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName, compatibility, privileged ? "yes" : "no"); return false; Loading
libs/nativewindow/include/apex/window.h +0 −13 Original line number Diff line number Diff line Loading @@ -39,19 +39,6 @@ enum ANativeWindowPerform { // clang-format on }; /* * Internal extension of compatibility value for ANativeWindow_setFrameRate. */ enum ANativeWindow_FrameRateCompatibilityInternal { /** * This surface belongs to an app on the High Refresh Rate Deny list, and needs the display * to operate at the exact frame rate. * * This is used internally by the platform and should not be used by apps. * @hide */ ANATIVEWINDOW_FRAME_RATE_EXACT = 100, }; /** * Prototype of the function that an ANativeWindow implementation would call * when ANativeWindow_cancelBuffer is called. Loading
libs/nativewindow/include/system/window.h +18 −0 Original line number Diff line number Diff line Loading @@ -1018,6 +1018,24 @@ static inline int native_window_set_auto_prerotation(struct ANativeWindow* windo return window->perform(window, NATIVE_WINDOW_SET_AUTO_PREROTATION, autoPrerotation); } /* * Internal extension of ANativeWindow_FrameRateCompatibility. */ enum { /** * This surface belongs to an app on the High Refresh Rate Deny list, and needs the display * to operate at the exact frame rate. * * Keep in sync with Surface.java constant. */ ANATIVEWINDOW_FRAME_RATE_EXACT = 100, /** * This surface is ignored while choosing the refresh rate. */ ANATIVEWINDOW_FRAME_RATE_NO_VOTE, }; static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) { return window->perform(window, NATIVE_WINDOW_SET_FRAME_RATE, (double)frameRate, Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +39 −13 Original line number Diff line number Diff line Loading @@ -5146,28 +5146,54 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp< return true; } /** * Get the touched foreground window on the given display. * Return null if there are no windows touched on that display, or if more than one foreground * window is being touched. */ sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(int32_t displayId) const { auto stateIt = mTouchStatesByDisplay.find(displayId); if (stateIt == mTouchStatesByDisplay.end()) { ALOGI("No touch state on display %" PRId32, displayId); return nullptr; } const TouchState& state = stateIt->second; sp<WindowInfoHandle> touchedForegroundWindow; // If multiple foreground windows are touched, return nullptr for (const TouchedWindow& window : state.windows) { if (window.targetFlags & InputTarget::FLAG_FOREGROUND) { if (touchedForegroundWindow != nullptr) { ALOGI("Two or more foreground windows: %s and %s", touchedForegroundWindow->getName().c_str(), window.windowHandle->getName().c_str()); return nullptr; } touchedForegroundWindow = window.windowHandle; } } return touchedForegroundWindow; } // Binder call bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken) { bool InputDispatcher::transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) { sp<IBinder> fromToken; { // acquire lock std::scoped_lock _l(mLock); auto it = std::find_if(mTouchStatesByDisplay.begin(), mTouchStatesByDisplay.end(), [](const auto& pair) { return pair.second.windows.size() == 1; }); if (it == mTouchStatesByDisplay.end()) { ALOGW("Cannot transfer touch state because there is no exact window being touched"); return false; } const int32_t displayId = it->first; sp<WindowInfoHandle> toWindowHandle = getWindowHandleLocked(destChannelToken, displayId); if (toWindowHandle == nullptr) { ALOGW("Could not find window associated with token=%p", destChannelToken.get()); ALOGW("Could not find window associated with token=%p on display %" PRId32, destChannelToken.get(), displayId); return false; } sp<WindowInfoHandle> from = findTouchedForegroundWindowLocked(displayId); if (from == nullptr) { ALOGE("Could not find a source window in %s for %p", __func__, destChannelToken.get()); return false; } TouchState& state = it->second; const TouchedWindow& touchedWindow = state.windows[0]; fromToken = touchedWindow.windowHandle->getToken(); fromToken = from->getToken(); } // release lock return transferTouchFocus(fromToken, destChannelToken); Loading
services/inputflinger/dispatcher/InputDispatcher.h +4 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public: bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, bool isDragDrop = false) override; bool transferTouch(const sp<IBinder>& destChannelToken) override; bool transferTouch(const sp<IBinder>& destChannelToken, int32_t displayId) override; base::Result<std::unique_ptr<InputChannel>> createInputChannel( const std::string& name) override; Loading Loading @@ -245,6 +245,9 @@ private: std::vector<sp<android::gui::WindowInfoHandle>> findTouchedSpyWindowsAtLocked( int32_t displayId, int32_t x, int32_t y, bool isStylus) const REQUIRES(mLock); sp<android::gui::WindowInfoHandle> findTouchedForegroundWindowLocked(int32_t displayId) const REQUIRES(mLock); sp<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const REQUIRES(mLock); Loading