diff --git a/frameworks/js/napi/source/location_napi_event.cpp b/frameworks/js/napi/source/location_napi_event.cpp index 586c21594..b08421ec3 100644 --- a/frameworks/js/napi/source/location_napi_event.cpp +++ b/frameworks/js/napi/source/location_napi_event.cpp @@ -440,13 +440,6 @@ napi_value Off(napi_env env, napi_callback_info cbinfo) NAPI_CALL(env, napi_get_value_string_utf8(env, argv[PARAM0], type, sizeof(type), &typeLen)); std::string event = type; LBSLOGI(LOCATION_NAPI, "Unsubscribe event: %{public}s", event.c_str()); - if(argc == PARAM1) { - NAPI_ASSERT(env, argc == PARAM1, "number of parameters should be one"); - g_switchCallbacks.UnsubscribeAllCallback(env, event); - napi_value result = nullptr; - NAPI_CALL(env, napi_get_undefined(env, &result)); - return result; - } if (event == "locationServiceState") { NAPI_ASSERT(env, argc == PARAM2, "number of parameters is wrong"); auto switchCallbackHost = g_switchCallbacks.GetCallbackPtr(env, argv[PARAM1]); diff --git a/frameworks/native/source/locator_impl.cpp b/frameworks/native/source/locator_impl.cpp index 58b4fd2df..98de8f58d 100644 --- a/frameworks/native/source/locator_impl.cpp +++ b/frameworks/native/source/locator_impl.cpp @@ -216,7 +216,7 @@ bool LocatorImpl::IsLocationPrivacyConfirmed(const int type) bool LocatorImpl::SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) { LBSLOGD(LOCATOR_STANDARD, "LocatorImpl::SetLocationPrivacyConfirmStatus()"); - return client_->SetLocationPrivacyConfirmStatus(type, isConfirmed); + return client_->SetLocationPrivacyConfirmStatus(type, isConfirmed) == REPLY_CODE_NO_EXCEPTION ? true : false; } int LocatorImpl::GetCachedGnssLocationsSize() diff --git a/frameworks/native/source/locator_proxy.cpp b/frameworks/native/source/locator_proxy.cpp index 50e8fcc66..a4646aa6c 100644 --- a/frameworks/native/source/locator_proxy.cpp +++ b/frameworks/native/source/locator_proxy.cpp @@ -251,14 +251,14 @@ bool LocatorProxy::SetLocationPrivacyConfirmStatus(const int type, bool isConfir MessageParcel reply; if (!data.WriteInterfaceToken(GetDescriptor())) { LBSLOGE(LOCATOR_STANDARD, "SetLocationPrivacyConfirmStatus, WriteInterfaceToken failed."); - return false; + return REPLY_CODE_EXCEPTION; } data.WriteInt32(type); data.WriteBool(isConfirmed); SendMsgWithDataReply(SET_PRIVACY_COMFIRM_STATUS, data, reply); int error = reply.ReadInt32(); LBSLOGD(LOCATOR_STANDARD, "Proxy::SetLocationPrivacyConfirmStatus Transact ErrCodes = %{public}d", error); - return error == REPLY_CODE_NO_EXCEPTION ? true : false; + return error; } int LocatorProxy::RegisterCachedLocationCallback(std::unique_ptr& request, diff --git a/interfaces/inner_api/include/i_locator.h b/interfaces/inner_api/include/i_locator.h index 47ed8ba6a..b0e1a2cc0 100644 --- a/interfaces/inner_api/include/i_locator.h +++ b/interfaces/inner_api/include/i_locator.h @@ -90,7 +90,7 @@ public: virtual int GetAddressByCoordinate(MessageParcel &data, MessageParcel &replay) = 0; virtual int GetAddressByLocationName(MessageParcel &data, MessageParcel &replay) = 0; virtual bool IsLocationPrivacyConfirmed(const int type) = 0; - virtual void SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) = 0; + virtual int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) = 0; virtual int RegisterCachedLocationCallback(std::unique_ptr& request, sptr& callback, std::string bundleName) = 0; diff --git a/interfaces/inner_api/include/locator.h b/interfaces/inner_api/include/locator.h index 6f6a52bbb..d6b52d643 100644 --- a/interfaces/inner_api/include/locator.h +++ b/interfaces/inner_api/include/locator.h @@ -65,7 +65,7 @@ public: virtual bool IsLocationPrivacyConfirmed(const int type) = 0; - virtual void SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) = 0; + virtual bool SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) = 0; virtual bool RegisterGnssStatusCallback(const sptr& callback, pid_t uid) = 0; diff --git a/interfaces/inner_api/include/locator_proxy.h b/interfaces/inner_api/include/locator_proxy.h index 6a193e5de..28d916069 100644 --- a/interfaces/inner_api/include/locator_proxy.h +++ b/interfaces/inner_api/include/locator_proxy.h @@ -56,7 +56,7 @@ public: int GetAddressByCoordinate(MessageParcel &data, MessageParcel &replay) override; int GetAddressByLocationName(MessageParcel &data, MessageParcel &replay) override; bool IsLocationPrivacyConfirmed(const int type) override; - bool SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) override; + int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) override; int RegisterCachedLocationCallback(std::unique_ptr& request, sptr& callback, std::string bundleName) override; diff --git a/services/location_locator/locator/include/location_config_manager.h b/services/location_locator/locator/include/location_config_manager.h index b190d7f8b..cf05bec97 100644 --- a/services/location_locator/locator/include/location_config_manager.h +++ b/services/location_locator/locator/include/location_config_manager.h @@ -56,7 +56,7 @@ public: std::string GetPrivacyTypeConfigPath(const int type); bool GetPrivacyTypeState(const int type); - void SetPrivacyTypeState(const int type, bool isConfirmed, MessageParcel &replay); + int SetPrivacyTypeState(const int type, bool isConfirmed); private: LocationConfigManager(); diff --git a/services/location_locator/locator/include/locator_ability.h b/services/location_locator/locator/include/locator_ability.h index e1f406341..d8ca38153 100644 --- a/services/location_locator/locator/include/locator_ability.h +++ b/services/location_locator/locator/include/locator_ability.h @@ -81,7 +81,7 @@ public: int GetAddressByLocationName(MessageParcel &data, MessageParcel &replay) override; bool IsLocationPrivacyConfirmed(const int type) override; - void SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed, MessageParcel &replay) override; + int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) override; int RegisterCachedLocationCallback(std::unique_ptr& request, sptr& callback, std::string bundleName) override; diff --git a/services/location_locator/locator/source/location_config_manager.cpp b/services/location_locator/locator/source/location_config_manager.cpp index 705515daf..791b72ce8 100644 --- a/services/location_locator/locator/source/location_config_manager.cpp +++ b/services/location_locator/locator/source/location_config_manager.cpp @@ -209,12 +209,11 @@ bool LocationConfigManager::GetPrivacyTypeState(const int type) return (mPrivacyTypeState[type] == STATE_OPEN) ? true : false; } -void LocationConfigManager::SetPrivacyTypeState(const int type, bool isConfirmed, MessageParcel &replay) +int LocationConfigManager::SetPrivacyTypeState(const int type, bool isConfirmed) { if (type < PRIVACY_TYPE_OTHERS || type > PRIVACY_TYPE_CORE_LOCATION) { - LBSLOGI(LOCATION_NAPI, "SetPrivacyTypeState,invalid types"); - replay.WriteInt32(REPLY_CODE_EXCEPTION); - return; + LBSLOGE(LOCATION_NAPI, "SetPrivacyTypeState,invalid types"); + return REPLY_CODE_EXCEPTION; } std::unique_lock lock(mMutex); if (!IsExistFile(GetPrivacyTypeConfigPath(type))) { @@ -223,8 +222,7 @@ void LocationConfigManager::SetPrivacyTypeState(const int type, bool isConfirmed std::fstream fs(GetPrivacyTypeConfigPath(type)); if (!fs.is_open()) { LBSLOGE(LOCATION_NAPI, "LocationConfigManager: fs.is_open false, return"); - replay.WriteInt32(REPLY_CODE_EXCEPTION); - return; + return REPLY_CODE_EXCEPTION; } std::string content = "0"; if (isConfirmed) { @@ -234,7 +232,7 @@ void LocationConfigManager::SetPrivacyTypeState(const int type, bool isConfirmed fs.clear(); fs.close(); mPrivacyTypeState[type] = isConfirmed ? 1 : 0; - replay.WriteInt32(REPLY_CODE_NO_EXCEPTION); + return REPLY_CODE_NO_EXCEPTION; } } // namespace Location } // namespace OHOS diff --git a/services/location_locator/locator/source/locator_ability.cpp b/services/location_locator/locator/source/locator_ability.cpp index 4cf2b6128..2b77e5674 100644 --- a/services/location_locator/locator/source/locator_ability.cpp +++ b/services/location_locator/locator/source/locator_ability.cpp @@ -345,9 +345,9 @@ bool LocatorAbility::IsLocationPrivacyConfirmed(const int type) return LocationConfigManager::GetInstance().GetPrivacyTypeState(type); } -void LocatorAbility::SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed, MessageParcel &replay) +int LocatorAbility::SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) { - LocationConfigManager::GetInstance().SetPrivacyTypeState(type, isConfirmed, replay); + return LocationConfigManager::GetInstance().SetPrivacyTypeState(type, isConfirmed); } void LocatorAbility::RegisterSwitchCallback(const sptr& callback, pid_t uid) diff --git a/services/location_locator/locator/source/locator_skeleton.cpp b/services/location_locator/locator/source/locator_skeleton.cpp index 14c6de5cb..b1cb93ba3 100644 --- a/services/location_locator/locator/source/locator_skeleton.cpp +++ b/services/location_locator/locator/source/locator_skeleton.cpp @@ -169,7 +169,7 @@ int32_t LocatorAbilityStub::ProcessMsgRequirLocationPermission(uint32_t &code, break; } case SET_PRIVACY_COMFIRM_STATUS: { - SetLocationPrivacyConfirmStatus(data.ReadInt32(), data.ReadBool(), reply); + reply.WriteInt32(SetLocationPrivacyConfirmStatus(data.ReadInt32(), data.ReadBool())); break; } case REG_CACHED_CALLBACK: {