diff --git a/graphics/composer/2.1/utils/vts/GraphicsComposerCallback.cpp b/graphics/composer/2.1/utils/vts/GraphicsComposerCallback.cpp
index 0ad440c..f7ea306 100644
--- a/graphics/composer/2.1/utils/vts/GraphicsComposerCallback.cpp
+++ b/graphics/composer/2.1/utils/vts/GraphicsComposerCallback.cpp
@@ -24,65 +24,64 @@
 namespace tests {
 
 void GraphicsComposerCallback::setVsyncAllowed(bool allowed) {
-  std::lock_guard<std::mutex> lock(mMutex);
-  mVsyncAllowed = allowed;
+    std::lock_guard<std::mutex> lock(mMutex);
+    mVsyncAllowed = allowed;
 }
 
 std::vector<Display> GraphicsComposerCallback::getDisplays() const {
-  std::lock_guard<std::mutex> lock(mMutex);
-  return std::vector<Display>(mDisplays.begin(), mDisplays.end());
+    std::lock_guard<std::mutex> lock(mMutex);
+    return std::vector<Display>(mDisplays.begin(), mDisplays.end());
 }
 
 int GraphicsComposerCallback::getInvalidHotplugCount() const {
-  std::lock_guard<std::mutex> lock(mMutex);
-  return mInvalidHotplugCount;
+    std::lock_guard<std::mutex> lock(mMutex);
+    return mInvalidHotplugCount;
 }
 
 int GraphicsComposerCallback::getInvalidRefreshCount() const {
-  std::lock_guard<std::mutex> lock(mMutex);
-  return mInvalidRefreshCount;
+    std::lock_guard<std::mutex> lock(mMutex);
+    return mInvalidRefreshCount;
 }
 
 int GraphicsComposerCallback::getInvalidVsyncCount() const {
-  std::lock_guard<std::mutex> lock(mMutex);
-  return mInvalidVsyncCount;
+    std::lock_guard<std::mutex> lock(mMutex);
+    return mInvalidVsyncCount;
 }
 
-Return<void> GraphicsComposerCallback::onHotplug(Display display,
-                                                 Connection connection) {
-  std::lock_guard<std::mutex> lock(mMutex);
+Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection connection) {
+    std::lock_guard<std::mutex> lock(mMutex);
 
-  if (connection == Connection::CONNECTED) {
-    if (!mDisplays.insert(display).second) {
-      mInvalidHotplugCount++;
+    if (connection == Connection::CONNECTED) {
+        if (!mDisplays.insert(display).second) {
+            mInvalidHotplugCount++;
+        }
+    } else if (connection == Connection::DISCONNECTED) {
+        if (!mDisplays.erase(display)) {
+            mInvalidHotplugCount++;
+        }
     }
-  } else if (connection == Connection::DISCONNECTED) {
-    if (!mDisplays.erase(display)) {
-      mInvalidHotplugCount++;
-    }
-  }
 
-  return Void();
+    return Void();
 }
 
 Return<void> GraphicsComposerCallback::onRefresh(Display display) {
-  std::lock_guard<std::mutex> lock(mMutex);
+    std::lock_guard<std::mutex> lock(mMutex);
 
-  if (mDisplays.count(display) == 0) {
-    mInvalidRefreshCount++;
-  }
+    if (mDisplays.count(display) == 0) {
+        mInvalidRefreshCount++;
+    }
 
-  return Void();
+    return Void();
 }
 
 Return<void> GraphicsComposerCallback::onVsync(Display display, int64_t) {
-  std::lock_guard<std::mutex> lock(mMutex);
+    std::lock_guard<std::mutex> lock(mMutex);
 
-  if (!mVsyncAllowed || mDisplays.count(display) == 0) {
-    mInvalidVsyncCount++;
-  }
+    if (!mVsyncAllowed || mDisplays.count(display) == 0) {
+        mInvalidVsyncCount++;
+    }
 
-  return Void();
+    return Void();
 }
 
 }  // namespace tests
diff --git a/graphics/composer/2.1/utils/vts/TestCommandReader.cpp b/graphics/composer/2.1/utils/vts/TestCommandReader.cpp
index b1f9aca..671005d 100644
--- a/graphics/composer/2.1/utils/vts/TestCommandReader.cpp
+++ b/graphics/composer/2.1/utils/vts/TestCommandReader.cpp
@@ -26,32 +26,32 @@
 namespace tests {
 
 void TestCommandReader::parse() {
-  while (!isEmpty()) {
-    IComposerClient::Command command;
-    uint16_t length;
-    ASSERT_TRUE(beginCommand(&command, &length));
+    while (!isEmpty()) {
+        IComposerClient::Command command;
+        uint16_t length;
+        ASSERT_TRUE(beginCommand(&command, &length));
 
-    switch (command) {
-      case IComposerClient::Command::SET_ERROR: {
-        ASSERT_EQ(2, length);
-        auto loc = read();
-        auto err = readSigned();
-        GTEST_FAIL() << "unexpected error " << err << " at location " << loc;
-      } break;
-      case IComposerClient::Command::SELECT_DISPLAY:
-      case IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES:
-      case IComposerClient::Command::SET_DISPLAY_REQUESTS:
-      case IComposerClient::Command::SET_PRESENT_FENCE:
-      case IComposerClient::Command::SET_RELEASE_FENCES:
-        break;
-      default:
-        GTEST_FAIL() << "unexpected return command " << std::hex
-                     << static_cast<int>(command);
-        break;
+        switch (command) {
+            case IComposerClient::Command::SET_ERROR: {
+                ASSERT_EQ(2, length);
+                auto loc = read();
+                auto err = readSigned();
+                GTEST_FAIL() << "unexpected error " << err << " at location " << loc;
+            } break;
+            case IComposerClient::Command::SELECT_DISPLAY:
+            case IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES:
+            case IComposerClient::Command::SET_DISPLAY_REQUESTS:
+            case IComposerClient::Command::SET_PRESENT_FENCE:
+            case IComposerClient::Command::SET_RELEASE_FENCES:
+                break;
+            default:
+                GTEST_FAIL() << "unexpected return command " << std::hex
+                             << static_cast<int>(command);
+                break;
+        }
+
+        endCommand();
     }
-
-    endCommand();
-  }
 }
 
 }  // namespace tests
diff --git a/graphics/composer/2.1/utils/vts/VtsHalGraphicsComposerTestUtils.cpp b/graphics/composer/2.1/utils/vts/VtsHalGraphicsComposerTestUtils.cpp
index c66cdd0..a7f3ecd 100644
--- a/graphics/composer/2.1/utils/vts/VtsHalGraphicsComposerTestUtils.cpp
+++ b/graphics/composer/2.1/utils/vts/VtsHalGraphicsComposerTestUtils.cpp
@@ -26,315 +26,294 @@
 namespace tests {
 
 Composer::Composer() {
-  mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>();
-  init();
+    mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>();
+    init();
 }
 
 Composer::Composer(const std::string& name) {
-  mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name);
-  init();
+    mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name);
+    init();
 }
 
 void Composer::init() {
-  ASSERT_NE(nullptr, mComposer.get()) << "failed to get composer service";
+    ASSERT_NE(nullptr, mComposer.get()) << "failed to get composer service";
 
-  std::vector<IComposer::Capability> capabilities = getCapabilities();
-  mCapabilities.insert(capabilities.begin(), capabilities.end());
+    std::vector<IComposer::Capability> capabilities = getCapabilities();
+    mCapabilities.insert(capabilities.begin(), capabilities.end());
 }
 
-sp<IComposer> Composer::getRaw() const { return mComposer; }
+sp<IComposer> Composer::getRaw() const {
+    return mComposer;
+}
 
 bool Composer::hasCapability(IComposer::Capability capability) const {
-  return mCapabilities.count(capability) > 0;
+    return mCapabilities.count(capability) > 0;
 }
 
 std::vector<IComposer::Capability> Composer::getCapabilities() {
-  std::vector<IComposer::Capability> capabilities;
-  mComposer->getCapabilities(
-      [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
+    std::vector<IComposer::Capability> capabilities;
+    mComposer->getCapabilities(
+        [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
 
-  return capabilities;
+    return capabilities;
 }
 
 std::string Composer::dumpDebugInfo() {
-  std::string debugInfo;
-  mComposer->dumpDebugInfo(
-      [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
+    std::string debugInfo;
+    mComposer->dumpDebugInfo([&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
 
-  return debugInfo;
+    return debugInfo;
 }
 
 std::unique_ptr<ComposerClient> Composer::createClient() {
-  std::unique_ptr<ComposerClient> client;
-  mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) {
-    ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
-    client = std::make_unique<ComposerClient>(tmpClient);
-  });
+    std::unique_ptr<ComposerClient> client;
+    mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) {
+        ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
+        client = std::make_unique<ComposerClient>(tmpClient);
+    });
 
-  return client;
+    return client;
 }
 
-ComposerClient::ComposerClient(const sp<IComposerClient>& client)
-    : mClient(client) {}
+ComposerClient::ComposerClient(const sp<IComposerClient>& client) : mClient(client) {}
 
 ComposerClient::~ComposerClient() {
-  for (auto it : mDisplayResources) {
-    Display display = it.first;
-    DisplayResource& resource = it.second;
+    for (auto it : mDisplayResources) {
+        Display display = it.first;
+        DisplayResource& resource = it.second;
 
-    for (auto layer : resource.layers) {
-      EXPECT_EQ(Error::NONE, mClient->destroyLayer(display, layer))
-          << "failed to destroy layer " << layer;
-    }
+        for (auto layer : resource.layers) {
+            EXPECT_EQ(Error::NONE, mClient->destroyLayer(display, layer))
+                << "failed to destroy layer " << layer;
+        }
 
-    if (resource.isVirtual) {
-      EXPECT_EQ(Error::NONE, mClient->destroyVirtualDisplay(display))
-          << "failed to destroy virtual display " << display;
+        if (resource.isVirtual) {
+            EXPECT_EQ(Error::NONE, mClient->destroyVirtualDisplay(display))
+                << "failed to destroy virtual display " << display;
+        }
     }
-  }
-  mDisplayResources.clear();
+    mDisplayResources.clear();
 }
 
-sp<IComposerClient> ComposerClient::getRaw() const { return mClient; }
+sp<IComposerClient> ComposerClient::getRaw() const {
+    return mClient;
+}
 
 void ComposerClient::registerCallback(const sp<IComposerCallback>& callback) {
-  mClient->registerCallback(callback);
+    mClient->registerCallback(callback);
 }
 
 uint32_t ComposerClient::getMaxVirtualDisplayCount() {
-  return mClient->getMaxVirtualDisplayCount();
+    return mClient->getMaxVirtualDisplayCount();
 }
 
 Display ComposerClient::createVirtualDisplay(uint32_t width, uint32_t height,
-                                             PixelFormat formatHint,
-                                             uint32_t outputBufferSlotCount,
+                                             PixelFormat formatHint, uint32_t outputBufferSlotCount,
                                              PixelFormat* outFormat) {
-  Display display = 0;
-  mClient->createVirtualDisplay(
-      width, height, formatHint, outputBufferSlotCount,
-      [&](const auto& tmpError, const auto& tmpDisplay, const auto& tmpFormat) {
-        ASSERT_EQ(Error::NONE, tmpError) << "failed to create virtual display";
-        display = tmpDisplay;
-        *outFormat = tmpFormat;
+    Display display = 0;
+    mClient->createVirtualDisplay(
+        width, height, formatHint, outputBufferSlotCount,
+        [&](const auto& tmpError, const auto& tmpDisplay, const auto& tmpFormat) {
+            ASSERT_EQ(Error::NONE, tmpError) << "failed to create virtual display";
+            display = tmpDisplay;
+            *outFormat = tmpFormat;
 
-        ASSERT_TRUE(
-            mDisplayResources.insert({display, DisplayResource(true)}).second)
-            << "duplicated virtual display id " << display;
-      });
+            ASSERT_TRUE(mDisplayResources.insert({display, DisplayResource(true)}).second)
+                << "duplicated virtual display id " << display;
+        });
 
-  return display;
+    return display;
 }
 
 void ComposerClient::destroyVirtualDisplay(Display display) {
-  Error error = mClient->destroyVirtualDisplay(display);
-  ASSERT_EQ(Error::NONE, error)
-      << "failed to destroy virtual display " << display;
+    Error error = mClient->destroyVirtualDisplay(display);
+    ASSERT_EQ(Error::NONE, error) << "failed to destroy virtual display " << display;
 
-  mDisplayResources.erase(display);
+    mDisplayResources.erase(display);
 }
 
 Layer ComposerClient::createLayer(Display display, uint32_t bufferSlotCount) {
-  Layer layer = 0;
-  mClient->createLayer(
-      display, bufferSlotCount,
-      [&](const auto& tmpError, const auto& tmpLayer) {
+    Layer layer = 0;
+    mClient->createLayer(display, bufferSlotCount, [&](const auto& tmpError, const auto& tmpLayer) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to create layer";
         layer = tmpLayer;
 
         auto resourceIt = mDisplayResources.find(display);
         if (resourceIt == mDisplayResources.end()) {
-          resourceIt =
-              mDisplayResources.insert({display, DisplayResource(false)}).first;
+            resourceIt = mDisplayResources.insert({display, DisplayResource(false)}).first;
         }
 
         ASSERT_TRUE(resourceIt->second.layers.insert(layer).second)
             << "duplicated layer id " << layer;
-      });
+    });
 
-  return layer;
+    return layer;
 }
 
 void ComposerClient::destroyLayer(Display display, Layer layer) {
-  Error error = mClient->destroyLayer(display, layer);
-  ASSERT_EQ(Error::NONE, error) << "failed to destroy layer " << layer;
+    Error error = mClient->destroyLayer(display, layer);
+    ASSERT_EQ(Error::NONE, error) << "failed to destroy layer " << layer;
 
-  auto resourceIt = mDisplayResources.find(display);
-  ASSERT_NE(mDisplayResources.end(), resourceIt);
-  resourceIt->second.layers.erase(layer);
+    auto resourceIt = mDisplayResources.find(display);
+    ASSERT_NE(mDisplayResources.end(), resourceIt);
+    resourceIt->second.layers.erase(layer);
 }
 
 Config ComposerClient::getActiveConfig(Display display) {
-  Config config = 0;
-  mClient->getActiveConfig(
-      display, [&](const auto& tmpError, const auto& tmpConfig) {
+    Config config = 0;
+    mClient->getActiveConfig(display, [&](const auto& tmpError, const auto& tmpConfig) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get active config";
         config = tmpConfig;
-      });
+    });
 
-  return config;
+    return config;
 }
 
-bool ComposerClient::getClientTargetSupport(Display display, uint32_t width,
-                                            uint32_t height, PixelFormat format,
-                                            Dataspace dataspace) {
-  Error error = mClient->getClientTargetSupport(display, width, height, format,
-                                                dataspace);
-  return error == Error::NONE;
+bool ComposerClient::getClientTargetSupport(Display display, uint32_t width, uint32_t height,
+                                            PixelFormat format, Dataspace dataspace) {
+    Error error = mClient->getClientTargetSupport(display, width, height, format, dataspace);
+    return error == Error::NONE;
 }
 
 std::vector<ColorMode> ComposerClient::getColorModes(Display display) {
-  std::vector<ColorMode> modes;
-  mClient->getColorModes(
-      display, [&](const auto& tmpError, const auto& tmpMode) {
+    std::vector<ColorMode> modes;
+    mClient->getColorModes(display, [&](const auto& tmpError, const auto& tmpMode) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get color mode";
         modes = tmpMode;
-      });
+    });
 
-  return modes;
+    return modes;
 }
 
-int32_t ComposerClient::getDisplayAttribute(
-    Display display, Config config, IComposerClient::Attribute attribute) {
-  int32_t value = 0;
-  mClient->getDisplayAttribute(display, config, attribute,
-                               [&](const auto& tmpError, const auto& tmpValue) {
-                                 ASSERT_EQ(Error::NONE, tmpError)
-                                     << "failed to get display attribute";
-                                 value = tmpValue;
-                               });
+int32_t ComposerClient::getDisplayAttribute(Display display, Config config,
+                                            IComposerClient::Attribute attribute) {
+    int32_t value = 0;
+    mClient->getDisplayAttribute(
+        display, config, attribute, [&](const auto& tmpError, const auto& tmpValue) {
+            ASSERT_EQ(Error::NONE, tmpError) << "failed to get display attribute";
+            value = tmpValue;
+        });
 
-  return value;
+    return value;
 }
 
 std::vector<Config> ComposerClient::getDisplayConfigs(Display display) {
-  std::vector<Config> configs;
-  mClient->getDisplayConfigs(
-      display, [&](const auto& tmpError, const auto& tmpConfigs) {
+    std::vector<Config> configs;
+    mClient->getDisplayConfigs(display, [&](const auto& tmpError, const auto& tmpConfigs) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get display configs";
         configs = tmpConfigs;
-      });
+    });
 
-  return configs;
+    return configs;
 }
 
 std::string ComposerClient::getDisplayName(Display display) {
-  std::string name;
-  mClient->getDisplayName(
-      display, [&](const auto& tmpError, const auto& tmpName) {
+    std::string name;
+    mClient->getDisplayName(display, [&](const auto& tmpError, const auto& tmpName) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get display name";
         name = tmpName.c_str();
-      });
+    });
 
-  return name;
+    return name;
 }
 
 IComposerClient::DisplayType ComposerClient::getDisplayType(Display display) {
-  IComposerClient::DisplayType type = IComposerClient::DisplayType::INVALID;
-  mClient->getDisplayType(
-      display, [&](const auto& tmpError, const auto& tmpType) {
+    IComposerClient::DisplayType type = IComposerClient::DisplayType::INVALID;
+    mClient->getDisplayType(display, [&](const auto& tmpError, const auto& tmpType) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get display type";
         type = tmpType;
-      });
+    });
 
-  return type;
+    return type;
 }
 
 bool ComposerClient::getDozeSupport(Display display) {
-  bool support = false;
-  mClient->getDozeSupport(
-      display, [&](const auto& tmpError, const auto& tmpSupport) {
+    bool support = false;
+    mClient->getDozeSupport(display, [&](const auto& tmpError, const auto& tmpSupport) {
         ASSERT_EQ(Error::NONE, tmpError) << "failed to get doze support";
         support = tmpSupport;
-      });
+    });
 
-  return support;
+    return support;
 }
 
-std::vector<Hdr> ComposerClient::getHdrCapabilities(
-    Display display, float* outMaxLuminance, float* outMaxAverageLuminance,
-    float* outMinLuminance) {
-  std::vector<Hdr> types;
-  mClient->getHdrCapabilities(
-      display,
-      [&](const auto& tmpError, const auto& tmpTypes,
-          const auto& tmpMaxLuminance, const auto& tmpMaxAverageLuminance,
-          const auto& tmpMinLuminance) {
-        ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities";
-        types = tmpTypes;
-        *outMaxLuminance = tmpMaxLuminance;
-        *outMaxAverageLuminance = tmpMaxAverageLuminance;
-        *outMinLuminance = tmpMinLuminance;
-      });
+std::vector<Hdr> ComposerClient::getHdrCapabilities(Display display, float* outMaxLuminance,
+                                                    float* outMaxAverageLuminance,
+                                                    float* outMinLuminance) {
+    std::vector<Hdr> types;
+    mClient->getHdrCapabilities(
+        display, [&](const auto& tmpError, const auto& tmpTypes, const auto& tmpMaxLuminance,
+                     const auto& tmpMaxAverageLuminance, const auto& tmpMinLuminance) {
+            ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities";
+            types = tmpTypes;
+            *outMaxLuminance = tmpMaxLuminance;
+            *outMaxAverageLuminance = tmpMaxAverageLuminance;
+            *outMinLuminance = tmpMinLuminance;
+        });
 
-  return types;
+    return types;
 }
 
-void ComposerClient::setClientTargetSlotCount(Display display,
-                                              uint32_t clientTargetSlotCount) {
-  Error error =
-      mClient->setClientTargetSlotCount(display, clientTargetSlotCount);
-  ASSERT_EQ(Error::NONE, error) << "failed to set client target slot count";
+void ComposerClient::setClientTargetSlotCount(Display display, uint32_t clientTargetSlotCount) {
+    Error error = mClient->setClientTargetSlotCount(display, clientTargetSlotCount);
+    ASSERT_EQ(Error::NONE, error) << "failed to set client target slot count";
 }
 
 void ComposerClient::setActiveConfig(Display display, Config config) {
-  Error error = mClient->setActiveConfig(display, config);
-  ASSERT_EQ(Error::NONE, error) << "failed to set active config";
+    Error error = mClient->setActiveConfig(display, config);
+    ASSERT_EQ(Error::NONE, error) << "failed to set active config";
 }
 
 void ComposerClient::setColorMode(Display display, ColorMode mode) {
-  Error error = mClient->setColorMode(display, mode);
-  ASSERT_EQ(Error::NONE, error) << "failed to set color mode";
+    Error error = mClient->setColorMode(display, mode);
+    ASSERT_EQ(Error::NONE, error) << "failed to set color mode";
 }
 
-void ComposerClient::setPowerMode(Display display,
-                                  IComposerClient::PowerMode mode) {
-  Error error = mClient->setPowerMode(display, mode);
-  ASSERT_EQ(Error::NONE, error) << "failed to set power mode";
+void ComposerClient::setPowerMode(Display display, IComposerClient::PowerMode mode) {
+    Error error = mClient->setPowerMode(display, mode);
+    ASSERT_EQ(Error::NONE, error) << "failed to set power mode";
 }
 
 void ComposerClient::setVsyncEnabled(Display display, bool enabled) {
-  IComposerClient::Vsync vsync = (enabled) ? IComposerClient::Vsync::ENABLE
-                                           : IComposerClient::Vsync::DISABLE;
-  Error error = mClient->setVsyncEnabled(display, vsync);
-  ASSERT_EQ(Error::NONE, error) << "failed to set vsync mode";
+    IComposerClient::Vsync vsync =
+        (enabled) ? IComposerClient::Vsync::ENABLE : IComposerClient::Vsync::DISABLE;
+    Error error = mClient->setVsyncEnabled(display, vsync);
+    ASSERT_EQ(Error::NONE, error) << "failed to set vsync mode";
 
-  // give the hwbinder thread some time to handle any pending vsync callback
-  if (!enabled) {
-      usleep(5 * 1000);
-  }
+    // give the hwbinder thread some time to handle any pending vsync callback
+    if (!enabled) {
+        usleep(5 * 1000);
+    }
 }
 
-void ComposerClient::execute(TestCommandReader* reader,
-                             CommandWriterBase* writer) {
-  bool queueChanged = false;
-  uint32_t commandLength = 0;
-  hidl_vec<hidl_handle> commandHandles;
-  ASSERT_TRUE(
-      writer->writeQueue(&queueChanged, &commandLength, &commandHandles));
+void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* writer) {
+    bool queueChanged = false;
+    uint32_t commandLength = 0;
+    hidl_vec<hidl_handle> commandHandles;
+    ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles));
 
-  if (queueChanged) {
-    auto ret = mClient->setInputCommandQueue(*writer->getMQDescriptor());
-    ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
-    return;
-  }
+    if (queueChanged) {
+        auto ret = mClient->setInputCommandQueue(*writer->getMQDescriptor());
+        ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
+        return;
+    }
 
-  mClient->executeCommands(
-      commandLength, commandHandles,
-      [&](const auto& tmpError, const auto& tmpOutQueueChanged,
-          const auto& tmpOutLength, const auto& tmpOutHandles) {
-        ASSERT_EQ(Error::NONE, tmpError);
+    mClient->executeCommands(commandLength, commandHandles,
+                             [&](const auto& tmpError, const auto& tmpOutQueueChanged,
+                                 const auto& tmpOutLength, const auto& tmpOutHandles) {
+                                 ASSERT_EQ(Error::NONE, tmpError);
 
-        if (tmpOutQueueChanged) {
-          mClient->getOutputCommandQueue(
-              [&](const auto& tmpError, const auto& tmpDescriptor) {
-                ASSERT_EQ(Error::NONE, tmpError);
-                reader->setMQDescriptor(tmpDescriptor);
-              });
-        }
+                                 if (tmpOutQueueChanged) {
+                                     mClient->getOutputCommandQueue(
+                                         [&](const auto& tmpError, const auto& tmpDescriptor) {
+                                             ASSERT_EQ(Error::NONE, tmpError);
+                                             reader->setMQDescriptor(tmpDescriptor);
+                                         });
+                                 }
 
-        ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles));
-        reader->parse();
-      });
+                                 ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles));
+                                 reader->parse();
+                             });
 }
 
 }  // namespace tests
diff --git a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/GraphicsComposerCallback.h b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/GraphicsComposerCallback.h
index e332086..a42dac5 100644
--- a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/GraphicsComposerCallback.h
+++ b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/GraphicsComposerCallback.h
@@ -31,32 +31,32 @@
 
 // IComposerCallback to be installed with IComposerClient::registerCallback.
 class GraphicsComposerCallback : public IComposerCallback {
- public:
-  void setVsyncAllowed(bool allowed);
+   public:
+    void setVsyncAllowed(bool allowed);
 
-  std::vector<Display> getDisplays() const;
+    std::vector<Display> getDisplays() const;
 
-  int getInvalidHotplugCount() const;
+    int getInvalidHotplugCount() const;
 
-  int getInvalidRefreshCount() const;
+    int getInvalidRefreshCount() const;
 
-  int getInvalidVsyncCount() const;
+    int getInvalidVsyncCount() const;
 
- private:
-  Return<void> onHotplug(Display display, Connection connection) override;
-  Return<void> onRefresh(Display display) override;
-  Return<void> onVsync(Display display, int64_t) override;
+   private:
+    Return<void> onHotplug(Display display, Connection connection) override;
+    Return<void> onRefresh(Display display) override;
+    Return<void> onVsync(Display display, int64_t) override;
 
-  mutable std::mutex mMutex;
-  // the set of all currently connected displays
-  std::unordered_set<Display> mDisplays;
-  // true only when vsync is enabled
-  bool mVsyncAllowed = true;
+    mutable std::mutex mMutex;
+    // the set of all currently connected displays
+    std::unordered_set<Display> mDisplays;
+    // true only when vsync is enabled
+    bool mVsyncAllowed = true;
 
-  // track invalid callbacks
-  int mInvalidHotplugCount = 0;
-  int mInvalidRefreshCount = 0;
-  int mInvalidVsyncCount = 0;
+    // track invalid callbacks
+    int mInvalidHotplugCount = 0;
+    int mInvalidRefreshCount = 0;
+    int mInvalidVsyncCount = 0;
 };
 
 }  // namespace tests
diff --git a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/TestCommandReader.h b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/TestCommandReader.h
index ae25d2d..fd7764f 100644
--- a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/TestCommandReader.h
+++ b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/TestCommandReader.h
@@ -29,10 +29,10 @@
 // A command parser that checks that no error nor unexpected commands are
 // returned.
 class TestCommandReader : public CommandReaderBase {
- public:
-  // Parse all commands in the return command queue.  Call GTEST_FAIL() for
-  // unexpected errors or commands.
-  void parse();
+   public:
+    // Parse all commands in the return command queue.  Call GTEST_FAIL() for
+    // unexpected errors or commands.
+    void parse();
 };
 
 }  // namespace tests
diff --git a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/VtsHalGraphicsComposerTestUtils.h b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/VtsHalGraphicsComposerTestUtils.h
index 00d9d8c..2a0b960 100644
--- a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/VtsHalGraphicsComposerTestUtils.h
+++ b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/VtsHalGraphicsComposerTestUtils.h
@@ -45,83 +45,79 @@
 
 // A wrapper to IComposer.
 class Composer {
- public:
-  Composer();
-  explicit Composer(const std::string& name);
+   public:
+    Composer();
+    explicit Composer(const std::string& name);
 
-  sp<IComposer> getRaw() const;
+    sp<IComposer> getRaw() const;
 
-  // Returns true when the composer supports the specified capability.
-  bool hasCapability(IComposer::Capability capability) const;
+    // Returns true when the composer supports the specified capability.
+    bool hasCapability(IComposer::Capability capability) const;
 
-  std::vector<IComposer::Capability> getCapabilities();
-  std::string dumpDebugInfo();
-  std::unique_ptr<ComposerClient> createClient();
+    std::vector<IComposer::Capability> getCapabilities();
+    std::string dumpDebugInfo();
+    std::unique_ptr<ComposerClient> createClient();
 
- protected:
-  sp<IComposer> mComposer;
+   protected:
+    sp<IComposer> mComposer;
 
- private:
-  void init();
+   private:
+    void init();
 
-  std::unordered_set<IComposer::Capability> mCapabilities;
+    std::unordered_set<IComposer::Capability> mCapabilities;
 };
 
 // A wrapper to IComposerClient.
 class ComposerClient {
- public:
-  ComposerClient(const sp<IComposerClient>& client);
-  ~ComposerClient();
+   public:
+    ComposerClient(const sp<IComposerClient>& client);
+    ~ComposerClient();
 
-  sp<IComposerClient> getRaw() const;
+    sp<IComposerClient> getRaw() const;
 
-  void registerCallback(const sp<IComposerCallback>& callback);
-  uint32_t getMaxVirtualDisplayCount();
+    void registerCallback(const sp<IComposerCallback>& callback);
+    uint32_t getMaxVirtualDisplayCount();
 
-  Display createVirtualDisplay(uint32_t width, uint32_t height,
-                               PixelFormat formatHint,
-                               uint32_t outputBufferSlotCount,
-                               PixelFormat* outFormat);
-  void destroyVirtualDisplay(Display display);
+    Display createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat formatHint,
+                                 uint32_t outputBufferSlotCount, PixelFormat* outFormat);
+    void destroyVirtualDisplay(Display display);
 
-  Layer createLayer(Display display, uint32_t bufferSlotCount);
-  void destroyLayer(Display display, Layer layer);
+    Layer createLayer(Display display, uint32_t bufferSlotCount);
+    void destroyLayer(Display display, Layer layer);
 
-  Config getActiveConfig(Display display);
-  bool getClientTargetSupport(Display display, uint32_t width, uint32_t height,
-                              PixelFormat format, Dataspace dataspace);
-  std::vector<ColorMode> getColorModes(Display display);
-  int32_t getDisplayAttribute(Display display, Config config,
-                              IComposerClient::Attribute attribute);
-  std::vector<Config> getDisplayConfigs(Display display);
-  std::string getDisplayName(Display display);
-  IComposerClient::DisplayType getDisplayType(Display display);
-  bool getDozeSupport(Display display);
-  std::vector<Hdr> getHdrCapabilities(Display display, float* outMaxLuminance,
-                                      float* outMaxAverageLuminance,
-                                      float* outMinLuminance);
+    Config getActiveConfig(Display display);
+    bool getClientTargetSupport(Display display, uint32_t width, uint32_t height,
+                                PixelFormat format, Dataspace dataspace);
+    std::vector<ColorMode> getColorModes(Display display);
+    int32_t getDisplayAttribute(Display display, Config config,
+                                IComposerClient::Attribute attribute);
+    std::vector<Config> getDisplayConfigs(Display display);
+    std::string getDisplayName(Display display);
+    IComposerClient::DisplayType getDisplayType(Display display);
+    bool getDozeSupport(Display display);
+    std::vector<Hdr> getHdrCapabilities(Display display, float* outMaxLuminance,
+                                        float* outMaxAverageLuminance, float* outMinLuminance);
 
-  void setClientTargetSlotCount(Display display,
-                                uint32_t clientTargetSlotCount);
-  void setActiveConfig(Display display, Config config);
-  void setColorMode(Display display, ColorMode mode);
-  void setPowerMode(Display display, IComposerClient::PowerMode mode);
-  void setVsyncEnabled(Display display, bool enabled);
+    void setClientTargetSlotCount(Display display, uint32_t clientTargetSlotCount);
+    void setActiveConfig(Display display, Config config);
+    void setColorMode(Display display, ColorMode mode);
+    void setPowerMode(Display display, IComposerClient::PowerMode mode);
+    void setVsyncEnabled(Display display, bool enabled);
 
-  void execute(TestCommandReader* reader, CommandWriterBase* writer);
+    void execute(TestCommandReader* reader, CommandWriterBase* writer);
 
- private:
-  sp<IComposerClient> mClient;
+   private:
+    sp<IComposerClient> mClient;
 
-  // Keep track of all virtual displays and layers.  When a test fails with
-  // ASSERT_*, the destructor will clean up the resources for the test.
-  struct DisplayResource {
-    DisplayResource(bool isVirtual_) : isVirtual(isVirtual_) {}
+    // Keep track of all virtual displays and layers.  When a test fails with
+    // ASSERT_*, the destructor will clean up the resources for the test.
+    struct DisplayResource {
+        DisplayResource(bool isVirtual_) : isVirtual(isVirtual_) {}
 
-    bool isVirtual;
-    std::unordered_set<Layer> layers;
-  };
-  std::unordered_map<Display, DisplayResource> mDisplayResources;
+        bool isVirtual;
+        std::unordered_set<Layer> layers;
+    };
+    std::unordered_map<Display, DisplayResource> mDisplayResources;
 };
 
 }  // namespace tests
