1 /*
2  * Copyright (c) 2024 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 #ifdef FEATURE_GNSS_SUPPORT
17 #ifdef NET_MANAGER_ENABLE
18 #include "net_conn_observer.h"
19 
20 #include "location_log.h"
21 #include "ntp_time_helper.h"
22 
23 using namespace OHOS::NetManagerStandard;
24 
25 namespace OHOS {
26 namespace Location {
NetAvailable(sptr<NetHandle> & netHandle)27 int32_t NetConnObserver::NetAvailable(sptr<NetHandle> &netHandle)
28 {
29     return ERR_OK;
30 }
31 
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netAllCap)32 int32_t NetConnObserver::NetCapabilitiesChange(sptr<NetHandle> &netHandle,
33     const sptr<NetAllCapabilities> &netAllCap)
34 {
35     LBSLOGI(GNSS, "Observe network capabilities change");
36     if (netAllCap == nullptr) {
37         LBSLOGE(GNSS, "Observe network netAllCap is null");
38         return -1;
39     }
40     if (netAllCap->netCaps_.count(NetCap::NET_CAPABILITY_INTERNET)) {
41 #ifdef TIME_SERVICE_ENABLE
42         auto npTimeHelper = NtpTimeHelper::GetInstance();
43         if (npTimeHelper != nullptr) {
44             npTimeHelper->RetrieveAndInjectNtpTime();
45         }
46 #endif
47     }
48     return ERR_OK;
49 }
50 
NetConnectionPropertiesChange(sptr<NetHandle> & netHandle,const sptr<NetLinkInfo> & info)51 int32_t NetConnObserver::NetConnectionPropertiesChange(sptr<NetHandle> &netHandle,
52     const sptr<NetLinkInfo> &info)
53 {
54     return ERR_OK;
55 }
56 
NetLost(sptr<NetHandle> & netHandle)57 int32_t NetConnObserver::NetLost(sptr<NetHandle> &netHandle)
58 {
59     return ERR_OK;
60 }
61 
NetUnavailable()62 int32_t NetConnObserver::NetUnavailable()
63 {
64     return ERR_OK;
65 }
66 
NetBlockStatusChange(sptr<NetHandle> & netHandle,bool blocked)67 int32_t NetConnObserver::NetBlockStatusChange(sptr<NetHandle> &netHandle, bool blocked)
68 {
69     return ERR_OK;
70 }
71 } // namespace Location
72 } // namespace OHOS
73 
74 #endif
75 #endif