mirror of
https://gitee.com/openharmony/advertising_oaid
synced 2024-11-23 07:49:59 +00:00
oaid重置上报HA,添加关键日志!
Signed-off-by: lipan <lipan111@huawei.com>
This commit is contained in:
parent
28689f5147
commit
6c59b6e5a2
@ -73,7 +73,7 @@ int32_t OAIDServiceProxy::ResetOAID()
|
||||
int32_t OAIDServiceProxy::RegisterObserver(const sptr<IRemoteConfigObserver> &observer)
|
||||
{
|
||||
if (!observer) {
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "Observer is null.");
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "Observer is null, error code is: %{public}d", ERR_NULL_POINTER);
|
||||
return ERR_NULL_POINTER;
|
||||
}
|
||||
MessageParcel data;
|
||||
@ -81,11 +81,13 @@ int32_t OAIDServiceProxy::RegisterObserver(const sptr<IRemoteConfigObserver> &ob
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "Failed to write RegisterObserver InterfaceToken");
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT,
|
||||
"Failed to write RegisterObserver InterfaceToken, error code is: %{public}d",
|
||||
ERR_WRITE_PARCEL_FAILED);
|
||||
return ERR_WRITE_PARCEL_FAILED;
|
||||
}
|
||||
if (!data.WriteRemoteObject(observer->AsObject())) {
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "Observer write failed.");
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "Observer write failed, error code is: %{public}d", ERR_WRITE_PARCEL_FAILED);
|
||||
return ERR_WRITE_PARCEL_FAILED;
|
||||
}
|
||||
OAID_HILOGE(OAID_MODULE_CLIENT, "RegisterObserver proxy");
|
||||
|
@ -52,7 +52,7 @@ void OaidObserverManager::OnUpdateOaid(const std::string &oaid)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lockUpdate(observerMutex_);
|
||||
if (observer_ == nullptr) {
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "observer is null");
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "observer is null, error code is: %{public}d", ERR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
std::string target = oaid.substr(0, 9).append(OAID_VIRTUAL_STR);
|
||||
|
@ -30,6 +30,7 @@ using namespace std::chrono;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Cloud {
|
||||
const std::string OAID_VIRTUAL_STR = "-****-****-****-************";
|
||||
namespace {
|
||||
char HexToChar(uint8_t hex)
|
||||
{
|
||||
@ -338,7 +339,8 @@ std::string OAIDService::GetOAID()
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Begin.");
|
||||
|
||||
std::string oaid = GainOAID();
|
||||
|
||||
std::string target = oaid.substr(0, 9).append(OAID_VIRTUAL_STR);
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "getOaid success oaid is: %{public}s", target.c_str());
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "End.");
|
||||
return oaid;
|
||||
}
|
||||
@ -350,6 +352,8 @@ int32_t OAIDService::ResetOAID()
|
||||
oaid_ = resetOaid;
|
||||
bool result = WriteValueToKvStore(OAID_KVSTORE_KEY, resetOaid);
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "ResetOAID WriteValueToKvStore %{public}s", result == true ? "success" : "failed");
|
||||
std::string target = resetOaid.substr(0, 9).append(OAID_VIRTUAL_STR);
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "resetOaid success oaid is: %{public}s", target.c_str());
|
||||
// 调用单例对象的oberser->OnUpdateOaid
|
||||
DelayedSingleton<OaidObserverManager>::GetInstance()->OnUpdateOaid(resetOaid);
|
||||
return ERR_OK;
|
||||
|
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -203,8 +206,7 @@ int32_t OAIDServiceStub::ValidateResetOAIDPermission(std::string bundleName, Mes
|
||||
}
|
||||
|
||||
if (!CheckSystemApp()) {
|
||||
OAID_HILOGW(
|
||||
OAID_MODULE_SERVICE, "CheckSystemApp fail.errorCode = %{public}d", OAID_ERROR_CODE_NOT_SYSTEM_APP);
|
||||
OAID_HILOGW(OAID_MODULE_SERVICE, "CheckSystemApp fail.errorCode = %{public}d", OAID_ERROR_CODE_NOT_SYSTEM_APP);
|
||||
if (!reply.WriteInt32(OAID_ERROR_CODE_NOT_SYSTEM_APP)) {
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE, "write errorCode to reply failed.");
|
||||
return ERR_SYSYTEM_ERROR;
|
||||
@ -251,8 +253,10 @@ void OAIDServiceStub::ExitIdleState()
|
||||
}
|
||||
int32_t ret = samgrProxy->CancelUnloadSystemAbility(OAID_SYSTME_ID);
|
||||
if (ret != ERR_OK) {
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE, "CancelUnload system ability %{public}d failed, result: %{public}d.",
|
||||
OAID_SYSTME_ID, ret);
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE,
|
||||
"CancelUnload system ability %{public}d failed, result: %{public}d.",
|
||||
OAID_SYSTME_ID,
|
||||
ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -274,8 +278,10 @@ void OAIDServiceStub::PostDelayUnloadTask()
|
||||
}
|
||||
int32_t ret = samgrProxy->UnloadSystemAbility(OAID_SYSTME_ID);
|
||||
if (ret != ERR_OK) {
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE, "Unload system ability %{public}d failed, result: %{public}d.",
|
||||
OAID_SYSTME_ID, ret);
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE,
|
||||
"Unload system ability %{public}d failed, result: %{public}d.",
|
||||
OAID_SYSTME_ID,
|
||||
ret);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -287,18 +293,18 @@ int32_t OAIDServiceStub::HandleRegisterControlConfigObserver(MessageParcel &data
|
||||
{
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
if (uid != HA_UID) {
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE, "callingUid error.");
|
||||
OAID_HILOGE(OAID_MODULE_SERVICE, "callingUid error, error code is: %{public}d", ERR_INVALID_PARAM);
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
if (!remoteObject) {
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "remoteObject is null");
|
||||
return ERR_SYSYTEM_ERROR;
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Observer is null, error code is: %{public}d", ERR_NULL_POINTER);
|
||||
return ERR_NULL_POINTER;
|
||||
}
|
||||
auto observer = iface_cast<IRemoteConfigObserver>(remoteObject);
|
||||
if (observer == nullptr) {
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Null observer.");
|
||||
return ERR_SYSYTEM_ERROR;
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Observer is null, error code is: %{public}d", ERR_NULL_POINTER);
|
||||
return ERR_NULL_POINTER;
|
||||
}
|
||||
return RegisterObserver(observer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user