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

Commit 7f7da325 authored by Dan Stoza's avatar Dan Stoza
Browse files

Enable changing display configuration

This allows querying and switching display device configurations
through the ISurfaceComposer/SurfaceComposerClient interface.

Bug: 14320401
Change-Id: I8c22165698950e5da32204c1c4da92122f91a715
parent 39c5e9f8
Loading
Loading
Loading
Loading
+14 −3
Original line number Original line Diff line number Diff line
@@ -113,9 +113,18 @@ public:
     */
     */
    virtual void unblank(const sp<IBinder>& display) = 0;
    virtual void unblank(const sp<IBinder>& display) = 0;


    /* returns information about a display
    /* returns information for each configuration of the given display
     * intended to be used to get information about built-in displays */
     * intended to be used to get information about built-in displays */
    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
            Vector<DisplayInfo>* configs) = 0;

    /* indicates which of the configurations returned by getDisplayInfo is
     * currently active */
    virtual int getActiveConfig(const sp<IBinder>& display) = 0;

    /* specifies which configuration (of those returned by getDisplayInfo)
     * should be used */
    virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0;


    /* Capture the specified screen. requires READ_FRAME_BUFFER permission
    /* Capture the specified screen. requires READ_FRAME_BUFFER permission
     * This function will fail if there is a secure window on screen.
     * This function will fail if there is a secure window on screen.
@@ -158,7 +167,9 @@ public:
        AUTHENTICATE_SURFACE,
        AUTHENTICATE_SURFACE,
        BLANK,
        BLANK,
        UNBLANK,
        UNBLANK,
        GET_DISPLAY_INFO,
        GET_DISPLAY_CONFIGS,
        GET_ACTIVE_CONFIG,
        SET_ACTIVE_CONFIG,
        CONNECT_DISPLAY,
        CONNECT_DISPLAY,
        CAPTURE_SCREEN,
        CAPTURE_SCREEN,
        CLEAR_ANIMATION_FRAME_STATS,
        CLEAR_ANIMATION_FRAME_STATS,
+15 −2
Original line number Original line Diff line number Diff line
@@ -66,8 +66,21 @@ public:
    status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
    status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
            void* cookie = NULL, uint32_t flags = 0);
            void* cookie = NULL, uint32_t flags = 0);


    // Get information about a display
    // Get a list of supported configurations for a given display
    static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
    static status_t getDisplayConfigs(const sp<IBinder>& display,
            Vector<DisplayInfo>* configs);

    // Get the DisplayInfo for the currently-active configuration
    static status_t getDisplayInfo(const sp<IBinder>& display,
            DisplayInfo* info);

    // Get the index of the current active configuration (relative to the list
    // returned by getDisplayInfo)
    static int getActiveConfig(const sp<IBinder>& display);

    // Set a new active configuration using an index relative to the list
    // returned by getDisplayInfo
    static status_t setActiveConfig(const sp<IBinder>& display, int id);


    /* triggers screen off and waits for it to complete */
    /* triggers screen off and waits for it to complete */
    static void blankDisplay(const sp<IBinder>& display);
    static void blankDisplay(const sp<IBinder>& display);
+0 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ struct DisplayInfo {
    float density;
    float density;
    uint8_t orientation;
    uint8_t orientation;
    bool secure;
    bool secure;
    uint8_t reserved[2];
};
};


/* Display orientations as defined in Surface.java and ISurfaceComposer.h. */
/* Display orientations as defined in Surface.java and ISurfaceComposer.h. */
+58 −7
Original line number Original line Diff line number Diff line
@@ -220,13 +220,43 @@ public:
        remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
        remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
    }
    }


    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info)
    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
            Vector<DisplayInfo>* configs)
    {
    {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display);
        data.writeStrongBinder(display);
        remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
        remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
        memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
        status_t result = reply.readInt32();
        if (result == NO_ERROR) {
            size_t numConfigs = static_cast<size_t>(reply.readInt32());
            configs->clear();
            configs->resize(numConfigs);
            for (size_t c = 0; c < numConfigs; ++c) {
                memcpy(&(configs->editItemAt(c)),
                        reply.readInplace(sizeof(DisplayInfo)),
                        sizeof(DisplayInfo));
            }
        }
        return result;
    }

    virtual int getActiveConfig(const sp<IBinder>& display)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display);
        remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
        return reply.readInt32();
    }

    virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display);
        data.writeInt32(id);
        remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
        return reply.readInt32();
        return reply.readInt32();
    }
    }


@@ -357,12 +387,33 @@ status_t BnSurfaceComposer::onTransact(
            unblank(display);
            unblank(display);
            return NO_ERROR;
            return NO_ERROR;
        }
        }
        case GET_DISPLAY_INFO: {
        case GET_DISPLAY_CONFIGS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            Vector<DisplayInfo> configs;
            sp<IBinder> display = data.readStrongBinder();
            status_t result = getDisplayConfigs(display, &configs);
            reply->writeInt32(result);
            if (result == NO_ERROR) {
                reply->writeInt32(static_cast<int32_t>(configs.size()));
                for (size_t c = 0; c < configs.size(); ++c) {
                    memcpy(reply->writeInplace(sizeof(DisplayInfo)),
                            &configs[c], sizeof(DisplayInfo));
                }
            }
            return NO_ERROR;
        }
        case GET_ACTIVE_CONFIG: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> display = data.readStrongBinder();
            int id = getActiveConfig(display);
            reply->writeInt32(id);
            return NO_ERROR;
        }
        case SET_ACTIVE_CONFIG: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            DisplayInfo info;
            sp<IBinder> display = data.readStrongBinder();
            sp<IBinder> display = data.readStrongBinder();
            status_t result = getDisplayInfo(display, &info);
            int id = data.readInt32();
            memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
            status_t result = setActiveConfig(display, id);
            reply->writeInt32(result);
            reply->writeInt32(result);
            return NO_ERROR;
            return NO_ERROR;
        }
        }
+29 −3
Original line number Original line Diff line number Diff line
@@ -623,10 +623,36 @@ void SurfaceComposerClient::setDisplayProjection(const sp<IBinder>& token,


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


status_t SurfaceComposerClient::getDisplayInfo(
status_t SurfaceComposerClient::getDisplayConfigs(
        const sp<IBinder>& display, DisplayInfo* info)
        const sp<IBinder>& display, Vector<DisplayInfo>* configs)
{
{
    return ComposerService::getComposerService()->getDisplayInfo(display, info);
    return ComposerService::getComposerService()->getDisplayConfigs(display, configs);
}

status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display,
        DisplayInfo* info) {
    Vector<DisplayInfo> configs;
    status_t result = getDisplayConfigs(display, &configs);
    if (result != NO_ERROR) {
        return result;
    }

    int activeId = getActiveConfig(display);
    if (activeId < 0) {
        ALOGE("No active configuration found");
        return NAME_NOT_FOUND;
    }

    *info = configs[activeId];
    return NO_ERROR;
}

int SurfaceComposerClient::getActiveConfig(const sp<IBinder>& display) {
    return ComposerService::getComposerService()->getActiveConfig(display);
}

status_t SurfaceComposerClient::setActiveConfig(const sp<IBinder>& display, int id) {
    return ComposerService::getComposerService()->setActiveConfig(display, id);
}
}


void SurfaceComposerClient::blankDisplay(const sp<IBinder>& token) {
void SurfaceComposerClient::blankDisplay(const sp<IBinder>& token) {
Loading