1 /*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "bytrace_adapter.h"
17
18 namespace OHOS {
19 namespace Msdp {
20 namespace DeviceStatus {
21 namespace {
22 const std::string clientSubscribe { "ClientSubscribe" };
23 const std::string clientUnsubscribe { "ClientUnsubscribe" };
24 const std::string serviceSubscribe { "ServiceSubscribe" };
25 const std::string serviceUnsubscribe { "ServiceUnsubscribe" };
26 } // namespace
StartBytrace(TraceBtn traceBtn, SubscribeType isSubscribe, SubscribeObject subscribeObject)27 void BytraceAdapter::StartBytrace(TraceBtn traceBtn, SubscribeType isSubscribe, SubscribeObject subscribeObject)
28 {
29 #ifdef MSDP_HIVIEWDFX_HITRACE_ENABLE
30 if (isSubscribe) {
31 if (traceBtn == TRACE_START) {
32 if (subscribeObject == CLIENT) {
33 StartTrace(HITRACE_TAG_MSDP, clientSubscribe);
34 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "client start subsvribe");
35 } else {
36 StartTrace(HITRACE_TAG_MSDP, serviceSubscribe);
37 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "service start subsvribe");
38 }
39 } else {
40 FinishTrace(HITRACE_TAG_MSDP);
41 }
42 } else {
43 if (traceBtn == TRACE_START) {
44 if (subscribeObject == CLIENT) {
45 StartTrace(HITRACE_TAG_MSDP, clientUnsubscribe);
46 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "client start unSubsvribe");
47 } else {
48 StartTrace(HITRACE_TAG_MSDP, serviceUnsubscribe);
49 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "service start unSubsvribe");
50 }
51 } else {
52 FinishTrace(HITRACE_TAG_MSDP);
53 }
54 }
55 #endif // MSDP_HIVIEWDFX_HITRACE_ENABLE
56 }
57 } // namespace DeviceStatus
58 } // namespace MSDP
59 } // namespace OHOS
60