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 if (isSubscribe) {
30 if (traceBtn == TRACE_START) {
31 if (subscribeObject == CLIENT) {
32 StartTrace(HITRACE_TAG_MSDP, clientSubscribe);
33 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "client start subsvribe");
34 } else {
35 StartTrace(HITRACE_TAG_MSDP, serviceSubscribe);
36 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "service start subsvribe");
37 }
38 } else {
39 FinishTrace(HITRACE_TAG_MSDP);
40 }
41 } else {
42 if (traceBtn == TRACE_START) {
43 if (subscribeObject == CLIENT) {
44 StartTrace(HITRACE_TAG_MSDP, clientUnsubscribe);
45 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "client start unSubsvribe");
46 } else {
47 StartTrace(HITRACE_TAG_MSDP, serviceUnsubscribe);
48 HITRACE_METER_NAME(HITRACE_TAG_MSDP, "service start unSubsvribe");
49 }
50 } else {
51 FinishTrace(HITRACE_TAG_MSDP);
52 }
53 }
54 }
55 } // namespace DeviceStatus
56 } // namespace MSDP
57 } // namespace OHOS
58