From dfa4d92b4efe2a63133a1eaeb4d461ed5c6d7f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=8F=9E=E9=A3=8E?= Date: Thu, 24 Mar 2022 07:21:37 +0000 Subject: [PATCH] Description: dotting function add Sig:appexecfwk Feature or Bugfix:Bugfix Binary Source:No #I4ZDPU; Signed-off-by: wuluofeng --- .../include/aafwk_product_adapter.h | 46 +++++++++++ .../bundle_lite/src/aafwk_product_adapter.cpp | 80 +++++++++++++++++++ .../src/gt_bundle_manager_service.cpp | 3 +- utils/bundle_lite/aafwk_event_error_code.cpp | 13 ++- utils/bundle_lite/aafwk_event_error_code.h | 8 +- utils/bundle_lite/adapter.h | 3 - 6 files changed, 138 insertions(+), 15 deletions(-) create mode 100644 frameworks/bundle_lite/include/aafwk_product_adapter.h create mode 100644 frameworks/bundle_lite/src/aafwk_product_adapter.cpp diff --git a/frameworks/bundle_lite/include/aafwk_product_adapter.h b/frameworks/bundle_lite/include/aafwk_product_adapter.h new file mode 100644 index 0000000..68d75d9 --- /dev/null +++ b/frameworks/bundle_lite/include/aafwk_product_adapter.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +#include + +namespace OHOS { +/** + * This handler type is so specific for product, should be designed from OS dfx level. + */ +typedef void (*EventPrintHandler)(uint8_t info1, uint8_t info2, uint8_t info3, uint8_t info4); +typedef void (*ErrCodePrintHandler)(uint8_t info1, uint8_t info2, uint8_t info3, uint16_t info4); + +/** + * The wrapper class for some product feature implementation, since some interfaces are provided by specific product. + */ +class AafwkProductAdapter final { +public: + AafwkProductAdapter(const AafwkProductAdapter &) = delete; + AafwkProductAdapter &operator=(const AafwkProductAdapter &) = delete; + AafwkProductAdapter(AafwkProductAdapter &&) = delete; + AafwkProductAdapter &operator=(AafwkProductAdapter &&) = delete; + AafwkProductAdapter() = delete; + ~AafwkProductAdapter() = delete; + + // initialization functions + static void InitTraceHandlers(EventPrintHandler eventHandler, ErrCodePrintHandler errCodeHandler); + static void InitAafwkTags(uint8_t *aceTags, uint8_t tagCount); + + // wrapper functions, for aafwk internal calling + static void PrintEventTrace(uint8_t info2, uint8_t info3, uint8_t info4); + static void PrintErrCode(uint8_t info2, uint16_t rfu); + +}; +} // namespace OHOS diff --git a/frameworks/bundle_lite/src/aafwk_product_adapter.cpp b/frameworks/bundle_lite/src/aafwk_product_adapter.cpp new file mode 100644 index 0000000..d54c16b --- /dev/null +++ b/frameworks/bundle_lite/src/aafwk_product_adapter.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +#include "aafwk_product_adapter.h" + +namespace OHOS { +/** + * Used for holding all the related dfx interfaces assigned from specific implementation. + */ +struct AafwkDFXWrapper { + AafwkDFXWrapper() + : eventTag_(0), + eventSubTag_(0), + errCodeTag_(0), + errCodeSubTag_(0), + eventPrintHandler_(nullptr), + errCodePrintHandler_(nullptr) + { + } + uint8_t eventTag_; + uint8_t eventSubTag_; + uint8_t errCodeTag_; + uint8_t errCodeSubTag_; + EventPrintHandler eventPrintHandler_; + ErrCodePrintHandler errCodePrintHandler_; +}; + +static AafwkDFXWrapper sDfxWrapper; + +void AafwkProductAdapter::InitAafwkTags(uint8_t *aafwkTags, uint8_t tagCount) +{ + const uint8_t minCount = 4; + if (aafwkTags == nullptr || tagCount < minCount) { + return; + } + uint8_t index = 0; + sDfxWrapper.eventTag_ = aafwkTags[index++]; + sDfxWrapper.eventSubTag_ = aafwkTags[index++]; + sDfxWrapper.errCodeTag_ = aafwkTags[index++]; + sDfxWrapper.errCodeSubTag_ = aafwkTags[index++]; +} + +void AafwkProductAdapter::InitTraceHandlers(EventPrintHandler eventHandler, ErrCodePrintHandler errCodeHandler) +{ + sDfxWrapper.eventPrintHandler_ = eventHandler; + sDfxWrapper.errCodePrintHandler_ = errCodeHandler; +} + + +void AafwkProductAdapter::PrintEventTrace(uint8_t info2, uint8_t info3, uint8_t info4) +{ + if (sDfxWrapper.eventPrintHandler_ == nullptr || sDfxWrapper.eventTag_ == 0 || sDfxWrapper.eventSubTag_ == 0) { + return; + } + + uint8_t subTag = (info2 == 0) ? sDfxWrapper.eventSubTag_ : info2; + sDfxWrapper.eventPrintHandler_(sDfxWrapper.eventTag_, subTag, info3, info4); +} + +void AafwkProductAdapter::PrintErrCode(uint8_t info2, uint16_t rfu) +{ + if (sDfxWrapper.errCodePrintHandler_ == nullptr || sDfxWrapper.errCodeTag_ == 0 || + sDfxWrapper.errCodeSubTag_ == 0) { + return; + } + sDfxWrapper.errCodePrintHandler_(sDfxWrapper.errCodeTag_, sDfxWrapper.errCodeSubTag_, info2, rfu); +} +} // namespace OHOS \ No newline at end of file diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 3d6504b..edb174f 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -14,7 +14,8 @@ */ #include "gt_bundle_manager_service.h" - +#include "aafwk_event_error_id.h" +#include "aafwk_event_error_code.h" #include "ability_info_utils.h" #include "ability_message_id.h" #include "appexecfwk_errors.h" diff --git a/utils/bundle_lite/aafwk_event_error_code.cpp b/utils/bundle_lite/aafwk_event_error_code.cpp index d6dda5a..1bf607f 100644 --- a/utils/bundle_lite/aafwk_event_error_code.cpp +++ b/utils/bundle_lite/aafwk_event_error_code.cpp @@ -14,11 +14,10 @@ */ #include "aafwk_event_error_code.h" -#include "product_adapter.h" - -using namespace OHOS::ACELite; +#include "aafwk_product_adapter.h" namespace OHOS { + AafwkEventCodePrint *AafwkEventCodePrint::GetInstance() { static AafwkEventCodePrint printInstance; @@ -27,16 +26,16 @@ AafwkEventCodePrint *AafwkEventCodePrint::GetInstance() void AafwkEventCodePrint::AafwkEventPrint(uint8_t info2, uint8_t info3) { - ProductAdapter::PrintEventTrace(0, info2, info3); + AafwkProductAdapter::PrintEventTrace(0, info2, info3); } void AafwkEventCodePrint::AafwkEventPrint(uint8_t info1, uint8_t info2, uint8_t info3) { - ProductAdapter::PrintEventTrace(info1, info2, info3); + AafwkProductAdapter::PrintEventTrace(info1, info2, info3); } void AafwkEventCodePrint::AafwkErrorPrint(uint8_t info1, uint16_t info2) { - ProductAdapter::PrintErrCode(info1, info2); + AafwkProductAdapter::PrintErrCode(info1, info2); } -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/utils/bundle_lite/aafwk_event_error_code.h b/utils/bundle_lite/aafwk_event_error_code.h index 10e5df5..c03dbcf 100644 --- a/utils/bundle_lite/aafwk_event_error_code.h +++ b/utils/bundle_lite/aafwk_event_error_code.h @@ -12,19 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "memory_heap.h" #include "aafwk_event_error_id.h" -using namespace OHOS::ACELite; +namespace OHOS { #define APP_EVENT(code1) \ AafwkEventCodePrint::GetInstance()->AafwkEventPrint(code1, 0) #define APP_ERRCODE_EXTRA(code1, code2) \ AafwkEventCodePrint::GetInstance()->AafwkErrorPrint(code1, code2) -namespace OHOS { -class AafwkEventCodePrint final : public MemoryHeap { +class AafwkEventCodePrint { public: AafwkEventCodePrint() = default; @@ -38,5 +37,6 @@ public: void AafwkEventPrint(uint8_t info1, uint8_t info2, uint8_t info3); void AafwkErrorPrint(uint8_t info2, uint16_t info3); + }; } diff --git a/utils/bundle_lite/adapter.h b/utils/bundle_lite/adapter.h index e6ce084..e52402b 100755 --- a/utils/bundle_lite/adapter.h +++ b/utils/bundle_lite/adapter.h @@ -76,9 +76,6 @@ const unsigned int RETRY_TIMES = 10; } \ } while (0) -#define APP_EVENT(code1) -#define APP_ERRCODE_EXTRA(code1, code2) - #define RecordAbiityInfoEvt(code1) #define MutexDelete(a) osMutexDelete(a) #define MutexAcquire(a, b) osMutexAcquire(a, b)