Description: dotting function add

Sig:appexecfwk
Feature or Bugfix:Bugfix
Binary Source:No
#I4ZDPU;
Signed-off-by: wuluofeng <wuluofeng@huawei.com>
This commit is contained in:
吴珞风
2022-03-24 07:21:37 +00:00
committed by Gitee
parent 8e57301c6e
commit dfa4d92b4e
6 changed files with 138 additions and 15 deletions
@@ -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 <cstdint>
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
@@ -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
@@ -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"
+6 -7
View File
@@ -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
+4 -4
View File
@@ -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);
};
}
-3
View File
@@ -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)