1 /*
2  * Copyright (C) 2022 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 #ifndef CELLULAR_DATA_HISYSEVENT_H
17 #define CELLULAR_DATA_HISYSEVENT_H
18 
19 #include <stdint.h>
20 
21 #include "iosfwd"
22 #include "telephony_hisysevent.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 static const int32_t DATA_ACTIVATE_TIME = 1000;
27 static const int32_t SWITCH_ON = 1;
28 static const int32_t SWITCH_OFF = 0;
29 
30 enum class DataDisconnectCause {
31     ON_THE_NETWORK_SIDE = 0,
32     BY_USER,
33     HIGN_PRIORITY_NETWORK,
34     LOST_CONNECTION,
35 };
36 
37 class CellularDataHiSysEvent : public TelephonyHiSysEvent {
38 public:
39     static void WriteDataDeactiveBehaviorEvent(const int32_t slotId, const DataDisconnectCause type,
40         const std::string &apnType = "default");
41     static void WriteDataConnectStateBehaviorEvent(const int32_t slotId, const std::string &apnType,
42         const uint64_t capability, const int32_t state);
43     static void WriteRoamingConnectStateBehaviorEvent(const int32_t state);
44     static void WriteCellularRequestBehaviorEvent(
45         const uint32_t uid, const std::string name, const uint64_t type, const int32_t state);
46     static void WriteDataActivateFaultEvent(const int32_t slotId, const int32_t switchState,
47         const CellularDataErrorCode errorType, const std::string &errorMsg);
48     void SetCellularDataActivateStartTime();
49     void JudgingDataActivateTimeOut(const int32_t slotId, const int32_t switchState);
50 
51 private:
52     int64_t dataActivateStartTime_ = 0L;
53 };
54 } // namespace Telephony
55 } // namespace OHOS
56 
57 #endif // CELLULAR_DATA_HISYSEVENT_H
58