1 /* 2 * Copyright (c) 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 #ifndef OHOS_FILEMGMT_CLOUD_SYNC_NETWORK_STATUS_H 17 #define OHOS_FILEMGMT_CLOUD_SYNC_NETWORK_STATUS_H 18 #include <cstdint> 19 #include "iremote_object.h" 20 #include "net_all_capabilities.h" 21 #include "data_sync_manager.h" 22 23 namespace OHOS::FileManagement::CloudSync { 24 class NetworkStatus { 25 public: 26 enum NetConnStatus { 27 NO_NETWORK, 28 ETHERNET_CONNECT, 29 WIFI_CONNECT, 30 CELLULAR_CONNECT, 31 NETWORK_AVAIL, 32 }; 33 static int32_t RegisterNetConnCallback(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager); 34 static int32_t GetDefaultNet(); 35 static int32_t GetAndRegisterNetwork(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager); 36 static void InitNetwork(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager); 37 static void SetNetConnStatus(NetManagerStandard::NetAllCapabilities &netAllCap); 38 static void SetNetConnStatus(NetConnStatus netStatus); 39 static NetConnStatus GetNetConnStatus(); 40 static void OnNetworkAvail(); 41 static bool CheckMobileNetwork(const std::string &bundleName, const int32_t userId); 42 static bool CheckNetwork(const std::string &bundleName, const int32_t userId); 43 static void NetWorkChangeStopUploadTask(); 44 45 private: 46 static inline NetConnStatus netStatus_{NO_NETWORK}; 47 }; 48 } // namespace OHOS::FileManagement::CloudSync 49 50 #endif // OHOS_FILEMGMT_CLOUD_SYNC_NETWORK_STATUS_H