Remove SurfaceInterceptor and surfacereplayer
Both are no longer used and thus obsolete.
Ignore-AOSP-First: depends on other changes on master
Bug: 241285477
Test: atest libgui_test libsurfaceflinger_unittest SurfaceFlinger_test
Change-Id: I1858826b9eca27b355edb4236510e3aad1ddb399
diff --git a/services/surfaceflinger/tests/Android.bp b/services/surfaceflinger/tests/Android.bp
index 13ce65d..71b1c0e 100644
--- a/services/surfaceflinger/tests/Android.bp
+++ b/services/surfaceflinger/tests/Android.bp
@@ -56,13 +56,11 @@
"SetFrameRateOverride_test.cpp",
"SetGeometry_test.cpp",
"Stress_test.cpp",
- "SurfaceInterceptor_test.cpp",
"VirtualDisplay_test.cpp",
"WindowInfosListener_test.cpp",
],
data: ["SurfaceFlinger_test.filter"],
static_libs: [
- "libtrace_proto",
"liblayers_proto",
"android.hardware.graphics.composer@2.1",
],
diff --git a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp
deleted file mode 100644
index 7166d41..0000000
--- a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp
+++ /dev/null
@@ -1,961 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wconversion"
-#pragma clang diagnostic ignored "-Wextra"
-
-#include <android-base/stringprintf.h>
-#include <frameworks/native/cmds/surfacereplayer/proto/src/trace.pb.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <gtest/gtest.h>
-#include <gui/ISurfaceComposer.h>
-#include <gui/LayerState.h>
-#include <gui/Surface.h>
-#include <gui/SurfaceComposerClient.h>
-#include <private/gui/ComposerService.h>
-#include <ui/DisplayMode.h>
-
-#include <fstream>
-#include <random>
-#include <thread>
-
-namespace android {
-
-using Transaction = SurfaceComposerClient::Transaction;
-using SurfaceChange = surfaceflinger::SurfaceChange;
-using Trace = surfaceflinger::Trace;
-using Increment = surfaceflinger::Increment;
-
-constexpr uint32_t BUFFER_UPDATES = 18;
-constexpr uint32_t LAYER_UPDATE = INT_MAX - 2;
-constexpr uint32_t SIZE_UPDATE = 134;
-constexpr uint32_t STACK_UPDATE = 1;
-constexpr int32_t RELATIVE_Z = 42;
-constexpr float ALPHA_UPDATE = 0.29f;
-constexpr float CORNER_RADIUS_UPDATE = 0.2f;
-constexpr int BACKGROUND_BLUR_RADIUS_UPDATE = 24;
-constexpr float POSITION_UPDATE = 121;
-const Rect CROP_UPDATE(16, 16, 32, 32);
-const float SHADOW_RADIUS_UPDATE = 35.0f;
-std::vector<BlurRegion> BLUR_REGIONS_UPDATE;
-
-const String8 DISPLAY_NAME("SurfaceInterceptor Display Test");
-constexpr auto TEST_BG_SURFACE_NAME = "BG Interceptor Test Surface";
-constexpr auto TEST_FG_SURFACE_NAME = "FG Interceptor Test Surface";
-constexpr auto LAYER_NAME = "Layer Create and Delete Test";
-
-constexpr auto DEFAULT_FILENAME = "/data/misc/wmtrace/transaction_trace.winscope";
-
-// Fill an RGBA_8888 formatted surface with a single color.
-static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, uint8_t b) {
- ANativeWindow_Buffer outBuffer;
- sp<Surface> s = sc->getSurface();
- ASSERT_TRUE(s != nullptr);
- ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, nullptr));
- uint8_t* img = reinterpret_cast<uint8_t*>(outBuffer.bits);
- for (int y = 0; y < outBuffer.height; y++) {
- for (int x = 0; x < outBuffer.width; x++) {
- uint8_t* pixel = img + (4 * (y*outBuffer.stride + x));
- pixel[0] = r;
- pixel[1] = g;
- pixel[2] = b;
- pixel[3] = 255;
- }
- }
- ASSERT_EQ(NO_ERROR, s->unlockAndPost());
-}
-
-static status_t readProtoFile(Trace* trace) {
- status_t err = NO_ERROR;
-
- int fd = open(DEFAULT_FILENAME, O_RDONLY);
- {
- google::protobuf::io::FileInputStream f(fd);
- if (fd && !trace->ParseFromZeroCopyStream(&f)) {
- err = PERMISSION_DENIED;
- }
- }
- close(fd);
-
- return err;
-}
-
-static void enableInterceptor() {
- system("service call SurfaceFlinger 1020 i32 1 > /dev/null");
-}
-
-static void disableInterceptor() {
- system("service call SurfaceFlinger 1020 i32 0 > /dev/null");
-}
-
-std::string getUniqueName(const std::string& name, const Increment& increment) {
- return base::StringPrintf("%s#%d", name.c_str(), increment.surface_creation().id());
-}
-
-int32_t getSurfaceId(const Trace& capturedTrace, const std::string& surfaceName) {
- int32_t layerId = 0;
- for (const auto& increment : capturedTrace.increment()) {
- if (increment.increment_case() == increment.kSurfaceCreation) {
- if (increment.surface_creation().name() == getUniqueName(surfaceName, increment)) {
- layerId = increment.surface_creation().id();
- }
- }
- }
- return layerId;
-}
-
-int32_t getDisplayId(const Trace& capturedTrace, const std::string& displayName) {
- int32_t displayId = 0;
- for (const auto& increment : capturedTrace.increment()) {
- if (increment.increment_case() == increment.kDisplayCreation) {
- if (increment.display_creation().name() == displayName) {
- displayId = increment.display_creation().id();
- break;
- }
- }
- }
- return displayId;
-}
-
-class SurfaceInterceptorTest : public ::testing::Test {
-protected:
- void SetUp() override {
- // Allow SurfaceInterceptor write to /data
- system("setenforce 0");
-
- mComposerClient = sp<SurfaceComposerClient>::make();
- ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
- GTEST_SKIP();
- }
-
- void TearDown() override {
- mComposerClient->dispose();
- mBGSurfaceControl.clear();
- mFGSurfaceControl.clear();
- mComposerClient.clear();
- system("setenforce 1");
- }
-
- sp<SurfaceComposerClient> mComposerClient;
- sp<SurfaceControl> mBGSurfaceControl;
- sp<SurfaceControl> mFGSurfaceControl;
- int32_t mBGLayerId;
- int32_t mFGLayerId;
-
-public:
- using TestTransactionAction = void (SurfaceInterceptorTest::*)(Transaction&);
- using TestAction = void (SurfaceInterceptorTest::*)();
- using TestBooleanVerification = bool (SurfaceInterceptorTest::*)(const Trace&);
- using TestVerification = void (SurfaceInterceptorTest::*)(const Trace&);
-
- void setupBackgroundSurface();
- void preProcessTrace(const Trace& trace);
-
- // captureTest will enable SurfaceInterceptor, setup background surface,
- // disable SurfaceInterceptor, collect the trace and process the trace for
- // id of background surface before further verification.
- void captureTest(TestTransactionAction action, TestBooleanVerification verification);
- void captureTest(TestTransactionAction action, SurfaceChange::SurfaceChangeCase changeCase);
- void captureTest(TestTransactionAction action, Increment::IncrementCase incrementCase);
- void captureTest(TestAction action, TestBooleanVerification verification);
- void captureTest(TestAction action, TestVerification verification);
- void runInTransaction(TestTransactionAction action);
-
- // Verification of changes to a surface
- bool positionUpdateFound(const SurfaceChange& change, bool foundPosition);
- bool sizeUpdateFound(const SurfaceChange& change, bool foundSize);
- bool alphaUpdateFound(const SurfaceChange& change, bool foundAlpha);
- bool layerUpdateFound(const SurfaceChange& change, bool foundLayer);
- bool cropUpdateFound(const SurfaceChange& change, bool foundCrop);
- bool cornerRadiusUpdateFound(const SurfaceChange& change, bool foundCornerRadius);
- bool backgroundBlurRadiusUpdateFound(const SurfaceChange& change,
- bool foundBackgroundBlurRadius);
- bool blurRegionsUpdateFound(const SurfaceChange& change, bool foundBlurRegions);
- bool matrixUpdateFound(const SurfaceChange& change, bool foundMatrix);
- bool scalingModeUpdateFound(const SurfaceChange& change, bool foundScalingMode);
- bool transparentRegionHintUpdateFound(const SurfaceChange& change, bool foundTransparentRegion);
- bool layerStackUpdateFound(const SurfaceChange& change, bool foundLayerStack);
- bool hiddenFlagUpdateFound(const SurfaceChange& change, bool foundHiddenFlag);
- bool opaqueFlagUpdateFound(const SurfaceChange& change, bool foundOpaqueFlag);
- bool secureFlagUpdateFound(const SurfaceChange& change, bool foundSecureFlag);
- bool reparentUpdateFound(const SurfaceChange& change, bool found);
- bool relativeParentUpdateFound(const SurfaceChange& change, bool found);
- bool shadowRadiusUpdateFound(const SurfaceChange& change, bool found);
- bool trustedOverlayUpdateFound(const SurfaceChange& change, bool found);
- bool surfaceUpdateFound(const Trace& trace, SurfaceChange::SurfaceChangeCase changeCase);
-
- // Find all of the updates in the single trace
- void assertAllUpdatesFound(const Trace& trace);
-
- // Verification of creation and deletion of a surface
- bool surfaceCreationFound(const Increment& increment, bool foundSurface);
- bool surfaceDeletionFound(const Increment& increment, const int32_t targetId,
- bool foundSurface);
- bool displayCreationFound(const Increment& increment, bool foundDisplay);
- bool displayDeletionFound(const Increment& increment, const int32_t targetId,
- bool foundDisplay);
- bool singleIncrementFound(const Trace& trace, Increment::IncrementCase incrementCase);
-
- // Verification of buffer updates
- bool bufferUpdatesFound(const Trace& trace);
-
- // Perform each of the possible changes to a surface
- void positionUpdate(Transaction&);
- void sizeUpdate(Transaction&);
- void alphaUpdate(Transaction&);
- void layerUpdate(Transaction&);
- void cropUpdate(Transaction&);
- void cornerRadiusUpdate(Transaction&);
- void backgroundBlurRadiusUpdate(Transaction&);
- void blurRegionsUpdate(Transaction&);
- void matrixUpdate(Transaction&);
- void transparentRegionHintUpdate(Transaction&);
- void layerStackUpdate(Transaction&);
- void hiddenFlagUpdate(Transaction&);
- void opaqueFlagUpdate(Transaction&);
- void secureFlagUpdate(Transaction&);
- void reparentUpdate(Transaction&);
- void relativeParentUpdate(Transaction&);
- void shadowRadiusUpdate(Transaction&);
- void trustedOverlayUpdate(Transaction&);
- void surfaceCreation(Transaction&);
- void displayCreation(Transaction&);
- void displayDeletion(Transaction&);
-
- void nBufferUpdates();
- void runAllUpdates();
-
-private:
- void captureInTransaction(TestTransactionAction action, Trace*);
- void capture(TestAction action, Trace*);
-};
-
-void SurfaceInterceptorTest::captureInTransaction(TestTransactionAction action, Trace* outTrace) {
- enableInterceptor();
- setupBackgroundSurface();
- runInTransaction(action);
- disableInterceptor();
- ASSERT_EQ(NO_ERROR, readProtoFile(outTrace));
- preProcessTrace(*outTrace);
-}
-
-void SurfaceInterceptorTest::capture(TestAction action, Trace* outTrace) {
- enableInterceptor();
- setupBackgroundSurface();
- (this->*action)();
- disableInterceptor();
- ASSERT_EQ(NO_ERROR, readProtoFile(outTrace));
- preProcessTrace(*outTrace);
-}
-
-void SurfaceInterceptorTest::setupBackgroundSurface() {
- const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
- ASSERT_FALSE(ids.empty());
- const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
- ASSERT_FALSE(display == nullptr);
-
- ui::DisplayMode mode;
- ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode));
- const ui::Size& resolution = mode.resolution;
-
- // Background surface
- mBGSurfaceControl =
- mComposerClient->createSurface(String8(TEST_BG_SURFACE_NAME), resolution.getWidth(),
- resolution.getHeight(), PIXEL_FORMAT_RGBA_8888, 0);
- ASSERT_TRUE(mBGSurfaceControl != nullptr);
- ASSERT_TRUE(mBGSurfaceControl->isValid());
-
- // Foreground surface
- mFGSurfaceControl =
- mComposerClient->createSurface(String8(TEST_FG_SURFACE_NAME), resolution.getWidth(),
- resolution.getHeight(), PIXEL_FORMAT_RGBA_8888, 0);
- ASSERT_TRUE(mFGSurfaceControl != nullptr);
- ASSERT_TRUE(mFGSurfaceControl->isValid());
-
- Transaction t;
- t.setDisplayLayerStack(display, ui::DEFAULT_LAYER_STACK);
- ASSERT_EQ(NO_ERROR,
- t.setLayer(mBGSurfaceControl, INT_MAX - 3)
- .show(mBGSurfaceControl)
- .setLayer(mFGSurfaceControl, INT_MAX - 3)
- .show(mFGSurfaceControl)
- .apply());
-}
-
-void SurfaceInterceptorTest::preProcessTrace(const Trace& trace) {
- mBGLayerId = getSurfaceId(trace, TEST_BG_SURFACE_NAME);
- mFGLayerId = getSurfaceId(trace, TEST_FG_SURFACE_NAME);
-}
-
-void SurfaceInterceptorTest::captureTest(TestTransactionAction action,
- TestBooleanVerification verification) {
- Trace capturedTrace;
- captureInTransaction(action, &capturedTrace);
- ASSERT_TRUE((this->*verification)(capturedTrace));
-}
-
-void SurfaceInterceptorTest::captureTest(TestTransactionAction action,
- Increment::IncrementCase incrementCase) {
- Trace capturedTrace;
- captureInTransaction(action, &capturedTrace);
- ASSERT_TRUE(singleIncrementFound(capturedTrace, incrementCase));
-}
-
-void SurfaceInterceptorTest::captureTest(TestTransactionAction action,
- SurfaceChange::SurfaceChangeCase changeCase) {
- Trace capturedTrace;
- captureInTransaction(action, &capturedTrace);
- ASSERT_TRUE(surfaceUpdateFound(capturedTrace, changeCase));
-}
-
-void SurfaceInterceptorTest::captureTest(TestAction action, TestBooleanVerification verification) {
- Trace capturedTrace;
- capture(action, &capturedTrace);
- ASSERT_TRUE((this->*verification)(capturedTrace));
-}
-
-void SurfaceInterceptorTest::captureTest(TestAction action, TestVerification verification) {
- Trace capturedTrace;
- capture(action, &capturedTrace);
- (this->*verification)(capturedTrace);
-}
-
-void SurfaceInterceptorTest::runInTransaction(TestTransactionAction action) {
- Transaction t;
- (this->*action)(t);
- t.apply(true);
-}
-
-void SurfaceInterceptorTest::positionUpdate(Transaction& t) {
- t.setPosition(mBGSurfaceControl, POSITION_UPDATE, POSITION_UPDATE);
-}
-
-void SurfaceInterceptorTest::sizeUpdate(Transaction&) {}
-
-void SurfaceInterceptorTest::alphaUpdate(Transaction& t) {
- t.setAlpha(mBGSurfaceControl, ALPHA_UPDATE);
-}
-
-void SurfaceInterceptorTest::cornerRadiusUpdate(Transaction& t) {
- t.setCornerRadius(mBGSurfaceControl, CORNER_RADIUS_UPDATE);
-}
-
-void SurfaceInterceptorTest::backgroundBlurRadiusUpdate(Transaction& t) {
- t.setBackgroundBlurRadius(mBGSurfaceControl, BACKGROUND_BLUR_RADIUS_UPDATE);
-}
-
-void SurfaceInterceptorTest::blurRegionsUpdate(Transaction& t) {
- BLUR_REGIONS_UPDATE.empty();
- BLUR_REGIONS_UPDATE.push_back(BlurRegion());
- t.setBlurRegions(mBGSurfaceControl, BLUR_REGIONS_UPDATE);
-}
-
-void SurfaceInterceptorTest::layerUpdate(Transaction& t) {
- t.setLayer(mBGSurfaceControl, LAYER_UPDATE);
-}
-
-void SurfaceInterceptorTest::cropUpdate(Transaction& t) {
- t.setCrop(mBGSurfaceControl, CROP_UPDATE);
-}
-
-void SurfaceInterceptorTest::matrixUpdate(Transaction& t) {
- t.setMatrix(mBGSurfaceControl, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2);
-}
-
-void SurfaceInterceptorTest::transparentRegionHintUpdate(Transaction& t) {
- Region region(CROP_UPDATE);
- t.setTransparentRegionHint(mBGSurfaceControl, region);
-}
-
-void SurfaceInterceptorTest::layerStackUpdate(Transaction& t) {
- t.setLayerStack(mBGSurfaceControl, ui::LayerStack::fromValue(STACK_UPDATE));
-}
-
-void SurfaceInterceptorTest::hiddenFlagUpdate(Transaction& t) {
- t.setFlags(mBGSurfaceControl, layer_state_t::eLayerHidden, layer_state_t::eLayerHidden);
-}
-
-void SurfaceInterceptorTest::opaqueFlagUpdate(Transaction& t) {
- t.setFlags(mBGSurfaceControl, layer_state_t::eLayerOpaque, layer_state_t::eLayerOpaque);
-}
-
-void SurfaceInterceptorTest::secureFlagUpdate(Transaction& t) {
- t.setFlags(mBGSurfaceControl, layer_state_t::eLayerSecure, layer_state_t::eLayerSecure);
-}
-
-void SurfaceInterceptorTest::reparentUpdate(Transaction& t) {
- t.reparent(mBGSurfaceControl, mFGSurfaceControl);
-}
-
-void SurfaceInterceptorTest::relativeParentUpdate(Transaction& t) {
- t.setRelativeLayer(mBGSurfaceControl, mFGSurfaceControl, RELATIVE_Z);
-}
-
-void SurfaceInterceptorTest::shadowRadiusUpdate(Transaction& t) {
- t.setShadowRadius(mBGSurfaceControl, SHADOW_RADIUS_UPDATE);
-}
-
-void SurfaceInterceptorTest::trustedOverlayUpdate(Transaction& t) {
- t.setTrustedOverlay(mBGSurfaceControl, true);
-}
-
-void SurfaceInterceptorTest::displayCreation(Transaction&) {
- sp<IBinder> testDisplay = SurfaceComposerClient::createDisplay(DISPLAY_NAME, false);
- SurfaceComposerClient::destroyDisplay(testDisplay);
-}
-
-void SurfaceInterceptorTest::displayDeletion(Transaction&) {
- sp<IBinder> testDisplay = SurfaceComposerClient::createDisplay(DISPLAY_NAME, false);
- SurfaceComposerClient::destroyDisplay(testDisplay);
-}
-
-void SurfaceInterceptorTest::runAllUpdates() {
- runInTransaction(&SurfaceInterceptorTest::positionUpdate);
- runInTransaction(&SurfaceInterceptorTest::sizeUpdate);
- runInTransaction(&SurfaceInterceptorTest::alphaUpdate);
- runInTransaction(&SurfaceInterceptorTest::cornerRadiusUpdate);
- runInTransaction(&SurfaceInterceptorTest::backgroundBlurRadiusUpdate);
- runInTransaction(&SurfaceInterceptorTest::blurRegionsUpdate);
- runInTransaction(&SurfaceInterceptorTest::layerUpdate);
- runInTransaction(&SurfaceInterceptorTest::cropUpdate);
- runInTransaction(&SurfaceInterceptorTest::matrixUpdate);
- runInTransaction(&SurfaceInterceptorTest::transparentRegionHintUpdate);
- runInTransaction(&SurfaceInterceptorTest::layerStackUpdate);
- runInTransaction(&SurfaceInterceptorTest::hiddenFlagUpdate);
- runInTransaction(&SurfaceInterceptorTest::opaqueFlagUpdate);
- runInTransaction(&SurfaceInterceptorTest::secureFlagUpdate);
- runInTransaction(&SurfaceInterceptorTest::reparentUpdate);
- runInTransaction(&SurfaceInterceptorTest::relativeParentUpdate);
- runInTransaction(&SurfaceInterceptorTest::shadowRadiusUpdate);
- runInTransaction(&SurfaceInterceptorTest::trustedOverlayUpdate);
-}
-
-void SurfaceInterceptorTest::surfaceCreation(Transaction&) {
- mComposerClient->createSurface(String8(LAYER_NAME), SIZE_UPDATE, SIZE_UPDATE,
- PIXEL_FORMAT_RGBA_8888, 0);
-}
-
-void SurfaceInterceptorTest::nBufferUpdates() {
- std::random_device rd;
- std::mt19937_64 gen(rd());
- // This makes testing fun
- std::uniform_int_distribution<uint8_t> dis;
- for (uint32_t i = 0; i < BUFFER_UPDATES; ++i) {
- fillSurfaceRGBA8(mBGSurfaceControl, dis(gen), dis(gen), dis(gen));
- }
-}
-
-bool SurfaceInterceptorTest::positionUpdateFound(const SurfaceChange& change, bool foundPosition) {
- // There should only be one position transaction with x and y = POSITION_UPDATE
- bool hasX(change.position().x() == POSITION_UPDATE);
- bool hasY(change.position().y() == POSITION_UPDATE);
- if (hasX && hasY && !foundPosition) {
- foundPosition = true;
- } else if (hasX && hasY && foundPosition) {
- // Failed because the position update was found a second time
- [] () { FAIL(); }();
- }
- return foundPosition;
-}
-
-bool SurfaceInterceptorTest::sizeUpdateFound(const SurfaceChange&, bool) {
- return true;
-}
-
-bool SurfaceInterceptorTest::alphaUpdateFound(const SurfaceChange& change, bool foundAlpha) {
- bool hasAlpha(change.alpha().alpha() == ALPHA_UPDATE);
- if (hasAlpha && !foundAlpha) {
- foundAlpha = true;
- } else if (hasAlpha && foundAlpha) {
- [] () { FAIL(); }();
- }
- return foundAlpha;
-}
-
-bool SurfaceInterceptorTest::cornerRadiusUpdateFound(const SurfaceChange &change,
- bool foundCornerRadius) {
- bool hasCornerRadius(change.corner_radius().corner_radius() == CORNER_RADIUS_UPDATE);
- if (hasCornerRadius && !foundCornerRadius) {
- foundCornerRadius = true;
- } else if (hasCornerRadius && foundCornerRadius) {
- [] () { FAIL(); }();
- }
- return foundCornerRadius;
-}
-
-bool SurfaceInterceptorTest::backgroundBlurRadiusUpdateFound(const SurfaceChange& change,
- bool foundBackgroundBlur) {
- bool hasBackgroundBlur(change.background_blur_radius().background_blur_radius() ==
- BACKGROUND_BLUR_RADIUS_UPDATE);
- if (hasBackgroundBlur && !foundBackgroundBlur) {
- foundBackgroundBlur = true;
- } else if (hasBackgroundBlur && foundBackgroundBlur) {
- []() { FAIL(); }();
- }
- return foundBackgroundBlur;
-}
-
-bool SurfaceInterceptorTest::blurRegionsUpdateFound(const SurfaceChange& change,
- bool foundBlurRegions) {
- bool hasBlurRegions(change.blur_regions().blur_regions_size() == BLUR_REGIONS_UPDATE.size());
- if (hasBlurRegions && !foundBlurRegions) {
- foundBlurRegions = true;
- } else if (hasBlurRegions && foundBlurRegions) {
- []() { FAIL(); }();
- }
- return foundBlurRegions;
-}
-
-bool SurfaceInterceptorTest::layerUpdateFound(const SurfaceChange& change, bool foundLayer) {
- bool hasLayer(change.layer().layer() == LAYER_UPDATE);
- if (hasLayer && !foundLayer) {
- foundLayer = true;
- } else if (hasLayer && foundLayer) {
- [] () { FAIL(); }();
- }
- return foundLayer;
-}
-
-bool SurfaceInterceptorTest::cropUpdateFound(const SurfaceChange& change, bool foundCrop) {
- bool hasLeft(change.crop().rectangle().left() == CROP_UPDATE.left);
- bool hasTop(change.crop().rectangle().top() == CROP_UPDATE.top);
- bool hasRight(change.crop().rectangle().right() == CROP_UPDATE.right);
- bool hasBottom(change.crop().rectangle().bottom() == CROP_UPDATE.bottom);
- if (hasLeft && hasRight && hasTop && hasBottom && !foundCrop) {
- foundCrop = true;
- } else if (hasLeft && hasRight && hasTop && hasBottom && foundCrop) {
- [] () { FAIL(); }();
- }
- return foundCrop;
-}
-
-bool SurfaceInterceptorTest::matrixUpdateFound(const SurfaceChange& change, bool foundMatrix) {
- bool hasSx((float)change.matrix().dsdx() == (float)M_SQRT1_2);
- bool hasTx((float)change.matrix().dtdx() == (float)M_SQRT1_2);
- bool hasSy((float)change.matrix().dsdy() == (float)M_SQRT1_2);
- bool hasTy((float)change.matrix().dtdy() == (float)-M_SQRT1_2);
- if (hasSx && hasTx && hasSy && hasTy && !foundMatrix) {
- foundMatrix = true;
- } else if (hasSx && hasTx && hasSy && hasTy && foundMatrix) {
- [] () { FAIL(); }();
- }
- return foundMatrix;
-}
-
-bool SurfaceInterceptorTest::transparentRegionHintUpdateFound(const SurfaceChange& change,
- bool foundTransparentRegion) {
- auto traceRegion = change.transparent_region_hint().region(0);
- bool hasLeft(traceRegion.left() == CROP_UPDATE.left);
- bool hasTop(traceRegion.top() == CROP_UPDATE.top);
- bool hasRight(traceRegion.right() == CROP_UPDATE.right);
- bool hasBottom(traceRegion.bottom() == CROP_UPDATE.bottom);
- if (hasLeft && hasRight && hasTop && hasBottom && !foundTransparentRegion) {
- foundTransparentRegion = true;
- } else if (hasLeft && hasRight && hasTop && hasBottom && foundTransparentRegion) {
- [] () { FAIL(); }();
- }
- return foundTransparentRegion;
-}
-
-bool SurfaceInterceptorTest::layerStackUpdateFound(const SurfaceChange& change,
- bool foundLayerStack) {
- bool hasLayerStackUpdate(change.layer_stack().layer_stack() == STACK_UPDATE);
- if (hasLayerStackUpdate && !foundLayerStack) {
- foundLayerStack = true;
- } else if (hasLayerStackUpdate && foundLayerStack) {
- [] () { FAIL(); }();
- }
- return foundLayerStack;
-}
-
-bool SurfaceInterceptorTest::hiddenFlagUpdateFound(const SurfaceChange& change,
- bool foundHiddenFlag) {
- bool hasHiddenFlag(change.hidden_flag().hidden_flag());
- if (hasHiddenFlag && !foundHiddenFlag) {
- foundHiddenFlag = true;
- } else if (hasHiddenFlag && foundHiddenFlag) {
- [] () { FAIL(); }();
- }
- return foundHiddenFlag;
-}
-
-bool SurfaceInterceptorTest::opaqueFlagUpdateFound(const SurfaceChange& change,
- bool foundOpaqueFlag) {
- bool hasOpaqueFlag(change.opaque_flag().opaque_flag());
- if (hasOpaqueFlag && !foundOpaqueFlag) {
- foundOpaqueFlag = true;
- } else if (hasOpaqueFlag && foundOpaqueFlag) {
- [] () { FAIL(); }();
- }
- return foundOpaqueFlag;
-}
-
-bool SurfaceInterceptorTest::secureFlagUpdateFound(const SurfaceChange& change,
- bool foundSecureFlag) {
- bool hasSecureFlag(change.secure_flag().secure_flag());
- if (hasSecureFlag && !foundSecureFlag) {
- foundSecureFlag = true;
- } else if (hasSecureFlag && foundSecureFlag) {
- [] () { FAIL(); }();
- }
- return foundSecureFlag;
-}
-
-bool SurfaceInterceptorTest::reparentUpdateFound(const SurfaceChange& change, bool found) {
- bool hasId(change.reparent().parent_id() == mFGLayerId);
- if (hasId && !found) {
- found = true;
- } else if (hasId && found) {
- []() { FAIL(); }();
- }
- return found;
-}
-
-bool SurfaceInterceptorTest::relativeParentUpdateFound(const SurfaceChange& change, bool found) {
- bool hasId(change.relative_parent().relative_parent_id() == mFGLayerId);
- if (hasId && !found) {
- found = true;
- } else if (hasId && found) {
- []() { FAIL(); }();
- }
- return found;
-}
-
-bool SurfaceInterceptorTest::shadowRadiusUpdateFound(const SurfaceChange& change,
- bool foundShadowRadius) {
- bool hasShadowRadius(change.shadow_radius().radius() == SHADOW_RADIUS_UPDATE);
- if (hasShadowRadius && !foundShadowRadius) {
- foundShadowRadius = true;
- } else if (hasShadowRadius && foundShadowRadius) {
- []() { FAIL(); }();
- }
- return foundShadowRadius;
-}
-
-bool SurfaceInterceptorTest::trustedOverlayUpdateFound(const SurfaceChange& change,
- bool foundTrustedOverlay) {
- bool hasTrustedOverlay(change.trusted_overlay().is_trusted_overlay());
- if (hasTrustedOverlay && !foundTrustedOverlay) {
- foundTrustedOverlay = true;
- } else if (hasTrustedOverlay && foundTrustedOverlay) {
- []() { FAIL(); }();
- }
- return foundTrustedOverlay;
-}
-
-bool SurfaceInterceptorTest::surfaceUpdateFound(const Trace& trace,
- SurfaceChange::SurfaceChangeCase changeCase) {
- bool foundUpdate = false;
- for (const auto& increment : trace.increment()) {
- if (increment.increment_case() == increment.kTransaction) {
- for (const auto& change : increment.transaction().surface_change()) {
- if (change.id() == mBGLayerId && change.SurfaceChange_case() == changeCase) {
- switch (changeCase) {
- case SurfaceChange::SurfaceChangeCase::kPosition:
- // foundUpdate is sent for the tests to fail on duplicated increments
- foundUpdate = positionUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kSize:
- foundUpdate = sizeUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kAlpha:
- foundUpdate = alphaUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kLayer:
- foundUpdate = layerUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kCrop:
- foundUpdate = cropUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kCornerRadius:
- foundUpdate = cornerRadiusUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kBackgroundBlurRadius:
- foundUpdate = backgroundBlurRadiusUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kBlurRegions:
- foundUpdate = blurRegionsUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kMatrix:
- foundUpdate = matrixUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kTransparentRegionHint:
- foundUpdate = transparentRegionHintUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kLayerStack:
- foundUpdate = layerStackUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kHiddenFlag:
- foundUpdate = hiddenFlagUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kOpaqueFlag:
- foundUpdate = opaqueFlagUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kSecureFlag:
- foundUpdate = secureFlagUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kReparent:
- foundUpdate = reparentUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kRelativeParent:
- foundUpdate = relativeParentUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kShadowRadius:
- foundUpdate = shadowRadiusUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::kTrustedOverlay:
- foundUpdate = trustedOverlayUpdateFound(change, foundUpdate);
- break;
- case SurfaceChange::SurfaceChangeCase::SURFACECHANGE_NOT_SET:
- break;
- }
- }
- }
- }
- }
- return foundUpdate;
-}
-
-void SurfaceInterceptorTest::assertAllUpdatesFound(const Trace& trace) {
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kPosition));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kSize));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kAlpha));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kLayer));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kCrop));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kMatrix));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kTransparentRegionHint));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kLayerStack));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kHiddenFlag));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kOpaqueFlag));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kSecureFlag));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kReparent));
- ASSERT_TRUE(surfaceUpdateFound(trace, SurfaceChange::SurfaceChangeCase::kRelativeParent));
-}
-
-bool SurfaceInterceptorTest::surfaceCreationFound(const Increment& increment, bool foundSurface) {
- bool isMatch(increment.surface_creation().name() == getUniqueName(LAYER_NAME, increment));
- if (isMatch && !foundSurface) {
- foundSurface = true;
- } else if (isMatch && foundSurface) {
- [] () { FAIL(); }();
- }
- return foundSurface;
-}
-
-bool SurfaceInterceptorTest::surfaceDeletionFound(const Increment& increment,
- const int32_t targetId, bool foundSurface) {
- bool isMatch(increment.surface_deletion().id() == targetId);
- if (isMatch && !foundSurface) {
- foundSurface = true;
- } else if (isMatch && foundSurface) {
- [] () { FAIL(); }();
- }
- return foundSurface;
-}
-
-bool SurfaceInterceptorTest::displayCreationFound(const Increment& increment, bool foundDisplay) {
- bool isMatch(increment.display_creation().name() == DISPLAY_NAME.string() &&
- !increment.display_creation().is_secure());
- if (isMatch && !foundDisplay) {
- foundDisplay = true;
- } else if (isMatch && foundDisplay) {
- [] () { FAIL(); }();
- }
- return foundDisplay;
-}
-
-bool SurfaceInterceptorTest::displayDeletionFound(const Increment& increment,
- const int32_t targetId, bool foundDisplay) {
- bool isMatch(increment.display_deletion().id() == targetId);
- if (isMatch && !foundDisplay) {
- foundDisplay = true;
- } else if (isMatch && foundDisplay) {
- [] () { FAIL(); }();
- }
- return foundDisplay;
-}
-
-bool SurfaceInterceptorTest::singleIncrementFound(const Trace& trace,
- Increment::IncrementCase incrementCase) {
- bool foundIncrement = false;
- for (const auto& increment : trace.increment()) {
- if (increment.increment_case() == incrementCase) {
- int32_t targetId = 0;
- switch (incrementCase) {
- case Increment::IncrementCase::kSurfaceCreation:
- foundIncrement = surfaceCreationFound(increment, foundIncrement);
- break;
- case Increment::IncrementCase::kSurfaceDeletion:
- // Find the id of created surface.
- targetId = getSurfaceId(trace, LAYER_NAME);
- foundIncrement = surfaceDeletionFound(increment, targetId, foundIncrement);
- break;
- case Increment::IncrementCase::kDisplayCreation:
- foundIncrement = displayCreationFound(increment, foundIncrement);
- break;
- case Increment::IncrementCase::kDisplayDeletion:
- // Find the id of created display.
- targetId = getDisplayId(trace, DISPLAY_NAME.string());
- foundIncrement = displayDeletionFound(increment, targetId, foundIncrement);
- break;
- default:
- /* code */
- break;
- }
- }
- }
- return foundIncrement;
-}
-
-bool SurfaceInterceptorTest::bufferUpdatesFound(const Trace& trace) {
- uint32_t updates = 0;
- for (const auto& inc : trace.increment()) {
- if (inc.increment_case() == inc.kBufferUpdate && inc.buffer_update().id() == mBGLayerId) {
- updates++;
- }
- }
- return updates == BUFFER_UPDATES;
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptPositionUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::positionUpdate,
- SurfaceChange::SurfaceChangeCase::kPosition);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptSizeUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::sizeUpdate, SurfaceChange::SurfaceChangeCase::kSize);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptAlphaUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::alphaUpdate, SurfaceChange::SurfaceChangeCase::kAlpha);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptLayerUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::layerUpdate, SurfaceChange::SurfaceChangeCase::kLayer);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptCropUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::cropUpdate, SurfaceChange::SurfaceChangeCase::kCrop);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptCornerRadiusUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::cornerRadiusUpdate,
- SurfaceChange::SurfaceChangeCase::kCornerRadius);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptBackgroundBlurRadiusUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::backgroundBlurRadiusUpdate,
- SurfaceChange::SurfaceChangeCase::kBackgroundBlurRadius);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptBlurRegionsUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::blurRegionsUpdate,
- SurfaceChange::SurfaceChangeCase::kBlurRegions);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptMatrixUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::matrixUpdate, SurfaceChange::SurfaceChangeCase::kMatrix);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptTransparentRegionHintUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::transparentRegionHintUpdate,
- SurfaceChange::SurfaceChangeCase::kTransparentRegionHint);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptLayerStackUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::layerStackUpdate,
- SurfaceChange::SurfaceChangeCase::kLayerStack);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptHiddenFlagUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::hiddenFlagUpdate,
- SurfaceChange::SurfaceChangeCase::kHiddenFlag);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptOpaqueFlagUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::opaqueFlagUpdate,
- SurfaceChange::SurfaceChangeCase::kOpaqueFlag);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptSecureFlagUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::secureFlagUpdate,
- SurfaceChange::SurfaceChangeCase::kSecureFlag);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptReparentUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::reparentUpdate,
- SurfaceChange::SurfaceChangeCase::kReparent);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptRelativeParentUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::relativeParentUpdate,
- SurfaceChange::SurfaceChangeCase::kRelativeParent);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptShadowRadiusUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::shadowRadiusUpdate,
- SurfaceChange::SurfaceChangeCase::kShadowRadius);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptTrustedOverlayUpdateWorks) {
- captureTest(&SurfaceInterceptorTest::trustedOverlayUpdate,
- SurfaceChange::SurfaceChangeCase::kTrustedOverlay);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptAllUpdatesWorks) {
- captureTest(&SurfaceInterceptorTest::runAllUpdates,
- &SurfaceInterceptorTest::assertAllUpdatesFound);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptSurfaceCreationWorks) {
- captureTest(&SurfaceInterceptorTest::surfaceCreation,
- Increment::IncrementCase::kSurfaceCreation);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptDisplayCreationWorks) {
- captureTest(&SurfaceInterceptorTest::displayCreation,
- Increment::IncrementCase::kDisplayCreation);
-}
-
-TEST_F(SurfaceInterceptorTest, InterceptDisplayDeletionWorks) {
- enableInterceptor();
- runInTransaction(&SurfaceInterceptorTest::displayDeletion);
- disableInterceptor();
- Trace capturedTrace;
- ASSERT_EQ(NO_ERROR, readProtoFile(&capturedTrace));
- ASSERT_TRUE(singleIncrementFound(capturedTrace, Increment::IncrementCase::kDisplayDeletion));
-}
-
-// If the interceptor is enabled while buffer updates are being pushed, the interceptor should
-// first create a snapshot of the existing displays and surfaces and then start capturing
-// the buffer updates
-TEST_F(SurfaceInterceptorTest, InterceptWhileBufferUpdatesWorks) {
- setupBackgroundSurface();
- std::thread bufferUpdates(&SurfaceInterceptorTest::nBufferUpdates, this);
- enableInterceptor();
- disableInterceptor();
- bufferUpdates.join();
-
- Trace capturedTrace;
- ASSERT_EQ(NO_ERROR, readProtoFile(&capturedTrace));
- const auto& firstIncrement = capturedTrace.mutable_increment(0);
- ASSERT_EQ(firstIncrement->increment_case(), Increment::IncrementCase::kDisplayCreation);
-}
-}
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
diff --git a/services/surfaceflinger/tests/fakehwc/Android.bp b/services/surfaceflinger/tests/fakehwc/Android.bp
index 06afdb1..0d40e70 100644
--- a/services/surfaceflinger/tests/fakehwc/Android.bp
+++ b/services/surfaceflinger/tests/fakehwc/Android.bp
@@ -53,7 +53,6 @@
"libgmock",
"libperfetto_client_experimental",
"librenderengine",
- "libtrace_proto",
"libaidlcommonsupport",
],
header_libs: [
diff --git a/services/surfaceflinger/tests/unittests/Android.bp b/services/surfaceflinger/tests/unittests/Android.bp
index 4469df0..d2b5813 100644
--- a/services/surfaceflinger/tests/unittests/Android.bp
+++ b/services/surfaceflinger/tests/unittests/Android.bp
@@ -34,7 +34,6 @@
"mock/MockFrameTimeline.cpp",
"mock/MockFrameTracer.cpp",
"mock/MockNativeWindowSurface.cpp",
- "mock/MockSurfaceInterceptor.cpp",
"mock/MockTimeStats.cpp",
"mock/MockVsyncController.cpp",
"mock/MockVSyncTracker.cpp",
@@ -168,7 +167,6 @@
"libtimestats_atoms_proto",
"libtimestats_proto",
"libtonemap",
- "libtrace_proto",
"perfetto_trace_protos",
],
shared_libs: [
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index abe32c9..8b91c67 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -50,7 +50,6 @@
injectMockScheduler();
mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
- mFlinger.mutableInterceptor() = mSurfaceInterceptor;
injectMockComposer(0);
}
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h b/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h
index 20e776f..9cceb5e 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h
@@ -49,7 +49,6 @@
#include "mock/DisplayHardware/MockPowerAdvisor.h"
#include "mock/MockEventThread.h"
#include "mock/MockNativeWindowSurface.h"
-#include "mock/MockSurfaceInterceptor.h"
#include "mock/MockVsyncController.h"
#include "mock/system/window/MockNativeWindow.h"
@@ -120,7 +119,6 @@
// to keep a reference to them for use in setting up call expectations.
renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine();
Hwc2::mock::Composer* mComposer = nullptr;
- sp<mock::SurfaceInterceptor> mSurfaceInterceptor = sp<mock::SurfaceInterceptor>::make();
mock::VsyncController* mVsyncController = new mock::VsyncController;
mock::VSyncTracker* mVSyncTracker = new mock::VSyncTracker;
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index 978afc5..a5beaba 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -93,7 +93,6 @@
void expectVSyncSetDurationCallReceived(std::chrono::nanoseconds expectedDuration,
std::chrono::nanoseconds expectedReadyDuration);
VSyncSource::Callback* expectVSyncSetCallbackCallReceived();
- void expectInterceptCallReceived(nsecs_t expectedTimestamp);
void expectVsyncEventReceivedByConnection(const char* name,
ConnectionEventRecorder& connectionEventRecorder,
nsecs_t expectedTimestamp, unsigned expectedCount);
@@ -114,7 +113,6 @@
AsyncCallRecorder<void (*)(std::chrono::nanoseconds, std::chrono::nanoseconds)>
mVSyncSetDurationCallRecorder;
AsyncCallRecorder<void (*)()> mResyncCallRecorder;
- AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder;
AsyncCallRecorder<void (*)(nsecs_t, uid_t)> mThrottleVsyncCallRecorder;
ConnectionEventRecorder mConnectionEventCallRecorder{0};
ConnectionEventRecorder mThrottledConnectionEventCallRecorder{0};
@@ -181,7 +179,6 @@
mTokenManager = std::make_unique<frametimeline::impl::TokenManager>();
mThread = std::make_unique<impl::EventThread>(std::move(source), mTokenManager.get(),
- mInterceptVSyncCallRecorder.getInvocable(),
throttleVsync, getVsyncPeriod);
// EventThread should register itself as VSyncSource callback.
@@ -219,12 +216,6 @@
return callbackSet.has_value() ? std::get<0>(callbackSet.value()) : nullptr;
}
-void EventThreadTest::expectInterceptCallReceived(nsecs_t expectedTimestamp) {
- auto args = mInterceptVSyncCallRecorder.waitForCall();
- ASSERT_TRUE(args.has_value());
- EXPECT_EQ(expectedTimestamp, std::get<0>(args.value()));
-}
-
void EventThreadTest::expectThrottleVsyncReceived(nsecs_t expectedTimestamp, uid_t uid) {
auto args = mThrottleVsyncCallRecorder.waitForCall();
ASSERT_TRUE(args.has_value());
@@ -348,7 +339,6 @@
EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mVSyncSetDurationCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mResyncCallRecorder.waitForCall(0us).has_value());
- EXPECT_FALSE(mInterceptVSyncCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mConnectionEventCallRecorder.waitForCall(0us).has_value());
}
@@ -374,17 +364,15 @@
expectVSyncSetEnabledCallReceived(true);
// Use the received callback to signal a first vsync event.
- // The interceptor should receive the event, as well as the connection.
+ // The throttler should receive the event, as well as the connection.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectThrottleVsyncReceived(456, mConnectionUid);
expectVsyncEventReceivedByConnection(123, 1u);
// Use the received callback to signal a second vsync event.
- // The interceptor should receive the event, but the connection should
+ // The throttler should receive the event, but the connection should
// not as it was only interested in the first.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
EXPECT_FALSE(mThrottleVsyncCallRecorder.waitForUnexpectedCall().has_value());
EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
@@ -400,10 +388,9 @@
expectVSyncSetEnabledCallReceived(true);
// Use the received callback to signal a vsync event.
- // The interceptor should receive the event, as well as the connection.
+ // The throttler should receive the event, as well as the connection.
VSyncSource::VSyncData vsyncData = {456, 789};
mCallback->onVSyncEvent(123, vsyncData);
- expectInterceptCallReceived(123);
expectVsyncEventFrameTimelinesCorrect(123, vsyncData);
}
@@ -477,10 +464,9 @@
expectVSyncSetEnabledCallReceived(true);
// Send a vsync event. EventThread should then make a call to the
- // interceptor, and the second connection. The first connection should not
+ // the second connection. The first connection should not
// get the event.
mCallback->onVSyncEvent(123, {456, 0});
- expectInterceptCallReceived(123);
EXPECT_FALSE(firstConnectionEventRecorder.waitForUnexpectedCall().has_value());
expectVsyncEventReceivedByConnection("secondConnection", secondConnectionEventRecorder, 123,
1u);
@@ -493,21 +479,18 @@
expectVSyncSetEnabledCallReceived(true);
// Send a vsync event. EventThread should then make a call to the
- // interceptor, and the connection.
+ // throttler, and the connection.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectThrottleVsyncReceived(456, mConnectionUid);
expectVsyncEventReceivedByConnection(123, 1u);
// A second event should go to the same places.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
expectThrottleVsyncReceived(123, mConnectionUid);
expectVsyncEventReceivedByConnection(456, 2u);
// A third event should go to the same places.
mCallback->onVSyncEvent(789, {777, 111});
- expectInterceptCallReceived(789);
expectThrottleVsyncReceived(777, mConnectionUid);
expectVsyncEventReceivedByConnection(789, 3u);
}
@@ -518,27 +501,23 @@
// EventThread should enable vsync callbacks.
expectVSyncSetEnabledCallReceived(true);
- // The first event will be seen by the interceptor, and not the connection.
+ // The first event will not be seen by the connection.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
EXPECT_FALSE(mThrottleVsyncCallRecorder.waitForUnexpectedCall().has_value());
- // The second event will be seen by the interceptor and the connection.
+ // The second event will be seen by the connection.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
expectVsyncEventReceivedByConnection(456, 2u);
EXPECT_FALSE(mThrottleVsyncCallRecorder.waitForUnexpectedCall().has_value());
- // The third event will be seen by the interceptor, and not the connection.
+ // The third event will not be seen by the connection.
mCallback->onVSyncEvent(789, {777, 744});
- expectInterceptCallReceived(789);
EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
EXPECT_FALSE(mThrottleVsyncCallRecorder.waitForUnexpectedCall().has_value());
- // The fourth event will be seen by the interceptor and the connection.
+ // The fourth event will be seen by the connection.
mCallback->onVSyncEvent(101112, {7847, 86});
- expectInterceptCallReceived(101112);
expectVsyncEventReceivedByConnection(101112, 4u);
}
@@ -551,9 +530,8 @@
// Destroy the only (strong) reference to the connection.
mConnection = nullptr;
- // The first event will be seen by the interceptor, and not the connection.
+ // The first event will not be seen by the connection.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
// EventThread should disable vsync callbacks
@@ -568,16 +546,12 @@
// EventThread should enable vsync callbacks.
expectVSyncSetEnabledCallReceived(true);
- // The first event will be seen by the interceptor, and by the connection,
- // which then returns an error.
+ // The first event will be seen by the connection, which then returns an error.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
- // A subsequent event will be seen by the interceptor and not by the
- // connection.
+ // A subsequent event will not be seen by the connection.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
EXPECT_FALSE(errorConnectionEventRecorder.waitForUnexpectedCall().has_value());
// EventThread should disable vsync callbacks with the second event
@@ -599,10 +573,8 @@
// EventThread should enable vsync callbacks.
expectVSyncSetEnabledCallReceived(true);
- // The first event will be seen by the interceptor, and by the connection,
- // which then returns an error.
+ // The first event will be seen by the connection, which then returns an error.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
expectVsyncEventReceivedByConnection("successConnection", secondConnectionEventRecorder, 123,
1u);
@@ -617,16 +589,13 @@
// EventThread should enable vsync callbacks.
expectVSyncSetEnabledCallReceived(true);
- // The first event will be seen by the interceptor, and by the connection,
- // which then returns an non-fatal error.
+ // The first event will be seen by the connection, which then returns a non-fatal error.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
- // A subsequent event will be seen by the interceptor, and by the connection,
- // which still then returns an non-fatal error.
+ // A subsequent event will be seen by the connection, which still then returns a non-fatal
+ // error.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 456, 2u);
// EventThread will not disable vsync callbacks as the errors are non-fatal.
@@ -748,17 +717,15 @@
expectVSyncSetEnabledCallReceived(true);
// Use the received callback to signal a first vsync event.
- // The interceptor should receive the event, but not the connection.
+ // The throttler should receive the event, but not the connection.
mCallback->onVSyncEvent(123, {456, 789});
- expectInterceptCallReceived(123);
expectThrottleVsyncReceived(456, mThrottledConnectionUid);
mThrottledConnectionEventCallRecorder.waitForUnexpectedCall();
// Use the received callback to signal a second vsync event.
- // The interceptor should receive the event, but the connection should
+ // The throttler should receive the event, but the connection should
// not as it was only interested in the first.
mCallback->onVSyncEvent(456, {123, 0});
- expectInterceptCallReceived(456);
expectThrottleVsyncReceived(123, mThrottledConnectionUid);
EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
index f7d34ac..6a9c970 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
@@ -30,9 +30,6 @@
// --------------------------------------------------------------------
// Call Expectations
- // The call should notify the interceptor that a display was created.
- EXPECT_CALL(*mSurfaceInterceptor, saveDisplayCreation(_)).Times(1);
-
// --------------------------------------------------------------------
// Invocation
@@ -61,9 +58,6 @@
// --------------------------------------------------------------------
// Call Expectations
- // The call should notify the interceptor that a display was created.
- EXPECT_CALL(*mSurfaceInterceptor, saveDisplayCreation(_)).Times(1);
-
// --------------------------------------------------------------------
// Invocation
int64_t oldId = IPCThreadState::self()->clearCallingIdentity();
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
index 40ef949..93a3811 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
@@ -37,9 +37,6 @@
// --------------------------------------------------------------------
// Call Expectations
- // The call should notify the interceptor that a display was created.
- EXPECT_CALL(*mSurfaceInterceptor, saveDisplayDeletion(_)).Times(1);
-
// Destroying the display commits a display transaction.
EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayTransactionCommitTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayTransactionCommitTest.cpp
index 73f654b..94d517a 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayTransactionCommitTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayTransactionCommitTest.cpp
@@ -90,15 +90,12 @@
Case::HdrSupport::setupComposerCallExpectations(this);
Case::PerFrameMetadataSupport::setupComposerCallExpectations(this);
- EXPECT_CALL(*mSurfaceInterceptor, saveDisplayCreation(_)).Times(1);
expectHotplugReceived<Case, true>(mEventThread);
expectHotplugReceived<Case, true>(mSFEventThread);
}
template <typename Case>
void DisplayTransactionCommitTest::setupCommonCallExpectationsForDisconnectProcessing() {
- EXPECT_CALL(*mSurfaceInterceptor, saveDisplayDeletion(_)).Times(1);
-
expectHotplugReceived<Case, false>(mEventThread);
expectHotplugReceived<Case, false>(mSFEventThread);
}
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_OnInitializeDisplaysTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_OnInitializeDisplaysTest.cpp
index 98249bf..f553a23 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_OnInitializeDisplaysTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_OnInitializeDisplaysTest.cpp
@@ -38,11 +38,6 @@
// --------------------------------------------------------------------
// Call Expectations
- // We expect the surface interceptor to possibly be used, but we treat it as
- // disabled since it is called as a side effect rather than directly by this
- // function.
- EXPECT_CALL(*mSurfaceInterceptor, isEnabled()).WillOnce(Return(false));
-
// We expect a call to get the active display config.
Case::Display::setupHwcGetActiveConfigCallExpectations(this);
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
index 6f84437..25857ec 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
@@ -276,13 +276,6 @@
EXPECT_CALL(*test->mFlinger.scheduler(), scheduleFrame()).Times(1);
}
- static void setupSurfaceInterceptorCallExpectations(DisplayTransactionTest* test,
- PowerMode mode) {
- EXPECT_CALL(*test->mSurfaceInterceptor, isEnabled()).WillOnce(Return(true));
- EXPECT_CALL(*test->mSurfaceInterceptor, savePowerModeUpdate(_, static_cast<int32_t>(mode)))
- .Times(1);
- }
-
static void setupComposerCallExpectations(DisplayTransactionTest* test, PowerMode mode) {
// Any calls to get the active config will return a default value.
EXPECT_CALL(*test->mComposer, getActiveConfig(Display::HWC_DISPLAY_ID, _))
@@ -349,7 +342,6 @@
// --------------------------------------------------------------------
// Call Expectations
- Case::setupSurfaceInterceptorCallExpectations(this, Case::Transition::TARGET_POWER_MODE);
Case::Transition::template setupCallExpectations<Case>(this);
// --------------------------------------------------------------------
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index f5042d3..e0784ee 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -40,7 +40,6 @@
#include "StartPropertySetThread.h"
#include "SurfaceFlinger.h"
#include "SurfaceFlingerDefaultFactory.h"
-#include "SurfaceInterceptor.h"
#include "TestableScheduler.h"
#include "mock/DisplayHardware/MockComposer.h"
#include "mock/DisplayHardware/MockDisplayMode.h"
@@ -81,10 +80,6 @@
return std::make_unique<scheduler::FakePhaseOffsets>();
}
- sp<SurfaceInterceptor> createSurfaceInterceptor() override {
- return sp<android::impl::SurfaceInterceptor>::make();
- }
-
sp<StartPropertySetThread> createStartPropertySetThread(bool timestampPropertyValue) override {
return sp<StartPropertySetThread>::make(timestampPropertyValue);
}
@@ -518,7 +513,6 @@
auto& mutablePhysicalDisplays() { return mFlinger->mPhysicalDisplays; }
auto& mutableDrawingState() { return mFlinger->mDrawingState; }
auto& mutableGeometryDirty() { return mFlinger->mGeometryDirty; }
- auto& mutableInterceptor() { return mFlinger->mInterceptor; }
auto& mutableMainThreadId() { return mFlinger->mMainThreadId; }
auto& mutablePendingHotplugEvents() { return mFlinger->mPendingHotplugEvents; }
auto& mutableTexturePool() { return mFlinger->mTexturePool; }
@@ -543,7 +537,6 @@
mutableDisplays().clear();
mutableCurrentState().displays.clear();
mutableDrawingState().displays.clear();
- mutableInterceptor().clear();
mFlinger->mScheduler.reset();
mFlinger->mCompositionEngine->setHwComposer(std::unique_ptr<HWComposer>());
mFlinger->mCompositionEngine->setRenderEngine(
diff --git a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp b/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp
deleted file mode 100644
index 0a0e7b5..0000000
--- a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wconversion"
-
-#include "mock/MockSurfaceInterceptor.h"
-
-namespace android::mock {
-
-// Explicit default instantiation is recommended.
-SurfaceInterceptor::SurfaceInterceptor() = default;
-SurfaceInterceptor::~SurfaceInterceptor() = default;
-
-} // namespace android::mock
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wconversion"
diff --git a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.h b/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.h
deleted file mode 100644
index b085027..0000000
--- a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <gmock/gmock.h>
-
-#include "SurfaceInterceptor.h"
-
-namespace android::mock {
-
-class SurfaceInterceptor : public android::SurfaceInterceptor {
-public:
- SurfaceInterceptor();
- ~SurfaceInterceptor() override;
-
- MOCK_METHOD2(enable,
- void(const SortedVector<sp<Layer>>&,
- const DefaultKeyedVector<wp<IBinder>, DisplayDeviceState>&));
- MOCK_METHOD0(disable, void());
- MOCK_METHOD0(isEnabled, bool());
- MOCK_METHOD1(addTransactionTraceListener, void(const sp<gui::ITransactionTraceListener>&));
- MOCK_METHOD1(binderDied, void(const wp<IBinder>&));
- MOCK_METHOD7(saveTransaction,
- void(const Vector<ComposerState>&,
- const DefaultKeyedVector<wp<IBinder>, DisplayDeviceState>&,
- const Vector<DisplayState>&, uint32_t, int, int, uint64_t));
- MOCK_METHOD1(saveSurfaceCreation, void(const sp<const Layer>&));
- MOCK_METHOD1(saveSurfaceDeletion, void(const sp<const Layer>&));
- MOCK_METHOD4(saveBufferUpdate, void(int32_t, uint32_t, uint32_t, uint64_t));
- MOCK_METHOD1(saveDisplayCreation, void(const DisplayDeviceState&));
- MOCK_METHOD1(saveDisplayDeletion, void(int32_t));
- MOCK_METHOD2(savePowerModeUpdate, void(int32_t, int32_t));
- MOCK_METHOD1(saveVSyncEvent, void(nsecs_t));
-};
-
-} // namespace android::mock