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

Commit 29ae6e3b authored by Dan Stoza's avatar Dan Stoza
Browse files

libgui: Fix naming/enums in ISurfaceComposerClient

Moves the Tag enum out of the ISurfaceComposerClient header and into an
anonymous namespace in the .cpp file, changes it to UPPER_UNDERSCORE
naming, and makes its LAST entry actually point to the last value.

Test: m -j + manual testing
Change-Id: I73deaa446a87709548c2069c3a1f29605967ab97
parent c428826f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -29,14 +29,6 @@ class ISurfaceComposerClient : public IInterface {
public:
    DECLARE_META_INTERFACE(SurfaceComposerClient)

    enum class Tag : uint32_t {
        CreateSurface = IBinder::FIRST_CALL_TRANSACTION,
        DestroySurface,
        ClearLayerFrameStats,
        GetLayerFrameStats,
        Last,
    };

    // flags for createSurface()
    enum { // (keep in sync with Surface.java)
        eHidden = 0x00000004,
+25 −27
Original line number Diff line number Diff line
@@ -17,24 +17,28 @@
// tag as surfaceflinger
#define LOG_TAG "SurfaceFlinger"

#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <gui/ISurfaceComposerClient.h>

#include <gui/IGraphicBufferProducer.h>

#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/Parcel.h>
#include <binder/SafeInterface.h>

#include <ui/FrameStats.h>
#include <ui/Point.h>
#include <ui/Rect.h>

#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposerClient.h>

namespace android {

namespace { // Anonymous

enum class Tag : uint32_t {
    CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION,
    DESTROY_SURFACE,
    CLEAR_LAYER_FRAME_STATS,
    GET_LAYER_FRAME_STATS,
    LAST = GET_LAYER_FRAME_STATS,
};

} // Anonymous namespace

class BpSurfaceComposerClient : public SafeBpInterface<ISurfaceComposerClient> {
public:
    explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
@@ -46,7 +50,7 @@ public:
                           uint32_t flags, const sp<IBinder>& parent, uint32_t windowType,
                           uint32_t ownerUid, sp<IBinder>* handle,
                           sp<IGraphicBufferProducer>* gbp) override {
        return callRemote<decltype(&ISurfaceComposerClient::createSurface)>(Tag::CreateSurface,
        return callRemote<decltype(&ISurfaceComposerClient::createSurface)>(Tag::CREATE_SURFACE,
                                                                            name, width, height,
                                                                            format, flags, parent,
                                                                            windowType, ownerUid,
@@ -54,18 +58,19 @@ public:
    }

    status_t destroySurface(const sp<IBinder>& handle) override {
        return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DestroySurface,
        return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DESTROY_SURFACE,
                                                                             handle);
    }

    status_t clearLayerFrameStats(const sp<IBinder>& handle) const override {
        return callRemote<decltype(
                &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::ClearLayerFrameStats, handle);
                &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::CLEAR_LAYER_FRAME_STATS,
                                                                handle);
    }

    status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const override {
        return callRemote<decltype(
                &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GetLayerFrameStats, handle,
                &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GET_LAYER_FRAME_STATS, handle,
                                                              outStats);
    }
};
@@ -80,27 +85,20 @@ IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClie

status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
                                             uint32_t flags) {
    if (code < IBinder::FIRST_CALL_TRANSACTION || code >= static_cast<uint32_t>(Tag::Last)) {
    if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) {
        return BBinder::onTransact(code, data, reply, flags);
    }
    auto tag = static_cast<Tag>(code);
    switch (tag) {
        case Tag::CreateSurface: {
        case Tag::CREATE_SURFACE:
            return callLocal(data, reply, &ISurfaceComposerClient::createSurface);
        }
        case Tag::DestroySurface: {
        case Tag::DESTROY_SURFACE:
            return callLocal(data, reply, &ISurfaceComposerClient::destroySurface);
        }
        case Tag::ClearLayerFrameStats: {
        case Tag::CLEAR_LAYER_FRAME_STATS:
            return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
        }
        case Tag::GetLayerFrameStats: {
        case Tag::GET_LAYER_FRAME_STATS:
            return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
    }
        case Tag::Last:
            // Should not be possible because of the check at the beginning of the method
            return BBinder::onTransact(code, data, reply, flags);
    }
}

} // namespace android