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_CONTROLLER_H 17 #define CELLULAR_DATA_CONTROLLER_H 18 19 #include <memory> 20 21 #include "cellular_data_constant.h" 22 #include "cellular_data_handler.h" 23 #include "cellular_data_rdb_observer.h" 24 25 namespace OHOS { 26 namespace Telephony { 27 class CellularDataController : public AppExecFwk::EventHandler { 28 public: 29 explicit CellularDataController(std::shared_ptr<AppExecFwk::EventRunner> &runner, int32_t slotId); 30 ~CellularDataController(); 31 void Init(); 32 bool ReleaseNet(const NetRequest &request); 33 bool RequestNet(const NetRequest &request); 34 bool SetCellularDataEnable(bool userDataEnabled); 35 bool IsCellularDataEnabled() const; 36 bool SetCellularDataRoamingEnabled(bool dataRoamingEnabled); 37 ApnProfileState GetCellularDataState() const; 38 ApnProfileState GetCellularDataState(const std::string &apnType) const; 39 bool IsCellularDataRoamingEnabled() const; 40 void AsynchronousRegister(); 41 bool HandleApnChanged(); 42 int32_t GetCellularDataFlowType(); 43 void EstablishDataConnection(); 44 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 45 int32_t SetPolicyDataOn(bool enable); 46 bool IsRestrictedMode() const; 47 DisConnectionReason GetDisConnectionReason(); 48 bool HasInternetCapability(const int32_t cid) const; 49 bool ClearAllConnections(DisConnectionReason reason) const; 50 51 private: 52 void RegisterEvents(); 53 void UnRegisterEvents(); 54 void RegisterDatabaseObserver(); 55 void UnRegisterDataObserver(); 56 57 private: 58 std::shared_ptr<CellularDataHandler> cellularDataHandler_; 59 sptr<CellularDataRdbObserver> cellularDataRdbObserver_; 60 const int32_t slotId_; 61 }; 62 } // namespace Telephony 63 } // namespace OHOS 64 #endif // CELLULAR_DATA_CONTROLLER_H