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

Commit 5cb69a38 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Force callers to consume initial WindowInfosUpdate" into main

parents 3bc65643 1b9d06d6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3444,10 +3444,10 @@ int SurfaceComposerClient::getGpuContextPriority() {

status_t SurfaceComposerClient::addWindowInfosListener(
        const sp<WindowInfosListener>& windowInfosListener,
        std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo) {
        gui::WindowInfosUpdate* outInitialUpdate) {
    return WindowInfosListenerReporter::getInstance()
            ->addWindowInfosListener(windowInfosListener, ComposerServiceAIDL::getComposerService(),
                                     outInitialInfo);
                                     outInitialUpdate);
}

status_t SurfaceComposerClient::removeWindowInfosListener(
+5 −8
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ sp<WindowInfosListenerReporter> WindowInfosListenerReporter::getInstance() {
status_t WindowInfosListenerReporter::addWindowInfosListener(
        const sp<WindowInfosListener>& windowInfosListener,
        const sp<gui::ISurfaceComposer>& surfaceComposer,
        std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo) {
        gui::WindowInfosUpdate* outInitialUpdate) {
    status_t status = OK;
    {
        std::scoped_lock lock(mListenersMutex);
@@ -53,9 +53,8 @@ status_t WindowInfosListenerReporter::addWindowInfosListener(
            mWindowInfosListeners.insert(windowInfosListener);
        }

        if (outInitialInfo != nullptr) {
            outInitialInfo->first = mLastWindowInfos;
            outInitialInfo->second = mLastDisplayInfos;
        if (outInitialUpdate != nullptr) {
            *outInitialUpdate = mLastUpdate;
        }
    }

@@ -77,8 +76,7 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener(
            status = statusTFromBinderStatus(s);
            // Clear the last stored state since we're disabling updates and don't want to hold
            // stale values
            mLastWindowInfos.clear();
            mLastDisplayInfos.clear();
            mLastUpdate = gui::WindowInfosUpdate();
        }

        if (status == OK) {
@@ -100,8 +98,7 @@ binder::Status WindowInfosListenerReporter::onWindowInfosChanged(
            windowInfosListeners.insert(listener);
        }

        mLastWindowInfos = update.windowInfos;
        mLastDisplayInfos = update.displayInfos;
        mLastUpdate = update;
    }

    for (auto listener : windowInfosListeners) {
+2 −4
Original line number Diff line number Diff line
@@ -911,10 +911,8 @@ public:
    static status_t removeTunnelModeEnabledListener(
            const sp<gui::ITunnelModeEnabledListener>& listener);

    status_t addWindowInfosListener(
            const sp<gui::WindowInfosListener>& windowInfosListener,
            std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo =
                    nullptr);
    status_t addWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener,
                                    gui::WindowInfosUpdate* outInitialUpdate);
    status_t removeWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener);

    static void notifyShutdown();
+4 −6
Original line number Diff line number Diff line
@@ -31,10 +31,9 @@ class WindowInfosListenerReporter : public gui::BnWindowInfosListener {
public:
    static sp<WindowInfosListenerReporter> getInstance();
    binder::Status onWindowInfosChanged(const gui::WindowInfosUpdate& update) override;
    status_t addWindowInfosListener(
            const sp<gui::WindowInfosListener>& windowInfosListener,
    status_t addWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener,
                                    const sp<gui::ISurfaceComposer>&,
            std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo);
                                    gui::WindowInfosUpdate* outInitialUpdate);
    status_t removeWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener,
                                       const sp<gui::ISurfaceComposer>& surfaceComposer);
    void reconnect(const sp<gui::ISurfaceComposer>&);
@@ -47,8 +46,7 @@ private:
    std::unordered_set<sp<gui::WindowInfosListener>, gui::SpHash<gui::WindowInfosListener>>
            mWindowInfosListeners GUARDED_BY(mListenersMutex);

    std::vector<gui::WindowInfo> mLastWindowInfos GUARDED_BY(mListenersMutex);
    std::vector<gui::DisplayInfo> mLastDisplayInfos GUARDED_BY(mListenersMutex);
    gui::WindowInfosUpdate mLastUpdate GUARDED_BY(mListenersMutex);

    sp<gui::IWindowInfosPublisher> mWindowInfosPublisher;
    int64_t mListenerId;
+2 −3
Original line number Diff line number Diff line
@@ -107,13 +107,12 @@ PointerChoreographer::PointerChoreographer(InputListenerInterface& inputListener
      : PointerChoreographer(
                inputListener, policy,
                [](const sp<android::gui::WindowInfosListener>& listener) {
                    auto initialInfo = std::make_pair(std::vector<android::gui::WindowInfo>{},
                                                      std::vector<android::gui::DisplayInfo>{});
                    gui::WindowInfosUpdate initialInfo;
#if defined(__ANDROID__)
                    SurfaceComposerClient::getDefault()->addWindowInfosListener(listener,
                                                                                &initialInfo);
#endif
                    return initialInfo.first;
                    return initialInfo.windowInfos;
                },
                [](const sp<android::gui::WindowInfosListener>& listener) {
#if defined(__ANDROID__)
Loading