Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d041938 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11822896 from a9586371 to 24Q3-release

Change-Id: Ief30b5868d287124cdc7694294f20e990577c3f0
parents def933a3 a9586371
Loading
Loading
Loading
Loading
+74 −11
Original line number Diff line number Diff line
@@ -17,8 +17,20 @@
/**
 * @addtogroup Choreographer
 *
 * Choreographer coordinates the timing of frame rendering. This is the C version of the
 * android.view.Choreographer object in Java.
 * Choreographer coordinates the timing of frame rendering. This is the C
 * version of the android.view.Choreographer object in Java. If you do not use
 * Choreographer to pace your render loop, you may render too quickly for the
 * display, increasing latency between frame submission and presentation.
 *
 * Input events are guaranteed to be processed before the frame callback is
 * called, and will not be run concurrently. Input and sensor events should not
 * be handled in the Choregrapher callback.
 *
 * The frame callback is also the appropriate place to run any per-frame state
 * update logic. For example, in a game, the frame callback should be
 * responsible for updating things like physics, AI, game state, and rendering
 * the frame. Input and sensors should be handled separately via callbacks
 * registered with AInputQueue and ASensorManager.
 *
 * As of API level 33, apps can follow proper frame pacing and even choose a future frame to render.
 * The API is used as follows:
@@ -38,6 +50,11 @@
 * 4. SurfaceFlinger attempts to follow the chosen frame timeline, by not applying transactions or
 * latching buffers before the desired presentation time.
 *
 * On older devices, AChoreographer_postFrameCallback64 or
 * AChoreographer_postFrameCallback can be used to lesser effect. They cannot be
 * used to precisely plan your render timeline, but will rate limit to avoid
 * overloading the display pipeline and increasing frame latency.
 *
 * @{
 */

@@ -129,14 +146,46 @@ typedef void (*AChoreographer_refreshRateCallback)(int64_t vsyncPeriodNanos, voi
AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24);

/**
 * Deprecated: Use AChoreographer_postFrameCallback64 instead.
 * Post a callback to be run when the application should begin rendering the
 * next frame. The data pointer provided will be passed to the callback function
 * when it's called.
 *
 * The callback will only be run for the next frame, not all subsequent frames,
 * so to render continuously the callback should itself call
 * AChoreographer_postFrameCallback.
 *
 * \bug The callback receives the frame time in nanoseconds as a long. On 32-bit
 * systems, long is 32-bit, so the frame time will roll over roughly every two
 * seconds. If your minSdkVersion is 29 or higher, switch to
 * AChoreographer_postFrameCallback64, which uses a 64-bit frame time for all
 * platforms. For older OS versions, you must combine the argument with the
 * upper bits of clock_gettime(CLOCK_MONOTONIC, ...) on 32-bit systems.
 *
 * \deprecated Use AChoreographer_postFrameCallback64, which does not have the
 * bug described above.
 */
void AChoreographer_postFrameCallback(AChoreographer* choreographer,
                                      AChoreographer_frameCallback callback, void* data)
        __INTRODUCED_IN(24) __DEPRECATED_IN(29, "Use AChoreographer_postFrameCallback64 instead");

/**
 * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead.
 * Post a callback to be run when the application should begin rendering the
 * next frame following the specified delay. The data pointer provided will be
 * passed to the callback function when it's called.
 *
 * The callback will only be run for the next frame after the delay, not all
 * subsequent frames, so to render continuously the callback should itself call
 * AChoreographer_postFrameCallbackDelayed.
 *
 * \bug The callback receives the frame time in nanoseconds as a long. On 32-bit
 * systems, long is 32-bit, so the frame time will roll over roughly every two
 * seconds. If your minSdkVersion is 29 or higher, switch to
 * AChoreographer_postFrameCallbackDelayed64, which uses a 64-bit frame time for
 * all platforms. For older OS versions, you must combine the argument with the
 * upper bits of clock_gettime(CLOCK_MONOTONIC, ...) on 32-bit systems.
 *
 * \deprecated Use AChoreographer_postFrameCallbackDelayed64, which does not
 * have the bug described above.
 */
void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
                                             AChoreographer_frameCallback callback, void* data,
@@ -144,8 +193,13 @@ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
        __DEPRECATED_IN(29, "Use AChoreographer_postFrameCallbackDelayed64 instead");

/**
 * Post a callback to be run on the next frame.  The data pointer provided will
 * be passed to the callback function when it's called.
 * Post a callback to be run when the application should begin rendering the
 * next frame. The data pointer provided will be passed to the callback function
 * when it's called.
 *
 * The callback will only be run on the next frame, not all subsequent frames,
 * so to render continuously the callback should itself call
 * AChoreographer_postFrameCallback64.
 *
 * Available since API level 29.
 */
@@ -154,9 +208,13 @@ void AChoreographer_postFrameCallback64(AChoreographer* choreographer,
        __INTRODUCED_IN(29);

/**
 * Post a callback to be run on the frame following the specified delay.  The
 * data pointer provided will be passed to the callback function when it's
 * called.
 * Post a callback to be run when the application should begin rendering the
 * next frame following the specified delay. The data pointer provided will be
 * passed to the callback function when it's called.
 *
 * The callback will only be run for the next frame after the delay, not all
 * subsequent frames, so to render continuously the callback should itself call
 * AChoreographer_postFrameCallbackDelayed64.
 *
 * Available since API level 29.
 */
@@ -165,8 +223,13 @@ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
                                               uint32_t delayMillis) __INTRODUCED_IN(29);

/**
 * Posts a callback to be run on the next frame. The data pointer provided will
 * be passed to the callback function when it's called.
 * Posts a callback to be run when the application should begin rendering the
 * next frame. The data pointer provided will be passed to the callback function
 * when it's called.
 *
 * The callback will only be run for the next frame, not all subsequent frames,
 * so to render continuously the callback should itself call
 * AChoreographer_postVsyncCallback.
 *
 * Available since API level 33.
 */
+29 −15
Original line number Diff line number Diff line
@@ -182,23 +182,27 @@ typedef int (*ALooper_callbackFunc)(int fd, int events, void* data);
 * If the timeout is zero, returns immediately without blocking.
 * If the timeout is negative, waits indefinitely until an event appears.
 *
 * Returns ALOOPER_POLL_WAKE if the poll was awoken using wake() before
 * Returns ALOOPER_POLL_WAKE if the poll was awoken using ALooper_wake() before
 * the timeout expired and no callbacks were invoked and no other file
 * descriptors were ready.
 * descriptors were ready. **All return values may also imply
 * ALOOPER_POLL_WAKE.**
 *
 * Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked.
 * Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked. The poll
 * may also have been explicitly woken by ALooper_wake.
 *
 * Returns ALOOPER_POLL_TIMEOUT if there was no data before the given
 * timeout expired.
 * Returns ALOOPER_POLL_TIMEOUT if there was no data before the given timeout
 * expired. The poll may also have been explicitly woken by ALooper_wake.
 *
 * Returns ALOOPER_POLL_ERROR if an error occurred.
 * Returns ALOOPER_POLL_ERROR if the calling thread has no associated Looper or
 * for unrecoverable internal errors. The poll may also have been explicitly
 * woken by ALooper_wake.
 *
 * Returns a value >= 0 containing an identifier (the same identifier
 * `ident` passed to ALooper_addFd()) if its file descriptor has data
 * and it has no callback function (requiring the caller here to
 * handle it).  In this (and only this) case outFd, outEvents and
 * outData will contain the poll events and data associated with the
 * fd, otherwise they will be set to NULL.
 * Returns a value >= 0 containing an identifier (the same identifier `ident`
 * passed to ALooper_addFd()) if its file descriptor has data and it has no
 * callback function (requiring the caller here to handle it).  In this (and
 * only this) case outFd, outEvents and outData will contain the poll events and
 * data associated with the fd, otherwise they will be set to NULL. The poll may
 * also have been explicitly woken by ALooper_wake.
 *
 * This method does not return until it has finished invoking the appropriate callbacks
 * for all file descriptors that were signalled.
@@ -210,11 +214,21 @@ int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa
 * data has been consumed or a file descriptor is available with no callback.
 * This function will never return ALOOPER_POLL_CALLBACK.
 *
 * Removed in API 34 as ALooper_pollAll can swallow ALooper_wake calls.
 * Use ALooper_pollOnce instead.
 * This API cannot be used safely, but a safe alternative exists (see below). As
 * such, new builds will not be able to call this API and must migrate to the
 * safe API. Binary compatibility is preserved to support already-compiled apps.
 *
 * \bug ALooper_pollAll will not wake in response to ALooper_wake calls if it
 * also handles another event at the same time.
 *
 * \deprecated Calls to ALooper_pollAll should be replaced with
 * ALooper_pollOnce. If you call ALooper_pollOnce in a loop, you *must* treat
 * all return values as if they also indicate ALOOPER_POLL_WAKE.
 */
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
    __REMOVED_IN(1, "ALooper_pollAll may ignore wakes. Use ALooper_pollOnce instead. See https://github.com/android/ndk/discussions/2020 for more information");
        __REMOVED_IN(1,
                     "ALooper_pollAll may ignore wakes. Use ALooper_pollOnce instead. See "
                     "The API documentation for more information");

/**
 * Wakes the poll asynchronously.
+4 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ constexpr std::uint64_t shift_mix(std::uint64_t v) {
  return v ^ (v >> 47);
}

__attribute__((no_sanitize("unsigned-integer-overflow")))
constexpr std::uint64_t hash_length_16(std::uint64_t u, std::uint64_t v) {
  constexpr std::uint64_t kPrime = 0x9ddfea08eb382d69ull;
  auto a = (u ^ v) * kPrime;
@@ -58,6 +59,7 @@ constexpr std::uint64_t kPrime1 = 0xb492b66fbe98f273ull;
constexpr std::uint64_t kPrime2 = 0x9ae16a3b2f90404full;
constexpr std::uint64_t kPrime3 = 0xc949d7c7509e6557ull;

__attribute__((no_sanitize("unsigned-integer-overflow")))
inline std::uint64_t hash_length_0_to_16(const char* str, std::uint64_t length) {
  if (length > 8) {
    const auto a = read_unaligned(str);
@@ -80,6 +82,7 @@ inline std::uint64_t hash_length_0_to_16(const char* str, std::uint64_t length)
  return kPrime2;
}

__attribute__((no_sanitize("unsigned-integer-overflow")))
inline std::uint64_t hash_length_17_to_32(const char* str, std::uint64_t length) {
  const auto a = read_unaligned(str) * kPrime1;
  const auto b = read_unaligned(str + 8);
@@ -89,6 +92,7 @@ inline std::uint64_t hash_length_17_to_32(const char* str, std::uint64_t length)
                        a + rotate(b ^ kPrime3, 20) - c + length);
}

__attribute__((no_sanitize("unsigned-integer-overflow")))
inline std::uint64_t hash_length_33_to_64(const char* str, std::uint64_t length) {
  auto z = read_unaligned(str + 24);
  auto a = read_unaligned(str) + (length + read_unaligned(str + length - 16)) * kPrime0;
+34 −28
Original line number Diff line number Diff line
@@ -5363,13 +5363,14 @@ void InputDispatcher::setInputWindowsLocked(
        onFocusChangedLocked(*changes, traceContext.getTracker(), removedFocusedWindowHandle);
    }

    std::unordered_map<int32_t, TouchState>::iterator stateIt =
            mTouchStatesByDisplay.find(displayId);
    if (stateIt != mTouchStatesByDisplay.end()) {
        TouchState& state = stateIt->second;
    if (const auto& it = mTouchStatesByDisplay.find(displayId); it != mTouchStatesByDisplay.end()) {
        TouchState& state = it->second;
        for (size_t i = 0; i < state.windows.size();) {
            TouchedWindow& touchedWindow = state.windows[i];
            if (getWindowHandleLocked(touchedWindow.windowHandle) == nullptr) {
            if (getWindowHandleLocked(touchedWindow.windowHandle) != nullptr) {
                i++;
                continue;
            }
            LOG(INFO) << "Touched window was removed: " << touchedWindow.windowHandle->getName()
                      << " in display %" << displayId;
            CancelationOptions options(CancelationOptions::Mode::CANCEL_POINTER_EVENTS,
@@ -5380,14 +5381,14 @@ void InputDispatcher::setInputWindowsLocked(
            if (touchedWindow.targetFlags.test(InputTarget::Flags::FOREGROUND) &&
                touchedWindow.windowHandle->getInfo()->inputConfig.test(
                        gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)) {
                    if (const auto& ww = state.getWallpaperWindow(); ww) {
                for (const DeviceId deviceId : touchedWindow.getTouchingDeviceIds()) {
                    if (const auto& ww = state.getWallpaperWindow(deviceId); ww != nullptr) {
                        options.deviceId = deviceId;
                        synthesizeCancelationEventsForWindowLocked(ww, options);
                    }
                }
                state.windows.erase(state.windows.begin() + i);
            } else {
                ++i;
            }
            state.windows.erase(state.windows.begin() + i);
        }

        // If drag window is gone, it would receive a cancel event and broadcast the DRAG_END. We
@@ -5662,13 +5663,13 @@ bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const s
            ALOGD("Touch transfer failed because from window is not being touched.");
            return false;
        }
        std::set<int32_t> deviceIds = touchedWindow->getTouchingDeviceIds();
        std::set<DeviceId> deviceIds = touchedWindow->getTouchingDeviceIds();
        if (deviceIds.size() != 1) {
            LOG(INFO) << "Can't transfer touch. Currently touching devices: " << dumpSet(deviceIds)
                      << " for window: " << touchedWindow->dump();
            return false;
        }
        const int32_t deviceId = *deviceIds.begin();
        const DeviceId deviceId = *deviceIds.begin();

        const sp<WindowInfoHandle> fromWindowHandle = touchedWindow->windowHandle;
        const sp<WindowInfoHandle> toWindowHandle = getWindowHandleLocked(toToken, displayId);
@@ -5722,13 +5723,18 @@ bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const s
                                       "transferring touch from this window to another window",
                                       traceContext.getTracker());
            synthesizeCancelationEventsForWindowLocked(fromWindowHandle, options, fromConnection);
            synthesizePointerDownEventsForConnectionLocked(downTimeInTarget, toConnection,
                                                           newTargetFlags,
                                                           traceContext.getTracker());

            // Check if the wallpaper window should deliver the corresponding event.
            transferWallpaperTouch(oldTargetFlags, newTargetFlags, fromWindowHandle, toWindowHandle,
                                   *state, deviceId, pointers, traceContext.getTracker());

            // Because new window may have a wallpaper window, it will merge input state from it
            // parent window, after this the firstNewPointerIdx in input state will be reset, then
            // it will cause new move event be thought inconsistent, so we should synthesize the
            // down event after it reset.
            synthesizePointerDownEventsForConnectionLocked(downTimeInTarget, toConnection,
                                                           newTargetFlags,
                                                           traceContext.getTracker());
        }
    } // release lock

@@ -7039,7 +7045,7 @@ void InputDispatcher::setMonitorDispatchingTimeoutForTest(std::chrono::nanosecon
void InputDispatcher::slipWallpaperTouch(ftl::Flags<InputTarget::Flags> targetFlags,
                                         const sp<WindowInfoHandle>& oldWindowHandle,
                                         const sp<WindowInfoHandle>& newWindowHandle,
                                         TouchState& state, int32_t deviceId,
                                         TouchState& state, DeviceId deviceId,
                                         const PointerProperties& pointerProperties,
                                         std::vector<InputTarget>& targets) const {
    std::vector<PointerProperties> pointers{pointerProperties};
@@ -7049,7 +7055,7 @@ void InputDispatcher::slipWallpaperTouch(ftl::Flags<InputTarget::Flags> targetFl
            newWindowHandle->getInfo()->inputConfig.test(
                    gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER);
    const sp<WindowInfoHandle> oldWallpaper =
            oldHasWallpaper ? state.getWallpaperWindow() : nullptr;
            oldHasWallpaper ? state.getWallpaperWindow(deviceId) : nullptr;
    const sp<WindowInfoHandle> newWallpaper =
            newHasWallpaper ? findWallpaperWindowBelow(newWindowHandle) : nullptr;
    if (oldWallpaper == newWallpaper) {
@@ -7075,7 +7081,7 @@ void InputDispatcher::slipWallpaperTouch(ftl::Flags<InputTarget::Flags> targetFl
void InputDispatcher::transferWallpaperTouch(
        ftl::Flags<InputTarget::Flags> oldTargetFlags,
        ftl::Flags<InputTarget::Flags> newTargetFlags, const sp<WindowInfoHandle> fromWindowHandle,
        const sp<WindowInfoHandle> toWindowHandle, TouchState& state, int32_t deviceId,
        const sp<WindowInfoHandle> toWindowHandle, TouchState& state, DeviceId deviceId,
        const std::vector<PointerProperties>& pointers,
        const std::unique_ptr<trace::EventTrackerInterface>& traceTracker) {
    const bool oldHasWallpaper = oldTargetFlags.test(InputTarget::Flags::FOREGROUND) &&
@@ -7086,7 +7092,7 @@ void InputDispatcher::transferWallpaperTouch(
                    gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER);

    const sp<WindowInfoHandle> oldWallpaper =
            oldHasWallpaper ? state.getWallpaperWindow() : nullptr;
            oldHasWallpaper ? state.getWallpaperWindow(deviceId) : nullptr;
    const sp<WindowInfoHandle> newWallpaper =
            newHasWallpaper ? findWallpaperWindowBelow(toWindowHandle) : nullptr;
    if (oldWallpaper == newWallpaper) {
+2 −2
Original line number Diff line number Diff line
@@ -701,14 +701,14 @@ private:
    void slipWallpaperTouch(ftl::Flags<InputTarget::Flags> targetFlags,
                            const sp<android::gui::WindowInfoHandle>& oldWindowHandle,
                            const sp<android::gui::WindowInfoHandle>& newWindowHandle,
                            TouchState& state, int32_t deviceId,
                            TouchState& state, DeviceId deviceId,
                            const PointerProperties& pointerProperties,
                            std::vector<InputTarget>& targets) const REQUIRES(mLock);
    void transferWallpaperTouch(ftl::Flags<InputTarget::Flags> oldTargetFlags,
                                ftl::Flags<InputTarget::Flags> newTargetFlags,
                                const sp<android::gui::WindowInfoHandle> fromWindowHandle,
                                const sp<android::gui::WindowInfoHandle> toWindowHandle,
                                TouchState& state, int32_t deviceId,
                                TouchState& state, DeviceId deviceId,
                                const std::vector<PointerProperties>& pointers,
                                const std::unique_ptr<trace::EventTrackerInterface>& traceTracker)
            REQUIRES(mLock);
Loading