diff --git a/cmds/surfacereplayer/replayer/Replayer.cpp b/cmds/surfacereplayer/replayer/Replayer.cpp
deleted file mode 100644
index 44235cc..0000000
--- a/cmds/surfacereplayer/replayer/Replayer.cpp
+++ /dev/null
@@ -1,707 +0,0 @@
-/* Copyright 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.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "SurfaceReplayer"
-
-#include "Replayer.h"
-
-#include <android/native_window.h>
-
-#include <android-base/file.h>
-
-#include <gui/BufferQueue.h>
-#include <gui/ISurfaceComposer.h>
-#include <gui/LayerState.h>
-#include <gui/Surface.h>
-#include <private/gui/ComposerService.h>
-
-#include <utils/Log.h>
-#include <utils/String8.h>
-#include <utils/Trace.h>
-
-#include <chrono>
-#include <cmath>
-#include <condition_variable>
-#include <cstdlib>
-#include <fstream>
-#include <functional>
-#include <iostream>
-#include <mutex>
-#include <sstream>
-#include <string>
-#include <thread>
-#include <vector>
-
-using namespace android;
-
-std::atomic_bool Replayer::sReplayingManually(false);
-
-Replayer::Replayer(const std::string& filename, bool replayManually, int numThreads, bool wait,
-        nsecs_t stopHere)
-      : mTrace(),
-        mLoaded(false),
-        mIncrementIndex(0),
-        mCurrentTime(0),
-        mNumThreads(numThreads),
-        mWaitForTimeStamps(wait),
-        mStopTimeStamp(stopHere) {
-    srand(RAND_COLOR_SEED);
-
-    std::string input;
-    if (!android::base::ReadFileToString(filename, &input, true)) {
-        std::cerr << "Trace did not load. Does " << filename << " exist?" << std::endl;
-        abort();
-    }
-
-    mLoaded = mTrace.ParseFromString(input);
-    if (!mLoaded) {
-        std::cerr << "Trace did not load." << std::endl;
-        abort();
-    }
-
-    mCurrentTime = mTrace.increment(0).time_stamp();
-
-    sReplayingManually.store(replayManually);
-
-    if (stopHere < 0) {
-        mHasStopped = true;
-    }
-}
-
-Replayer::Replayer(const Trace& t, bool replayManually, int numThreads, bool wait, nsecs_t stopHere)
-      : mTrace(t),
-        mLoaded(true),
-        mIncrementIndex(0),
-        mCurrentTime(0),
-        mNumThreads(numThreads),
-        mWaitForTimeStamps(wait),
-        mStopTimeStamp(stopHere) {
-    srand(RAND_COLOR_SEED);
-    mCurrentTime = mTrace.increment(0).time_stamp();
-
-    sReplayingManually.store(replayManually);
-
-    if (stopHere < 0) {
-        mHasStopped = true;
-    }
-}
-
-status_t Replayer::replay() {
-    signal(SIGINT, Replayer::stopAutoReplayHandler); //for manual control
-
-    ALOGV("There are %d increments.", mTrace.increment_size());
-
-    status_t status = loadSurfaceComposerClient();
-
-    if (status != NO_ERROR) {
-        ALOGE("Couldn't create SurfaceComposerClient (%d)", status);
-        return status;
-    }
-
-    SurfaceComposerClient::enableVSyncInjections(true);
-
-    initReplay();
-
-    ALOGV("Starting actual Replay!");
-    while (!mPendingIncrements.empty()) {
-        mCurrentIncrement = mTrace.increment(mIncrementIndex);
-
-        if (mHasStopped == false && mCurrentIncrement.time_stamp() >= mStopTimeStamp) {
-            mHasStopped = true;
-            sReplayingManually.store(true);
-        }
-
-        waitForConsoleCommmand();
-
-        if (mWaitForTimeStamps) {
-            waitUntilTimestamp(mCurrentIncrement.time_stamp());
-        }
-
-        auto event = mPendingIncrements.front();
-        mPendingIncrements.pop();
-
-        event->complete();
-
-        if (event->getIncrementType() == Increment::kVsyncEvent) {
-            mWaitingForNextVSync = false;
-        }
-
-        if (mIncrementIndex + mNumThreads < mTrace.increment_size()) {
-            status = dispatchEvent(mIncrementIndex + mNumThreads);
-
-            if (status != NO_ERROR) {
-                SurfaceComposerClient::enableVSyncInjections(false);
-                return status;
-            }
-        }
-
-        mIncrementIndex++;
-        mCurrentTime = mCurrentIncrement.time_stamp();
-    }
-
-    SurfaceComposerClient::enableVSyncInjections(false);
-
-    return status;
-}
-
-status_t Replayer::initReplay() {
-    for (int i = 0; i < mNumThreads && i < mTrace.increment_size(); i++) {
-        status_t status = dispatchEvent(i);
-
-        if (status != NO_ERROR) {
-            ALOGE("Unable to dispatch event (%d)", status);
-            return status;
-        }
-    }
-
-    return NO_ERROR;
-}
-
-void Replayer::stopAutoReplayHandler(int /*signal*/) {
-    if (sReplayingManually) {
-        SurfaceComposerClient::enableVSyncInjections(false);
-        exit(0);
-    }
-
-    sReplayingManually.store(true);
-}
-
-std::vector<std::string> split(const std::string& s, const char delim) {
-    std::vector<std::string> elems;
-    std::stringstream ss(s);
-    std::string item;
-    while (getline(ss, item, delim)) {
-        elems.push_back(item);
-    }
-    return elems;
-}
-
-bool isNumber(const std::string& s) {
-    return !s.empty() &&
-           std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end();
-}
-
-void Replayer::waitForConsoleCommmand() {
-    if (!sReplayingManually || mWaitingForNextVSync) {
-        return;
-    }
-
-    while (true) {
-        std::string input = "";
-        std::cout << "> ";
-        getline(std::cin, input);
-
-        if (input.empty()) {
-            input = mLastInput;
-        } else {
-            mLastInput = input;
-        }
-
-        if (mLastInput.empty()) {
-            continue;
-        }
-
-        std::vector<std::string> inputs = split(input, ' ');
-
-        if (inputs[0] == "n") {  // next vsync
-            mWaitingForNextVSync = true;
-            break;
-
-        } else if (inputs[0] == "ni") {  // next increment
-            break;
-
-        } else if (inputs[0] == "c") {  // continue
-            if (inputs.size() > 1 && isNumber(inputs[1])) {
-                long milliseconds = stoi(inputs[1]);
-                std::thread([&] {
-                    std::cout << "Started!" << std::endl;
-                    std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
-                    sReplayingManually.store(true);
-                    std::cout << "Should have stopped!" << std::endl;
-                }).detach();
-            }
-            sReplayingManually.store(false);
-            mWaitingForNextVSync = false;
-            break;
-
-        } else if (inputs[0] == "s") {  // stop at this timestamp
-            if (inputs.size() < 1) {
-                std::cout << "No time stamp given" << std::endl;
-                continue;
-            }
-            sReplayingManually.store(false);
-            mStopTimeStamp = stol(inputs[1]);
-            mHasStopped = false;
-            break;
-        } else if (inputs[0] == "l") {  // list
-            std::cout << "Time stamp: " << mCurrentIncrement.time_stamp() << "\n";
-            continue;
-        } else if (inputs[0] == "q") {  // quit
-            SurfaceComposerClient::enableVSyncInjections(false);
-            exit(0);
-
-        } else if (inputs[0] == "h") {  // help
-                                        // add help menu
-            std::cout << "Manual Replay options:\n";
-            std::cout << " n  - Go to next VSync\n";
-            std::cout << " ni - Go to next increment\n";
-            std::cout << " c  - Continue\n";
-            std::cout << " c [milliseconds] - Continue until specified number of milliseconds\n";
-            std::cout << " s [timestamp]    - Continue and stop at specified timestamp\n";
-            std::cout << " l  - List out timestamp of current increment\n";
-            std::cout << " h  - Display help menu\n";
-            std::cout << std::endl;
-            continue;
-        }
-
-        std::cout << "Invalid Command" << std::endl;
-    }
-}
-
-status_t Replayer::dispatchEvent(int index) {
-    auto increment = mTrace.increment(index);
-    std::shared_ptr<Event> event = std::make_shared<Event>(increment.increment_case());
-    mPendingIncrements.push(event);
-
-    status_t status = NO_ERROR;
-    switch (increment.increment_case()) {
-        case increment.kTransaction: {
-            std::thread(&Replayer::doTransaction, this, increment.transaction(), event).detach();
-        } break;
-        case increment.kSurfaceCreation: {
-            std::thread(&Replayer::createSurfaceControl, this, increment.surface_creation(), event)
-                    .detach();
-        } break;
-        case increment.kBufferUpdate: {
-            std::lock_guard<std::mutex> lock1(mLayerLock);
-            std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock);
-
-            Dimensions dimensions(increment.buffer_update().w(), increment.buffer_update().h());
-            BufferEvent bufferEvent(event, dimensions);
-
-            auto layerId = increment.buffer_update().id();
-            if (mBufferQueueSchedulers.count(layerId) == 0) {
-                mBufferQueueSchedulers[layerId] = std::make_shared<BufferQueueScheduler>(
-                        mLayers[layerId], mColors[layerId], layerId);
-                mBufferQueueSchedulers[layerId]->addEvent(bufferEvent);
-
-                std::thread(&BufferQueueScheduler::startScheduling,
-                        mBufferQueueSchedulers[increment.buffer_update().id()].get())
-                        .detach();
-            } else {
-                auto bqs = mBufferQueueSchedulers[increment.buffer_update().id()];
-                bqs->addEvent(bufferEvent);
-            }
-        } break;
-        case increment.kVsyncEvent: {
-            std::thread(&Replayer::injectVSyncEvent, this, increment.vsync_event(), event).detach();
-        } break;
-        case increment.kDisplayCreation: {
-            std::thread(&Replayer::createDisplay, this, increment.display_creation(), event)
-                    .detach();
-        } break;
-        case increment.kDisplayDeletion: {
-            std::thread(&Replayer::deleteDisplay, this, increment.display_deletion(), event)
-                    .detach();
-        } break;
-        case increment.kPowerModeUpdate: {
-            std::thread(&Replayer::updatePowerMode, this, increment.power_mode_update(), event)
-                    .detach();
-        } break;
-        default:
-            ALOGE("Unknown Increment Type: %d", increment.increment_case());
-            status = BAD_VALUE;
-            break;
-    }
-
-    return status;
-}
-
-status_t Replayer::doTransaction(const Transaction& t, const std::shared_ptr<Event>& event) {
-    ALOGV("Started Transaction");
-
-    SurfaceComposerClient::Transaction liveTransaction;
-
-    status_t status = NO_ERROR;
-
-    status = doSurfaceTransaction(liveTransaction, t.surface_change());
-    doDisplayTransaction(liveTransaction, t.display_change());
-
-    if (t.animation()) {
-        liveTransaction.setAnimationTransaction();
-    }
-
-    event->readyToExecute();
-
-    liveTransaction.apply(t.synchronous());
-
-    ALOGV("Ended Transaction");
-
-    return status;
-}
-
-status_t Replayer::doSurfaceTransaction(
-        SurfaceComposerClient::Transaction& transaction,
-        const SurfaceChanges& surfaceChanges) {
-    status_t status = NO_ERROR;
-
-    for (const SurfaceChange& change : surfaceChanges) {
-        std::unique_lock<std::mutex> lock(mLayerLock);
-        if (mLayers[change.id()] == nullptr) {
-            mLayerCond.wait(lock, [&] { return (mLayers[change.id()] != nullptr); });
-        }
-
-        switch (change.SurfaceChange_case()) {
-            case SurfaceChange::SurfaceChangeCase::kPosition:
-                setPosition(transaction, change.id(), change.position());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kSize:
-                setSize(transaction, change.id(), change.size());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kAlpha:
-                setAlpha(transaction, change.id(), change.alpha());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kLayer:
-                setLayer(transaction, change.id(), change.layer());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kCrop:
-                setCrop(transaction, change.id(), change.crop());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kCornerRadius:
-                setCornerRadius(transaction, change.id(), change.corner_radius());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kMatrix:
-                setMatrix(transaction, change.id(), change.matrix());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kTransparentRegionHint:
-                setTransparentRegionHint(transaction, change.id(),
-                        change.transparent_region_hint());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kLayerStack:
-                setLayerStack(transaction, change.id(), change.layer_stack());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kHiddenFlag:
-                setHiddenFlag(transaction, change.id(), change.hidden_flag());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kOpaqueFlag:
-                setOpaqueFlag(transaction, change.id(), change.opaque_flag());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kSecureFlag:
-                setSecureFlag(transaction, change.id(), change.secure_flag());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kReparent:
-                setReparentChange(transaction, change.id(), change.reparent());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kRelativeParent:
-                setRelativeParentChange(transaction, change.id(), change.relative_parent());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kShadowRadius:
-                setShadowRadiusChange(transaction, change.id(), change.shadow_radius());
-                break;
-            case SurfaceChange::SurfaceChangeCase::kBlurRegions:
-                setBlurRegionsChange(transaction, change.id(), change.blur_regions());
-                break;
-            default:
-                status = 1;
-                break;
-        }
-
-        if (status != NO_ERROR) {
-            ALOGE("Unknown Transaction Code");
-            return status;
-        }
-    }
-    return status;
-}
-
-void Replayer::doDisplayTransaction(SurfaceComposerClient::Transaction& t,
-        const DisplayChanges& displayChanges) {
-    for (const DisplayChange& change : displayChanges) {
-        ALOGV("Doing display transaction");
-        std::unique_lock<std::mutex> lock(mDisplayLock);
-        if (mDisplays[change.id()] == nullptr) {
-            mDisplayCond.wait(lock, [&] { return (mDisplays[change.id()] != nullptr); });
-        }
-
-        switch (change.DisplayChange_case()) {
-            case DisplayChange::DisplayChangeCase::kSurface:
-                setDisplaySurface(t, change.id(), change.surface());
-                break;
-            case DisplayChange::DisplayChangeCase::kLayerStack:
-                setDisplayLayerStack(t, change.id(), change.layer_stack());
-                break;
-            case DisplayChange::DisplayChangeCase::kSize:
-                setDisplaySize(t, change.id(), change.size());
-                break;
-            case DisplayChange::DisplayChangeCase::kProjection:
-                setDisplayProjection(t, change.id(), change.projection());
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-void Replayer::setPosition(SurfaceComposerClient::Transaction& t,
-        layer_id id, const PositionChange& pc) {
-    ALOGV("Layer %d: Setting Position -- x=%f, y=%f", id, pc.x(), pc.y());
-    t.setPosition(mLayers[id], pc.x(), pc.y());
-}
-
-void Replayer::setSize(SurfaceComposerClient::Transaction& t,
-        layer_id id, const SizeChange& sc) {
-    ALOGV("Layer %d: Setting Size -- w=%u, h=%u", id, sc.w(), sc.h());
-}
-
-void Replayer::setLayer(SurfaceComposerClient::Transaction& t,
-        layer_id id, const LayerChange& lc) {
-    ALOGV("Layer %d: Setting Layer -- layer=%d", id, lc.layer());
-    t.setLayer(mLayers[id], lc.layer());
-}
-
-void Replayer::setAlpha(SurfaceComposerClient::Transaction& t,
-        layer_id id, const AlphaChange& ac) {
-    ALOGV("Layer %d: Setting Alpha -- alpha=%f", id, ac.alpha());
-    t.setAlpha(mLayers[id], ac.alpha());
-}
-
-void Replayer::setCrop(SurfaceComposerClient::Transaction& t,
-        layer_id id, const CropChange& cc) {
-    ALOGV("Layer %d: Setting Crop -- left=%d, top=%d, right=%d, bottom=%d", id,
-            cc.rectangle().left(), cc.rectangle().top(), cc.rectangle().right(),
-            cc.rectangle().bottom());
-
-    Rect r = Rect(cc.rectangle().left(), cc.rectangle().top(), cc.rectangle().right(),
-            cc.rectangle().bottom());
-    t.setCrop(mLayers[id], r);
-}
-
-void Replayer::setCornerRadius(SurfaceComposerClient::Transaction& t,
-        layer_id id, const CornerRadiusChange& cc) {
-    ALOGV("Layer %d: Setting Corner Radius -- cornerRadius=%d", id, cc.corner_radius());
-
-    t.setCornerRadius(mLayers[id], cc.corner_radius());
-}
-
-void Replayer::setBackgroundBlurRadius(SurfaceComposerClient::Transaction& t,
-        layer_id id, const BackgroundBlurRadiusChange& cc) {
-    ALOGV("Layer %d: Setting Background Blur Radius -- backgroundBlurRadius=%d", id,
-        cc.background_blur_radius());
-
-    t.setBackgroundBlurRadius(mLayers[id], cc.background_blur_radius());
-}
-
-void Replayer::setMatrix(SurfaceComposerClient::Transaction& t,
-        layer_id id, const MatrixChange& mc) {
-    ALOGV("Layer %d: Setting Matrix -- dsdx=%f, dtdx=%f, dsdy=%f, dtdy=%f", id, mc.dsdx(),
-            mc.dtdx(), mc.dsdy(), mc.dtdy());
-    t.setMatrix(mLayers[id], mc.dsdx(), mc.dtdx(), mc.dsdy(), mc.dtdy());
-}
-
-void Replayer::setTransparentRegionHint(SurfaceComposerClient::Transaction& t,
-        layer_id id, const TransparentRegionHintChange& trhc) {
-    ALOGV("Setting Transparent Region Hint");
-    Region re = Region();
-
-    for (const auto& r : trhc.region()) {
-        Rect rect = Rect(r.left(), r.top(), r.right(), r.bottom());
-        re.merge(rect);
-    }
-
-    t.setTransparentRegionHint(mLayers[id], re);
-}
-
-void Replayer::setLayerStack(SurfaceComposerClient::Transaction& t,
-        layer_id id, const LayerStackChange& lsc) {
-    ALOGV("Layer %d: Setting LayerStack -- layer_stack=%d", id, lsc.layer_stack());
-    t.setLayerStack(mLayers[id], ui::LayerStack::fromValue(lsc.layer_stack()));
-}
-
-void Replayer::setHiddenFlag(SurfaceComposerClient::Transaction& t,
-        layer_id id, const HiddenFlagChange& hfc) {
-    ALOGV("Layer %d: Setting Hidden Flag -- hidden_flag=%d", id, hfc.hidden_flag());
-    layer_id flag = hfc.hidden_flag() ? layer_state_t::eLayerHidden : 0;
-
-    t.setFlags(mLayers[id], flag, layer_state_t::eLayerHidden);
-}
-
-void Replayer::setOpaqueFlag(SurfaceComposerClient::Transaction& t,
-        layer_id id, const OpaqueFlagChange& ofc) {
-    ALOGV("Layer %d: Setting Opaque Flag -- opaque_flag=%d", id, ofc.opaque_flag());
-    layer_id flag = ofc.opaque_flag() ? layer_state_t::eLayerOpaque : 0;
-
-    t.setFlags(mLayers[id], flag, layer_state_t::eLayerOpaque);
-}
-
-void Replayer::setSecureFlag(SurfaceComposerClient::Transaction& t,
-        layer_id id, const SecureFlagChange& sfc) {
-    ALOGV("Layer %d: Setting Secure Flag -- secure_flag=%d", id, sfc.secure_flag());
-    layer_id flag = sfc.secure_flag() ? layer_state_t::eLayerSecure : 0;
-
-    t.setFlags(mLayers[id], flag, layer_state_t::eLayerSecure);
-}
-
-void Replayer::setDisplaySurface(SurfaceComposerClient::Transaction& t,
-        display_id id, const DispSurfaceChange& /*dsc*/) {
-    sp<IGraphicBufferProducer> outProducer;
-    sp<IGraphicBufferConsumer> outConsumer;
-    BufferQueue::createBufferQueue(&outProducer, &outConsumer);
-
-    t.setDisplaySurface(mDisplays[id], outProducer);
-}
-
-void Replayer::setDisplayLayerStack(SurfaceComposerClient::Transaction& t,
-        display_id id, const LayerStackChange& lsc) {
-    t.setDisplayLayerStack(mDisplays[id], ui::LayerStack::fromValue(lsc.layer_stack()));
-}
-
-void Replayer::setDisplaySize(SurfaceComposerClient::Transaction& t,
-        display_id id, const SizeChange& sc) {
-    t.setDisplaySize(mDisplays[id], sc.w(), sc.h());
-}
-
-void Replayer::setDisplayProjection(SurfaceComposerClient::Transaction& t,
-        display_id id, const ProjectionChange& pc) {
-    Rect viewport = Rect(pc.viewport().left(), pc.viewport().top(), pc.viewport().right(),
-            pc.viewport().bottom());
-    Rect frame = Rect(pc.frame().left(), pc.frame().top(), pc.frame().right(), pc.frame().bottom());
-
-    t.setDisplayProjection(mDisplays[id], ui::toRotation(pc.orientation()), viewport, frame);
-}
-
-status_t Replayer::createSurfaceControl(
-        const SurfaceCreation& create, const std::shared_ptr<Event>& event) {
-    event->readyToExecute();
-
-    ALOGV("Creating Surface Control: ID: %d", create.id());
-    sp<SurfaceControl> surfaceControl = mComposerClient->createSurface(
-            String8(create.name().c_str()), create.w(), create.h(), PIXEL_FORMAT_RGBA_8888, 0);
-
-    if (surfaceControl == nullptr) {
-        ALOGE("CreateSurfaceControl: unable to create surface control");
-        return BAD_VALUE;
-    }
-
-    std::lock_guard<std::mutex> lock1(mLayerLock);
-    auto& layer = mLayers[create.id()];
-    layer = surfaceControl;
-
-    mColors[create.id()] = HSV(rand() % 360, 1, 1);
-
-    mLayerCond.notify_all();
-
-    std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock);
-    if (mBufferQueueSchedulers.count(create.id()) != 0) {
-        mBufferQueueSchedulers[create.id()]->setSurfaceControl(
-                mLayers[create.id()], mColors[create.id()]);
-    }
-
-    return NO_ERROR;
-}
-
-status_t Replayer::injectVSyncEvent(
-        const VSyncEvent& vSyncEvent, const std::shared_ptr<Event>& event) {
-    ALOGV("Injecting VSync Event");
-
-    event->readyToExecute();
-
-    SurfaceComposerClient::injectVSync(vSyncEvent.when());
-
-    return NO_ERROR;
-}
-
-void Replayer::createDisplay(const DisplayCreation& create, const std::shared_ptr<Event>& event) {
-    ALOGV("Creating display");
-    event->readyToExecute();
-
-    std::lock_guard<std::mutex> lock(mDisplayLock);
-    sp<IBinder> display = SurfaceComposerClient::createDisplay(
-            String8(create.name().c_str()), create.is_secure());
-    mDisplays[create.id()] = display;
-
-    mDisplayCond.notify_all();
-
-    ALOGV("Done creating display");
-}
-
-void Replayer::deleteDisplay(const DisplayDeletion& delete_, const std::shared_ptr<Event>& event) {
-    ALOGV("Delete display");
-    event->readyToExecute();
-
-    std::lock_guard<std::mutex> lock(mDisplayLock);
-    SurfaceComposerClient::destroyDisplay(mDisplays[delete_.id()]);
-    mDisplays.erase(delete_.id());
-}
-
-void Replayer::updatePowerMode(const PowerModeUpdate& pmu, const std::shared_ptr<Event>& event) {
-    ALOGV("Updating power mode");
-    event->readyToExecute();
-    SurfaceComposerClient::setDisplayPowerMode(mDisplays[pmu.id()], pmu.mode());
-}
-
-void Replayer::waitUntilTimestamp(int64_t timestamp) {
-    ALOGV("Waiting for %lld nanoseconds...", static_cast<int64_t>(timestamp - mCurrentTime));
-    std::this_thread::sleep_for(std::chrono::nanoseconds(timestamp - mCurrentTime));
-}
-
-status_t Replayer::loadSurfaceComposerClient() {
-    mComposerClient = new SurfaceComposerClient;
-    return mComposerClient->initCheck();
-}
-
-void Replayer::setReparentChange(SurfaceComposerClient::Transaction& t,
-        layer_id id, const ReparentChange& c) {
-    sp<SurfaceControl> newSurfaceControl = nullptr;
-    if (mLayers.count(c.parent_id()) != 0 && mLayers[c.parent_id()] != nullptr) {
-        newSurfaceControl = mLayers[c.parent_id()];
-    }
-    t.reparent(mLayers[id], newSurfaceControl);
-}
-
-void Replayer::setRelativeParentChange(SurfaceComposerClient::Transaction& t,
-        layer_id id, const RelativeParentChange& c) {
-    if (mLayers.count(c.relative_parent_id()) == 0 || mLayers[c.relative_parent_id()] == nullptr) {
-        ALOGE("Layer %d not found in set relative parent transaction", c.relative_parent_id());
-        return;
-    }
-    t.setRelativeLayer(mLayers[id], mLayers[c.relative_parent_id()], c.z());
-}
-
-void Replayer::setShadowRadiusChange(SurfaceComposerClient::Transaction& t,
-        layer_id id, const ShadowRadiusChange& c) {
-    t.setShadowRadius(mLayers[id], c.radius());
-}
-
-void Replayer::setBlurRegionsChange(SurfaceComposerClient::Transaction& t,
-        layer_id id, const BlurRegionsChange& c) {
-    std::vector<BlurRegion> regions;
-    for(size_t i=0; i < c.blur_regions_size(); i++) {
-        auto protoRegion = c.blur_regions(i);
-        regions.push_back(BlurRegion{
-            .blurRadius = protoRegion.blur_radius(),
-            .alpha = protoRegion.alpha(),
-            .cornerRadiusTL = protoRegion.corner_radius_tl(),
-            .cornerRadiusTR = protoRegion.corner_radius_tr(),
-            .cornerRadiusBL = protoRegion.corner_radius_bl(),
-            .cornerRadiusBR = protoRegion.corner_radius_br(),
-            .left = protoRegion.left(),
-            .top = protoRegion.top(),
-            .right = protoRegion.right(),
-            .bottom = protoRegion.bottom()
-        });
-    }
-    t.setBlurRegions(mLayers[id], regions);
-}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 3743025..7aaaebb 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -89,6 +89,8 @@
 void emptyCallback(nsecs_t, const sp<Fence>&, const std::vector<SurfaceControlStats>&) {}
 } // namespace
 
+const std::string SurfaceComposerClient::kEmpty{};
+
 ComposerService::ComposerService()
 : Singleton<ComposerService>() {
     Mutex::Autolock _l(mLock);
@@ -1278,14 +1280,13 @@
 }
 // ---------------------------------------------------------------------------
 
-sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool secure,
-                                                 float requestedRefereshRate) {
+sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool isSecure,
+                                                 const std::string& uniqueId,
+                                                 float requestedRefreshRate) {
     sp<IBinder> display = nullptr;
-    binder::Status status =
-            ComposerServiceAIDL::getComposerService()->createDisplay(std::string(
-                                                                             displayName.c_str()),
-                                                                     secure, requestedRefereshRate,
-                                                                     &display);
+    binder::Status status = ComposerServiceAIDL::getComposerService()
+                                    ->createDisplay(std::string(displayName.c_str()), isSecure,
+                                                    uniqueId, requestedRefreshRate, &display);
     return status.isOk() ? display : nullptr;
 }
 
diff --git a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
index a2549e7..c6e7197 100644
--- a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
+++ b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
@@ -72,7 +72,7 @@
     void bootFinished();
 
     /**
-     * Create a display event connection
+     * Create a display event connection.
      *
      * layerHandle
      *     Optional binder handle representing a Layer in SF to associate the new
@@ -89,12 +89,14 @@
     @nullable ISurfaceComposerClient createConnection();
 
     /**
-     * Create a virtual display
+     * Create a virtual display.
      *
      * displayName
-     *     The name of the virtual display
-     * secure
-     *     Whether this virtual display is secure
+     *     The name of the virtual display.
+     * isSecure
+     *     Whether this virtual display is secure.
+     * uniqueId
+     *     The unique ID for the display.
      * requestedRefreshRate
      *     The refresh rate, frames per second, to request on the virtual display.
      *     This is just a request, the actual rate may be adjusted to align well
@@ -103,11 +105,11 @@
      *
      * requires ACCESS_SURFACE_FLINGER permission.
      */
-    @nullable IBinder createDisplay(@utf8InCpp String displayName, boolean secure,
-            float requestedRefreshRate);
+    @nullable IBinder createDisplay(@utf8InCpp String displayName, boolean isSecure,
+            @utf8InCpp String uniqueId, float requestedRefreshRate);
 
     /**
-     * Destroy a virtual display
+     * Destroy a virtual display.
      * requires ACCESS_SURFACE_FLINGER permission.
      */
     void destroyDisplay(IBinder display);
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 49b0a7d..987efe0 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -18,6 +18,7 @@
 
 #include <stdint.h>
 #include <sys/types.h>
+
 #include <set>
 #include <thread>
 #include <unordered_map>
@@ -374,17 +375,15 @@
 
     sp<SurfaceControl> mirrorDisplay(DisplayId displayId);
 
-    //! Create a virtual display
-    static sp<IBinder> createDisplay(const String8& displayName, bool secure,
-                                     float requestedRefereshRate = 0);
+    static const std::string kEmpty;
+    static sp<IBinder> createDisplay(const String8& displayName, bool isSecure,
+                                     const std::string& uniqueId = kEmpty,
+                                     float requestedRefreshRate = 0);
 
-    //! Destroy a virtual display
     static void destroyDisplay(const sp<IBinder>& display);
 
-    //! Get stable IDs for connected physical displays
     static std::vector<PhysicalDisplayId> getPhysicalDisplayIds();
 
-    //! Get token for a physical display given its stable ID
     static sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId);
 
     // Returns StalledTransactionInfo if a transaction from the provided pid has not been applied
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index f4b059c..eee4fb9 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -673,8 +673,8 @@
         return binder::Status::ok();
     }
 
-    binder::Status createDisplay(const std::string& /*displayName*/, bool /*secure*/,
-                                 float /*requestedRefreshRate*/,
+    binder::Status createDisplay(const std::string& /*displayName*/, bool /*isSecure*/,
+                                 const std::string& /*uniqueId*/, float /*requestedRefreshRate*/,
                                  sp<IBinder>* /*outDisplay*/) override {
         return binder::Status::ok();
     }
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index fc5089b..c2d09c9 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -329,6 +329,7 @@
     uint32_t width = 0;
     uint32_t height = 0;
     std::string displayName;
+    std::string uniqueId;
     bool isSecure = false;
     bool isProtected = false;
     // Refer to DisplayDevice::mRequestedRefreshRate, for virtual display only
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0d2e514..5181fb8 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -573,13 +573,13 @@
     mScheduler->run();
 }
 
-sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName, bool secure,
-                                          float requestedRefreshRate) {
+sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName, bool isSecure,
+                                          const std::string& uniqueId, float requestedRefreshRate) {
     // SurfaceComposerAIDL checks for some permissions, but adding an additional check here.
     // This is to ensure that only root, system, and graphics can request to create a secure
     // display. Secure displays can show secure content so we add an additional restriction on it.
-    const int uid = IPCThreadState::self()->getCallingUid();
-    if (secure && uid != AID_ROOT && uid != AID_GRAPHICS && uid != AID_SYSTEM) {
+    const uid_t uid = IPCThreadState::self()->getCallingUid();
+    if (isSecure && uid != AID_ROOT && uid != AID_GRAPHICS && uid != AID_SYSTEM) {
         ALOGE("Only privileged processes can create a secure display");
         return nullptr;
     }
@@ -603,11 +603,12 @@
     Mutex::Autolock _l(mStateLock);
     // Display ID is assigned when virtual display is allocated by HWC.
     DisplayDeviceState state;
-    state.isSecure = secure;
+    state.isSecure = isSecure;
     // Set display as protected when marked as secure to ensure no behavior change
     // TODO (b/314820005): separate as a different arg when creating the display.
-    state.isProtected = secure;
+    state.isProtected = isSecure;
     state.displayName = displayName;
+    state.uniqueId = uniqueId;
     state.requestedRefreshRate = Fps::fromValue(requestedRefreshRate);
     mCurrentState.displays.add(token, state);
     return token;
@@ -9552,7 +9553,8 @@
     }
 }
 
-binder::Status SurfaceComposerAIDL::createDisplay(const std::string& displayName, bool secure,
+binder::Status SurfaceComposerAIDL::createDisplay(const std::string& displayName, bool isSecure,
+                                                  const std::string& uniqueId,
                                                   float requestedRefreshRate,
                                                   sp<IBinder>* outDisplay) {
     status_t status = checkAccessPermission();
@@ -9560,7 +9562,7 @@
         return binderStatusFromStatusT(status);
     }
     String8 displayName8 = String8::format("%s", displayName.c_str());
-    *outDisplay = mFlinger->createDisplay(displayName8, secure, requestedRefreshRate);
+    *outDisplay = mFlinger->createDisplay(displayName8, isSecure, uniqueId, requestedRefreshRate);
     return binder::Status::ok();
 }
 
@@ -9577,10 +9579,10 @@
     std::vector<PhysicalDisplayId> physicalDisplayIds = mFlinger->getPhysicalDisplayIds();
     std::vector<int64_t> displayIds;
     displayIds.reserve(physicalDisplayIds.size());
-    for (auto item : physicalDisplayIds) {
-        displayIds.push_back(static_cast<int64_t>(item.value));
+    for (const auto id : physicalDisplayIds) {
+        displayIds.push_back(static_cast<int64_t>(id.value));
     }
-    *outDisplayIds = displayIds;
+    *outDisplayIds = std::move(displayIds);
     return binder::Status::ok();
 }
 
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 4cb5aa3..8474515 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -539,15 +539,16 @@
 
     static const size_t MAX_LAYERS = 4096;
 
-    // Implements IBinder.
-    status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override;
-    status_t dump(int fd, const Vector<String16>& args) override { return priorityDump(fd, args); }
-    bool callingThreadHasUnscopedSurfaceFlingerAccess(bool usePermissionCache = true)
+    static bool callingThreadHasUnscopedSurfaceFlingerAccess(bool usePermissionCache = true)
             EXCLUDES(mStateLock);
 
-    // Implements ISurfaceComposer
-    sp<IBinder> createDisplay(const String8& displayName, bool secure,
-                              float requestedRefreshRate = 0.0f);
+    // IBinder overrides:
+    status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override;
+    status_t dump(int fd, const Vector<String16>& args) override { return priorityDump(fd, args); }
+
+    // ISurfaceComposer implementation:
+    sp<IBinder> createDisplay(const String8& displayName, bool isSecure,
+                              const std::string& uniqueId, float requestedRefreshRate = 0.0f);
     void destroyDisplay(const sp<IBinder>& displayToken);
     std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const EXCLUDES(mStateLock) {
         Mutex::Autolock lock(mStateLock);
@@ -667,7 +668,7 @@
 
     void updateHdcpLevels(hal::HWDisplayId hwcDisplayId, int32_t connectedLevel, int32_t maxLevel);
 
-    // Implements IBinder::DeathRecipient.
+    // IBinder::DeathRecipient overrides:
     void binderDied(const wp<IBinder>& who) override;
 
     // HWC2::ComposerCallback overrides:
@@ -1559,7 +1560,7 @@
 
 class SurfaceComposerAIDL : public gui::BnSurfaceComposer {
 public:
-    SurfaceComposerAIDL(sp<SurfaceFlinger> sf) : mFlinger(std::move(sf)) {}
+    explicit SurfaceComposerAIDL(sp<SurfaceFlinger> sf) : mFlinger(std::move(sf)) {}
 
     binder::Status bootFinished() override;
     binder::Status createDisplayEventConnection(
@@ -1567,8 +1568,9 @@
             const sp<IBinder>& layerHandle,
             sp<gui::IDisplayEventConnection>* outConnection) override;
     binder::Status createConnection(sp<gui::ISurfaceComposerClient>* outClient) override;
-    binder::Status createDisplay(const std::string& displayName, bool secure,
-                                 float requestedRefreshRate, sp<IBinder>* outDisplay) override;
+    binder::Status createDisplay(const std::string& displayName, bool isSecure,
+                                 const std::string& uniqueId, float requestedRefreshRate,
+                                 sp<IBinder>* outDisplay) override;
     binder::Status destroyDisplay(const sp<IBinder>& display) override;
     binder::Status getPhysicalDisplayIds(std::vector<int64_t>* outDisplayIds) override;
     binder::Status getPhysicalDisplayToken(int64_t displayId, sp<IBinder>* outDisplay) override;
@@ -1690,7 +1692,7 @@
                                               gui::DynamicDisplayInfo*& outInfo);
 
 private:
-    sp<SurfaceFlinger> mFlinger;
+    const sp<SurfaceFlinger> mFlinger;
 };
 
 } // namespace android
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
index 28162f4..bf5ae21 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp
@@ -132,6 +132,36 @@
     EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
 }
 
+TEST_F(CreateDisplayTest, createDisplaySetsCurrentStateForUniqueId) {
+    const String8 name("virtual.test");
+    const std::string uniqueId = "virtual:package:id";
+
+    // --------------------------------------------------------------------
+    // Call Expectations
+
+    // --------------------------------------------------------------------
+    // Invocation
+
+    sp<IBinder> displayToken = mFlinger.createDisplay(name, false, uniqueId);
+
+    // --------------------------------------------------------------------
+    // Postconditions
+
+    // The display should have been added to the current state
+    ASSERT_TRUE(hasCurrentDisplayState(displayToken));
+    const auto& display = getCurrentDisplayState(displayToken);
+    EXPECT_TRUE(display.isVirtual());
+    EXPECT_FALSE(display.isSecure);
+    EXPECT_EQ(display.uniqueId, "virtual:package:id");
+    EXPECT_EQ(name.c_str(), display.displayName);
+
+    // --------------------------------------------------------------------
+    // Cleanup conditions
+
+    // Creating the display commits a display transaction.
+    EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
+}
+
 // Requesting 0 tells SF not to do anything, i.e., default to refresh as physical displays
 TEST_F(CreateDisplayTest, createDisplayWithRequestedRefreshRate0) {
     const String8 displayName("virtual.test");
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index a0c1372..b251e2c 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -420,8 +420,15 @@
         commit(kComposite);
     }
 
-    auto createDisplay(const String8& displayName, bool secure, float requestedRefreshRate = 0.0f) {
-        return mFlinger->createDisplay(displayName, secure, requestedRefreshRate);
+    auto createDisplay(const String8& displayName, bool isSecure,
+                       float requestedRefreshRate = 0.0f) {
+        const std::string testId = "virtual:libsurfaceflinger_unittest:TestableSurfaceFlinger";
+        return mFlinger->createDisplay(displayName, isSecure, testId, requestedRefreshRate);
+    }
+
+    auto createDisplay(const String8& displayName, bool isSecure, const std::string& uniqueId,
+                       float requestedRefreshRate = 0.0f) {
+        return mFlinger->createDisplay(displayName, isSecure, uniqueId, requestedRefreshRate);
     }
 
     auto destroyDisplay(const sp<IBinder>& displayToken) {
