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

Commit 7defaf37 authored by Kriti Dang's avatar Kriti Dang
Browse files

Add boot time display mode to native framework

Bug: 203520442
Test: m
Test: atest libsurfaceflinger_unittest
Test: atest libgui_test

Change-Id: I61ad0c75576a4e1ee54d657e6906bc5d6c10afaf
parent 1ca1c61d
Loading
Loading
Loading
Loading
+138 −0
Original line number Original line Diff line number Diff line
@@ -428,6 +428,94 @@ public:
        return static_cast<status_t>(reply.readInt32());
        return static_cast<status_t>(reply.readInt32());
    }
    }


    // TODO(b/213909104) : Add unit tests to verify surface flinger boot time APIs
    status_t getBootDisplayModeSupport(bool* outSupport) const override {
        Parcel data, reply;
        status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (error != NO_ERROR) {
            ALOGE("getBootDisplayModeSupport: failed to write interface token: %d", error);
            return error;
        }
        error = remote()->transact(BnSurfaceComposer::GET_BOOT_DISPLAY_MODE_SUPPORT, data, &reply);
        if (error != NO_ERROR) {
            ALOGE("getBootDisplayModeSupport: failed to transact: %d", error);
            return error;
        }
        bool support;
        error = reply.readBool(&support);
        if (error != NO_ERROR) {
            ALOGE("getBootDisplayModeSupport: failed to read support: %d", error);
            return error;
        }
        *outSupport = support;
        return NO_ERROR;
    }

    status_t setBootDisplayMode(const sp<IBinder>& display,
                                ui::DisplayModeId displayModeId) override {
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (result != NO_ERROR) {
            ALOGE("setBootDisplayMode failed to writeInterfaceToken: %d", result);
            return result;
        }
        result = data.writeStrongBinder(display);
        if (result != NO_ERROR) {
            ALOGE("setBootDisplayMode failed to writeStrongBinder: %d", result);
            return result;
        }
        result = data.writeInt32(displayModeId);
        if (result != NO_ERROR) {
            ALOGE("setBootDisplayMode failed to writeIint32: %d", result);
            return result;
        }
        result = remote()->transact(BnSurfaceComposer::SET_BOOT_DISPLAY_MODE, data, &reply);
        if (result != NO_ERROR) {
            ALOGE("setBootDisplayMode failed to transact: %d", result);
        }
        return result;
    }

    status_t clearBootDisplayMode(const sp<IBinder>& display) override {
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (result != NO_ERROR) {
            ALOGE("clearBootDisplayMode failed to writeInterfaceToken: %d", result);
            return result;
        }
        result = data.writeStrongBinder(display);
        if (result != NO_ERROR) {
            ALOGE("clearBootDisplayMode failed to writeStrongBinder: %d", result);
            return result;
        }
        result = remote()->transact(BnSurfaceComposer::CLEAR_BOOT_DISPLAY_MODE, data, &reply);
        if (result != NO_ERROR) {
            ALOGE("clearBootDisplayMode failed to transact: %d", result);
        }
        return result;
    }

    status_t getPreferredBootDisplayMode(const sp<IBinder>& display,
                                         ui::DisplayModeId* displayModeId) override {
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (result != NO_ERROR) {
            ALOGE("getPreferredBootDisplayMode failed to writeInterfaceToken: %d", result);
            return result;
        }
        result = data.writeStrongBinder(display);
        if (result != NO_ERROR) {
            ALOGE("getPreferredBootDisplayMode failed to writeStrongBinder: %d", result);
            return result;
        }
        result = remote()->transact(BnSurfaceComposer::GET_PREFERRED_BOOT_DISPLAY_MODE, data,
                                    &reply);
        if (result == NO_ERROR) {
            reply.writeInt32(*displayModeId);
        }
        return result;
    }

    void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override {
    void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override {
        Parcel data, reply;
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
@@ -1521,6 +1609,56 @@ status_t BnSurfaceComposer::onTransact(
            result = reply->writeInt32(result);
            result = reply->writeInt32(result);
            return result;
            return result;
        }
        }
        case GET_BOOT_DISPLAY_MODE_SUPPORT: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            bool support = false;
            status_t result = getBootDisplayModeSupport(&support);
            if (result == NO_ERROR) {
                reply->writeBool(support);
            }
            return result;
        }
        case SET_BOOT_DISPLAY_MODE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> display = nullptr;
            status_t result = data.readStrongBinder(&display);
            if (result != NO_ERROR) {
                ALOGE("setBootDisplayMode failed to readStrongBinder: %d", result);
                return result;
            }
            ui::DisplayModeId displayModeId;
            result = data.readInt32(&displayModeId);
            if (result != NO_ERROR) {
                ALOGE("setBootDisplayMode failed to readInt32: %d", result);
                return result;
            }
            return setBootDisplayMode(display, displayModeId);
        }
        case CLEAR_BOOT_DISPLAY_MODE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> display = nullptr;
            status_t result = data.readStrongBinder(&display);
            if (result != NO_ERROR) {
                ALOGE("clearBootDisplayMode failed to readStrongBinder: %d", result);
                return result;
            }
            return clearBootDisplayMode(display);
        }
        case GET_PREFERRED_BOOT_DISPLAY_MODE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> display = nullptr;
            status_t result = data.readStrongBinder(&display);
            if (result != NO_ERROR) {
                ALOGE("getPreferredBootDisplayMode failed to readStrongBinder: %d", result);
                return result;
            }
            ui::DisplayModeId displayModeId;
            result = getPreferredBootDisplayMode(display, &displayModeId);
            if (result == NO_ERROR) {
                reply->writeInt32(displayModeId);
            }
            return result;
        }
        case SET_AUTO_LOW_LATENCY_MODE: {
        case SET_AUTO_LOW_LATENCY_MODE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> display = nullptr;
            sp<IBinder> display = nullptr;
+19 −0
Original line number Original line Diff line number Diff line
@@ -2075,6 +2075,25 @@ status_t SurfaceComposerClient::setActiveColorMode(const sp<IBinder>& display,
    return ComposerService::getComposerService()->setActiveColorMode(display, colorMode);
    return ComposerService::getComposerService()->setActiveColorMode(display, colorMode);
}
}


status_t SurfaceComposerClient::getBootDisplayModeSupport(bool* support) {
    return ComposerService::getComposerService()->getBootDisplayModeSupport(support);
}

status_t SurfaceComposerClient::setBootDisplayMode(const sp<IBinder>& display,
                                                   ui::DisplayModeId displayModeId) {
    return ComposerService::getComposerService()->setBootDisplayMode(display, displayModeId);
}

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

status_t SurfaceComposerClient::getPreferredBootDisplayMode(const sp<IBinder>& display,
                                                            ui::DisplayModeId* displayModeId) {
    return ComposerService::getComposerService()->getPreferredBootDisplayMode(display,
                                                                              displayModeId);
}

void SurfaceComposerClient::setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
void SurfaceComposerClient::setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
    ComposerService::getComposerService()->setAutoLowLatencyMode(display, on);
    ComposerService::getComposerService()->setAutoLowLatencyMode(display, on);
}
}
+33 −0
Original line number Original line Diff line number Diff line
@@ -223,6 +223,35 @@ public:
    virtual status_t setActiveColorMode(const sp<IBinder>& display,
    virtual status_t setActiveColorMode(const sp<IBinder>& display,
            ui::ColorMode colorMode) = 0;
            ui::ColorMode colorMode) = 0;


    /**
     * Sets the user-preferred display mode that a device should boot in.
     */
    virtual status_t setBootDisplayMode(const sp<IBinder>& display, ui::DisplayModeId) = 0;

    /**
     * Clears the user-preferred display mode. The device should now boot in system preferred
     * display mode.
     */
    virtual status_t clearBootDisplayMode(const sp<IBinder>& display) = 0;

    /**
     * Gets the display mode in which the device boots if there is no user-preferred display mode.
     */
    virtual status_t getPreferredBootDisplayMode(const sp<IBinder>& display,
                                                 ui::DisplayModeId*) = 0;

    /**
     * Gets whether boot time display mode operations are supported on the device.
     *
     * outSupport
     *      An output parameter for whether boot time display mode operations are supported.
     *
     * Returns NO_ERROR upon success. Otherwise,
     *      NAME_NOT_FOUND if the display is invalid, or
     *      BAD_VALUE      if the output parameter is invalid.
     */
    virtual status_t getBootDisplayModeSupport(bool* outSupport) const = 0;

    /**
    /**
     * Switches Auto Low Latency Mode on/off on the connected display, if it is
     * Switches Auto Low Latency Mode on/off on the connected display, if it is
     * available. This should only be called if the display supports Auto Low
     * available. This should only be called if the display supports Auto Low
@@ -645,6 +674,10 @@ public:
        REMOVE_WINDOW_INFOS_LISTENER,
        REMOVE_WINDOW_INFOS_LISTENER,
        GET_PRIMARY_PHYSICAL_DISPLAY_ID,
        GET_PRIMARY_PHYSICAL_DISPLAY_ID,
        GET_DISPLAY_DECORATION_SUPPORT,
        GET_DISPLAY_DECORATION_SUPPORT,
        GET_BOOT_DISPLAY_MODE_SUPPORT,
        SET_BOOT_DISPLAY_MODE,
        CLEAR_BOOT_DISPLAY_MODE,
        GET_PREFERRED_BOOT_DISPLAY_MODE,
        // Always append new enum to the end.
        // Always append new enum to the end.
    };
    };


+9 −0
Original line number Original line Diff line number Diff line
@@ -167,6 +167,15 @@ public:
    static status_t setActiveColorMode(const sp<IBinder>& display,
    static status_t setActiveColorMode(const sp<IBinder>& display,
            ui::ColorMode colorMode);
            ui::ColorMode colorMode);


    // Gets if boot display mode operations are supported on a device
    static status_t getBootDisplayModeSupport(bool* support);
    // Sets the user-preferred display mode that a device should boot in
    static status_t setBootDisplayMode(const sp<IBinder>& display, ui::DisplayModeId);
    // Clears the user-preferred display mode
    static status_t clearBootDisplayMode(const sp<IBinder>& display);
    // Gets the display mode in which the device boots if there is no user-preferred display mode
    static status_t getPreferredBootDisplayMode(const sp<IBinder>& display, ui::DisplayModeId*);

    // Switches on/off Auto Low Latency Mode on the connected display. This should only be
    // Switches on/off Auto Low Latency Mode on the connected display. This should only be
    // called if the connected display supports Auto Low Latency Mode as reported by
    // called if the connected display supports Auto Low Latency Mode as reported by
    // #getAutoLowLatencyModeSupport
    // #getAutoLowLatencyModeSupport
+9 −0
Original line number Original line Diff line number Diff line
@@ -755,6 +755,15 @@ public:
    }
    }
    status_t setActiveColorMode(const sp<IBinder>& /*display*/,
    status_t setActiveColorMode(const sp<IBinder>& /*display*/,
        ColorMode /*colorMode*/) override { return NO_ERROR; }
        ColorMode /*colorMode*/) override { return NO_ERROR; }
    status_t getBootDisplayModeSupport(bool* /*outSupport*/) const override { return NO_ERROR; }
    status_t setBootDisplayMode(const sp<IBinder>& /*display*/, ui::DisplayModeId /*id*/) override {
        return NO_ERROR;
    }
    status_t clearBootDisplayMode(const sp<IBinder>& /*display*/) override { return NO_ERROR; }
    status_t getPreferredBootDisplayMode(const sp<IBinder>& /*display*/,
                                         ui::DisplayModeId* /*id*/) override {
        return NO_ERROR;
    }
    void setAutoLowLatencyMode(const sp<IBinder>& /*display*/, bool /*on*/) override {}
    void setAutoLowLatencyMode(const sp<IBinder>& /*display*/, bool /*on*/) override {}
    void setGameContentType(const sp<IBinder>& /*display*/, bool /*on*/) override {}
    void setGameContentType(const sp<IBinder>& /*display*/, bool /*on*/) override {}


Loading