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

Commit 838de062 authored by Ady Abraham's avatar Ady Abraham
Browse files

SurfaceFlinger: add setAllowedDisplayConfigs

Add an API to ISurfaceComposer to set allowed display configurations.
This API is expected to be called by DisplayManager depends on the
current policy in place. Once setAllowedDisplayConfigs is called,
SF can only set a new display config if it is part of the allowed
configurations list.

Test: call setAllowedDisplayConfigs() from backdoor and
      observe config change.
Bug: 122905403
Change-Id: I1d0a3649bbe7a08efeb72dc270f0b2df330b021c
parent 705fad86
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -806,6 +806,32 @@ public:
        }
        return error;
    }

    virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
                                              const std::vector<int32_t>& allowedConfigs) {
        Parcel data, reply;
        status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (result != NO_ERROR) {
            ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
            return result;
        }
        result = data.writeStrongBinder(displayToken);
        if (result != NO_ERROR) {
            ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
            return result;
        }
        result = data.writeInt32Vector(allowedConfigs);
        if (result != NO_ERROR) {
            ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
            return result;
        }
        result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
        if (result != NO_ERROR) {
            ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
            return result;
        }
        return reply.readInt32();
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -1317,6 +1343,15 @@ status_t BnSurfaceComposer::onTransact(
            }
            return removeRegionSamplingListener(listener);
        }
        case SET_ALLOWED_DISPLAY_CONFIGS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> displayToken = data.readStrongBinder();
            std::vector<int32_t> allowedConfigs;
            data.readInt32Vector(&allowedConfigs);
            status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
            reply->writeInt32(result);
            return result;
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+6 −0
Original line number Diff line number Diff line
@@ -1382,6 +1382,12 @@ status_t SurfaceComposerClient::setActiveConfig(const sp<IBinder>& display, int
    return ComposerService::getComposerService()->setActiveConfig(display, id);
}

status_t SurfaceComposerClient::setAllowedDisplayConfigs(
        const sp<IBinder>& displayToken, const std::vector<int32_t>& allowedConfigs) {
    return ComposerService::getComposerService()->setAllowedDisplayConfigs(displayToken,
                                                                           allowedConfigs);
}

status_t SurfaceComposerClient::getDisplayColorModes(const sp<IBinder>& display,
        Vector<ColorMode>* outColorModes) {
    return ComposerService::getComposerService()->getDisplayColorModes(display, outColorModes);
+9 −1
Original line number Diff line number Diff line
@@ -359,6 +359,14 @@ public:
     * Removes a listener that was streaming median luma updates from SurfaceFlinger.
     */
    virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) = 0;

    /*
     * Sets the allowed display configurations to be used.
     * The allowedConfigs in a vector of indexes corresponding to the configurations
     * returned from getDisplayConfigs().
     */
    virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
                                              const std::vector<int32_t>& allowedConfigs) = 0;
};

// ----------------------------------------------------------------------------
@@ -406,7 +414,7 @@ public:
        GET_PHYSICAL_DISPLAY_IDS,
        ADD_REGION_SAMPLING_LISTENER,
        REMOVE_REGION_SAMPLING_LISTENER,

        SET_ALLOWED_DISPLAY_CONFIGS,
        // Always append new enum to the end.
    };

+6 −0
Original line number Diff line number Diff line
@@ -111,6 +111,12 @@ public:
    // returned by getDisplayInfo
    static status_t setActiveConfig(const sp<IBinder>& display, int id);

    // Sets the allowed display configurations to be used.
    // The allowedConfigs in a vector of indexes corresponding to the configurations
    // returned from getDisplayConfigs().
    static status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
                                             const std::vector<int32_t>& allowedConfigs);

    // Gets the list of supported color modes for the given display
    static status_t getDisplayColorModes(const sp<IBinder>& display,
            Vector<ui::ColorMode>* outColorModes);
+4 −0
Original line number Diff line number Diff line
@@ -678,6 +678,10 @@ public:
            const sp<IRegionSamplingListener>& /*listener*/) override {
        return NO_ERROR;
    }
    status_t setAllowedDisplayConfigs(const sp<IBinder>& /*displayToken*/,
                                      const std::vector<int32_t>& /*allowedConfigs*/) override {
        return NO_ERROR;
    }

protected:
    IBinder* onAsBinder() override { return nullptr; }
Loading