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

Commit a8299895 authored by Sally Qi's avatar Sally Qi Committed by Android (Google) Code Review
Browse files

Merge "Clean up `display_protected` flag." into main

parents e2c01c5f 668e8270
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -1282,18 +1282,11 @@ void Output::updateProtectedContentState() {
    auto& renderEngine = getCompositionEngine().getRenderEngine();
    const bool supportsProtectedContent = renderEngine.supportsProtectedContent();

    bool isProtected;
    if (FlagManager::getInstance().display_protected()) {
        isProtected = outputState.isProtected;
    } else {
        isProtected = outputState.isSecure;
    }

    // We need to set the render surface as protected (DRM) if all the following conditions are met:
    // 1. The display is protected (in legacy, check if the display is secure)
    // 2. Protected content is supported
    // 3. At least one layer has protected content.
    if (isProtected && supportsProtectedContent) {
    if (outputState.isProtected && supportsProtectedContent) {
        auto layers = getOutputLayersOrderedByZ();
        bool needsProtected = std::any_of(layers.begin(), layers.end(), [](auto* layer) {
            return layer->getLayerFE().getCompositionState()->hasProtectedContent &&
@@ -1544,16 +1537,13 @@ std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
                                             BlurRegionsOnly
                                   : LayerFE::ClientCompositionTargetSettings::BlurSetting::
                                             Enabled);
                bool isProtected = supportsProtectedContent;
                if (FlagManager::getInstance().display_protected()) {
                    isProtected = outputState.isProtected && supportsProtectedContent;
                }
                compositionengine::LayerFE::ClientCompositionTargetSettings
                        targetSettings{.clip = clip,
                                       .needsFiltering = layer->needsFiltering() ||
                                               outputState.needsFiltering,
                                       .isSecure = outputState.isSecure,
                                       .isProtected = isProtected,
                                       .isProtected = outputState.isProtected &&
                                               supportsProtectedContent,
                                       .viewport = outputState.layerStackSpace.getContent(),
                                       .dataspace = outputDataspace,
                                       .realContentIsVisible = realContentIsVisible,
+6 −30
Original line number Diff line number Diff line
@@ -4330,11 +4330,7 @@ struct OutputComposeSurfacesTest_HandlesProtectedContent : public OutputComposeS

TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifNoProtectedContentLayers) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer2.mLayerFEState.hasProtectedContent = false;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));
    EXPECT_CALL(*mRenderSurface, isProtected).WillOnce(Return(true));
@@ -4349,11 +4345,7 @@ TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifNoProtectedContentLa

TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifNotEnabled) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer2.mLayerFEState.hasProtectedContent = true;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));

@@ -4376,11 +4368,7 @@ TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifNotEnabled) {

TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifAlreadyEnabledEverywhere) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer2.mLayerFEState.hasProtectedContent = true;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));
    EXPECT_CALL(*mRenderSurface, isProtected).WillOnce(Return(true));
@@ -4394,11 +4382,7 @@ TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifAlreadyEnabledEveryw

TEST_F(OutputComposeSurfacesTest_HandlesProtectedContent, ifAlreadyEnabledInRenderSurface) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer2.mLayerFEState.hasProtectedContent = true;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));
    EXPECT_CALL(*mRenderSurface, isProtected).WillOnce(Return(true));
@@ -5518,11 +5502,7 @@ struct OutputUpdateProtectedContentStateTest : public testing::Test {

TEST_F(OutputUpdateProtectedContentStateTest, ifProtectedContentLayerComposeByHWC) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer1.mLayerFEState.hasProtectedContent = false;
    mLayer2.mLayerFEState.hasProtectedContent = true;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));
@@ -5534,11 +5514,7 @@ TEST_F(OutputUpdateProtectedContentStateTest, ifProtectedContentLayerComposeByHW

TEST_F(OutputUpdateProtectedContentStateTest, ifProtectedContentLayerComposeByClient) {
    SET_FLAG_FOR_TEST(flags::protected_if_client, true);
    if (FlagManager::getInstance().display_protected()) {
    mOutput.mState.isProtected = true;
    } else {
        mOutput.mState.isSecure = true;
    }
    mLayer1.mLayerFEState.hasProtectedContent = false;
    mLayer2.mLayerFEState.hasProtectedContent = true;
    EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(true));
+1 −8
Original line number Diff line number Diff line
@@ -233,15 +233,8 @@ void LayerFE::prepareBufferStateClientComposition(
        // activeBuffer, then we need to return LayerSettings.
        return;
    }
    bool blackOutLayer;
    if (FlagManager::getInstance().display_protected()) {
        blackOutLayer = (mSnapshot->hasProtectedContent && !targetSettings.isProtected) ||
    bool blackOutLayer = (mSnapshot->hasProtectedContent && !targetSettings.isProtected) ||
                (mSnapshot->isSecure && !targetSettings.isSecure);
    } else {
        blackOutLayer = (mSnapshot->hasProtectedContent && !targetSettings.isProtected) ||
                ((mSnapshot->isSecure || mSnapshot->hasProtectedContent) &&
                 !targetSettings.isSecure);
    }
    const bool bufferCanBeUsedAsHwTexture =
            mSnapshot->externalTexture->getUsage() & GraphicBuffer::USAGE_HW_TEXTURE;
    if (blackOutLayer || !bufferCanBeUsedAsHwTexture) {
+0 −2
Original line number Diff line number Diff line
@@ -149,7 +149,6 @@ void FlagManager::dump(std::string& result) const {
    DUMP_ACONFIG_FLAG(detached_mirror);
    DUMP_ACONFIG_FLAG(disable_synthetic_vsync_for_performance);
    DUMP_ACONFIG_FLAG(display_config_error_hal);
    DUMP_ACONFIG_FLAG(display_protected);
    DUMP_ACONFIG_FLAG(dont_skip_on_early_ro);
    DUMP_ACONFIG_FLAG(enable_fro_dependent_features);
    DUMP_ACONFIG_FLAG(enable_layer_command_batching);
@@ -264,7 +263,6 @@ FLAG_MANAGER_ACONFIG_FLAG(use_known_refresh_rate_for_fps_consistency, "")
FLAG_MANAGER_ACONFIG_FLAG(cache_when_source_crop_layer_only_moved,
                          "debug.sf.cache_source_crop_only_moved")
FLAG_MANAGER_ACONFIG_FLAG(enable_fro_dependent_features, "")
FLAG_MANAGER_ACONFIG_FLAG(display_protected, "")
FLAG_MANAGER_ACONFIG_FLAG(fp16_client_target, "debug.sf.fp16_client_target")
FLAG_MANAGER_ACONFIG_FLAG(game_default_frame_rate, "")
FLAG_MANAGER_ACONFIG_FLAG(enable_layer_command_batching, "debug.sf.enable_layer_command_batching")
+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ public:
    bool detached_mirror() const;
    bool disable_synthetic_vsync_for_performance() const;
    bool display_config_error_hal() const;
    bool display_protected() const;
    bool dont_skip_on_early_ro() const;
    bool enable_fro_dependent_features() const;
    bool enable_layer_command_batching() const;
Loading