From 0343e96f3e54a09b5aaeb02b62ea1ea0f5a3732b Mon Sep 17 00:00:00 2001 From: lipan Date: Tue, 11 Jun 2024 15:42:38 +0800 Subject: [PATCH] =?UTF-8?q?ResetOAID=E6=B7=BB=E5=8A=A0=E6=89=93=E7=82=B9?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lipan --- bundle.json | 2 +- interfaces/innerkits/BUILD.gn | 2 +- .../innerkits/src/oaid_service_proxy.cpp | 37 ++++++++++++++----- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/bundle.json b/bundle.json index e1428a0..c40a375 100644 --- a/bundle.json +++ b/bundle.json @@ -35,7 +35,7 @@ "napi", "safwk", "samgr", - "hianalytics_service" + "hiappevent" ], "third_party": [ "libuv", diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index d4279a0..41b53cd 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -46,7 +46,7 @@ ohos_shared_library("oaid_client") { "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hianalytics_service:ha_client", + "hiappevent:hiappevent_innerapi", ] version_script = "liboaidclient.versionscript" subsystem_name = "advertising" diff --git a/interfaces/innerkits/src/oaid_service_proxy.cpp b/interfaces/innerkits/src/oaid_service_proxy.cpp index da7b18b..b71f2d6 100644 --- a/interfaces/innerkits/src/oaid_service_proxy.cpp +++ b/interfaces/innerkits/src/oaid_service_proxy.cpp @@ -18,18 +18,21 @@ #include "oaid_common.h" #include "oaid_service_interface.h" #include "oaid_service_ipc_interface_code.h" -#include "ha_inner_api.h" +#include "app_event_processor_mgr.h" +#include "app_event.h" namespace OHOS { namespace Cloud { using namespace OHOS::HiviewDFX; -OAIDServiceProxy::OAIDServiceProxy(const sptr& object) : IRemoteProxy(object) {} +OAIDServiceProxy::OAIDServiceProxy(const sptr &object) : IRemoteProxy(object) +{} std::string OAIDServiceProxy::GetOAID() { OAID_HILOGI(OAID_MODULE_CLIENT, "GetOAID Begin."); - MessageParcel data, reply; + MessageParcel data; + MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { @@ -50,7 +53,8 @@ std::string OAIDServiceProxy::GetOAID() int32_t OAIDServiceProxy::ResetOAID() { OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID Begin."); - MessageParcel data, reply; + MessageParcel data; + MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { @@ -62,13 +66,28 @@ int32_t OAIDServiceProxy::ResetOAID() OAID_HILOGE(OAID_MODULE_CLIENT, "Reset OAID failed, error code is: %{public}d", result); } OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID End."); + if (result == ERR_OK) { auto oaid = GetOAID(); - std::string eventId = "ADS_ID_REFRESH"; - std::unordered_map someKv({{"type", "oaid"}, {"id", oaid.c_str()}}); - int32_t onEventRet = - HaCloud::HaInnerApi::OnEvent("$CommonEvent", HaCloud::EventType::operation, eventId, someKv); - OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID onEventRet: %{public}d", onEventRet); + HiviewDFX::HiAppEvent::ReportConfig config; + config.name = "ha_app_event"; + config.routeInfo = "AUTO"; + config.eventConfigs.clear(); + + HiviewDFX::HiAppEvent::EventConfig eventConfig; + eventConfig.domain = "CommonEvent"; + eventConfig.name = "ADS_ID_REFRESH"; + eventConfig.isRealTime = true; + config.eventConfigs.push_back(eventConfig); + HiviewDFX::HiAppEvent::AppEventProcessorMgr::AddProcessor(config); + + // 写事件 + HiviewDFX::HiAppEvent::Event event("CommonEvent", "ADS_ID_REFRESH", HiviewDFX::HiAppEvent::BEHAVIOR); + std::string oaidKey = "oaid"; + event.AddParam("type", oaidKey); + event.AddParam("id", oaid); + HiviewDFX::HiAppEvent::Write(event); + OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID WriteEvent success!"); } int32_t errorCode = reply.ReadInt32(); OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID End.errorCode = %{public}d", errorCode);