diff --git a/bundle.json b/bundle.json index 0d94a658..cec91778 100644 --- a/bundle.json +++ b/bundle.json @@ -76,7 +76,8 @@ "image_framework", "movement", "device_standby", - "time_service" + "time_service", + "netmanager_base" ] }, "build": { diff --git a/config.gni b/config.gni index 0e2d5d78..b76757e4 100644 --- a/config.gni +++ b/config.gni @@ -56,9 +56,10 @@ declare_args() { hdf_drivers_interface_location_geofence_enable = true multimedia_image_framework_enable = true notification_distributed_notification_service_enable = true - time_service_enable = true movement_client_enable = true location_device_standby_enable = true + time_service_enable = true + net_manager_enable = true if (defined(global_parts_info) && !defined(global_parts_info.global_i18n)) { i18n_enable = false @@ -152,4 +153,9 @@ declare_args() { !defined(global_parts_info.time_time_service)) { time_service_enable = false } + + if (defined(global_parts_info) && + !defined(global_parts_info.communication_netmanager_base)) { + net_manager_enable = false + } } diff --git a/frameworks/location_common/common/source/location_data_rdb_manager.cpp b/frameworks/location_common/common/source/location_data_rdb_manager.cpp index b4d7b765..a1407129 100644 --- a/frameworks/location_common/common/source/location_data_rdb_manager.cpp +++ b/frameworks/location_common/common/source/location_data_rdb_manager.cpp @@ -108,7 +108,7 @@ int LocationDataRdbManager::GetSwitchMode() std::string value = ""; std::unique_lock lock(mutex_); auto res = GetParameter(LOCATION_SWITCH_MODE, "", result, MAX_SIZE); - if (res <= 0 || strlen(result) == 0) { + if (res < 0 || strlen(result) == 0) { LBSLOGE(COMMON_UTILS, "%{public}s get para value failed, res: %{public}d", __func__, res); return UNKNOW_ERROR; } diff --git a/frameworks/native/locator_sdk/BUILD.gn b/frameworks/native/locator_sdk/BUILD.gn index f7145775..80d822fa 100644 --- a/frameworks/native/locator_sdk/BUILD.gn +++ b/frameworks/native/locator_sdk/BUILD.gn @@ -31,6 +31,7 @@ local_base_sources = [ "$LOCATION_NATIVE_DIR/locator_sdk/source/country_code_callback_host.cpp", "$LOCATION_NATIVE_DIR/locator_sdk/source/country_code_manager.cpp", "$LOCATION_NATIVE_DIR/locator_sdk/source/geo_convert_callback_host.cpp", + "$LOCATION_NATIVE_DIR/locator_sdk/source/gnss_status_callback_host.cpp", "$LOCATION_NATIVE_DIR/locator_sdk/source/location_data_manager.cpp", "$LOCATION_NATIVE_DIR/locator_sdk/source/location_data_rdb_observer.cpp", "$LOCATION_NATIVE_DIR/locator_sdk/source/location_switch_callback_host.cpp", diff --git a/frameworks/native/locator_sdk/include/country_code_callback_host.h b/frameworks/native/locator_sdk/include/country_code_callback_host.h index 1ea69da5..4838b9f7 100644 --- a/frameworks/native/locator_sdk/include/country_code_callback_host.h +++ b/frameworks/native/locator_sdk/include/country_code_callback_host.h @@ -24,8 +24,8 @@ namespace OHOS { namespace Location { class CountryCodeCallbackHost : public IRemoteStub { public: - virtual int OnRemoteRequest(uint32_t code, - MessageParcel& data, MessageParcel& reply, MessageOption& option) override; + virtual int OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; void OnCountryCodeChange(const std::shared_ptr& country) override; }; } // namespace Location diff --git a/frameworks/native/locator_sdk/include/gnss_status_callback_host.h b/frameworks/native/locator_sdk/include/gnss_status_callback_host.h new file mode 100644 index 00000000..8ed99167 --- /dev/null +++ b/frameworks/native/locator_sdk/include/gnss_status_callback_host.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GNSS_STATUS_CALLBACK_HOST_H +#define GNSS_STATUS_CALLBACK_HOST_H + +#include "iremote_stub.h" +#include "i_gnss_status_callback.h" +#include "satellite_status.h" + +namespace OHOS { +namespace Location { +class GnssStatusCallbackHost : public IRemoteStub { +public: + virtual int OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; + void OnStatusChange(const std::unique_ptr& statusInfo) override; +}; +} // namespace Location +} // namespace OHOS +#endif // GNSS_STATUS_CALLBACK_HOST_H diff --git a/frameworks/native/locator_sdk/include/locator_callback_host.h b/frameworks/native/locator_sdk/include/locator_callback_host.h index 902300cf..b6cd7dcb 100644 --- a/frameworks/native/locator_sdk/include/locator_callback_host.h +++ b/frameworks/native/locator_sdk/include/locator_callback_host.h @@ -23,8 +23,8 @@ namespace OHOS { namespace Location { class LocatorCallbackHost : public IRemoteStub { public: - virtual int OnRemoteRequest(uint32_t code, - MessageParcel& data, MessageParcel& reply, MessageOption& option) override; + virtual int OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; void OnLocationReport(const std::unique_ptr& location) override; void OnLocatingStatusChange(const int status) override; void OnErrorReport(const int errorCode) override; diff --git a/frameworks/native/locator_sdk/source/country_code_callback_host.cpp b/frameworks/native/locator_sdk/source/country_code_callback_host.cpp index 8bdca176..21faf182 100644 --- a/frameworks/native/locator_sdk/source/country_code_callback_host.cpp +++ b/frameworks/native/locator_sdk/source/country_code_callback_host.cpp @@ -21,7 +21,7 @@ namespace Location { int CountryCodeCallbackHost::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - LBSLOGD(COUNTRY_CODE_CALLBACK, "CountryCodeCallbackHost::OnRemoteRequest!"); + LBSLOGD(COUNTRY_CODE_CALLBACK, "CountryCodeCallbackHost::OnRemoteRequest! code %{punlic}d", code); if (data.ReadInterfaceToken() != GetDescriptor()) { LBSLOGE(COUNTRY_CODE_CALLBACK, "invalid token."); return -1; diff --git a/frameworks/native/locator_sdk/source/gnss_status_callback_host.cpp b/frameworks/native/locator_sdk/source/gnss_status_callback_host.cpp new file mode 100644 index 00000000..1fbf4b6c --- /dev/null +++ b/frameworks/native/locator_sdk/source/gnss_status_callback_host.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gnss_status_callback_host.h" + +#include "location_log.h" + +namespace OHOS { +namespace Location { +int GnssStatusCallbackHost::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + LBSLOGD(GNSS_STATUS_CALLBACK, "GnssStatusCallbackHost::OnRemoteRequest!"); + if (data.ReadInterfaceToken() != GetDescriptor()) { + LBSLOGE(GNSS_STATUS_CALLBACK, "invalid token."); + return -1; + } + + switch (code) { + case RECEIVE_STATUS_INFO_EVENT: { + std::unique_ptr statusInfo = SatelliteStatus::Unmarshalling(data); + OnStatusChange(statusInfo); + break; + } + default: { + IPCObjectStub::OnRemoteRequest(code, data, reply, option); + break; + } + } + return 0; +} + +void GnssStatusCallbackHost::OnStatusChange(const std::unique_ptr& statusInfo) +{ +} +} // namespace Location +} // namespace OHOS diff --git a/frameworks/native/locator_sdk/source/location_switch_callback_host.cpp b/frameworks/native/locator_sdk/source/location_switch_callback_host.cpp index ba000ab3..312752af 100644 --- a/frameworks/native/locator_sdk/source/location_switch_callback_host.cpp +++ b/frameworks/native/locator_sdk/source/location_switch_callback_host.cpp @@ -21,7 +21,7 @@ namespace Location { int LocationSwitchCallbackHost::OnRemoteRequest( uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - LBSLOGD(SWITCH_CALLBACK, "LocationSwitchCallbackHost::OnRemoteRequest!"); + LBSLOGD(SWITCH_CALLBACK, "LocationSwitchCallbackHost::OnRemoteRequest! code %{punlic}d", code); if (data.ReadInterfaceToken() != GetDescriptor()) { LBSLOGE(SWITCH_CALLBACK, "invalid token."); return -1; @@ -39,6 +39,7 @@ int LocationSwitchCallbackHost::OnRemoteRequest( } return 0; } + void LocationSwitchCallbackHost::OnSwitchChange(int switchState) { } diff --git a/frameworks/native/locator_sdk/source/locator_callback_host.cpp b/frameworks/native/locator_sdk/source/locator_callback_host.cpp index 8fc6faa2..6b89c9e7 100644 --- a/frameworks/native/locator_sdk/source/locator_callback_host.cpp +++ b/frameworks/native/locator_sdk/source/locator_callback_host.cpp @@ -21,7 +21,7 @@ namespace Location { int LocatorCallbackHost::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - LBSLOGD(LOCATOR_CALLBACK, "LocatorCallbackHost::OnRemoteRequest!"); + LBSLOGD(LOCATOR_CALLBACK, "LocatorCallbackHost::OnRemoteRequest! code %{public}d", code); if (data.ReadInterfaceToken() != GetDescriptor()) { LBSLOGE(LOCATOR_CALLBACK, "invalid token."); return -1; @@ -51,6 +51,7 @@ int LocatorCallbackHost::OnRemoteRequest(uint32_t code, } return 0; } + void LocatorCallbackHost::OnLocationReport(const std::unique_ptr& location) { } diff --git a/interfaces/inner_api/include/common_hisysevent.h b/interfaces/inner_api/include/common_hisysevent.h index d80102a8..4170e182 100644 --- a/interfaces/inner_api/include/common_hisysevent.h +++ b/interfaces/inner_api/include/common_hisysevent.h @@ -20,8 +20,8 @@ namespace OHOS { namespace Location { -void WriteAppLocatingStateEvent(const std::string& state, const pid_t pid, const pid_t uid); void WriteGnssStateEvent(const std::string& state, const pid_t pid, const pid_t uid); +void WriteAppLocatingStateEvent(const std::string& state, const pid_t pid, const pid_t uid); void WriteLocationSwitchStateEvent(const std::string& state); void WriteLocationInnerEvent(const int event, std::vector names, std::vector& values); void WriteLocationInnerEvent(const int event, std::initializer_list params); diff --git a/services/etc/init/locationsa.cfg b/services/etc/init/locationsa.cfg index bb1b8fa3..ca76c5a7 100644 --- a/services/etc/init/locationsa.cfg +++ b/services/etc/init/locationsa.cfg @@ -35,6 +35,7 @@ "ohos.permission.MANAGE_SETTINGS", "ohos.permission.ACTIVITY_MOTION", "ohos.permission.INTERNET", + "ohos.permission.GET_NETWORK_INFO", "ohos.permission.RECEIVE_SMS", "ohos.permission.MANAGE_LOCAL_ACCOUNTS" ], diff --git a/services/location_geocode/geocode/source/geo_convert_service.cpp b/services/location_geocode/geocode/source/geo_convert_service.cpp index bada7510..f040a887 100644 --- a/services/location_geocode/geocode/source/geo_convert_service.cpp +++ b/services/location_geocode/geocode/source/geo_convert_service.cpp @@ -81,6 +81,7 @@ void GeoConvertService::OnStop() LBSLOGD(GEO_CONVERT, "GeoConvertService::OnStop and disconnect"); UnRegisterGeoServiceDeathRecipient(); SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT); + conn_ = nullptr; } LBSLOGI(GEO_CONVERT, "GeoConvertService::OnStop service stopped."); } @@ -346,6 +347,7 @@ void GeoConvertService::DisconnectAbilityConnect() if (conn_ != nullptr) { AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn_); SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT); + conn_ = nullptr; LBSLOGI(GEO_CONVERT, "UnloadGeoConvert OnStop and disconnect"); } } diff --git a/services/location_gnss/gnss/BUILD.gn b/services/location_gnss/gnss/BUILD.gn index b947f3c1..940fe20d 100644 --- a/services/location_gnss/gnss/BUILD.gn +++ b/services/location_gnss/gnss/BUILD.gn @@ -23,6 +23,12 @@ if (location_feature_with_gnss) { "$LOCATION_GNSS_ROOT/source/gnss_ability_skeleton.cpp", "$LOCATION_GNSS_ROOT/source/gnss_common_event_subscriber.cpp", "$LOCATION_GNSS_ROOT/source/gnss_event_callback.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/elapsed_real_time_check.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/gps_time_manager.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/net_conn_observer.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/ntp_time_check.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/ntp_time_helper.cpp", + "$LOCATION_GNSS_ROOT/source/ntp/time_manager.cpp", "$LOCATION_GNSS_ROOT/source/string_utils.cpp", "$LOCATION_LOCATOR_ROOT/source/location_config_manager.cpp", "$LOCATION_LOCATOR_ROOT/source/subability_common.cpp", @@ -36,6 +42,7 @@ if (location_feature_with_gnss) { include_dirs = [ "$LOCATION_ROOT_DIR/interfaces/inner_api/include", "$LOCATION_GNSS_ROOT/include", + "$LOCATION_GNSS_ROOT/include/ntp", "$LOCATION_LOCATOR_ROOT/include", ] @@ -143,6 +150,11 @@ if (location_feature_with_gnss) { defines += [ "TIME_SERVICE_ENABLE" ] } + if (net_manager_enable) { + external_deps += [ "netmanager_base:net_conn_manager_if" ] + defines += [ "NET_MANAGER_ENABLE" ] + } + # Used to control the export of dynamic library symbols. version_script = "liblbsservice_gnss_version_script.txt" @@ -156,6 +168,7 @@ if (location_feature_with_gnss) { include_dirs = [ "$LOCATION_ROOT_DIR/interfaces/inner_api/include", "$LOCATION_GNSS_ROOT/include", + "$LOCATION_GNSS_ROOT/include/ntp", "$LOCATION_LOCATOR_ROOT/include", ] @@ -251,6 +264,11 @@ if (location_feature_with_gnss) { defines += [ "TIME_SERVICE_ENABLE" ] } + if (net_manager_enable) { + external_deps += [ "netmanager_base:net_conn_manager_if" ] + defines += [ "NET_MANAGER_ENABLE" ] + } + part_name = "location" subsystem_name = "location" } diff --git a/services/location_gnss/gnss/include/gnss_ability.h b/services/location_gnss/gnss/include/gnss_ability.h index 26ae8320..82125bcd 100644 --- a/services/location_gnss/gnss/include/gnss_ability.h +++ b/services/location_gnss/gnss/include/gnss_ability.h @@ -45,6 +45,15 @@ #include "geofence_event_callback.h" #include "ipc_skeleton.h" +#ifdef TIME_SERVICE_ENABLE +#include "time_manager.h" +#endif +#ifdef NET_MANAGER_ENABLE +#include "net_conn_observer.h" +#include "net_conn_client.h" +#include "net_specifier.h" +#endif + namespace OHOS { namespace Location { #ifdef __aarch64__ @@ -211,6 +220,8 @@ public: LocationErrCode SendNetworkLocation(const std::unique_ptr& location) override; LocationErrCode InjectLocation(); LocationErrCode InjectTime(); + LocationErrCode UpdateNtpTime(int64_t ntpTime, int64_t elapsedTime); + void MonitorNetwork(); private: bool Init(); @@ -251,6 +262,12 @@ private: std::vector> nmeaCallback_; sptr gnssCallback_; Location nlpLocation_; +#ifdef TIME_SERVICE_ENABLE + TimeManager ntpTime_; +#endif +#ifdef NET_MANAGER_ENABLE + sptr netWorkObserver_ = nullptr; +#endif #ifdef HDF_DRIVERS_INTERFACE_AGNSS_ENABLE sptr agnssCallback_; #endif diff --git a/services/location_gnss/gnss/include/ntp/elapsed_real_time_check.h b/services/location_gnss/gnss/include/ntp/elapsed_real_time_check.h new file mode 100644 index 00000000..f7591b98 --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/elapsed_real_time_check.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ELAPSED_REAL_TIME_CHECK_H +#define ELAPSED_REAL_TIME_CHECK_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include + +namespace OHOS { +namespace Location { +class ElapsedRealTimeCheck { +public: + static ElapsedRealTimeCheck* GetInstance(); + void CheckRealTime(int64_t time); + bool CanTrustElapsedRealTime(); + +private: + ElapsedRealTimeCheck(); + ~ElapsedRealTimeCheck(); + + int64_t timeBegin_; + int64_t timeBeginElapsed_; + int64_t timeCheck_; + int64_t timeCheckElapsed_; + bool canTrustElapsedRealTime_ = true; // default is true, usually we trust this time. +}; +} // namespace Location +} // namespace OHOS + +#endif // TIME_SERVICE_ENABLE +#endif // FEATURE_GNSS_SUPPORT +#endif // ELAPSED_REAL_TIME_CHECK_H diff --git a/services/location_gnss/gnss/include/ntp/gps_time_manager.h b/services/location_gnss/gnss/include/ntp/gps_time_manager.h new file mode 100644 index 00000000..ebcc0f8b --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/gps_time_manager.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GPS_TIME_MANAGER_H +#define GPS_TIME_MANAGER_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include "time_manager.h" + +namespace OHOS { +namespace Location { +class GpsTimeManager { +public: + GpsTimeManager(); + ~GpsTimeManager(); + int64_t GetGpsTime(); + void SetGpsTime(int64_t gpsTime, int64_t bootTimeMs); + +private: + bool CheckValid(int64_t gpsTime, int64_t lastSystemTime); + TimeManager timeManager_; + bool validFlag_ {false}; + int64_t lastSystemTime_; +}; +} // namespace Location +} // namespace OHOS + +#endif // TIME_SERVICE_ENABLE +#endif // FEATURE_GNSS_SUPPORT +#endif // GPS_TIME_MANAGER_H diff --git a/services/location_gnss/gnss/include/ntp/net_conn_observer.h b/services/location_gnss/gnss/include/ntp/net_conn_observer.h new file mode 100644 index 00000000..81bd53b8 --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/net_conn_observer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NETMANAGER_BASE_NET_CONN_CALLBACK_OBSERVER_H +#define NETMANAGER_BASE_NET_CONN_CALLBACK_OBSERVER_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef NET_MANAGER_ENABLE + +#include "net_all_capabilities.h" +#include "net_conn_callback_stub.h" + +namespace OHOS { +namespace Location { +class NetConnObserver : public NetManagerStandard::NetConnCallbackStub { +public: + int32_t NetAvailable(sptr &netHandle) override; + + int32_t NetCapabilitiesChange(sptr &netHandle, + const sptr &netAllCap) override; + + int32_t NetConnectionPropertiesChange(sptr &netHandle, + const sptr &info) override; + + int32_t NetLost(sptr &netHandle) override; + + int32_t NetUnavailable() override; + + int32_t NetBlockStatusChange(sptr &netHandle, bool blocked) override; +}; +} // namespace Location +} // namespace OHOS + +#endif +#endif // NET_MANAGER_ENABLE +#endif // NETMANAGER_BASE_NET_CONN_CALLBACK_OBSERVER_H diff --git a/services/location_gnss/gnss/include/ntp/ntp_time_check.h b/services/location_gnss/gnss/include/ntp/ntp_time_check.h new file mode 100644 index 00000000..85ac8ea0 --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/ntp_time_check.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GPS_NTP_TIME_CHECK_H +#define GPS_NTP_TIME_CHECK_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include "gps_time_manager.h" + +namespace OHOS { +namespace Location { +const int64_t DEFAULT_UNCERTAINTY = 30; +class NtpTimeCheck { +public: + static NtpTimeCheck* GetInstance(); + bool CheckNtpTime(int64_t ntpMsTime, int64_t msTimeSynsBoot); + int GetUncertainty(); + void SetGpsTime(int64_t gpsMsTime, int64_t bootTimeMs); + +private: + NtpTimeCheck(); + ~NtpTimeCheck(); + bool CompareTime(int64_t currentNtpTime, int64_t compareTime); + GpsTimeManager gpsTimeManager_; + int difference_ = DEFAULT_UNCERTAINTY; +}; +} // namespace Location +} // namespace OHOS + +#endif // TIME_SERVICE_ENABLE +#endif // FEATURE_GNSS_SUPPORT +#endif // GPS_NTP_TIME_CHECK_H diff --git a/services/location_gnss/gnss/include/ntp/ntp_time_helper.h b/services/location_gnss/gnss/include/ntp/ntp_time_helper.h new file mode 100644 index 00000000..96d27494 --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/ntp_time_helper.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NTP_TIME_HELPER_H +#define NTP_TIME_HELPER_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include +#include "time_manager.h" + +namespace OHOS { +namespace Location { + +struct NtpTrustedTime { + int64_t ntpTime = 0; + int64_t ageMillis = 0; + int64_t elapsedRealTime = 0; +}; + +class NtpTimeHelper { +public: + static NtpTimeHelper* GetInstance(); + void RetrieveAndInjectNtpTime(); + +private: + NtpTimeHelper() = default; + ~NtpTimeHelper() = default; + + NtpTrustedTime ntpResult_; +}; +} // namespace Location +} // namespace OHOS + +#endif // TIME_SERVICE_ENABLE +#endif // FEATURE_GNSS_SUPPORT +#endif // NTP_TIME_HELPER_H diff --git a/services/location_gnss/gnss/include/ntp/time_manager.h b/services/location_gnss/gnss/include/ntp/time_manager.h new file mode 100644 index 00000000..21db8450 --- /dev/null +++ b/services/location_gnss/gnss/include/ntp/time_manager.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TIME_MANAGER_H +#define TIME_MANAGER_H +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include + +namespace OHOS { +namespace Location { +const int64_t EXPIRT_TIME = 14 * 24 * 60 * 60 * 1000L; // 14 day, two week + +class TimeManager { +public: + TimeManager() = default; + explicit TimeManager(int64_t expireTime) : expireTime_(expireTime) {} + ~TimeManager() = default; + int64_t GetCurrentTime(); + void SetCurrentTime(int64_t msTime, int64_t msTimeSynsBoot); + int64_t GetTimestamp(); + +private: + int64_t timestamp_ = 0; + int64_t timeSynsBoot_ = 0; + int64_t expireTime_ = EXPIRT_TIME; +}; +} // namespace Location +} // namespace OHOS + +#endif // TIME_SERVICE_ENABLE +#endif // FEATURE_GNSS_SUPPORT +#endif // TIME_MANAGER_H diff --git a/services/location_gnss/gnss/source/agnss_ni_manager.cpp b/services/location_gnss/gnss/source/agnss_ni_manager.cpp index 5400ef00..631c12ab 100644 --- a/services/location_gnss/gnss/source/agnss_ni_manager.cpp +++ b/services/location_gnss/gnss/source/agnss_ni_manager.cpp @@ -397,11 +397,11 @@ void AGnssNiManager::SendNiNotification(const GnssNiNotificationRequest ¬if) void AGnssNiManager::SendUserResponse(GnssNiResponseCmd responseCmd) { + std::unique_lock lock(mutex_); if (gnssInterface_ == nullptr) { LBSLOGE(GNSS, "gnssInterfacev1_0 is nullptr"); return; } - std::unique_lock lock(mutex_); gnssInterface_->SendNiUserResponse(niNotificationId_, responseCmd); } diff --git a/services/location_gnss/gnss/source/gnss_ability.cpp b/services/location_gnss/gnss/source/gnss_ability.cpp index 6fb7191d..f613f16a 100644 --- a/services/location_gnss/gnss/source/gnss_ability.cpp +++ b/services/location_gnss/gnss/source/gnss_ability.cpp @@ -52,6 +52,7 @@ #ifdef TIME_SERVICE_ENABLE #include "time_service_client.h" +#include "ntp_time_check.h" #endif namespace OHOS { @@ -70,10 +71,8 @@ constexpr const char *GEOFENCE_SERVICE_NAME = "geofence_interface_service"; constexpr const char *UNLOAD_GNSS_TASK = "gnss_sa_unload"; const uint32_t RETRY_INTERVAL_OF_UNLOAD_SA = 4 * 60 * EVENT_INTERVAL_UNITE; constexpr int32_t FENCE_MAX_ID = 1000000; -#ifdef TIME_SERVICE_ENABLE -constexpr int DEFAULT_UNCERTAINTY = 30; -#endif constexpr int NLP_FIX_VALID_TIME = 2; +const int64_t INVALID_TIME = 0; } const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility( @@ -104,11 +103,17 @@ GnssAbility::GnssAbility() : SystemAbility(LOCATION_GNSS_SA_ID, true) if (agnssNiManager != nullptr) { agnssNiManager->SubscribeSaStatusChangeListerner(); } + MonitorNetwork(); LBSLOGI(GNSS, "ability constructed."); } GnssAbility::~GnssAbility() { +#ifdef NET_MANAGER_ENABLE + if (netWorkObserver_ != nullptr) { + NetManagerStandard::NetConnClient::GetInstance().UnregisterNetConnCallback(netWorkObserver_); + } +#endif } bool GnssAbility::CheckIfHdiConnected() @@ -125,8 +130,8 @@ bool GnssAbility::CheckIfHdiConnected() if (!IsDeviceLoaded(GEOFENCE_SERVICE_NAME)) { return false; } - return true; #endif + return true; } void GnssAbility::OnStart() @@ -515,27 +520,69 @@ LocationErrCode GnssAbility::SetPositionMode() return ERRCODE_SUCCESS; } +void GnssAbility::MonitorNetwork() +{ +#ifdef NET_MANAGER_ENABLE + NetManagerStandard::NetSpecifier netSpecifier; + NetManagerStandard::NetAllCapabilities netAllCapabilities; + netAllCapabilities.netCaps_.insert(NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET); + netSpecifier.netCapabilities_ = netAllCapabilities; + sptr specifier( + new (std::nothrow) NetManagerStandard::NetSpecifier(netSpecifier)); + if (specifier == nullptr) { + LBSLOGE(GNSS, "new operator error.specifier is nullptr"); + return; + } + netWorkObserver_ = sptr((new (std::nothrow) NetConnObserver())); + if (netWorkObserver_ == nullptr) { + LBSLOGE(GNSS, "new operator error.netWorkObserver_ is nullptr"); + return; + } + int ret = NetManagerStandard::NetConnClient::GetInstance().RegisterNetConnCallback(specifier, netWorkObserver_, 0); + LBSLOGI(GNSS, "RegisterNetConnCallback retcode= %{public}d", ret); +#endif + return; +} + LocationErrCode GnssAbility::InjectTime() { #ifdef TIME_SERVICE_ENABLE - sptr gnssInterface = IGnssInterface::Get(); - if (gnssInterface == nullptr) { - LBSLOGE(GNSS, "gnssInterface is nullptr"); + LBSLOGD(GNSS, "InjectTime"); + int64_t currentTime = ntpTime_.GetCurrentTime(); + if (currentTime == INVALID_TIME) { return ERRCODE_SERVICE_UNAVAILABLE; } - - GnssRefInfo refInfo; - refInfo.type = GnssRefInfoType::GNSS_REF_INFO_TIME; - auto wallTime = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs(); auto elapsedTime = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs(); - if (wallTime < 0 || elapsedTime < 0) { - LBSLOGE(GNSS, "get time failed"); + if (elapsedTime < 0) { + LBSLOGE(GNSS, "get boot time failed"); return ERRCODE_SERVICE_UNAVAILABLE; } - refInfo.time.time = wallTime; - refInfo.time.elapsedRealtime = elapsedTime; - refInfo.time.uncertaintyOfTime = DEFAULT_UNCERTAINTY; - gnssInterface->SetGnssReferenceInfo(refInfo); + auto ntpTimeCheck = NtpTimeCheck::GetInstance(); + if (ntpTimeCheck != nullptr && ntpTimeCheck->CheckNtpTime(currentTime, elapsedTime)) { + GnssRefInfo refInfo; + refInfo.type = GnssRefInfoType::GNSS_REF_INFO_TIME; + refInfo.time.time = currentTime; + refInfo.time.elapsedRealtime = elapsedTime; + refInfo.time.uncertaintyOfTime = ntpTimeCheck->GetUncertainty(); + auto gnssInterface = IGnssInterface::Get(); + if (gnssInterface != nullptr) { + LBSLOGI(GNSS, "inject ntp time: %{public}s unert %{public}d", + std::to_string(currentTime).c_str(), ntpTimeCheck->GetUncertainty()); + gnssInterface->SetGnssReferenceInfo(refInfo); + } + } +#endif + return ERRCODE_SUCCESS; +} + +LocationErrCode GnssAbility::UpdateNtpTime(int64_t ntpTime, int64_t elapsedTime) +{ +#ifdef TIME_SERVICE_ENABLE + if (ntpTime <= 0 || elapsedTime <= 0) { + LBSLOGE(GNSS, "failed to UpdateNtpTime"); + return ERRCODE_SERVICE_UNAVAILABLE; + } + ntpTime_.SetCurrentTime(ntpTime, elapsedTime); #endif return ERRCODE_SUCCESS; } @@ -569,7 +616,9 @@ LocationErrCode GnssAbility::InjectLocation() GnssRefInfo refInfo; refInfo.type = GnssRefInfoType::GNSS_REF_INFO_LOCATION; refInfo.gnssLocation.fieldValidity = - GnssLocationValidity::GNSS_LOCATION_LAT_VALID | GnssLocationValidity::GNSS_LOCATION_LONG_VALID; + GnssLocationValidity::GNSS_LOCATION_LAT_VALID | + GnssLocationValidity::GNSS_LOCATION_LONG_VALID | + GnssLocationValidity::GNSS_LOCATION_HORIZONTAL_ACCURACY_VALID; refInfo.gnssLocation.latitude = nlpLocation_.GetLatitude(); refInfo.gnssLocation.longitude = nlpLocation_.GetLongitude(); refInfo.gnssLocation.altitude = nlpLocation_.GetAltitude(); @@ -1517,6 +1566,7 @@ void GnssAbility::SendMessage(uint32_t code, MessageParcel &data, MessageParcel } #endif case static_cast(GnssInterfaceCode::SEND_NETWORK_LOCATION): { + LBSLOGI(GNSS, "%{public}s: send network location", __func__); auto request = Location::Unmarshalling(data); AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(code, request); SendEvent(event, reply); diff --git a/services/location_gnss/gnss/source/gnss_ability_skeleton.cpp b/services/location_gnss/gnss/source/gnss_ability_skeleton.cpp index 01cf5af8..97958574 100644 --- a/services/location_gnss/gnss/source/gnss_ability_skeleton.cpp +++ b/services/location_gnss/gnss/source/gnss_ability_skeleton.cpp @@ -343,6 +343,7 @@ int GnssAbilityStub::QuerySupportCoordinateSystemTypeInner( int GnssAbilityStub::SendNetworkLocationInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity) { + LBSLOGI(GNSS, "SendNetworkLocationInner"); if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) { return ERRCODE_PERMISSION_DENIED; } diff --git a/services/location_gnss/gnss/source/gnss_event_callback.cpp b/services/location_gnss/gnss/source/gnss_event_callback.cpp index 2cd92ca7..fe0f7ba2 100644 --- a/services/location_gnss/gnss/source/gnss_event_callback.cpp +++ b/services/location_gnss/gnss/source/gnss_event_callback.cpp @@ -25,6 +25,10 @@ #include "common_hisysevent.h" #include "agnss_ni_manager.h" +#ifdef TIME_SERVICE_ENABLE +#include "ntp_time_check.h" +#include "time_service_client.h" +#endif namespace OHOS { namespace Location { using namespace OHOS::HiviewDFX; @@ -37,6 +41,17 @@ bool g_hasLocation = false; bool g_svIncrease = false; std::unique_ptr g_svInfo = nullptr; +static void SetGpsTime(int64_t gpsTime) +{ +#ifdef TIME_SERVICE_ENABLE + auto ntpTimeCheck = NtpTimeCheck::GetInstance(); + if (ntpTimeCheck != nullptr) { + auto elapsedRealTime = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs(); + ntpTimeCheck->SetGpsTime(gpsTime, elapsedRealTime); + } +#endif +} + int32_t GnssEventCallback::ReportLocation(const LocationInfo& location) { auto gnssAbility = GnssAbility::GetInstance(); @@ -80,6 +95,7 @@ int32_t GnssEventCallback::ReportLocation(const LocationInfo& location) #ifdef FEATURE_PASSIVE_SUPPORT gnssAbility->ReportLocationInfo(PASSIVE_ABILITY, locationNew); #endif + SetGpsTime(locationNew->GetTimeStamp()); IPCSkeleton::SetCallingIdentity(identity); return ERR_OK; } diff --git a/services/location_gnss/gnss/source/ntp/elapsed_real_time_check.cpp b/services/location_gnss/gnss/source/ntp/elapsed_real_time_check.cpp new file mode 100644 index 00000000..b28d38fc --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/elapsed_real_time_check.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE +#include "elapsed_real_time_check.h" + +#include +#include + +#include "common_utils.h" +#include "location_log.h" +#include "time_service_client.h" + +namespace OHOS { +namespace Location { +const int64_t MAX_MISS_MS = 24 * 1000; // we only allow 24s misstake + +ElapsedRealTimeCheck *ElapsedRealTimeCheck::GetInstance() +{ + static ElapsedRealTimeCheck data; + return &data; +} + +ElapsedRealTimeCheck::ElapsedRealTimeCheck() {} + +ElapsedRealTimeCheck::~ElapsedRealTimeCheck() {} + +void ElapsedRealTimeCheck::CheckRealTime(int64_t time) +{ + if (timeBegin_ == 0) { + timeBegin_ = time; + timeBeginElapsed_ = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs(); + } else if (timeCheck_ == 0) { + timeCheck_ = time; + timeCheckElapsed_ = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs(); + } else { + LBSLOGD(GNSS, "checkRealTime"); + } + + if ((timeBegin_ != 0) && (timeCheck_ != 0)) { + int64_t missTime = (timeCheck_ - timeBegin_) - (timeCheckElapsed_ - timeBeginElapsed_); + LBSLOGD(GNSS, + "checkRealTime timeBegin_:%{public}s, timeCheck_:%{public}s, timeBeginElapsed_:%{public}s, " + "timeCheckElapsed_:%{public}s", + std::to_string(timeBegin_).c_str(), std::to_string(timeCheck_).c_str(), + std::to_string(timeBeginElapsed_).c_str(), std::to_string(timeCheckElapsed_).c_str()); + LBSLOGI(GNSS, "checkRealTime missTime:%{public}s", std::to_string(missTime).c_str()); + // we found missTime usually should not grow, results should be simillar on any moment. + // so if very high missTime should be problem. + if (std::abs(missTime) >= MAX_MISS_MS) { + LBSLOGI(GNSS, "checkRealTime false"); + canTrustElapsedRealTime_ = false; + } else { + // sometimes just once system communication block, this could recover automaticly, + // elapsedRealtime still be ok. + canTrustElapsedRealTime_ = true; + } + timeCheck_ = 0; + timeCheckElapsed_ = 0; + } +} + +bool ElapsedRealTimeCheck::CanTrustElapsedRealTime() +{ + return canTrustElapsedRealTime_; +} + +} // namespace Location +} // namespace OHOS +#endif // TIME_SERVICE_ENABLE +#endif diff --git a/services/location_gnss/gnss/source/ntp/gps_time_manager.cpp b/services/location_gnss/gnss/source/ntp/gps_time_manager.cpp new file mode 100644 index 00000000..0349e47a --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/gps_time_manager.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE + +#include "gps_time_manager.h" + +#include "elapsed_real_time_check.h" +#include "location_log.h" +#include "time_service_client.h" + +namespace OHOS { +namespace Location { +const int64_t INVALID_TIME = 0L; +const int64_t MAX_MISSTAKE_TIME = 10 * 1000L; + +GpsTimeManager::GpsTimeManager() +{ + timeManager_ = TimeManager(EXPIRT_TIME); +} + +GpsTimeManager::~GpsTimeManager() {} + +bool GpsTimeManager::CheckValid(int64_t gpsTime, int64_t lastSystemTime) +{ + int64_t bootTimeDiff = gpsTime - timeManager_.GetTimestamp(); + int64_t systemTimeDiff = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs() - lastSystemTime; + if (abs(bootTimeDiff - systemTimeDiff) > MAX_MISSTAKE_TIME) { + return false; + } + return true; +} + +int64_t GpsTimeManager::GetGpsTime() +{ + int64_t tmpTime = timeManager_.GetCurrentTime(); + if ((!validFlag_) && (tmpTime > 0)) { + if (!CheckValid(tmpTime, lastSystemTime_)) { + return INVALID_TIME; + } + } + return tmpTime; +} + +void GpsTimeManager::SetGpsTime(int64_t gpsMsTime, int64_t bootTimeMs) +{ + validFlag_ = true; + lastSystemTime_ = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs(); + timeManager_.SetCurrentTime(gpsMsTime, bootTimeMs); + auto elapsedRealTimeCheck = ElapsedRealTimeCheck::GetInstance(); + if (elapsedRealTimeCheck != nullptr) { + elapsedRealTimeCheck->CheckRealTime(gpsMsTime); + } +} + +} // namespace Location +} // namespace OHOS +#endif // TIME_SERVICE_ENABLE +#endif diff --git a/services/location_gnss/gnss/source/ntp/net_conn_observer.cpp b/services/location_gnss/gnss/source/ntp/net_conn_observer.cpp new file mode 100644 index 00000000..8fb75d29 --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/net_conn_observer.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef NET_MANAGER_ENABLE +#include "net_conn_observer.h" + +#include "location_log.h" +#include "ntp_time_helper.h" + +using namespace OHOS::NetManagerStandard; + +namespace OHOS { +namespace Location { +int32_t NetConnObserver::NetAvailable(sptr &netHandle) +{ + return ERR_OK; +} + +int32_t NetConnObserver::NetCapabilitiesChange(sptr &netHandle, + const sptr &netAllCap) +{ + LBSLOGI(GNSS, "Observe network capabilities change"); + if (netAllCap == nullptr) { + LBSLOGE(GNSS, "Observe network netAllCap is null"); + return -1; + } + if (netAllCap->netCaps_.count(NetCap::NET_CAPABILITY_INTERNET)) { +#ifdef TIME_SERVICE_ENABLE + auto npTimeHelper = NtpTimeHelper::GetInstance(); + if (npTimeHelper != nullptr) { + npTimeHelper->RetrieveAndInjectNtpTime(); + } +#endif + } + return ERR_OK; +} + +int32_t NetConnObserver::NetConnectionPropertiesChange(sptr &netHandle, + const sptr &info) +{ + return ERR_OK; +} + +int32_t NetConnObserver::NetLost(sptr &netHandle) +{ + return ERR_OK; +} + +int32_t NetConnObserver::NetUnavailable() +{ + return ERR_OK; +} + +int32_t NetConnObserver::NetBlockStatusChange(sptr &netHandle, bool blocked) +{ + return ERR_OK; +} +} // namespace Location +} // namespace OHOS + +#endif +#endif \ No newline at end of file diff --git a/services/location_gnss/gnss/source/ntp/ntp_time_check.cpp b/services/location_gnss/gnss/source/ntp/ntp_time_check.cpp new file mode 100644 index 00000000..fcea116f --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/ntp_time_check.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE +#include "ntp_time_check.h" + +#include +#include + +#include "common_utils.h" +#include "location_log.h" +#include "time_service_client.h" + +namespace OHOS { +namespace Location { +const int64_t INVALID_TIME = 0; +const int64_t MISSTAKE_TIME = 50 * 1000; // 50s + +NtpTimeCheck::NtpTimeCheck() {} + +NtpTimeCheck::~NtpTimeCheck() {} + +NtpTimeCheck *NtpTimeCheck::GetInstance() +{ + static NtpTimeCheck data; + return &data; +} + +bool NtpTimeCheck::CheckNtpTime(int64_t ntpMsTime, int64_t msTimeSynsBoot) +{ + int64_t currentNtpTime = + ntpMsTime + MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs() - msTimeSynsBoot; + if (gpsTimeManager_.GetGpsTime() != INVALID_TIME) { + return CompareTime(currentNtpTime, gpsTimeManager_.GetGpsTime()); + } + + LBSLOGI(GNSS, "checkNtpTime return false"); + return false; +} + +bool NtpTimeCheck::CompareTime(int64_t currentNtpTime, int64_t compareTime) +{ + LBSLOGI(GNSS, "compareTime currentNtpTime:%{public}s, compareTime:%{public}s", + std::to_string(currentNtpTime).c_str(), std::to_string(compareTime).c_str()); + int64_t misstake = std::abs(currentNtpTime - compareTime); + if (misstake > MISSTAKE_TIME) { + LBSLOGI(GNSS, "find error ntp time:%{public}s", std::to_string(misstake).c_str()); + return false; + } else { + difference_ = misstake; + return true; + } +} + +void NtpTimeCheck::SetGpsTime(int64_t gpsMsTime, int64_t bootTimeMs) +{ + if (gpsMsTime <= 0 || bootTimeMs <= 0) { + LBSLOGE(GNSS, "set gps time failed :%{public}s, %{public}s", std::to_string(gpsMsTime).c_str(), + std::to_string(bootTimeMs).c_str()); + return; + } + gpsTimeManager_.SetGpsTime(gpsMsTime, bootTimeMs); +} + +int NtpTimeCheck::GetUncertainty() +{ + return (difference_ > DEFAULT_UNCERTAINTY) ? difference_ : DEFAULT_UNCERTAINTY; +} + +} // namespace Location +} // namespace OHOS +#endif // TIME_SERVICE_ENABLE +#endif diff --git a/services/location_gnss/gnss/source/ntp/ntp_time_helper.cpp b/services/location_gnss/gnss/source/ntp/ntp_time_helper.cpp new file mode 100644 index 00000000..1f401746 --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/ntp_time_helper.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE +#include "ntp_time_helper.h" + +#include +#include "gnss_ability.h" +#include "location_log.h" +#include "ntp_time_check.h" +#include "time_service_client.h" + +namespace OHOS { +namespace Location { +static const int64_t NTP_INTERVAL = 24 * 60 * 60 * 1000; + +NtpTimeHelper *NtpTimeHelper::GetInstance() +{ + static NtpTimeHelper data; + return &data; +} + +void NtpTimeHelper::RetrieveAndInjectNtpTime() +{ + if (ntpResult_.elapsedRealTime > 0) { + ntpResult_.ageMillis = + MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs() - ntpResult_.elapsedRealTime; + LBSLOGD(GNSS, "ntp age millis %{public}s", std::to_string(ntpResult_.ageMillis).c_str()); + } + + auto gnssAbility = GnssAbility::GetInstance(); + if (ntpResult_.ntpTime == 0 || ntpResult_.ageMillis > NTP_INTERVAL) { + auto ret = MiscServices::TimeServiceClient::GetInstance()->GetNtpTimeMs(ntpResult_.ntpTime); + if (ret != ERR_OK) { + ntpResult_.ntpTime = 0; + LBSLOGE(GNSS, "failed to get ntp time %{public}d", ret); + return; + } + LBSLOGI(GNSS, "get ntp time %{public}s", std::to_string(ntpResult_.ntpTime).c_str()); + ntpResult_.elapsedRealTime = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs(); + ntpResult_.ageMillis = 0; + if (gnssAbility != nullptr) { + gnssAbility->UpdateNtpTime(ntpResult_.ntpTime, ntpResult_.elapsedRealTime); + } + } + if (gnssAbility != nullptr) { + gnssAbility->InjectTime(); + } +} + +} // namespace Location +} // namespace OHOS +#endif // TIME_SERVICE_ENABLE +#endif diff --git a/services/location_gnss/gnss/source/ntp/time_manager.cpp b/services/location_gnss/gnss/source/ntp/time_manager.cpp new file mode 100644 index 00000000..3d625c6c --- /dev/null +++ b/services/location_gnss/gnss/source/ntp/time_manager.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef FEATURE_GNSS_SUPPORT +#ifdef TIME_SERVICE_ENABLE +#include "time_manager.h" + +#include +#include "common_utils.h" +#include "elapsed_real_time_check.h" +#include "location_log.h" +#include "time_service_client.h" + +namespace OHOS { +namespace Location { +const int64_t INVALID_TIME = 0; +const int64_t GPS_UTC_REFERENCE_TIME = 946656000; // 946656000:UTC time of 2000-01-01 00:00:00 + +int64_t TimeManager::GetCurrentTime() +{ + LBSLOGI(GNSS, "beginning timestamp_ is %{public}s", std::to_string(timestamp_).c_str()); + if (timestamp_ < GPS_UTC_REFERENCE_TIME) { + return INVALID_TIME; + } + if (!ElapsedRealTimeCheck::GetInstance()->CanTrustElapsedRealTime()) { + LBSLOGI(GNSS, "getCurrentTime ElapsedRealTime INVALID_TIME"); + return INVALID_TIME; + } + + int64_t timeTillNow = MiscServices::TimeServiceClient::GetInstance()->GetBootTimeMs() - timeSynsBoot_; + if (timeTillNow >= expireTime_) { + LBSLOGI(GNSS, "getCurrentTime INVALID_TIME"); + return INVALID_TIME; + } else { + LBSLOGI(GNSS, "getCurrentTime:%{public}s", std::to_string(timestamp_ + timeTillNow).c_str()); + return timestamp_ + timeTillNow; + } +} + +void TimeManager::SetCurrentTime(int64_t msTime, int64_t msTimeSynsBoot) +{ + timestamp_ = msTime; + timeSynsBoot_ = msTimeSynsBoot; + LBSLOGI(GNSS, "setCurrentTime timestamp_:%{public}s, mTimeReference:%{public}s", + std::to_string(timestamp_).c_str(), std::to_string(timeSynsBoot_).c_str()); +} + +int64_t TimeManager::GetTimestamp() +{ + return timestamp_; +} + +} // namespace Location +} // namespace OHOS +#endif // TIME_SERVICE_ENABLE +#endif diff --git a/services/location_locator/locator/include/location_config_manager.h b/services/location_locator/locator/include/location_config_manager.h index 1937daf8..7dc1429a 100644 --- a/services/location_locator/locator/include/location_config_manager.h +++ b/services/location_locator/locator/include/location_config_manager.h @@ -61,7 +61,6 @@ public: void OpenPrivacyDialog(); void ConnectExtensionAbility(const AAFwk::Want &want, const std::string &commandStr); std::string GenerateStartCommand(); - int GetCachePrivacyType(); bool SetCachePrivacyType(int value); /* diff --git a/services/location_locator/locator/include/locator_ability.h b/services/location_locator/locator/include/locator_ability.h index b8131d45..be8c1fea 100644 --- a/services/location_locator/locator/include/locator_ability.h +++ b/services/location_locator/locator/include/locator_ability.h @@ -99,7 +99,7 @@ public: void RemoveUnloadTask(uint32_t code) override; void PostUnloadTask(uint32_t code) override; ServiceRunningState QueryServiceState() const - { + { return state_; } void InitSaAbility(); diff --git a/services/location_locator/locator/source/location_config_manager.cpp b/services/location_locator/locator/source/location_config_manager.cpp index 75189251..3a4c8ebb 100644 --- a/services/location_locator/locator/source/location_config_manager.cpp +++ b/services/location_locator/locator/source/location_config_manager.cpp @@ -261,11 +261,6 @@ int LocationConfigManager::SetLocationSwitchState(int state) LocationErrCode LocationConfigManager::GetPrivacyTypeState(const int type, bool& isConfirmed) { int status = 0; - int cacheState = GetCachePrivacyType(); - if (cacheState == DISABLED || cacheState == ENABLED) { - isConfirmed = (status == 1); - return ERRCODE_SUCCESS; - } if (!LocationDataRdbManager::GetLocationEnhanceStatus(status)) { return ERRCODE_SERVICE_UNAVAILABLE; } @@ -273,11 +268,6 @@ LocationErrCode LocationConfigManager::GetPrivacyTypeState(const int type, bool& return ERRCODE_SUCCESS; } -int LocationConfigManager::GetCachePrivacyType() -{ - return GetIntParameter(LOCATION_PRIVACY_MODE); -} - bool LocationConfigManager::SetCachePrivacyType(int value) { char valueArray[MAX_SIZE] = {0}; @@ -296,7 +286,6 @@ LocationErrCode LocationConfigManager::SetPrivacyTypeState(const int type, bool if (!LocationDataRdbManager::SetLocationEnhanceStatus(status)) { return ERRCODE_SERVICE_UNAVAILABLE; } - SetCachePrivacyType(status); return ERRCODE_SUCCESS; } diff --git a/services/location_locator/locator/source/locator_ability.cpp b/services/location_locator/locator/source/locator_ability.cpp index 369ca673..79f70c78 100644 --- a/services/location_locator/locator/source/locator_ability.cpp +++ b/services/location_locator/locator/source/locator_ability.cpp @@ -425,7 +425,7 @@ void LocatorAbility::SendSwitchState(const int state) bool LocatorAbility::CheckIfLocatorConnecting() { - return LocatorRequiredDataManager::GetInstance()->IsConnecting() && GetActiveRequestNum() > 0; + return LocatorRequiredDataManager::GetInstance()->IsConnecting() || GetActiveRequestNum() > 0; } LocationErrCode LocatorAbility::EnableAbility(bool isEnabled) @@ -935,8 +935,7 @@ LocationErrCode LocatorAbility::StartLocating(std::unique_ptr& re bool LocatorAbility::IsCacheVaildScenario(const sptr& requestConfig) { - if (requestConfig->GetFixNumber() == 1 && - requestConfig->GetPriority() != LOCATION_PRIORITY_ACCURACY && + if (requestConfig->GetPriority() != LOCATION_PRIORITY_ACCURACY && ((requestConfig->GetPriority() == LOCATION_PRIORITY_LOCATING_SPEED) || (requestConfig->GetScenario() == SCENE_DAILY_LIFE_SERVICE) || ((requestConfig->GetScenario() == SCENE_UNSET) && (requestConfig->GetPriority() == PRIORITY_FAST_FIRST_FIX)) || @@ -971,7 +970,7 @@ bool LocatorAbility::NeedReportCacheLocation(const std::shared_ptr& req if (reportManager_ == nullptr || request == nullptr) { return false; } - // report cache location in single location request + // report cache location if (IsSingleRequest(request->GetRequestConfig()) && IsCacheVaildScenario(request->GetRequestConfig())) { auto cacheLocation = reportManager_->GetCacheLocation(request); if (cacheLocation != nullptr && callback != nullptr) { @@ -1622,19 +1621,19 @@ bool LocatorAbility::IsProcessRunning(pid_t pid, const uint32_t tokenId) sptr samgrClient = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (samgrClient == nullptr) { LBSLOGE(LOCATOR, "Get system ability manager failed."); - return false; + return true; } sptr iAppManager = iface_cast(samgrClient->GetSystemAbility(APP_MGR_SERVICE_ID)); if (iAppManager == nullptr) { LBSLOGE(LOCATOR, "Failed to get ability manager service."); - return false; + return true; } std::vector runningProcessList; int32_t res = iAppManager->GetAllRunningProcesses(runningProcessList); if (res != ERR_OK) { LBSLOGE(LOCATOR, "Failed to get all running process."); - return false; + return true; } auto it = std::find_if(runningProcessList.begin(), runningProcessList.end(), [pid] (auto runningProcessInfo) { return pid == runningProcessInfo.pid_; diff --git a/services/location_locator/locator/source/report_manager.cpp b/services/location_locator/locator/source/report_manager.cpp index 4a67f642..c088d95f 100644 --- a/services/location_locator/locator/source/report_manager.cpp +++ b/services/location_locator/locator/source/report_manager.cpp @@ -35,8 +35,8 @@ const long NANOS_PER_MILLI = 1000000L; const int MAX_SA_SCHEDULING_JITTER_MS = 200; static constexpr double MAXIMUM_FUZZY_LOCATION_DISTANCE = 4000.0; // Unit m static constexpr double MINIMUM_FUZZY_LOCATION_DISTANCE = 3000.0; // Unit m -static constexpr int GNSS_FIX_CACHED_TIME = 60; -static constexpr int NLP_FIX_CACHED_TIME = 45; +static constexpr int GNSS_FIX_CACHED_TIME = 25; +static constexpr int NLP_FIX_CACHED_TIME = 25; ReportManager* ReportManager::GetInstance() { diff --git a/services/location_network/network/source/network_ability.cpp b/services/location_network/network/source/network_ability.cpp index 093a8375..70df9b58 100644 --- a/services/location_network/network/source/network_ability.cpp +++ b/services/location_network/network/source/network_ability.cpp @@ -280,6 +280,7 @@ void NetworkAbility::RequestRecord(WorkRecord &workRecord, bool isAdded) if (GetRequestNum() == 0 && conn_ != nullptr) { LBSLOGI(NETWORK, "RequestRecord disconnect"); AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn_); + conn_ = nullptr; } } } diff --git a/services/location_ui/entry/src/main/ets/confirmuiextability/ConfirmUIExtAbility.ets b/services/location_ui/entry/src/main/ets/confirmuiextability/ConfirmUIExtAbility.ets index 765f6cd4..57f61c88 100644 --- a/services/location_ui/entry/src/main/ets/confirmuiextability/ConfirmUIExtAbility.ets +++ b/services/location_ui/entry/src/main/ets/confirmuiextability/ConfirmUIExtAbility.ets @@ -38,7 +38,7 @@ export default class ConfirmUIExtAbility extends UIExtensionAbility { let storage: LocalStorage = new LocalStorage(param); session.loadContent('pages/ConfirmDialog', storage); session.setWindowBackgroundColor('#00000000'); - AppStorage.setOrCreate('ConfirmSession',session); + AppStorage.setOrCreate('ConfirmSession', session); } onSessionDestroy(session: UIExtensionContentSession) { diff --git a/services/location_ui/entry/src/main/ets/locationprivacyextability/LocationPrivacyExtAbility.ets b/services/location_ui/entry/src/main/ets/locationprivacyextability/LocationPrivacyExtAbility.ets index ea3d108e..b9c71300 100644 --- a/services/location_ui/entry/src/main/ets/locationprivacyextability/LocationPrivacyExtAbility.ets +++ b/services/location_ui/entry/src/main/ets/locationprivacyextability/LocationPrivacyExtAbility.ets @@ -38,7 +38,7 @@ export default class LocationPrivacyExtAbility extends UIExtensionAbility { let storage: LocalStorage = new LocalStorage(param); session.loadContent('pages/LocationPrivacyDialog', storage); session.setWindowBackgroundColor('#00000000'); - AppStorage.setOrCreate('ConfirmSession',session); + AppStorage.setOrCreate('ConfirmSession', session); } onSessionDestroy(session: UIExtensionContentSession) { diff --git a/services/location_ui/entry/src/main/ets/pages/ConfirmDialog.ets b/services/location_ui/entry/src/main/ets/pages/ConfirmDialog.ets index 8d9432a4..e3d3ba08 100644 --- a/services/location_ui/entry/src/main/ets/pages/ConfirmDialog.ets +++ b/services/location_ui/entry/src/main/ets/pages/ConfirmDialog.ets @@ -17,8 +17,8 @@ import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSessi import commonEventManager from '@ohos.commonEventManager'; let TAG = '[AGNSS-NI:ConfirmDialog]==>'; -const AGNSS_NI_ACCEPT_EVENT: string = "usual.event.AGNSS_NI_ACCEPT"; -const AGNSS_NI_REJECT_EVENT: string = "usual.event.AGNSS_NI_REJECT"; +const AGNSS_NI_ACCEPT_EVENT: string = 'usual.event.AGNSS_NI_ACCEPT'; +const AGNSS_NI_REJECT_EVENT: string = 'usual.event.AGNSS_NI_REJECT'; @Entry @Component diff --git a/services/location_ui/entry/src/main/ets/pages/LocationPrivacyDialog.ets b/services/location_ui/entry/src/main/ets/pages/LocationPrivacyDialog.ets index cec75c10..e51ba67d 100644 --- a/services/location_ui/entry/src/main/ets/pages/LocationPrivacyDialog.ets +++ b/services/location_ui/entry/src/main/ets/pages/LocationPrivacyDialog.ets @@ -17,8 +17,8 @@ import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSessi import commonEventManager from '@ohos.commonEventManager'; let TAG = '[Location-Privacy]==>'; -const LOCATION_PRIVACY_ACCEPT_EVENT: string = "usual.event.LOCATION_PRIVACY_ACCEPT"; -const LOCATION_PRIVACY_REJECT_EVENT: string = "usual.event.LOCATION_PRIVACY_REJECT"; +const LOCATION_PRIVACY_ACCEPT_EVENT: string = 'usual.event.LOCATION_PRIVACY_ACCEPT'; +const LOCATION_PRIVACY_REJECT_EVENT: string = 'usual.event.LOCATION_PRIVACY_REJECT'; @Entry @Component diff --git a/test/location_gnss/BUILD.gn b/test/location_gnss/BUILD.gn index d110a399..81674dce 100644 --- a/test/location_gnss/BUILD.gn +++ b/test/location_gnss/BUILD.gn @@ -26,6 +26,7 @@ if (location_feature_with_gnss) { "$GNSS_UNIT_TEST_DIR/source/gnss_ability_test.cpp", "$GNSS_UNIT_TEST_DIR/source/gnss_event_callback_test.cpp", "$GNSS_UNIT_TEST_DIR/source/gnss_interface_test.cpp", + "$GNSS_UNIT_TEST_DIR/source/ntp_time_test.cpp", "$LOCATION_ROOT_DIR/test/mock/src/mock_service_registry.cpp", ] diff --git a/test/location_gnss/include/ntp_time_test.h b/test/location_gnss/include/ntp_time_test.h new file mode 100644 index 00000000..2cb9b3a7 --- /dev/null +++ b/test/location_gnss/include/ntp_time_test.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NTP_TIME_TEST_H +#define NTP_TIME_TEST_H + +#include + +namespace OHOS { +namespace Location { +class NtpTimeTest : public testing::Test { +public: + void SetUp(); + void TearDown(); +}; +} // namespace Location +} // namespace OHOS +#endif // NTP_TIME_TEST_H \ No newline at end of file diff --git a/test/location_gnss/source/ntp_time_test.cpp b/test/location_gnss/source/ntp_time_test.cpp new file mode 100644 index 00000000..6ede55ac --- /dev/null +++ b/test/location_gnss/source/ntp_time_test.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ntp_time_test.h" + +#include "location_log.h" +#include "ntp_time_check.h" + +using namespace testing::ext; +namespace OHOS { +namespace Location { +void NtpTimeTest::SetUp() +{ +} + +void NtpTimeTest::TearDown() +{ +} + +HWTEST_F(NtpTimeTest, NtpTimeCheckSetGpsTimeTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) + << "NtpTimeTest, NtpTimeCheckSetGpsTimeTest001, TestSize.Level1"; + LBSLOGI(GNSS_TEST, "[NtpTimeTest] NtpTimeCheckSetGpsTimeTest001 begin"); + auto ntpTimeCheck = NtpTimeCheck::GetInstance(); + EXPECT_NE(nullptr, ntpTimeCheck); + int64_t gpsMsTime = -1; + int64_t bootTimeMs = -1; + ntpTimeCheck->SetGpsTime(gpsMsTime, bootTimeMs); + LBSLOGI(GNSS_TEST, "[NtpTimeTest] NtpTimeCheckSetGpsTimeTest001 end"); +} + +HWTEST_F(NtpTimeTest, NtpTimeCheckCheckNtpTimeTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) + << "NtpTimeTest, NtpTimeCheckCheckNtpTimeTest001, TestSize.Level1"; + LBSLOGI(GNSS_TEST, "[NtpTimeTest] NtpTimeCheckCheckNtpTimeTest001 begin"); + auto ntpTimeCheck = NtpTimeCheck::GetInstance(); + EXPECT_NE(nullptr, ntpTimeCheck); + int64_t gpsMsTime = 1720522730000; + int64_t bootTimeMs = 1; + ntpTimeCheck->SetGpsTime(gpsMsTime, bootTimeMs); + int64_t ntpMsTime = 1720522730000; + int64_t msTimeSynsBoot = 1; + ntpTimeCheck->CheckNtpTime(ntpMsTime, msTimeSynsBoot); + LBSLOGI(GNSS_TEST, "[NtpTimeTest] NtpTimeCheckCheckNtpTimeTest001 end"); +} + +} +} \ No newline at end of file diff --git a/test/location_locator/source/location_config_manager_test.cpp b/test/location_locator/source/location_config_manager_test.cpp index 7df60f6f..edde4981 100644 --- a/test/location_locator/source/location_config_manager_test.cpp +++ b/test/location_locator/source/location_config_manager_test.cpp @@ -202,14 +202,5 @@ HWTEST_F(LocationConfigManagerTest, SetCachePrivacyType001, TestSize.Level1) LocationConfigManager::GetInstance()->SetCachePrivacyType(111); LBSLOGI(LOCATOR, "[LocationConfigManagerTest] SetCachePrivacyType001 end"); } - -HWTEST_F(LocationConfigManagerTest, GetCachePrivacyType001, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "LocationConfigManagerTest, GetCachePrivacyType001, TestSize.Level1"; - LBSLOGI(LOCATOR, "[LocationConfigManagerTest] GetCachePrivacyType001 begin"); - LocationConfigManager::GetInstance()->GetCachePrivacyType(); - LBSLOGI(LOCATOR, "[LocationConfigManagerTest] GetCachePrivacyType001 end"); -} } // namespace Location } // namespace OHOS \ No newline at end of file