From 06c69bfd89eaf4d2e61fa70a4dfabf5a73dadc8f Mon Sep 17 00:00:00 2001 From: roynatech2544 Date: Fri, 14 Oct 2022 21:11:43 +0900 Subject: [PATCH] universal7885: parts-aidl: Just use new operator Using std::unique_ptr may result in deleted pointer --- .../apps/aidl-support/parts/default/SmartCharge.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/universal7885-common/apps/aidl-support/parts/default/SmartCharge.cpp b/universal7885-common/apps/aidl-support/parts/default/SmartCharge.cpp index 3cda360..22145df 100644 --- a/universal7885-common/apps/aidl-support/parts/default/SmartCharge.cpp +++ b/universal7885-common/apps/aidl-support/parts/default/SmartCharge.cpp @@ -17,11 +17,10 @@ #include #include -#include namespace aidl::vendor::eureka::hardware::parts { -static std::unique_ptr kInst; +static SmartChargeImpl *kInst; static int limit = 0; static int restart = 0; @@ -33,7 +32,7 @@ static int restart_stat = 0; if (limit == 0 || restart == 0) return ::ndk::ScopedAStatus::fromExceptionCodeWithMessage( EX_ILLEGAL_ARGUMENT, "Start called without configuring."); - kInst = std::make_unique(limit, restart); + kInst = new SmartChargeImpl(limit, restart); kInst->start(); return ::ndk::ScopedAStatus::ok(); } @@ -43,7 +42,8 @@ static int restart_stat = 0; kInst->stop(); limit_stat += kInst->charge_limit_cnt; restart_stat += kInst->restart_cnt; - kInst.reset(); + delete kInst; + kInst = nullptr; } return ::ndk::ScopedAStatus::ok(); }