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

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

Rename ANR -> Anr am: b1a1627d am: 1ea55a23

Change-Id: I2628c30918d8344173c4d20132019a5c109465d7
parents 848ea235 1ea55a23
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@ protected:
private:
private:
    virtual void notifyConfigurationChanged(nsecs_t) override {}
    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 {
                              const std::string& name) override {
        ALOGE("The window is not responding : %s", name.c_str());
        ALOGE("The window is not responding : %s", name.c_str());
        return 0;
        return 0;
+22 −22
Original line number Original line Diff line number Diff line
@@ -531,7 +531,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
        }
        }


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


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


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


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


        // Force poll loop to wake up immediately on next iteration once we get the
        // 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;
    return 0;
}
}


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


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


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


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


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


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


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


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


    mLock.lock();
    mLock.lock();


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


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


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


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


    // Dispatch inbound events.
    // Dispatch inbound events.
    bool dispatchConfigurationChangedLocked(nsecs_t currentTime, ConfigurationChangedEntry* entry)
    bool dispatchConfigurationChangedLocked(nsecs_t currentTime, ConfigurationChangedEntry* entry)
@@ -360,7 +360,7 @@ private:
                                                 const sp<IBinder>& inputConnectionToken)
                                                 const sp<IBinder>& inputConnectionToken)
            REQUIRES(mLock);
            REQUIRES(mLock);
    nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime) 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 getTargetDisplayId(const EventEntry& entry);
    int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry& entry,
    int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry& entry,
@@ -468,7 +468,7 @@ private:
            REQUIRES(mLock);
            REQUIRES(mLock);
    void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus,
    void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus,
                              const sp<InputWindowHandle>& newFocus) REQUIRES(mLock);
                              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,
                     const sp<InputWindowHandle>& windowHandle, nsecs_t eventTime,
                     nsecs_t waitStartTime, const char* reason) REQUIRES(mLock);
                     nsecs_t waitStartTime, const char* reason) REQUIRES(mLock);


@@ -477,7 +477,7 @@ private:
            REQUIRES(mLock);
            REQUIRES(mLock);
    void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doNotifyFocusChangedLockedInterruptible(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)
    void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry)
            REQUIRES(mLock);
            REQUIRES(mLock);
    void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
    void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
+1 −1
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@ public:


    /* Notifies the system that an application is not responding.
    /* Notifies the system that an application is not responding.
     * Returns a new timeout to continue waiting, or 0 to abort dispatch. */
     * 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;
                              const sp<IBinder>& token, const std::string& reason) = 0;


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


    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&,
    virtual nsecs_t notifyAnr(const sp<InputApplicationHandle>&, const sp<IBinder>&,
            const sp<IBinder>&,
                              const std::string&) override {
            const std::string&) {
        return 0;
        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;
        *outConfig = mConfig;
    }
    }


@@ -160,19 +157,17 @@ private:
        return true;
        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>&,
    virtual nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>&, const KeyEvent*,
            const KeyEvent*, uint32_t) {
                                                  uint32_t) override {
        return 0;
        return 0;
    }
    }


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


@@ -184,14 +179,13 @@ private:
        mLastNotifySwitch = NotifySwitchArgs(1 /*id*/, when, policyFlags, switchValues, switchMask);
        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;
        return false;
    }
    }


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