• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sync_rule/net_conn_callback_observer.h"
17 #include "dfs_error.h"
18 #include "sync_rule/network_status.h"
19 #include "utils_log.h"
20 
21 using namespace OHOS::NetManagerStandard;
22 
23 namespace OHOS::FileManagement::CloudSync {
NetConnCallbackObserver(std::shared_ptr<DataSyncManager> dataSyncManager)24 NetConnCallbackObserver::NetConnCallbackObserver(std::shared_ptr<DataSyncManager> dataSyncManager)
25 {
26     dataSyncManager_ = dataSyncManager;
27 }
28 
NetAvailable(sptr<NetHandle> & netHandle)29 int32_t NetConnCallbackObserver::NetAvailable(sptr<NetHandle> &netHandle)
30 {
31     LOGI("network is available");
32     NetworkStatus::OnNetworkAvail();
33     dataSyncManager_->TriggerRecoverySync(triggerType_);
34     return E_OK;
35 }
36 
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netAllCap)37 int32_t NetConnCallbackObserver::NetCapabilitiesChange(sptr<NetHandle> &netHandle,
38     const sptr<NetAllCapabilities> &netAllCap)
39 {
40     NetworkStatus::SetNetConnStatus(*netAllCap);
41     return E_OK;
42 }
43 
NetConnectionPropertiesChange(sptr<NetHandle> & netHandle,const sptr<NetLinkInfo> & info)44 int32_t NetConnCallbackObserver::NetConnectionPropertiesChange(sptr<NetHandle> &netHandle,
45     const sptr<NetLinkInfo> &info)
46 {
47     return E_OK;
48 }
49 
NetLost(sptr<NetHandle> & netHandle)50 int32_t NetConnCallbackObserver::NetLost(sptr<NetHandle> &netHandle)
51 {
52     LOGI("NetConnCallbackObserver::NetLost");
53     NetworkStatus::SetNetConnStatus(NetworkStatus::NetConnStatus::NO_NETWORK);
54     return E_OK;
55 }
56 
NetUnavailable()57 int32_t NetConnCallbackObserver::NetUnavailable()
58 {
59     return E_OK;
60 }
61 
NetBlockStatusChange(sptr<NetHandle> & netHandle,bool blocked)62 int32_t NetConnCallbackObserver::NetBlockStatusChange(sptr<NetHandle> &netHandle, bool blocked)
63 {
64     return E_OK;
65 }
66 } // namespace OHOS::FileManagement::CloudSync