我要上王者 v1.1版本的 MD5 值为:b7d3566522def961cabeb92cb17f5db9
以下内容为反编译后的 ConfigParser.java 源代码,内容仅作参考
package com.oo.sdk.config;
import android.content.Context;
import com.anythink.core.api.ATAdConst;
import com.kwad.sdk.core.scene.URLPackage;
import com.oo.sdk.config.AdConfigJsonParse;
import com.oo.sdk.utils.LogUtil;
import com.oo.sdk.utils.PlacementIdUtil;
import com.oo.sdk.utils.StringUtil;
import com.oo.sdk.utils.net.BaseJsonParse;
import com.oo.sdk.utils.net.HttpConnectionHelper;
import com.oo.sdk.utils.net.WebAccessThread;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import org.json.JSONArray;
import org.json.JSONObject;
public class ConfigParser {
public static AdConfigJsonParse.BuysBean bean;
private Context mContext;
private int requestConfigCount = 0;
private static final ConfigParser CONFIG_PARSER = new ConfigParser();
public static Map<String, String> evnetMap = new HashMap();
public static WeightRandom<String> nativeInterIdWeightRandom = WeightRandom.create();
public static WeightRandom<String> insertIdWeightRandom = WeightRandom.create();
public static WeightRandom<String> bannerBottomIdsWeightRandom = WeightRandom.create();
public static WeightRandom<String> bannerTopIdsWeightRandom = WeightRandom.create();
public static WeightRandom<String> nativeBannerTopIdsWeightRandom = WeightRandom.create();
public static WeightRandom<String> nativeBannerBottomIdsWeightRandom = WeightRandom.create();
public static WeightRandom<String> rewardIdsWeightRandom = WeightRandom.create();
public static WeightRandom<String> fullIdsWeightRandom = WeightRandom.create();
private ConfigParser() {
}
public static ConfigParser getInstance() {
return CONFIG_PARSER;
}
public void init(final Context context) {
this.mContext = context;
try {
WebAccessThread webAccessThread = new WebAccessThread("http://adconfig.leading.games/buys/getAdConfig", false, new WebAccessThread.WebAccessResponse() {
@Override
public void onResponse(HttpConnectionHelper.ConnectResult connectResult) {
if (connectResult.getResponseCode() == 200 && !connectResult.getResult().isEmpty()) {
BaseJsonParse.JsonBean<AdConfigJsonParse.BuysBean> parseJson = new AdConfigJsonParse().parseJson(connectResult.getResult());
if (parseJson != null && parseJson.getBean() != null) {
ConfigParser.bean = parseJson.getBean();
LogUtil.d("bean:" + ConfigParser.bean.toString());
if (ConfigParser.bean != null && "1".equals(ConfigParser.bean.evntSwitch)) {
ConfigParser.this.parseEvnet(connectResult.getResult());
LogUtil.d("事件开关开启");
ConfigParser.this.parseIds(ConfigConstant.BANNER_BOTTOM_IDS, ConfigParser.bannerBottomIdsWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.BANNER_TOP_IDS, ConfigParser.bannerTopIdsWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.NATIVE_BANNER_BOTTOM_IDS, ConfigParser.nativeBannerBottomIdsWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.NATIVE_BANNER_TOP_IDS, ConfigParser.nativeBannerTopIdsWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.NATIVE_INTER_IDS, ConfigParser.nativeInterIdWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.REWARD_IDS, ConfigParser.rewardIdsWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.INSERT_IDS, ConfigParser.insertIdWeightRandom);
ConfigParser.this.parseIds(ConfigConstant.FULL_IDS, ConfigParser.fullIdsWeightRandom);
return;
}
LogUtil.d("事件开关关闭");
ConfigParser.evnetMap.clear();
return;
}
LogUtil.e("数据解析异常");
ConfigParser.this.retryConfigRequest(context);
return;
}
LogUtil.e("配置信息获取失败");
ConfigParser.this.retryConfigRequest(context);
}
});
HashMap hashMap = new HashMap();
hashMap.put("gameId", PlacementIdUtil.getOtherPlacements(context).get("game_id"));
hashMap.put(URLPackage.KEY_CHANNEL_ID, PlacementIdUtil.getOtherPlacements(context).get("channel_id"));
webAccessThread.executeSafe(hashMap);
} catch (Exception e) {
e.printStackTrace();
}
}
public void retryConfigRequest(Context context) {
this.requestConfigCount++;
LogUtil.e("配置信息获取失败,发起重试请求,当前重试请求次数:" + this.requestConfigCount);
if (this.requestConfigCount < 3) {
init(context);
}
}
public void parseEvnet(String str) {
try {
JSONArray jSONArray = new JSONObject(str).getJSONObject("data").getJSONObject("adConfig").getJSONArray("tbGamebuysEvents");
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject = jSONArray.getJSONObject(i);
evnetMap.put(jSONObject.getString("eventName"), jSONObject.getString("eventValue"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean getTimingVideoOpen() {
return evnetMap.get(ConfigConstant.TIMING_VIDEO) != null && Integer.valueOf(evnetMap.get(ConfigConstant.TIMING_VIDEO)).intValue() > 0;
}
public long getTimingVideoTime() {
if (evnetMap.get(ConfigConstant.TIMING_VIDEO) == null) {
return 180000L;
}
String trim = evnetMap.get(ConfigConstant.TIMING_VIDEO).trim();
if (StringUtil.isNotEmpty(trim)) {
return Long.parseLong(trim);
}
return 180000L;
}
public boolean getTimingRewardOpen() {
return evnetMap.get(ConfigConstant.TIMING_REWARD) != null && Integer.valueOf(evnetMap.get(ConfigConstant.TIMING_REWARD)).intValue() > 0;
}
public long getTimingRewardVideoTime() {
if (evnetMap.get(ConfigConstant.TIMING_REWARD) == null) {
return 180000L;
}
String trim = evnetMap.get(ConfigConstant.TIMING_REWARD).trim();
if (StringUtil.isNotEmpty(trim)) {
return Long.parseLong(trim);
}
return 180000L;
}
public long getNewPlayerNoAdsTime() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.NEW_PLAYER_NO_ADS_TIME) == null) {
return 300000L;
}
return Long.parseLong(evnetMap.get(ConfigConstant.NEW_PLAYER_NO_ADS_TIME));
}
public long getVideoLimitRequestCnt() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.VIDEO_LIMIT_REQUEST_CNT) == null) {
return 1000L;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.VIDEO_LIMIT_REQUEST_CNT)).intValue();
}
public long getFullVideoCoolTime() {
if (evnetMap.get(ConfigConstant.FULL_VIDEO_COOL_TIME) == null) {
return 180000L;
}
String trim = evnetMap.get(ConfigConstant.FULL_VIDEO_COOL_TIME).trim();
if (StringUtil.isNotEmpty(trim)) {
return Long.parseLong(trim);
}
return 180000L;
}
public boolean isUse233FullscreenAd() {
if (evnetMap.get(ConfigConstant.FULL_SCREEN_USE_PROBABILITY) == null) {
return StringUtil.isNotEmpty(PlacementIdUtil.getPlacements(this.mContext, "m233").get(ATAdConst.NETWORK_REQUEST_PARAMS_KEY.APP_KEY));
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.FULL_SCREEN_USE_PROBABILITY)));
}
public boolean getTimingInsertOpen() {
return evnetMap.get(ConfigConstant.TIMING_INSERT) != null && Integer.valueOf(evnetMap.get(ConfigConstant.TIMING_INSERT)).intValue() > 0;
}
public long getTimingInsertTime() {
if (evnetMap.get(ConfigConstant.TIMING_INSERT) == null) {
return 0L;
}
String str = evnetMap.get(ConfigConstant.TIMING_INSERT);
if (StringUtil.isNotEmpty(str)) {
return Long.parseLong(str);
}
return 0L;
}
public int getInsertAdCoolTime() {
if (evnetMap.get(ConfigConstant.INSERT_AD_COOL_TIME) == null) {
return 60000;
}
return Integer.parseInt(evnetMap.get(ConfigConstant.INSERT_AD_COOL_TIME));
}
public long getInsertLimitRequestCnt() {
if (evnetMap.get(ConfigConstant.INSERT_LIMIT_REQUEST_CNT) == null) {
return 1000L;
}
return Integer.parseInt(evnetMap.get(ConfigConstant.INSERT_LIMIT_REQUEST_CNT));
}
public long getNativeSelfRenderRequestCntLimitRequestCnt() {
if (evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_LIMIT_REQUEST_CNT) == null) {
return 1000L;
}
return Integer.parseInt(evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_LIMIT_REQUEST_CNT));
}
public boolean isUse233InsertAd() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.INSERT_USE_233_PROBABILITY) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.INSERT_USE_233_PROBABILITY)));
}
public boolean isUse233RewardAd() {
if (evnetMap.get(ConfigConstant.REWARD_USE_233_PROBABILITY) == null) {
return StringUtil.isNotEmpty(PlacementIdUtil.getPlacements(this.mContext, "m233").get(ATAdConst.NETWORK_REQUEST_PARAMS_KEY.APP_KEY));
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.REWARD_USE_233_PROBABILITY)));
}
public boolean isUse233BannerAd() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.BANNER_USE_233_PROBABILITY) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.BANNER_USE_233_PROBABILITY)));
}
public boolean isInitUmAnalysis() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.UM_GAME_INIT_PRO) == null) {
return true;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.UM_GAME_INIT_PRO)));
}
public boolean isFullScreenCloseShowInsert() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.FULL_SCREEN_CLOSE_SHOW_INSERT) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.FULL_SCREEN_CLOSE_SHOW_INSERT)));
}
public long getNotShowBannerTime() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.NOT_SHOW_BANNER_TIME) == null) {
return 0L;
}
return Long.parseLong(evnetMap.get(ConfigConstant.NOT_SHOW_BANNER_TIME));
}
public boolean isSwitchFullRewardAD() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.SWITCH_FULL_REWARD_AD) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.SWITCH_FULL_REWARD_AD)));
}
public int getRefreshTopBannerTime() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.REFRESH_TOP_BANNER_TIME) == null) {
return 30000;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.REFRESH_TOP_BANNER_TIME)).intValue();
}
public int getRefreshBottomBannerTime() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.REFRESH_BOTTOM_BANNER_TIME) == null) {
return 30000;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.REFRESH_BOTTOM_BANNER_TIME)).intValue();
}
public long getBannerLimitRequestCnt() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.BANNER_LIMIT_REQUEST_CNT) == null) {
return 1000L;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.BANNER_LIMIT_REQUEST_CNT)).intValue();
}
public long getBannerMistouchCloseCnt() {
if (evnetMap.get(ConfigConstant.BANNER_MISTOUCH_CLOSE_CNT) == null) {
return 1L;
}
return Long.parseLong(evnetMap.get(ConfigConstant.BANNER_MISTOUCH_CLOSE_CNT));
}
public long getInsertMistouchCloseCnt() {
if (evnetMap.get(ConfigConstant.INSERT_MISTOUCH_CLOSE_CNT) == null) {
return 1L;
}
return Long.parseLong(evnetMap.get(ConfigConstant.INSERT_MISTOUCH_CLOSE_CNT));
}
public boolean isOpenInterMistouch() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.INTER_MISTOUCH_RATE) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.INTER_MISTOUCH_RATE)));
}
public boolean isOpenBannerMistouch() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.BANNER_MISTOUCH_RATE) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.BANNER_MISTOUCH_RATE)));
}
public boolean isOpenTopBanner() {
return evnetMap.get(ConfigConstant.BANNER_TOP_SWITCH) != null && Integer.valueOf(evnetMap.get(ConfigConstant.BANNER_TOP_SWITCH)).intValue() > 0;
}
public boolean isOpenBottomBanner() {
return evnetMap.get(ConfigConstant.BANNER_BOTTOM_SWITCH) == null || Integer.valueOf(evnetMap.get(ConfigConstant.BANNER_BOTTOM_SWITCH)).intValue() > 0;
}
public String getInsertShowMode() {
return evnetMap.get(ConfigConstant.INSERT_SHOW_MODE) == null ? "3" : String.valueOf(evnetMap.get(ConfigConstant.INSERT_SHOW_MODE));
}
public String getBannerShowMode() {
return evnetMap.get(ConfigConstant.BANNER_SHOW_MODE) == null ? "3" : String.valueOf(evnetMap.get(ConfigConstant.BANNER_SHOW_MODE));
}
public String getInsertOrFullMode() {
return evnetMap.get(ConfigConstant.INSERT_OR_FULL_MODE) == null ? "2" : String.valueOf(evnetMap.get(ConfigConstant.INSERT_OR_FULL_MODE));
}
public String getMistakeMode() {
return evnetMap.get(ConfigConstant.MISTAKE_MODE) == null ? "2" : String.valueOf(evnetMap.get(ConfigConstant.MISTAKE_MODE));
}
public String getTouchEventMode() {
return evnetMap.get(ConfigConstant.TOUCH_EVENT_MODE) == null ? "0" : String.valueOf(evnetMap.get(ConfigConstant.TOUCH_EVENT_MODE));
}
public int getLongTouchTime() {
if (evnetMap.size() <= 0 || evnetMap.get(ConfigConstant.LONG_TOUCH_TIME) == null) {
return 0;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.LONG_TOUCH_TIME)).intValue();
}
public int getTouchEventClickCount() {
if (evnetMap.get(ConfigConstant.CLICK_COUNT) == null) {
return 0;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.CLICK_COUNT)).intValue();
}
public boolean getLongTouchEventRate() {
if (evnetMap.get(ConfigConstant.LONG_TOUCH_EVENT_RATE) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.LONG_TOUCH_EVENT_RATE)));
}
public boolean getTouchEventClickRate() {
if (evnetMap.get(ConfigConstant.CLICK_EVENT_RATE) == null) {
return false;
}
return randomRate(Integer.valueOf(evnetMap.get(ConfigConstant.CLICK_EVENT_RATE)));
}
public long getNativeSelfRenderTime() {
if (evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_TIME) == null) {
return 30000L;
}
return Integer.valueOf(evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_TIME)).intValue();
}
public boolean getNativeSelfRenderOpen() {
return evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_TIME) != null && Integer.parseInt(evnetMap.get(ConfigConstant.NATIVE_SELF_RENDER_TIME)) > 0;
}
public int getConfigInt(String str, int i) {
if (evnetMap.size() > 0 && evnetMap.get(str) != null) {
try {
return Integer.parseInt(evnetMap.get(str));
} catch (Exception unused) {
}
}
return i;
}
public boolean getConfigBoolean(String str, boolean z) {
return evnetMap.get(str) == null ? z : randomRate(Integer.valueOf(Integer.parseInt(evnetMap.get(str))));
}
public void parseIds(String str, WeightRandom<String> weightRandom) {
if (evnetMap.size() <= 0) {
return;
}
try {
String str2 = evnetMap.get(str);
LogUtil.d(str + ":" + str2);
JSONObject jSONObject = new JSONObject(str2);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
weightRandom.add(next, jSONObject.getInt(next));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public String getInsertId() {
return insertIdWeightRandom.next();
}
public String getFullId() {
return fullIdsWeightRandom.next();
}
public String getNativeInsertId() {
return nativeInterIdWeightRandom.next();
}
public String getRewardId() {
return rewardIdsWeightRandom.next();
}
public String getTopBannerIds() {
return bannerTopIdsWeightRandom.next();
}
public String getBottomBannerIds() {
return bannerBottomIdsWeightRandom.next();
}
public String getNativeBannerTopIds() {
return nativeBannerTopIdsWeightRandom.next();
}
public String getNativeBannerBottomIds() {
return nativeBannerBottomIdsWeightRandom.next();
}
public boolean isOpenSplash() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.splashSwitch);
}
public boolean isOpenInsert() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.interSwitch);
}
public boolean isOpenFullScreen() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.fullSwitch);
}
public boolean isOpenNativeInsert() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.nativeInterSwitch);
}
public boolean isOpenBanner() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.bannerSwitch);
}
public boolean isOpenNativeBanner() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean == null || getTimeOpen(buysBean.nativeBannerSwitch);
}
public boolean isReview() {
AdConfigJsonParse.BuysBean buysBean = bean;
return buysBean != null && "1".equals(buysBean.isReview);
}
private boolean randomRate(Integer num) {
int nextInt = new Random().nextInt(100);
LogUtil.d("概率:随机到的概率数:" + nextInt + ",后台配置概率数:" + num);
if (nextInt < num.intValue()) {
return true;
}
if (num.intValue() == 0) {
}
return false;
}
public boolean getTimeOpen(String str) {
LogUtil.d("timeStr:" + str);
return "1".equals(str);
}
}