• 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 <memory>
20 #include <string>
21 #include <singleton.h>
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 all registration information to the network management
55      */
56     void UnregisterAllNetSupplier();
57 
58     bool RegisterPolicyCallback();
59     void UnregisterPolicyCallback();
60 
61     /**
62      * Update network information
63      *
64      * @param supplierId network unique identity id returned after network registration
65      * @param netSupplierInfo network data information
66      */
67     void UpdateNetSupplierInfo(int32_t supplierId, sptr<NetManagerStandard::NetSupplierInfo> &netSupplierInfo);
68 
69     /**
70      * Update link information
71      *
72      * @param supplierId network unique identity id returned after network registration
73      * @param netLinkInfo network link data information
74      */
75     void UpdateNetLinkInfo(int32_t supplierId, sptr<NetManagerStandard::NetLinkInfo> &netLinkInfo);
76 
77     /**
78      * Collect all network
79      *
80      * @param netSupplier a specific network
81      */
82     void AddNetSupplier(const NetSupplier &netSupplier);
83 
84     /**
85      * Clear all network
86      */
87     void ClearNetSupplier();
88 
89     /**
90      * Gets the unique identity of successful registered registration
91      *
92      * @param slotId card slot identification
93      * @param capability a network capability
94      * @return unique identify
95      */
96     int32_t GetSupplierId(const int32_t slotId, uint64_t capability) const;
97 
98 private:
99     std::vector<NetSupplier> netSuppliers_;
100     sptr<NetManagerCallBack> callBack_;
101     sptr<NetManagerTacticsCallBack> tacticsCallBack_;
102 };
103 } // namespace Telephony
104 } // namespace OHOS
105 #endif // CELLULAR_DATA_NET_AGENT_H
106