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

Commit 5d47791e authored by Ana Krulec's avatar Ana Krulec
Browse files

SF Crash Bug fix

There is a state when Scheduler returns a config which is not allowed
by the policy. This can happen when policy has changed, and scheduler
decided that the next config should be the current config. We fix it
by returning the current config, if allowed, otherwise the default.

Change-Id: Id49674dc5cf6cc36eb6a48dfec7d007063c1f382
Bug: 149077559
Test: Turn off all policies. Toggle smoooth display. Doesn't fail.
Test: Turn off all polcies. Open Waze. Doesn't fail.
Test: Turn off all policies. Open TouchLatency app. Switch between 60/90.
Test: Turn off all policies. Play youtube video.
Test: Turn off all policies. Open Chrome. Play video.
parent 74a2eb62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -229,6 +229,15 @@ const RefreshRate& RefreshRateConfigs::getCurrentRefreshRate() const {
    return *mCurrentRefreshRate;
}

const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicy() const {
    std::lock_guard lock(mLock);
    if (std::find(mAvailableRefreshRates.begin(), mAvailableRefreshRates.end(),
                  mCurrentRefreshRate) != mAvailableRefreshRates.end()) {
        return *mCurrentRefreshRate;
    }
    return mRefreshRates.at(mDefaultConfig);
}

void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) {
    std::lock_guard lock(mLock);
    mCurrentRefreshRate = &mRefreshRates.at(configId);
+4 −0
Original line number Diff line number Diff line
@@ -149,6 +149,10 @@ public:
    // Returns the current refresh rate
    const RefreshRate& getCurrentRefreshRate() const EXCLUDES(mLock);

    // Returns the current refresh rate, if allowed. Otherwise the default that is allowed by
    // the policy.
    const RefreshRate& getCurrentRefreshRateByPolicy() const;

    // Returns the refresh rate that corresponds to a HwcConfigIndexType. This won't change at
    // runtime.
    const RefreshRate& getRefreshRateFromConfigId(HwcConfigIndexType configId) const {
+2 −2
Original line number Diff line number Diff line
@@ -624,8 +624,8 @@ HwcConfigIndexType Scheduler::calculateRefreshRateType() {
                .configId;
    }

    // There are no signals for refresh rate, just leave it as is
    return mRefreshRateConfigs.getCurrentRefreshRate().configId;
    // There are no signals for refresh rate, just leave it as is.
    return mRefreshRateConfigs.getCurrentRefreshRateByPolicy().configId;
}

std::optional<HwcConfigIndexType> Scheduler::getPreferredConfigId() {