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

Commit fb85366f authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: add display id to 1035 backdoor

Bug: 179593619
Test: adb shell service call SurfaceFlinger 1035 i32 <mode id> i64 <display id>
Change-Id: Ifc7fe51989c2315f2c935995fd981ace5260c9c4
parent aa9d25b7
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -5582,9 +5582,24 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r
                const int modeId = data.readInt32();
                mDebugDisplayModeSetByBackdoor = false;

                const auto displayId = getInternalDisplayId();
                const auto displayId = [&]() -> std::optional<PhysicalDisplayId> {
                    uint64_t inputDisplayId = 0;
                    if (data.readUint64(&inputDisplayId) == NO_ERROR) {
                        const auto token = getPhysicalDisplayToken(
                                static_cast<PhysicalDisplayId>(inputDisplayId));
                        if (!token) {
                            ALOGE("No display with id: %" PRIu64, inputDisplayId);
                            return std::nullopt;
                        }

                        return std::make_optional<PhysicalDisplayId>(inputDisplayId);
                    }

                    return getInternalDisplayId();
                }();

                if (!displayId) {
                    ALOGE("No internal display found.");
                    ALOGE("No display found");
                    return NO_ERROR;
                }

@@ -6297,6 +6312,11 @@ status_t SurfaceFlinger::setDesiredDisplayModeSpecsInternal(
                        "Can only set override policy on the primary display");
    LOG_ALWAYS_FATAL_IF(!policy && !overridePolicy, "Can only clear the override policy");

    if (mDebugDisplayModeSetByBackdoor) {
        // ignore this request as mode is overridden by backdoor
        return NO_ERROR;
    }

    if (!display->isPrimary()) {
        // TODO(b/144711714): For non-primary displays we should be able to set an active mode
        // as well. For now, just call directly to initiateModeChange but ideally
@@ -6323,11 +6343,6 @@ status_t SurfaceFlinger::setDesiredDisplayModeSpecsInternal(
        return NO_ERROR;
    }

    if (mDebugDisplayModeSetByBackdoor) {
        // ignore this request as mode is overridden by backdoor
        return NO_ERROR;
    }

    status_t setPolicyResult = overridePolicy
            ? mRefreshRateConfigs->setOverridePolicy(policy)
            : mRefreshRateConfigs->setDisplayManagerPolicy(*policy);