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

Commit 611a65d5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix "Abnormal while playing netflix in PIP mode"" into main

parents fc59b33a 45099663
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1276,7 +1276,9 @@ void Output::updateProtectedContentState() {
    if (isProtected && supportsProtectedContent) {
        auto layers = getOutputLayersOrderedByZ();
        bool needsProtected = std::any_of(layers.begin(), layers.end(), [](auto* layer) {
            return layer->getLayerFE().getCompositionState()->hasProtectedContent;
            return layer->getLayerFE().getCompositionState()->hasProtectedContent &&
                    (!FlagManager::getInstance().protected_if_client() ||
                     layer->requiresClientComposition());
        });
        if (needsProtected != mRenderSurface->isProtected()) {
            mRenderSurface->setProtected(needsProtected);
+79 −0
Original line number Diff line number Diff line
@@ -4051,6 +4051,7 @@ struct OutputComposeSurfacesTest_HandlesProtectedContent : public OutputComposeS
        Layer() {
            EXPECT_CALL(*mLayerFE, getCompositionState()).WillRepeatedly(Return(&mLayerFEState));
            EXPECT_CALL(mOutputLayer, getLayerFE()).WillRepeatedly(ReturnRef(*mLayerFE));
            EXPECT_CALL(mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
        }

        StrictMock<mock::OutputLayer> mOutputLayer;
@@ -4091,6 +4092,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 {
@@ -4109,6 +4111,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 {
@@ -4135,6 +4138,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 {
@@ -4152,6 +4156,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 {
@@ -5096,5 +5101,79 @@ TEST_F(OutputPresentFrameAndReleaseLayersAsyncTest, calledForOneFrame) {
    mOutput->present(mRefreshArgs);
}

/*
 * Output::updateProtectedContentState()
 */

struct OutputUpdateProtectedContentStateTest : public testing::Test {
    struct OutputPartialMock : public OutputPartialMockBase {
        // Sets up the helper functions called by the function under test to use
        // mock implementations.
        MOCK_CONST_METHOD0(getCompositionEngine, const CompositionEngine&());
    };

    OutputUpdateProtectedContentStateTest() {
        mOutput.setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(mRenderSurface));
        EXPECT_CALL(mOutput, getCompositionEngine()).WillRepeatedly(ReturnRef(mCompositionEngine));
        EXPECT_CALL(mCompositionEngine, getRenderEngine()).WillRepeatedly(ReturnRef(mRenderEngine));
        EXPECT_CALL(mOutput, getOutputLayerCount()).WillRepeatedly(Return(2u));
        EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(0))
                .WillRepeatedly(Return(&mLayer1.mOutputLayer));
        EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(1))
                .WillRepeatedly(Return(&mLayer2.mOutputLayer));
    }

    struct Layer {
        Layer() {
            EXPECT_CALL(*mLayerFE, getCompositionState()).WillRepeatedly(Return(&mLayerFEState));
            EXPECT_CALL(mOutputLayer, getLayerFE()).WillRepeatedly(ReturnRef(*mLayerFE));
        }

        StrictMock<mock::OutputLayer> mOutputLayer;
        sp<StrictMock<mock::LayerFE>> mLayerFE = sp<StrictMock<mock::LayerFE>>::make();
        LayerFECompositionState mLayerFEState;
    };

    mock::RenderSurface* mRenderSurface = new StrictMock<mock::RenderSurface>();
    StrictMock<OutputPartialMock> mOutput;
    StrictMock<mock::CompositionEngine> mCompositionEngine;
    StrictMock<renderengine::mock::RenderEngine> mRenderEngine;
    Layer mLayer1;
    Layer mLayer2;
};

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));
    EXPECT_CALL(*mRenderSurface, isProtected).WillOnce(Return(false));
    EXPECT_CALL(mLayer1.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
    EXPECT_CALL(mLayer2.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(false));
    mOutput.updateProtectedContentState();
}

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));
    EXPECT_CALL(*mRenderSurface, isProtected).WillOnce(Return(false));
    EXPECT_CALL(*mRenderSurface, setProtected(true));
    EXPECT_CALL(mLayer1.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
    EXPECT_CALL(mLayer2.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
    mOutput.updateProtectedContentState();
}

} // namespace
} // namespace android::compositionengine
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ void FlagManager::dump(std::string& result) const {
    DUMP_READ_ONLY_FLAG(renderable_buffer_usage);
    DUMP_READ_ONLY_FLAG(restore_blur_step);
    DUMP_READ_ONLY_FLAG(dont_skip_on_early_ro);
    DUMP_READ_ONLY_FLAG(protected_if_client);
#undef DUMP_READ_ONLY_FLAG
#undef DUMP_SERVER_FLAG
#undef DUMP_FLAG_INTERVAL
@@ -210,6 +211,7 @@ FLAG_MANAGER_READ_ONLY_FLAG(vulkan_renderengine, "debug.renderengine.vulkan")
FLAG_MANAGER_READ_ONLY_FLAG(renderable_buffer_usage, "")
FLAG_MANAGER_READ_ONLY_FLAG(restore_blur_step, "debug.renderengine.restore_blur_step")
FLAG_MANAGER_READ_ONLY_FLAG(dont_skip_on_early_ro, "")
FLAG_MANAGER_READ_ONLY_FLAG(protected_if_client, "")

/// Trunk stable server flags ///
FLAG_MANAGER_SERVER_FLAG(refresh_rate_overlay_on_external_display, "")
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public:
    bool renderable_buffer_usage() const;
    bool restore_blur_step() const;
    bool dont_skip_on_early_ro() const;
    bool protected_if_client() const;

protected:
    // overridden for unit tests
+7 −0
Original line number Diff line number Diff line
@@ -189,6 +189,13 @@ flag {
  namespace: "core_graphics"
  description: "This flag is guarding the behaviour where SurfaceFlinger is trying to opportunistically present a frame when the configuration change from late to early"
  bug: "273702768"
}

flag {
  name: "protected_if_client"
  namespace: "core_graphics"
  description: "Only set the RenderSurface to protected if protected layers are in client composition."
  bug: "307674749"
  is_fixed_read_only: true
  metadata {
    purpose: PURPOSE_BUGFIX