MD5 校验值:27cf44ec6e0720408f5ef017a90a3331
MopubRequestManager.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.jiubang.commerce.mopub.dilute; import android.content.Context; import android.text.TextUtils; import com.gau.utils.net.IConnectListener; import com.gau.utils.net.request.THttpRequest; import com.gau.utils.net.response.IResponse; import com.jb.ga0.commerce.util.LogUtils; import com.jb.ga0.commerce.util.thread.CustomThreadExecutorProxy; import com.jiubang.commerce.ad.abtest.AbBean; import com.jiubang.commerce.ad.http.AdSdkRequestDataUtils; import com.jiubang.commerce.ad.http.AdvertHttpAdapter; import com.jiubang.commerce.ad.http.AdvertJsonOperator; import com.jiubang.commerce.ad.http.decrypt.Des; import com.jiubang.commerce.ad.manager.AdSdkManager; import com.jiubang.commerce.mopub.database.DilutePositionTable; import com.jiubang.commerce.mopub.dilute.MopubDiluteAbTestCfg; import com.jiubang.commerce.mopub.params.MopubConfigManager; import com.jiubang.commerce.mopub.supply.AbStractAbManager; import com.jiubang.commerce.mopub.supply.SupplyAbManager; import com.jiubang.commerce.mopub.supply.ab.AbConfigStrategy; import com.jiubang.commerce.mopub.supply.ab.MopubDiluteAbConfig; import com.jiubang.commerce.statistics.MopubDiluteStatics; import com.jiubang.commerce.utils.StringUtils; import com.jiubang.commerce.utils.SystemUtils; import java.util.List; import org.apache.http.HttpResponse; import org.json.JSONArray; import org.json.JSONObject; public class MopubRequestManager extends AbStractAbManager { public static final String MOPUB_DILUTE_SERVER_URL = "http://advuser.goforandroid.com/api/v1/info"; public static final String MOPUB_DILUTE_TEST_SERVER_URL = "http://192.168.215.98:8080/adv_user/api/v2/userinfo"; private static final String MOPUB_TAG = "mopub_dilute"; private static final String REQUEST_MOPUB_DILUTE_BID = "240"; private static final String SEPERATE = "&"; private static MopubRequestManager sInstance; private int mDiluteTime; private int mPosition; private int mPositionCount; public static MopubRequestManager getInstance(Context context) { if (sInstance == null) { synchronized (MopubRequestManager.class) { if (sInstance == null) { sInstance = new MopubRequestManager(context, REQUEST_MOPUB_DILUTE_BID, new MopubDiluteAbConfig()); } } } return sInstance; } public MopubRequestManager(Context context, String str, AbConfigStrategy abConfigStrategy) { super(context, str, abConfigStrategy); } private MopubDiluteAbTestCfg.Conf decideMaxDiluteConf(MopubDiluteAbTestCfg mopubDiluteAbTestCfg) { List<MopubDiluteAbTestCfg.Conf> confs = mopubDiluteAbTestCfg.getConfs(); this.mPositionCount = confs.size(); MopubDiluteAbTestCfg.Conf conf = confs.get(0); for (int i = 0; i < confs.size(); i++) { int dilutePosition = confs.get(i).getDilutePosition(); MopubDiluteAbTestCfg.Conf queryPositionSetting = queryPositionSetting(dilutePosition); LogUtils.d("mopub_dilute", "[MopubRequestManager::decideMaxDiluteConf] queryPositionSetting:" + (queryPositionSetting != null)); MopubDiluteAbTestCfg.Conf conf2 = confs.get(i); if (queryPositionSetting != null) { conf2.setAdid(queryPositionSetting.getAdid()); conf2.setRefreshTime(queryPositionSetting.getRefreshTime()); conf2.setDiluteTime(queryPositionSetting.getDiluteTime()); LogUtils.d("mopub_dilute", "[MopubRequestManager::decideMaxDiluteConf] 该位置原来已经有数据,更新mopub配置数据到数据库:" + DilutePositionTable.getInstance(this.mContext).updateDilutePositionInfo(conf2)); } else { LogUtils.d("mopub_dilute", "[MopubRequestManager::decideMaxDiluteConf] 插入mopub配置数据到数据库:" + DilutePositionTable.getInstance(this.mContext).insertDilutePositionInfoWithoutDiluteTime(conf2)); } if (conf2.getDiluteNumPeople() > conf.getDiluteNumPeople()) { conf = conf2; } MopubDiluteStatics.uploadReqControlNumAdsdk(this.mContext, confs.get(i).getControlCount(), dilutePosition); } return conf; } private MopubDiluteAbTestCfg.Conf queryPositionSetting(int i) { return DilutePositionTable.getInstance(this.mContext).queryConfForPosition(i); } private void requestMopubDiluteId(final int i) { CustomThreadExecutorProxy.getInstance().execute(new Runnable() { @Override public void run() { MopubRequestManager.this.ckeckMopubDiluteId(new IConnectListener() { @Override public void onFinish(THttpRequest tHttpRequest, IResponse iResponse) { JSONObject jSONObject; int i2; try { jSONObject = new JSONObject(StringUtils.toString(iResponse.getResponse())); LogUtils.d("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId]datasJson= " + jSONObject.toString()); } catch (Exception e) { e.printStackTrace(); } if (jSONObject != null) { List<MopubDiluteBean> diluteOldList = MopubDiluteCfg.getDiluteOldList(MopubRequestManager.this.mContext); LogUtils.d("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId]oldList " + diluteOldList.size()); JSONArray optJSONArray = jSONObject.optJSONArray(MopubDiluteCfg.USERINFOS); int i3 = 0; int length = optJSONArray != null ? optJSONArray.length() : 0; int i4 = 0; while (i4 < length) { JSONObject optJSONObject = optJSONArray.optJSONObject(i4); if (optJSONObject != null) { if (TextUtils.isEmpty(optJSONObject.optString("aid")) || TextUtils.isEmpty(optJSONObject.optString(MopubDiluteCfg.ADID))) { i2 = i3 + 1; i4++; i3 = i2; } else { diluteOldList.add(new MopubDiluteBean(0, optJSONObject.optString("aid"), optJSONObject.optString(MopubDiluteCfg.ADID), 0L, 0L, 0)); } } i2 = i3; i4++; i3 = i2; } MopubDiluteStatics.uploadDiluteReqNum(MopubRequestManager.this.mContext.getApplicationContext(), optJSONArray.length(), i, MopubRequestManager.this.mPosition + "", i3); if (optJSONArray.length() != 0) { LogUtils.d("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId]获取新数据后本地已有用于稀释android的存量oldList " + diluteOldList.size()); MopubConfigManager.getInstance(MopubRequestManager.this.mContext).setMopubDiluteStock(diluteOldList.size() + 1); String jSONArrayStr = MopubDiluteBean.toJSONArrayStr(diluteOldList); LogUtils.d("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId]存储的newArrayStr " + jSONArrayStr); MopubConfigManager.getInstance(MopubRequestManager.this.mContext).setRequestCountStr(jSONArrayStr); SupplyAbManager.getInstance(MopubRequestManager.this.mContext).beginAbClock(false); return; } return; } LogUtils.d("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId]返回的datasJson为空"); } @Override public void onException(THttpRequest tHttpRequest, int i2) { LogUtils.e("mopub_dilute", "[MopubRequestManager::requestMopubDiluteId](error, reason:" + i2 + ")"); MopubDiluteStatics.uploadDiluteReqNum(MopubRequestManager.this.mContext.getApplicationContext(), -1, i, MopubRequestManager.this.mPosition + "", -1); SupplyAbManager.getInstance(MopubRequestManager.this.mContext).beginAbClock(false); } @Override public void onStart(THttpRequest tHttpRequest) { } @Override public void onException(THttpRequest tHttpRequest, HttpResponse httpResponse, int i2) { onException(tHttpRequest, i2); } }, i); } }); } public void ckeckMopubDiluteId(IConnectListener iConnectListener, int i) { try { THttpRequest tHttpRequest = new THttpRequest(getMopubDiluteUrl(i), iConnectListener); LogUtils.d("mopub_dilute", "mopub稀释,请求gadid的url:" + getMopubDiluteUrl(i)); if (tHttpRequest != null) { tHttpRequest.setProtocol(0); tHttpRequest.setTimeoutValue(60000); tHttpRequest.setRequestPriority(10); tHttpRequest.setOperator(new AdvertJsonOperator(false).decrypt(Des.get(Des.Which.UserInfo))); AdvertHttpAdapter.getInstance(this.mContext).addTask(tHttpRequest, true); } else { LogUtils.d("mopub_dilute", "[MopubRequestManager::ckeckMopubDiluteId](error, httpRequest is null)"); } } catch (Exception e) { LogUtils.e("mopub_dilute", "[MopubRequestManager::ckeckMopubDiluteId](error, " + (e != null ? e.getMessage() : "==") + ")"); } } private String getMopubDiluteUrl(int i) { AdSdkManager adSdkManager = AdSdkManager.getInstance(); return MOPUB_DILUTE_SERVER_URL + "?aid=" + StringUtils.toString(SystemUtils.getAndroidId(this.mContext)) + SEPERATE + "adid=" + adSdkManager.getGoogleId() + SEPERATE + "size=" + (i + "") + SEPERATE + "country=" + StringUtils.toUpperCase(SystemUtils.getLocal(this.mContext)); } @Override protected void onAbException(String str, int i) { MopubDiluteStatics.uploadDiluteSuccess(this.mContext.getApplicationContext(), this.mDiluteTime, -1); } @Override protected void onAbFinish(String str, AbBean abBean) { MopubConfigManager.getInstance(this.mContext).saveMopubAbTestCheckTime(System.currentTimeMillis()); String str2 = null; if (abBean != null) { str2 = abBean.getJsonStr(); } LogUtils.d("mopub_dilute", "A/B Test,下发的mopub稀释json->" + str2); DilutePositionTable.getInstance(this.mContext).deleteAll(); if (!TextUtils.isEmpty(str2)) { try { MopubDiluteAbTestCfg.Conf decideMaxDiluteConf = decideMaxDiluteConf(new MopubDiluteAbTestCfg(new JSONObject(str2).getJSONObject(AdSdkRequestDataUtils.RESPONSE_JOSN_TAG_DATAS).getJSONObject("infos"))); this.mDiluteTime = decideMaxDiluteConf.getDiluteNumPeople(); this.mPosition = decideMaxDiluteConf.getDilutePosition(); MopubDiluteStatics.uploadDiluteSuccess(this.mContext.getApplicationContext(), this.mDiluteTime, this.mPositionCount); } catch (Exception e) { e.printStackTrace(); LogUtils.d("mopub_dilute", "A/B Test,下发的mopub稀释JSON解析异常->errorMsg:" + e); MopubDiluteStatics.uploadDiluteSuccess(this.mContext.getApplicationContext(), this.mDiluteTime, 0); MopubDiluteStatics.uploadReqControlNumAdsdk(this.mContext, -1, -1); } } else { MopubDiluteStatics.uploadDiluteSuccess(this.mContext.getApplicationContext(), this.mDiluteTime, 0); MopubDiluteStatics.uploadReqControlNumAdsdk(this.mContext, -2, -1); } SupplyAbManager.getInstance(this.mContext).beginAbClock(false); } public void checkReqDiluteId(int i) { int mopubDiluteStock = i - MopubConfigManager.getInstance(this.mContext).getMopubDiluteStock(); LogUtils.d("mopub_dilute", "A/B Test,服务器下发的位置中最大的稀释人数和本地已有稀释人数差值" + mopubDiluteStock); if (mopubDiluteStock > 0) { LogUtils.d("mopub_dilute", "A/B Test,本地人数不够稀释倍数,访问服务器,获取新的数据"); requestMopubDiluteId(mopubDiluteStock); } } }