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

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

Snap for 11432142 from 63cdb2e2 to 24Q3-release

Change-Id: If90137c6689c86dc12b326eccfc5331253945984
parents d8dd5cee 63cdb2e2
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -2089,13 +2089,23 @@ void InputDispatcher::cancelEventsForAnrLocked(const std::shared_ptr<Connection>
    // pile up.
    ALOGW("Canceling events for %s because it is unresponsive",
          connection->getInputChannelName().c_str());
    if (connection->status == Connection::Status::NORMAL) {
    if (connection->status != Connection::Status::NORMAL) {
        return;
    }
    CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS,
                               "application not responding");
        synthesizeCancelationEventsForConnectionLocked(connection, options,
                                                       getWindowHandleLocked(
                                                               connection->getToken()));

    sp<WindowInfoHandle> windowHandle;
    if (!connection->monitor) {
        windowHandle = getWindowHandleLocked(connection->getToken());
        if (windowHandle == nullptr) {
            // The window that is receiving this ANR was removed, so there is no need to generate
            // cancellations, because the cancellations would have already been generated when
            // the window was removed.
            return;
        }
    }
    synthesizeCancelationEventsForConnectionLocked(connection, options, windowHandle);
}

void InputDispatcher::resetNoFocusedWindowTimeoutLocked() {
+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <optional>

#include <com_android_input_flags.h>
#include <ftl/enum.h>
#include <input/AccelerationCurve.h>

#include "CursorButtonAccumulator.h"
@@ -136,7 +137,7 @@ void CursorInputMapper::dump(std::string& dump) {
    dump += StringPrintf(INDENT3 "VWheelScale: %0.3f\n", mVWheelScale);
    dump += StringPrintf(INDENT3 "HWheelScale: %0.3f\n", mHWheelScale);
    dump += StringPrintf(INDENT3 "DisplayId: %s\n", toString(mDisplayId).c_str());
    dump += StringPrintf(INDENT3 "Orientation: %d\n", mOrientation);
    dump += StringPrintf(INDENT3 "Orientation: %s\n", ftl::enum_string(mOrientation).c_str());
    dump += StringPrintf(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
    dump += StringPrintf(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
    dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "KeyboardInputMapper.h"

#include <ftl/enum.h>
#include <ui/Rotation.h>

namespace android {
@@ -143,7 +144,7 @@ void KeyboardInputMapper::dump(std::string& dump) {
    dump += INDENT2 "Keyboard Input Mapper:\n";
    dumpParameters(dump);
    dump += StringPrintf(INDENT3 "KeyboardType: %d\n", mKeyboardType);
    dump += StringPrintf(INDENT3 "Orientation: %d\n", getOrientation());
    dump += StringPrintf(INDENT3 "Orientation: %s\n", ftl::enum_string(getOrientation()).c_str());
    dump += StringPrintf(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
    dump += StringPrintf(INDENT3 "MetaState: 0x%0x\n", mMetaState);
    dump += INDENT3 "KeyboardLayoutInfo: ";
+60 −7
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ static KeyEvent getTestKeyEvent() {
class FakeInputDispatcherPolicy : public InputDispatcherPolicyInterface {
    struct AnrResult {
        sp<IBinder> token{};
        gui::Pid pid{gui::Pid::INVALID};
        std::optional<gui::Pid> pid{};
    };
    /* Stores data about a user-activity-poke event from the dispatcher. */
    struct UserActivityPokeEvent {
@@ -260,7 +260,7 @@ public:
    void assertNotifyWindowUnresponsiveWasCalled(std::chrono::nanoseconds timeout,
                                                 const sp<IBinder>& expectedToken,
                                                 gui::Pid expectedPid) {
                                                 std::optional<gui::Pid> expectedPid) {
        std::unique_lock lock(mLock);
        android::base::ScopedLockAssertion assumeLocked(mLock);
        AnrResult result;
@@ -280,7 +280,7 @@ public:
    }
    void assertNotifyWindowResponsiveWasCalled(const sp<IBinder>& expectedToken,
                                               gui::Pid expectedPid) {
                                               std::optional<gui::Pid> expectedPid) {
        std::unique_lock lock(mLock);
        android::base::ScopedLockAssertion assumeLocked(mLock);
        AnrResult result;
@@ -524,16 +524,14 @@ private:
    void notifyWindowUnresponsive(const sp<IBinder>& connectionToken, std::optional<gui::Pid> pid,
                                  const std::string&) override {
        std::scoped_lock lock(mLock);
        ASSERT_TRUE(pid.has_value());
        mAnrWindows.push({connectionToken, *pid});
        mAnrWindows.push({connectionToken, pid});
        mNotifyAnr.notify_all();
    }
    void notifyWindowResponsive(const sp<IBinder>& connectionToken,
                                std::optional<gui::Pid> pid) override {
        std::scoped_lock lock(mLock);
        ASSERT_TRUE(pid.has_value());
        mResponsiveWindows.push({connectionToken, *pid});
        mResponsiveWindows.push({connectionToken, pid});
        mNotifyAnr.notify_all();
    }
@@ -9059,6 +9057,61 @@ TEST_F(InputDispatcherSingleWindowAnr, TwoGesturesWithAnr) {
    mWindow->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
}
// Send an event to the app and have the app not respond right away. Then remove the app window.
// When the window is removed, the dispatcher will cancel the events for that window.
// 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}));
    const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN
    ASSERT_TRUE(sequenceNum);
    // Remove the window, but the input channel should remain alive.
    mDispatcher->onWindowInfosChanged({{}, {}, 0, 0});
    const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
    // Since the window was removed, Dispatcher does not know the PID associated with the window
    // anymore, so the policy is notified without the PID.
    mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(timeout, mWindow->getToken(),
                                                         /*pid=*/std::nullopt);
    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)));
    mWindow->consumeFocusEvent(false);
    ASSERT_TRUE(mDispatcher->waitForIdle());
    mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), /*pid=*/std::nullopt);
}
// Send an event to the app and have the app not respond right away. Wait for the policy to be
// 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}));
    const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN
    ASSERT_TRUE(sequenceNum);
    const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
    mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(timeout, mWindow);
    // Remove the window, but the input channel should remain alive.
    mDispatcher->onWindowInfosChanged({{}, {}, 0, 0});
    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)));
    mWindow->consumeFocusEvent(false);
    ASSERT_TRUE(mDispatcher->waitForIdle());
    // Since the window was removed, Dispatcher does not know the PID associated with the window
    // becoming responsive, so the policy is notified without the PID.
    mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), /*pid=*/std::nullopt);
}
class InputDispatcherMultiWindowAnr : public InputDispatcherTest {
    virtual void SetUp() override {
        InputDispatcherTest::SetUp();
+3 −7
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ namespace impl {
using aidl::android::hardware::power::Boost;
using aidl::android::hardware::power::Mode;
using aidl::android::hardware::power::SessionHint;
using aidl::android::hardware::power::SessionTag;
using aidl::android::hardware::power::WorkDuration;

PowerAdvisor::~PowerAdvisor() = default;
@@ -207,12 +206,9 @@ bool PowerAdvisor::supportsPowerHintSession() {

bool PowerAdvisor::ensurePowerHintSessionRunning() {
    if (mHintSession == nullptr && !mHintSessionThreadIds.empty() && usePowerHintSession()) {
        auto ret =
                getPowerHal().createHintSessionWithConfig(getpid(), static_cast<int32_t>(getuid()),
                                                          mHintSessionThreadIds,
                                                          mTargetDuration.ns(),
                                                          SessionTag::SURFACEFLINGER,
                                                          &mSessionConfig);
        auto ret = getPowerHal().createHintSession(getpid(), static_cast<int32_t>(getuid()),
                                                   mHintSessionThreadIds, mTargetDuration.ns());

        if (ret.isOk()) {
            mHintSession = ret.value();
        }
Loading