• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_NET_AGENT_H
17 #define CELLULAR_DATA_NET_AGENT_H
18 
19 #include <singleton.h>
20 #include <memory>
21 #include <string>
22 #include <utility>
23 
24 #include "i_net_conn_service.h"
25 #include "if_system_ability_manager.h"
26 #include "iservice_registry.h"
27 #include "system_ability_definition.h"
28 
29 #include "cellular_data_constant.h"
30 #include "net_manager_call_back.h"
31 #include "net_manager_tactics_call_back.h"
32 
33 namespace OHOS {
34 namespace Telephony {
35 class CellularDataNetAgent : public DelayedRefSingleton<CellularDataNetAgent> {
36     DECLARE_DELAYED_REF_SINGLETON(CellularDataNetAgent);
37 
38 public:
39     /**
40      * Register the network information with the network management module
41      *
42      * @return true if register success else return false;
43      */
44     bool RegisterNetSupplier(const int32_t slotId);
45 
46     /**
47      * Cancel the registration information to the network management
48      *
49      * @param slotId card slot identification
50      */
51     void UnregisterNetSupplier(const int32_t slotId);
52 
53     /**
54      * Cancel the registration information to the network management for sim state update
55      *
56      * @param slotId card slot identification
57      */
58     void UnregisterNetSupplierForSimUpdate(const int32_t slotId);
59 
60     /**
61      * Cancel all registration information to the network management
62      */
63     void UnregisterAllNetSupplier();
64 
65     bool RegisterPolicyCallback();
66     void UnregisterPolicyCallback();
67 
68     /**
69      * Update network information
70      *
71      * @param supplierId network unique identity id returned after network registration
72      * @param netSupplierInfo network data information
73      */
74     int32_t UpdateNetSupplierInfo(uint32_t supplierId, sptr<NetManagerStandard::NetSupplierInfo> &netSupplierInfo);
75 
76     /**
77      * Update link information
78      *
79      * @param supplierId network unique identity id returned after network registration
80      * @param netLinkInfo network link data information
81      */
82     void UpdateNetLinkInfo(int32_t supplierId, sptr<NetManagerStandard::NetLinkInfo> &netLinkInfo);
83 
84     /**
85      * Set reused supplier id
86      * @param supplierId network unique identity id returned after network registration
87      * @param reuseSupplierId network identity id to be reused
88      * @param isReused whether to be reused or removed
89      */
90     void SetReuseSupplierId(int32_t supplierId, int32_t reuseSupplierId, bool isReused);
91 
92     /**
93      * Collect all network
94      *
95      * @param netSupplier a specific network
96      */
97     void AddNetSupplier(const NetSupplier &netSupplier);
98 
99     /**
100      * Clear all network
101      */
102     void ClearNetSupplier();
103 
104     /**
105      * Gets the unique identity of successful registered registration
106      *
107      * @param slotId card slot identification
108      * @param capability a network capability
109      * @return unique identify
110      */
111     int32_t GetSupplierId(const int32_t slotId, uint64_t capability) const;
112 
113     void RegisterSlotType(int32_t supplierId, int32_t radioTech);
114 
115     bool GetSupplierRegState(uint32_t supplierId, int32_t &regState);
116 
117 private:
118     std::vector<NetSupplier> netSuppliers_;
119     sptr<NetManagerCallBack> callBack_;
120     sptr<NetManagerTacticsCallBack> tacticsCallBack_;
121 };
122 } // namespace Telephony
123 } // namespace OHOS
124 #endif // CELLULAR_DATA_NET_AGENT_H
125