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

Commit 16a0537c authored by Mark Yacoub's avatar Mark Yacoub Committed by Android (Google) Code Review
Browse files

Merge "Get the latest hotplugs" into main

parents 0f8ae4fc 77df0f49
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -458,6 +458,11 @@ ComposerClientWrapper::takeListOfRefreshRateChangedDebugData() {
    return mComposerCallback->takeListOfRefreshRateChangedDebugData();
}

std::vector<std::pair<int64_t, common::DisplayHotplugEvent>>
ComposerClientWrapper::getAndClearLatestHotplugs() {
    return mComposerCallback->getAndClearLatestHotplugs();
}

int64_t ComposerClientWrapper::getInvalidDisplayId() {
    // returns an invalid display id (one that has not been registered to a
    // display. Currently assuming that a device will never have close to
+15 −0
Original line number Diff line number Diff line
@@ -100,6 +100,16 @@ int32_t GraphicsComposerCallback::getInvalidRefreshRateDebugEnabledCallbackCount
    return mInvalidRefreshRateDebugEnabledCallbackCount;
}

std::vector<std::pair<int64_t, common::DisplayHotplugEvent>>
GraphicsComposerCallback::getAndClearLatestHotplugs() {
    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> ret;
    {
        std::scoped_lock lock(mMutex);
        ret.swap(mLatestHotplugs);
    }
    return ret;
}

::ndk::ScopedAStatus GraphicsComposerCallback::onHotplug(int64_t in_display, bool in_connected) {
    std::scoped_lock lock(mMutex);

@@ -196,6 +206,11 @@ int32_t GraphicsComposerCallback::getInvalidRefreshRateDebugEnabledCallbackCount

::ndk::ScopedAStatus GraphicsComposerCallback::onHotplugEvent(int64_t in_display,
                                                              common::DisplayHotplugEvent event) {
    {
        std::scoped_lock lock(mMutex);
        mLatestHotplugs.emplace_back(in_display, event);
    }

    switch (event) {
        case common::DisplayHotplugEvent::CONNECTED:
            return onHotplug(in_display, true);
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,8 @@ class ComposerClientWrapper {
    std::pair<ScopedAStatus, std::vector<Luts>> getLuts(int64_t display,
                                                        const std::vector<Buffer>& buffers);

    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> getAndClearLatestHotplugs();

    static constexpr int32_t kMaxFrameIntervalNs = 50000000;  // 20fps
    static constexpr int32_t kNoFrameIntervalNs = 0;

+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ class GraphicsComposerCallback : public BnComposerCallback {

    int32_t getInvalidRefreshRateDebugEnabledCallbackCount() const;

    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> getAndClearLatestHotplugs();

  private:
    virtual ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override;
    virtual ::ndk::ScopedAStatus onRefresh(int64_t in_display) override;
@@ -71,6 +73,8 @@ class GraphicsComposerCallback : public BnComposerCallback {
    mutable std::mutex mMutex;
    // the set of all currently connected displays
    std::vector<int64_t> mDisplays GUARDED_BY(mMutex);
    std::vector<std::pair<int64_t /*display id*/, common::DisplayHotplugEvent>> mLatestHotplugs
            GUARDED_BY(mMutex);
    // true only when vsync is enabled
    bool mVsyncAllowed GUARDED_BY(mMutex) = true;
    // true only when RefreshRateChangedCallbackDebugEnabled is set to true.