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

Commit e1dd30a3 authored by Changyeon Jo's avatar Changyeon Jo
Browse files

Implement getDisplayInfo()



This change implements getDisplayInfo() method that returns the main
display information from SurfaceComposerClient.

Bug: 141886260
Test: VtsHalEvsV1_1TargetTest
Change-Id: I6fe05aef9868c202e8b0a4664783122180235fe0
Signed-off-by: default avatarChangyeon Jo <changyeon@google.com>
parent d1233911
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@
#include <utility>

#include <gui/bufferqueue/2.0/B2HGraphicBufferProducer.h>
#include <ui/DisplayConfig.h>
#include <ui/DisplayState.h>

#include "CarWindowService.h"

@@ -48,26 +46,24 @@ Return<sp<IGraphicBufferProducer>>
            return nullptr;
        }

        DisplayConfig displayConfig;
        err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig);
        err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &mDpyConfig);
        if (err != NO_ERROR) {
            ALOGE("Failed to get active display config");
            return nullptr;
        }

        ui::DisplayState displayState;
        err = SurfaceComposerClient::getDisplayState(displayToken, &displayState);
        err = SurfaceComposerClient::getDisplayState(displayToken, &mDpyState);
        if (err != NO_ERROR) {
            ALOGE("Failed to get display state");
            return nullptr;
        }

        const ui::Size& resolution = displayConfig.resolution;
        const ui::Size& resolution = mDpyConfig.resolution;
        auto width = resolution.getWidth();
        auto height = resolution.getHeight();

        if (displayState.orientation == ui::ROTATION_90 ||
            displayState.orientation == ui::ROTATION_270) {
        if (mDpyState.orientation == ui::ROTATION_90 ||
            mDpyState.orientation == ui::ROTATION_270) {
            std::swap(width, height);
        }

+14 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <ui/DisplayConfig.h>
#include <ui/DisplayState.h>

namespace android {
namespace frameworks {
@@ -37,11 +39,23 @@ public:
    Return<sp<IGraphicBufferProducer>> getIGraphicBufferProducer() override;
    Return<bool> showWindow() override;
    Return<bool> hideWindow() override;
    Return<void> getDisplayInfo(getDisplayInfo_cb _info_cb) override {
        HwDisplayConfig cfg;
        cfg.setToExternal((uint8_t*)&mDpyConfig, sizeof(DisplayConfig));

        HwDisplayState state;
        state.setToExternal((uint8_t*)&mDpyState, sizeof(DisplayState));

       _info_cb(cfg, state);
        return hardware::Void();
    }

private:
    sp<android::Surface> mSurface;
    sp<android::SurfaceComposerClient> mSurfaceComposerClient;
    sp<android::SurfaceControl> mSurfaceControl;
    DisplayConfig mDpyConfig;
    DisplayState  mDpyState;
};
}  // namespace implementation
}  // namespace V1_0