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

Commit 07e5470d authored by Ady Abraham's avatar Ady Abraham
Browse files

SurfaceFlinger: add a backdoor to override DisplayManager policy

Added a new backdoor, for debugging purposes, to override DisplayManager
policy and allow SurfaceFlinger to freely switch refresh rates.

To override DisplayManager policy:
	adb shell service call SurfaceFlinger 1036 i32 1
To undo the override
	adb shell service call SurfaceFlinger 1036 i32 0

Bug: 152411921
Test: override policy by backdoor and observe dumpsys SurfaceFlinger
Change-Id: I14bb4722986f6df9100959eea66e5e3a3fa6f953
parent 89089c9a
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -4398,11 +4398,19 @@ void SurfaceFlinger::dumpVSync(std::string& result) const {

    scheduler::RefreshRateConfigs::Policy policy = mRefreshRateConfigs->getDisplayManagerPolicy();
    StringAppendF(&result,
                  "DesiredDisplayConfigSpecs: default config ID: %d"
                  "DesiredDisplayConfigSpecs (DisplayManager): default config ID: %d"
                  ", min: %.2f Hz, max: %.2f Hz",
                  policy.defaultConfig.value(), policy.minRefreshRate, policy.maxRefreshRate);
    StringAppendF(&result, "(config override by backdoor: %s)\n\n",
                  mDebugDisplayConfigSetByBackdoor ? "yes" : "no");
    scheduler::RefreshRateConfigs::Policy currentPolicy = mRefreshRateConfigs->getCurrentPolicy();
    if (currentPolicy != policy) {
        StringAppendF(&result,
                      "DesiredDisplayConfigSpecs (Override): default config ID: %d"
                      ", min: %.2f Hz, max: %.2f Hz\n\n",
                      currentPolicy.defaultConfig.value(), currentPolicy.minRefreshRate,
                      currentPolicy.maxRefreshRate);
    }

    mScheduler->dump(mAppConnectionHandle, result);
    mScheduler->getPrimaryDispSync().dump(result);
@@ -4927,9 +4935,9 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) {
        code == IBinder::SYSPROPS_TRANSACTION) {
        return OK;
    }
    // Numbers from 1000 to 1034 are currently used for backdoors. The code
    // Numbers from 1000 to 1036 are currently used for backdoors. The code
    // in onTransact verifies that the user is root, and has access to use SF.
    if (code >= 1000 && code <= 1035) {
    if (code >= 1000 && code <= 1036) {
        ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
        return OK;
    }
@@ -5258,6 +5266,18 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r
                }
                return NO_ERROR;
            }
            case 1036: {
                if (data.readInt32() > 0) {
                    status_t result =
                            acquireFrameRateFlexibilityToken(&mDebugFrameRateFlexibilityToken);
                    if (result != NO_ERROR) {
                        return result;
                    }
                } else {
                    mDebugFrameRateFlexibilityToken = nullptr;
                }
                return NO_ERROR;
            }
        }
    }
    return err;
+2 −0
Original line number Diff line number Diff line
@@ -1262,6 +1262,8 @@ private:
    bool inputDirty() { return mInputDirty; }

    int mFrameRateFlexibilityTokenCount = 0;

    sp<IBinder> mDebugFrameRateFlexibilityToken;
};

} // namespace android