- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
416 lines
18 KiB
Java
416 lines
18 KiB
Java
package csdk.gluads.impl;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import csdk.gluads.Consts;
|
|
import csdk.gluads.CustomAction;
|
|
import csdk.gluads.IAdvertising;
|
|
import csdk.gluads.IAdvertisingListener;
|
|
import csdk.gluads.PlacementEvent;
|
|
import csdk.gluads.PrivacyStatus;
|
|
import csdk.gluads.Reward;
|
|
import csdk.gluads.eventbus.GluAdsEventHandler;
|
|
import csdk.gluads.util.Common;
|
|
import csdk.gluads.util.ConfigUtil;
|
|
import csdk.gluads.util.GluActivityLifecycleCallbacks;
|
|
import csdk.gluads.util.IAction1;
|
|
import csdk.gluads.util.IAction2;
|
|
import csdk.gluads.util.broadcastmanager.IBroadcastManger;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class AdvertisingImpl implements IAdvertising, IAdvertisingListener {
|
|
private Map<String, IAdvertising> handlers;
|
|
private boolean hasInitRun;
|
|
private final IBroadcastManger mBroadcastManager;
|
|
private Context mContext;
|
|
private GluAdsEventHandler mEventHandler;
|
|
private GluActivityLifecycleCallbacks mGluActivityLifecycleCallbacks;
|
|
private Runnable mOnDestroy;
|
|
private Runnable mOnInit;
|
|
private AdsSubscriber mSubscriber;
|
|
private Integer userAge;
|
|
private final AtomicReference<IAdvertisingListener> listener = new AtomicReference<>(NullAdvertisingListener.INSTANCE);
|
|
private Map<String, IAction1<PrivacyStatus>> mInitHandlers = Collections.synchronizedMap(Common.createMap());
|
|
private final Map<String, IAction1<PrivacyStatus>> mPrivacyStatusUpdateHandlers = Collections.synchronizedMap(Common.createMap());
|
|
private final Map<String, String> mPrivacyStages = Collections.synchronizedMap(Common.createMap());
|
|
|
|
@NonNull
|
|
public Map<String, IAdvertising> getComponentHandlers() {
|
|
return this.handlers;
|
|
}
|
|
|
|
public void updateUserAge(Integer num) {
|
|
this.userAge = num;
|
|
}
|
|
|
|
public AdvertisingImpl(IBroadcastManger iBroadcastManger, Context context) {
|
|
this.mContext = context;
|
|
int i = 0;
|
|
while (true) {
|
|
String[] strArr = Consts.SDK_ARRAY_AD_NETWORKS;
|
|
if (i < strArr.length) {
|
|
this.mPrivacyStages.put(strArr[i], Consts.SDK_PRIVACY_STAGE_UNINITIALIZED);
|
|
i++;
|
|
} else {
|
|
this.mBroadcastManager = iBroadcastManger;
|
|
this.mSubscriber = AdsSubscriber.subscribe(iBroadcastManger, this, this.mPrivacyStages.size());
|
|
this.hasInitRun = false;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void initialize(Runnable runnable, Runnable runnable2, GluAdsEventHandler gluAdsEventHandler) {
|
|
this.mOnDestroy = runnable2;
|
|
this.mEventHandler = gluAdsEventHandler;
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().setAdvertisingListener(this);
|
|
}
|
|
this.mOnInit = runnable;
|
|
AdsSubscriber adsSubscriber = this.mSubscriber;
|
|
if (adsSubscriber != null && adsSubscriber.isPrivacyReady() && !this.hasInitRun) {
|
|
this.mOnInit.run();
|
|
this.hasInitRun = true;
|
|
}
|
|
this.mGluActivityLifecycleCallbacks = new GluActivityLifecycleCallbacks(this.mContext, new IAction2<String, Activity>() { // from class: csdk.gluads.impl.AdvertisingImpl.1
|
|
@Override // csdk.gluads.util.IAction2
|
|
public void apply(String str, Activity activity) {
|
|
if ("onApplicationResumed".equals(str)) {
|
|
AdvertisingImpl.this.onResume();
|
|
} else if ("onApplicationPaused".equals(str)) {
|
|
AdvertisingImpl.this.onPause();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void rewireListeners() {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().setAdvertisingListener(this);
|
|
}
|
|
}
|
|
|
|
public void handleOnInit() {
|
|
Runnable runnable = this.mOnInit;
|
|
if (runnable == null || this.hasInitRun) {
|
|
return;
|
|
}
|
|
runnable.run();
|
|
this.hasInitRun = true;
|
|
}
|
|
|
|
public void setComponentHandlers(@NonNull Map<String, IAdvertising> map) {
|
|
Common.require(map != null, "handlers can't be null.");
|
|
Map<String, IAdvertising> map2 = this.handlers;
|
|
if (map2 == null) {
|
|
this.handlers = map;
|
|
return;
|
|
}
|
|
Map<String, IAdvertising> shallowClone = Common.shallowClone(map2);
|
|
shallowClone.putAll(map);
|
|
this.handlers = shallowClone;
|
|
}
|
|
|
|
public void updatePrivacyStage(String str, String str2) {
|
|
this.mPrivacyStages.put(str, str2);
|
|
}
|
|
|
|
public void setAdvertisingPrivacyStage(String str, String str2, IAction1<PrivacyStatus> iAction1) {
|
|
this.mPrivacyStatusUpdateHandlers.put(str, iAction1);
|
|
this.mPrivacyStages.put(str, str2);
|
|
}
|
|
|
|
public void setInitHandler(String str, IAction1<PrivacyStatus> iAction1) {
|
|
this.mInitHandlers.put(str, iAction1);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void setAdvertisingListener(@Nullable IAdvertisingListener iAdvertisingListener) {
|
|
AtomicReference<IAdvertisingListener> atomicReference = this.listener;
|
|
if (iAdvertisingListener == null) {
|
|
iAdvertisingListener = NullAdvertisingListener.INSTANCE;
|
|
}
|
|
atomicReference.set(iAdvertisingListener);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public boolean isLoaded(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "placement can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
return iAdvertising != null && iAdvertising.isLoaded(str, str2, map);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void load(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "placement can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
iAdvertising.load(str, str2, putIfUserAgeIsPresent(map));
|
|
return;
|
|
}
|
|
this.listener.get().onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_LOAD_FINISHED, new UnsupportedOperationException("Unknown advertisementType: " + str + Consts.STRING_PERIOD), map));
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void show(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "placement can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
iAdvertising.show(str, str2, putIfUserAgeIsPresent(map));
|
|
return;
|
|
}
|
|
this.listener.get().onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_SHOW_FINISHED, new UnsupportedOperationException("Unknown advertisementType: " + str + Consts.STRING_PERIOD), map));
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void onAdvertisementImpression(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "identifier can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
iAdvertising.onAdvertisementImpression(str, str2, map);
|
|
return;
|
|
}
|
|
throw new UnsupportedOperationException("Unknown advertisementType: " + str + Consts.STRING_PERIOD);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void onAdvertisementClick(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "identifier can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
iAdvertising.onAdvertisementClick(str, str2, map);
|
|
return;
|
|
}
|
|
throw new UnsupportedOperationException("Unknown advertisementType: " + str + Consts.STRING_PERIOD);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void destroy() {
|
|
this.hasInitRun = false;
|
|
this.mBroadcastManager.unsubscribe();
|
|
this.listener.set(NullAdvertisingListener.INSTANCE);
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().destroy();
|
|
}
|
|
this.handlers.clear();
|
|
Runnable runnable = this.mOnDestroy;
|
|
if (runnable != null) {
|
|
runnable.run();
|
|
}
|
|
this.mGluActivityLifecycleCallbacks.destroy();
|
|
this.mGluActivityLifecycleCallbacks = null;
|
|
this.mContext = null;
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void onPause() {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onPause();
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void onResume() {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onResume();
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void setUserIdentifier(@Nullable String str, @Nullable Map<String, Object> map) {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().setUserIdentifier(str, map);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_setGemsData(@Nullable String str, @Nullable Map<String, Object> map) {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().internal_setGemsData(str, map);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void discard(@NonNull String str, @NonNull String str2, @Nullable Map<String, Object> map) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
iAdvertising.discard(str, str2, map);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void setCustomProperties(@Nullable Map<String, Object> map) {
|
|
if (isPrivacyPolicyUpdate(map)) {
|
|
updatePrivacyStatus(map);
|
|
}
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().setCustomProperties(map);
|
|
}
|
|
}
|
|
|
|
private boolean isPrivacyPolicyUpdate(@Nullable Map<String, Object> map) {
|
|
return containsKey(map, PrivacyStatus.GDPR_APPLIES) && containsKey(map, PrivacyStatus.CCPA_APPLIES) && containsKey(map, PrivacyStatus.UNDER_AGE_USER) && containsKey(map, PrivacyStatus.TEEN_USER);
|
|
}
|
|
|
|
private void updatePrivacyStatus(Map<String, Object> map) {
|
|
internal_updatePrivacyStatus(new PrivacyStatus(Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.GDPR_APPLIES)).booleanValue(), Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.HAS_CONSENT)).booleanValue(), Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.CCPA_APPLIES)).booleanValue(), Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.CCPA_OPT_OUT)).booleanValue(), Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.UNDER_AGE_USER)).booleanValue(), Boolean.valueOf(ConfigUtil.getBoolean(map, PrivacyStatus.TEEN_USER)).booleanValue()));
|
|
}
|
|
|
|
private boolean containsKey(@Nullable Map<String, Object> map, String str) {
|
|
return map != null && map.containsKey(str);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public Reward getReward(@NonNull String str, @NonNull String str2) {
|
|
Common.require(str != null, "advertisementType can't be null.");
|
|
Common.require(str2 != null, "placement can't be null.");
|
|
IAdvertising iAdvertising = this.handlers.get(str);
|
|
if (iAdvertising != null) {
|
|
return iAdvertising.getReward(str, str2);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertisingListener
|
|
public void onCustomActionReceived(@NonNull CustomAction customAction) {
|
|
this.listener.get().onCustomActionReceived(customAction);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertisingListener
|
|
public void onPlacementEvent(@NonNull PlacementEvent placementEvent) {
|
|
Map<String, Object> map;
|
|
if (TextUtils.equals(placementEvent.status, Consts.PLACEMENT_STATUS_SHOW_STARTED)) {
|
|
String GetServedByAdNetworkAndClear = this.mSubscriber.GetServedByAdNetworkAndClear();
|
|
if (!TextUtils.isEmpty(GetServedByAdNetworkAndClear) && (map = placementEvent.extra) != null) {
|
|
map.put(Consts.SERVED_BY_NETWORK, GetServedByAdNetworkAndClear);
|
|
}
|
|
}
|
|
this.mEventHandler.onPlacementEvent(placementEvent);
|
|
if (TextUtils.equals(placementEvent.status, Consts.PLACEMENT_STATUS_SHOW_ATTEMPT) || TextUtils.equals(placementEvent.status, Consts.SINGULAR_AD_REVENUE_REPORT)) {
|
|
return;
|
|
}
|
|
if ((TextUtils.equals(placementEvent.status, Consts.PLACEMENT_STATUS_SHOW_STARTED) && TextUtils.equals(placementEvent.advertisementType, "banner") && Common.get(placementEvent.extra, Consts.KEY_NAME_PUB_REVENUE) != null) || placementEvent.placement == null) {
|
|
return;
|
|
}
|
|
if (placementEvent.advertisementType == "nativeAd") {
|
|
this.listener.get().onPlacementEvent(placementEvent);
|
|
} else {
|
|
this.listener.get().onPlacementEvent(dropPlacementEventExtraIfNotRequired(placementEvent));
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertisingListener
|
|
public void onRewardReceived(@NonNull Reward reward) {
|
|
this.mEventHandler.onRewardReceived(reward);
|
|
this.listener.get().onRewardReceived(reward);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_updatePrivacyStatus(PrivacyStatus privacyStatus) {
|
|
int size = this.mPrivacyStages.size() * 3;
|
|
int i = 0;
|
|
String str = "";
|
|
for (Map.Entry<String, String> entry : this.mPrivacyStages.entrySet()) {
|
|
String value = entry.getValue();
|
|
if (value.equals(Consts.SDK_PRIVACY_STAGE_UNINITIALIZED)) {
|
|
str = str + entry.getKey() + " " + Consts.SDK_PRIVACY_STAGE_UNINITIALIZED + " ";
|
|
} else if (value.equals("disabled") || value.equals(Consts.SDK_PRIVACY_STAGE_UNSUPPORTED)) {
|
|
size -= 3;
|
|
} else if (value.equals("started")) {
|
|
i += 2;
|
|
str = str + entry.getKey() + " started ";
|
|
} else if (value.equals(Consts.SDK_PRIVACY_STAGE_ADDED)) {
|
|
i += 3;
|
|
}
|
|
}
|
|
if (i == size) {
|
|
Map<String, IAction1<PrivacyStatus>> map = this.mInitHandlers;
|
|
if (map != null) {
|
|
this.mInitHandlers = null;
|
|
Iterator<IAction1<PrivacyStatus>> it = map.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().apply(privacyStatus);
|
|
}
|
|
}
|
|
for (IAction1<PrivacyStatus> iAction1 : this.mPrivacyStatusUpdateHandlers.values()) {
|
|
if (iAction1 != null) {
|
|
iAction1.apply(privacyStatus);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
throw new UnsupportedOperationException("Not all privacy status have been collected: " + str);
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_updateRewardList(@NonNull Map<String, Object> map) {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().internal_updateRewardList(map);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_updateAdsFrequency(@NonNull Map<String, Object> map) {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().internal_updateAdsFrequency(map);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_updateCrossPromotion(@NonNull String str, @NonNull Map<String, Object> map, @Nullable Map<String, Object> map2) {
|
|
IAdvertising iAdvertising;
|
|
if ((TextUtils.equals(str, Consts.ADVERTISEMENT_TYPE_REWARDED_INTERSTITIAL) || TextUtils.equals(str, "interstitial")) && (iAdvertising = this.handlers.get(str)) != null) {
|
|
iAdvertising.internal_updateCrossPromotion(str, map, map2);
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.IAdvertising
|
|
public void internal_onNewSession() {
|
|
Iterator<IAdvertising> it = this.handlers.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().internal_onNewSession();
|
|
}
|
|
}
|
|
|
|
private PlacementEvent dropPlacementEventExtraIfNotRequired(PlacementEvent placementEvent) {
|
|
return placementEvent.extra == null ? placementEvent : new PlacementEvent(placementEvent.advertisementType, placementEvent.placement, placementEvent.status, placementEvent.error, null, placementEvent.textureInfo);
|
|
}
|
|
|
|
private Map<String, Object> putIfUserAgeIsPresent(@Nullable Map<String, Object> map) {
|
|
Integer num = this.userAge;
|
|
if (num == null || num.intValue() < 0) {
|
|
return map;
|
|
}
|
|
Map<String, Object> createMap = Common.createMap();
|
|
if (map != null) {
|
|
createMap.putAll(map);
|
|
}
|
|
createMap.put(Consts.EXTRA_KEYWORDS_AGE, String.format(Locale.ENGLISH, "m_age:%d", this.userAge));
|
|
return createMap;
|
|
}
|
|
}
|