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

Commit 10460043 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove device state when device is reset" into rvc-dev

parents d45b96e2 e3021d70
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -45,10 +45,7 @@ public:
    T pop() {
        std::unique_lock lock(mLock);
        android::base::ScopedLockAssertion assumeLock(mLock);
        mHasElements.wait(lock, [this]{
                android::base::ScopedLockAssertion assumeLock(mLock);
                return !this->mQueue.empty();
        });
        mHasElements.wait(lock, [this]() REQUIRES(mLock) { return !this->mQueue.empty(); });
        T t = std::move(mQueue.front());
        mQueue.erase(mQueue.begin());
        return t;
+8 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ void MotionClassifier::callInputClassifierHal() {
            case ClassifierEventType::DEVICE_RESET: {
                const int32_t deviceId = *(event.getDeviceId());
                halResponseOk = mService->resetDevice(deviceId).isOk();
                setClassification(deviceId, MotionClassification::NONE);
                clearDeviceState(deviceId);
                break;
            }
            case ClassifierEventType::HAL_RESET: {
@@ -321,6 +321,12 @@ void MotionClassifier::updateLastDownTime(int32_t deviceId, nsecs_t downTime) {
    mClassifications[deviceId] = MotionClassification::NONE;
}

void MotionClassifier::clearDeviceState(int32_t deviceId) {
    std::scoped_lock lock(mLock);
    mClassifications.erase(deviceId);
    mLastDownTimes.erase(deviceId);
}

MotionClassification MotionClassifier::classify(const NotifyMotionArgs& args) {
    if ((args.action & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_DOWN) {
        updateLastDownTime(args.deviceId, args.downTime);
@@ -455,6 +461,7 @@ void InputClassifier::serviceDied(uint64_t /*cookie*/,
void InputClassifier::dump(std::string& dump) {
    std::scoped_lock lock(mLock);
    dump += "Input Classifier State:\n";
    dump += StringPrintf(INDENT1 "Deep press: %s\n", deepPressEnabled() ? "enabled" : "disabled");

    dump += INDENT1 "Motion Classifier:\n";
    if (mMotionClassifier) {
+2 −0
Original line number Diff line number Diff line
@@ -212,6 +212,8 @@ private:

    void updateLastDownTime(int32_t deviceId, nsecs_t downTime);

    void clearDeviceState(int32_t deviceId);

    /**
     * Exit the InputClassifier HAL thread.
     * Useful for tests to ensure proper cleanup.