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

Commit 2dce34e1 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Automerger Merge Worker
Browse files

Rename ANR -> Anr am: b1a1627d am: 84011888

Change-Id: Ia2e0e35f7dcdefb3d2f5b5cad991251dce326ea8
parents 848ea235 84011888
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ protected:
private:
    virtual void notifyConfigurationChanged(nsecs_t) override {}

    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&, const sp<IBinder>&,
    virtual nsecs_t notifyAnr(const sp<InputApplicationHandle>&, const sp<IBinder>&,
                              const std::string& name) override {
        ALOGE("The window is not responding : %s", name.c_str());
        return 0;
+22 −22
Original line number Diff line number Diff line
@@ -531,7 +531,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
        }

        // Get ready to dispatch the event.
        resetANRTimeoutsLocked();
        resetAnrTimeoutsLocked();
    }

    // Now we have an event to dispatch.
@@ -888,7 +888,7 @@ void InputDispatcher::drainInboundQueueLocked() {

void InputDispatcher::releasePendingEventLocked() {
    if (mPendingEvent) {
        resetANRTimeoutsLocked();
        resetAnrTimeoutsLocked();
        releaseInboundEventLocked(mPendingEvent);
        mPendingEvent = nullptr;
    }
@@ -1299,7 +1299,7 @@ int32_t InputDispatcher::handleTargetsNotReadyLocked(
    }

    if (currentTime >= mInputTargetWaitTimeoutTime) {
        onANRLocked(currentTime, applicationHandle, windowHandle, entry.eventTime,
        onAnrLocked(currentTime, applicationHandle, windowHandle, entry.eventTime,
                    mInputTargetWaitStartTime, reason);

        // Force poll loop to wake up immediately on next iteration once we get the
@@ -1352,7 +1352,7 @@ nsecs_t InputDispatcher::getTimeSpentWaitingForApplicationLocked(nsecs_t current
    return 0;
}

void InputDispatcher::resetANRTimeoutsLocked() {
void InputDispatcher::resetAnrTimeoutsLocked() {
    if (DEBUG_FOCUS) {
        ALOGD("Resetting ANR timeouts.");
    }
@@ -3800,12 +3800,12 @@ void InputDispatcher::setFocusedApplication(
        if (inputApplicationHandle != nullptr && inputApplicationHandle->updateInfo()) {
            if (oldFocusedApplicationHandle != inputApplicationHandle) {
                if (oldFocusedApplicationHandle != nullptr) {
                    resetANRTimeoutsLocked();
                    resetAnrTimeoutsLocked();
                }
                mFocusedApplicationHandlesByDisplay[displayId] = inputApplicationHandle;
            }
        } else if (oldFocusedApplicationHandle != nullptr) {
            resetANRTimeoutsLocked();
            resetAnrTimeoutsLocked();
            oldFocusedApplicationHandle.clear();
            mFocusedApplicationHandlesByDisplay.erase(displayId);
        }
@@ -3886,7 +3886,7 @@ void InputDispatcher::setInputDispatchMode(bool enabled, bool frozen) {

        if (mDispatchEnabled != enabled || mDispatchFrozen != frozen) {
            if (mDispatchFrozen && !frozen) {
                resetANRTimeoutsLocked();
                resetAnrTimeoutsLocked();
            }

            if (mDispatchEnabled && !enabled) {
@@ -4026,7 +4026,7 @@ void InputDispatcher::resetAndDropEverythingLocked(const char* reason) {
    resetKeyRepeatLocked();
    releasePendingEventLocked();
    drainInboundQueueLocked();
    resetANRTimeoutsLocked();
    resetAnrTimeoutsLocked();

    mTouchStatesByDisplay.clear();
    mLastHoverWindowHandle.clear();
@@ -4526,7 +4526,7 @@ void InputDispatcher::onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus
    postCommandLocked(std::move(commandEntry));
}

void InputDispatcher::onANRLocked(nsecs_t currentTime,
void InputDispatcher::onAnrLocked(nsecs_t currentTime,
                                  const sp<InputApplicationHandle>& applicationHandle,
                                  const sp<InputWindowHandle>& windowHandle, nsecs_t eventTime,
                                  nsecs_t waitStartTime, const char* reason) {
@@ -4543,19 +4543,19 @@ void InputDispatcher::onANRLocked(nsecs_t currentTime,
    localtime_r(&t, &tm);
    char timestr[64];
    strftime(timestr, sizeof(timestr), "%F %T", &tm);
    mLastANRState.clear();
    mLastANRState += INDENT "ANR:\n";
    mLastANRState += StringPrintf(INDENT2 "Time: %s\n", timestr);
    mLastANRState +=
    mLastAnrState.clear();
    mLastAnrState += INDENT "ANR:\n";
    mLastAnrState += StringPrintf(INDENT2 "Time: %s\n", timestr);
    mLastAnrState +=
            StringPrintf(INDENT2 "Window: %s\n",
                         getApplicationWindowLabel(applicationHandle, windowHandle).c_str());
    mLastANRState += StringPrintf(INDENT2 "DispatchLatency: %0.1fms\n", dispatchLatency);
    mLastANRState += StringPrintf(INDENT2 "WaitDuration: %0.1fms\n", waitDuration);
    mLastANRState += StringPrintf(INDENT2 "Reason: %s\n", reason);
    dumpDispatchStateLocked(mLastANRState);
    mLastAnrState += StringPrintf(INDENT2 "DispatchLatency: %0.1fms\n", dispatchLatency);
    mLastAnrState += StringPrintf(INDENT2 "WaitDuration: %0.1fms\n", waitDuration);
    mLastAnrState += StringPrintf(INDENT2 "Reason: %s\n", reason);
    dumpDispatchStateLocked(mLastAnrState);

    std::unique_ptr<CommandEntry> commandEntry =
            std::make_unique<CommandEntry>(&InputDispatcher::doNotifyANRLockedInterruptible);
            std::make_unique<CommandEntry>(&InputDispatcher::doNotifyAnrLockedInterruptible);
    commandEntry->inputApplicationHandle = applicationHandle;
    commandEntry->inputChannel =
            windowHandle != nullptr ? getInputChannelLocked(windowHandle->getToken()) : nullptr;
@@ -4591,13 +4591,13 @@ void InputDispatcher::doNotifyFocusChangedLockedInterruptible(CommandEntry* comm
    mLock.lock();
}

void InputDispatcher::doNotifyANRLockedInterruptible(CommandEntry* commandEntry) {
void InputDispatcher::doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) {
    sp<IBinder> token =
            commandEntry->inputChannel ? commandEntry->inputChannel->getConnectionToken() : nullptr;
    mLock.unlock();

    nsecs_t newTimeout =
            mPolicy->notifyANR(commandEntry->inputApplicationHandle, token, commandEntry->reason);
            mPolicy->notifyAnr(commandEntry->inputApplicationHandle, token, commandEntry->reason);

    mLock.lock();

@@ -4958,9 +4958,9 @@ void InputDispatcher::dump(std::string& dump) {
    dump += "Input Dispatcher State:\n";
    dumpDispatchStateLocked(dump);

    if (!mLastANRState.empty()) {
    if (!mLastAnrState.empty()) {
        dump += "\nInput Dispatcher State at time of last ANR:\n";
        dump += mLastANRState;
        dump += mLastAnrState;
    }
}

+4 −4
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ private:
    int32_t mFocusedDisplayId GUARDED_BY(mLock);

    // Dispatcher state at time of last ANR.
    std::string mLastANRState GUARDED_BY(mLock);
    std::string mLastAnrState GUARDED_BY(mLock);

    // Dispatch inbound events.
    bool dispatchConfigurationChangedLocked(nsecs_t currentTime, ConfigurationChangedEntry* entry)
@@ -360,7 +360,7 @@ private:
                                                 const sp<IBinder>& inputConnectionToken)
            REQUIRES(mLock);
    nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime) REQUIRES(mLock);
    void resetANRTimeoutsLocked() REQUIRES(mLock);
    void resetAnrTimeoutsLocked() REQUIRES(mLock);

    int32_t getTargetDisplayId(const EventEntry& entry);
    int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry& entry,
@@ -468,7 +468,7 @@ private:
            REQUIRES(mLock);
    void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus,
                              const sp<InputWindowHandle>& newFocus) REQUIRES(mLock);
    void onANRLocked(nsecs_t currentTime, const sp<InputApplicationHandle>& applicationHandle,
    void onAnrLocked(nsecs_t currentTime, const sp<InputApplicationHandle>& applicationHandle,
                     const sp<InputWindowHandle>& windowHandle, nsecs_t eventTime,
                     nsecs_t waitStartTime, const char* reason) REQUIRES(mLock);

@@ -477,7 +477,7 @@ private:
            REQUIRES(mLock);
    void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doNotifyFocusChangedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doNotifyANRLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry)
            REQUIRES(mLock);
    void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public:

    /* Notifies the system that an application is not responding.
     * Returns a new timeout to continue waiting, or 0 to abort dispatch. */
    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
    virtual nsecs_t notifyAnr(const sp<InputApplicationHandle>& inputApplicationHandle,
                              const sp<IBinder>& token, const std::string& reason) = 0;

    /* Notifies the system that an input channel is unrecoverably broken. */
+14 −20
Original line number Diff line number Diff line
@@ -127,19 +127,16 @@ private:
        mConfigurationChangedTime = when;
    }

    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&,
            const sp<IBinder>&,
            const std::string&) {
    virtual nsecs_t notifyAnr(const sp<InputApplicationHandle>&, const sp<IBinder>&,
                              const std::string&) override {
        return 0;
    }

    virtual void notifyInputChannelBroken(const sp<IBinder>&) {
    }
    virtual void notifyInputChannelBroken(const sp<IBinder>&) override {}

    virtual void notifyFocusChanged(const sp<IBinder>&, const sp<IBinder>&) {
    }
    virtual void notifyFocusChanged(const sp<IBinder>&, const sp<IBinder>&) override {}

    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) override {
        *outConfig = mConfig;
    }

@@ -160,19 +157,17 @@ private:
        return true;
    }

    virtual void interceptKeyBeforeQueueing(const KeyEvent*, uint32_t&) {
    }
    virtual void interceptKeyBeforeQueueing(const KeyEvent*, uint32_t&) override {}

    virtual void interceptMotionBeforeQueueing(int32_t, nsecs_t, uint32_t&) {
    }
    virtual void interceptMotionBeforeQueueing(int32_t, nsecs_t, uint32_t&) override {}

    virtual nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>&,
            const KeyEvent*, uint32_t) {
    virtual nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>&, const KeyEvent*,
                                                  uint32_t) override {
        return 0;
    }

    virtual bool dispatchUnhandledKey(const sp<IBinder>&,
            const KeyEvent*, uint32_t, KeyEvent*) {
    virtual bool dispatchUnhandledKey(const sp<IBinder>&, const KeyEvent*, uint32_t,
                                      KeyEvent*) override {
        return false;
    }

@@ -184,14 +179,13 @@ private:
        mLastNotifySwitch = NotifySwitchArgs(1 /*id*/, when, policyFlags, switchValues, switchMask);
    }

    virtual void pokeUserActivity(nsecs_t, int32_t) {
    }
    virtual void pokeUserActivity(nsecs_t, int32_t) override {}

    virtual bool checkInjectEventsPermissionNonReentrant(int32_t, int32_t) {
    virtual bool checkInjectEventsPermissionNonReentrant(int32_t, int32_t) override {
        return false;
    }

    virtual void onPointerDownOutsideFocus(const sp<IBinder>& newToken) {
    virtual void onPointerDownOutsideFocus(const sp<IBinder>& newToken) override {
        mOnPointerDownToken = newToken;
    }