From cfd7b999dd3f3566ae5b728d4e83af9b058e7b92 Mon Sep 17 00:00:00 2001 From: Ethan Chen Date: Thu, 14 Jun 2018 22:50:47 -0700 Subject: livedisplay: Don't use a singleton for Color service * There's really no need for this here, the service only ever creates one instance ever. Change-Id: Iea24bddd51138d9dc729cfeb3acb0204b1098464 --- livedisplay/1.0/default/include/Color.h | 5 +---- livedisplay/1.0/default/service.cpp | 3 +-- livedisplay/1.0/default/src/Color.cpp | 9 --------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/livedisplay/1.0/default/include/Color.h b/livedisplay/1.0/default/include/Color.h index e6fca65..91d2ca2 100644 --- a/livedisplay/1.0/default/include/Color.h +++ b/livedisplay/1.0/default/include/Color.h @@ -40,7 +40,7 @@ class ColorBackend; class Color : public IColor { public: - static android::sp getInstance(); + Color(); Return getSupportedFeatures() override; @@ -75,9 +75,6 @@ class Color : public IColor { bool connect(); void reset(); - Color(); - static android::sp sInstance; - uint32_t mFeatures; bool mConnected; diff --git a/livedisplay/1.0/default/service.cpp b/livedisplay/1.0/default/service.cpp index b8f5cb5..4370545 100644 --- a/livedisplay/1.0/default/service.cpp +++ b/livedisplay/1.0/default/service.cpp @@ -39,14 +39,13 @@ using ::vendor::lineage::livedisplay::V1_0::implementation::Color; int main() { status_t status; - android::sp service = nullptr; LOG(INFO) << "LiveDisplay HAL service is starting."; // The LiveDisplay HAL may communicate to other vendor components via /dev/vndbinder android::ProcessState::initWithDriver("/dev/vndbinder"); - service = Color::getInstance(); + android::sp service = new Color(); if (service == nullptr) { LOG(ERROR) << "Can not create an instance of LiveDisplay HAL Iface, exiting."; goto shutdown; diff --git a/livedisplay/1.0/default/src/Color.cpp b/livedisplay/1.0/default/src/Color.cpp index accd1d3..b586e39 100644 --- a/livedisplay/1.0/default/src/Color.cpp +++ b/livedisplay/1.0/default/src/Color.cpp @@ -60,8 +60,6 @@ using ::android::OK; using ::android::sp; using ::android::status_t; -sp Color::sInstance = nullptr; - Color::Color() : mConnected(false), mBackend(nullptr) { #if defined(COLOR_BACKEND_SDM) mBackend = std::make_unique(); @@ -118,13 +116,6 @@ bool Color::connect() { return mFeatures > 0; } -sp Color::getInstance() { - if (sInstance == nullptr) { - sInstance = new Color(); - } - return sInstance; -} - Return Color::getSupportedFeatures() { connect(); return mFeatures; -- cgit v1.2.3