mirror of
https://github.com/openharmony/advertising_ads_framework.git
synced 2026-07-01 20:14:09 -04:00
@@ -38,7 +38,6 @@ ohos_source_set("advertising_common") {
|
||||
"ipc/src/ad_load_callback_stub.cpp",
|
||||
"ipc/src/ad_load_proxy.cpp",
|
||||
"ipc/src/ad_request_body_stub.cpp",
|
||||
"model/src/request_data.cpp",
|
||||
"utils/src/ad_common_util.cpp",
|
||||
"utils/src/ad_json_util.cpp",
|
||||
]
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_CLOUD_ADVERTISING_AD_DATA_H
|
||||
#define OHOS_CLOUD_ADVERTISING_AD_DATA_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "want.h"
|
||||
#include "want_params.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Cloud {
|
||||
namespace AdsSAData {
|
||||
struct AdRequestParams : public Parcelable {
|
||||
std::string adId;
|
||||
uint32_t adType;
|
||||
uint32_t adCount;
|
||||
uint32_t adWidth;
|
||||
uint32_t adHeight;
|
||||
AAFwk::WantParams adRequestExtra;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static AdRequestParams *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
struct AdOptions : public Parcelable {
|
||||
uint32_t tagForChildProtection;
|
||||
std::string adContentClassification = "";
|
||||
uint32_t nonPersonalizedAd;
|
||||
AAFwk::WantParams adOptionsExtrea;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static AdOptions *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace AdsSAData
|
||||
} // namespace Cloud
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_CLOUD_ADVERTISING_CLIENT_H
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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 "ad_hilog_wreapper.h"
|
||||
#include "request_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Cloud {
|
||||
namespace AdsSAData {
|
||||
bool AdRequestParams::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if ((!parcel.ReadString(adId)) || (!parcel.ReadUint32(adType)) || (!parcel.ReadUint32(adCount)) ||
|
||||
(!parcel.ReadUint32(adWidth)) || (!parcel.ReadUint32(adHeight))) {
|
||||
return false;
|
||||
}
|
||||
sptr<AAFwk::WantParams> paramsPtr = parcel.ReadParcelable<AAFwk::WantParams>();
|
||||
if (paramsPtr == nullptr) {
|
||||
return false;
|
||||
}
|
||||
adRequestExtra = *paramsPtr;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdRequestParams::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return parcel.WriteString(adId) && parcel.WriteUint32(adType) && parcel.WriteUint32(adCount) &&
|
||||
parcel.WriteUint32(adWidth) && parcel.WriteUint32(adHeight);
|
||||
}
|
||||
|
||||
AdRequestParams *AdRequestParams::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
AdRequestParams *info = new (std::nothrow) AdRequestParams();
|
||||
if ((info != nullptr) && (!info->ReadFromParcel(parcel))) {
|
||||
ADS_HILOGE(OHOS::Cloud::ADS_MODULE_COMMON, "ad requestParams read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
bool AdOptions::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
if ((!parcel.ReadUint32(tagForChildProtection)) || (!parcel.ReadString(adContentClassification)) ||
|
||||
(!parcel.ReadUint32(nonPersonalizedAd))) {
|
||||
return false;
|
||||
}
|
||||
sptr<AAFwk::WantParams> paramsPtr = parcel.ReadParcelable<AAFwk::WantParams>();
|
||||
if (paramsPtr == nullptr) {
|
||||
return false;
|
||||
}
|
||||
adOptionsExtrea = *paramsPtr;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdOptions::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return parcel.WriteUint32(tagForChildProtection) && parcel.WriteString(adContentClassification) &&
|
||||
parcel.WriteUint32(nonPersonalizedAd);
|
||||
}
|
||||
|
||||
AdOptions *AdOptions::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
AdOptions *info = new (std::nothrow) AdOptions();
|
||||
if ((info != nullptr) && (!info->ReadFromParcel(parcel))) {
|
||||
ADS_HILOGE(OHOS::Cloud::ADS_MODULE_COMMON, "ad options read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace AdsSAData
|
||||
} // namespace Cloud
|
||||
} // namespace OHOS
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "request_data.h"
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "system_ability.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "iad_load_callback.h"
|
||||
#include "ad_load_napi_common.h"
|
||||
#include "request_data.h"
|
||||
#include "want.h"
|
||||
#include "want_params.h"
|
||||
#include "parcel.h"
|
||||
@@ -54,28 +53,6 @@ struct Advertisment {
|
||||
AAFwk::WantParams adExtrea;
|
||||
};
|
||||
|
||||
struct AdRequestParams : public Parcelable {
|
||||
std::string adId;
|
||||
uint32_t adType;
|
||||
uint32_t adCount;
|
||||
uint32_t adWidth;
|
||||
uint32_t adHeight;
|
||||
AAFwk::WantParams adRequestExtra;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static AdRequestParams *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
struct AdOptions : public Parcelable {
|
||||
uint32_t tagForChildProtection;
|
||||
std::string adContentClassification = "";
|
||||
uint32_t nonPersonalizedAd;
|
||||
AAFwk::WantParams adOptionsExtrea;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static AdOptions *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
struct ShowAdRequest {
|
||||
napi_env env = nullptr;
|
||||
napi_async_work asyncWork;
|
||||
@@ -90,8 +67,6 @@ struct AdvertisingRequestContext {
|
||||
int8_t errorCode = NO_ERROR;
|
||||
std::string requestString;
|
||||
std::string optionString;
|
||||
AdsSAData::AdRequestParams requestParams;
|
||||
AdsSAData::AdOptions adOption;
|
||||
AdJSCallback callback;
|
||||
sptr<IAdLoadCallback> adLoadCallback = nullptr;
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "ad_constant.h"
|
||||
#include "iad_load_callback.h"
|
||||
#include "ad_inner_error_code.h"
|
||||
#include "request_data.h"
|
||||
#include "iad_load_callback.h"
|
||||
#include "ad_load_service.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user