MD5 校验值:27cf44ec6e0720408f5ef017a90a3331
AvoidHttpHandler.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.jiubang.commerce.ad.avoid.ref; import android.content.Context; 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.Machine; import com.jiubang.commerce.ad.avoid.ref.AvoidDetector; import com.jiubang.commerce.ad.http.AdHttpPostHandlerForNet; import com.jiubang.commerce.ad.http.AdvertHttpAdapter; import com.jiubang.commerce.ad.http.AdvertJsonOperator; import com.jiubang.commerce.ad.http.bean.BaseModuleDataItemBean; import com.jiubang.commerce.ad.http.decrypt.Des; import com.jiubang.commerce.ad.manager.AdSdkManager; import com.jiubang.commerce.product.Product; import com.jiubang.commerce.statistics.AvoidStatistic; import com.jiubang.commerce.utils.NetworkUtils; import com.jiubang.commerce.utils.ResourcesFinder; import com.jiubang.commerce.utils.RootTools; import com.jiubang.commerce.utils.StringUtils; import java.util.HashMap; import org.apache.http.HttpResponse; import org.json.JSONException; import org.json.JSONObject; public class AvoidHttpHandler extends AdHttpPostHandlerForNet implements IConnectListener { static final String CID = "cid"; static final String URL = "http://advshield.goforandroid.com/adv_shield/shield/confirmShield"; private AvoidHttpListener mAvoidHttpListener; public interface AvoidHttpListener { void onAvoidFinish(AvoidResponse avoidResponse); } public AvoidHttpHandler(Context context, AvoidHttpListener avoidHttpListener) { super(context); this.mAvoidHttpListener = avoidHttpListener; } public void startRequest(AvoidDetector.DetectInfo detectInfo) { if (this.mAvoidHttpListener != null) { if (!NetworkUtils.isNetworkOK(this.mContext)) { AvoidStatistic.uploadReqServer(this.mContext, "2", 0L); this.mAvoidHttpListener.onAvoidFinish(null); return; } THttpRequest createRequest = createRequest(detectInfo); if (createRequest != null) { AdvertHttpAdapter.getInstance(this.mContext).addTask(createRequest, true); } else { this.mAvoidHttpListener.onAvoidFinish(null); } } } @Override public void onFinish(THttpRequest tHttpRequest, IResponse iResponse) { AvoidResponse avoidResponse; AvoidResponse avoidResponse2; String obj = iResponse.getResponse().toString(); if (LogUtils.isShowLog()) { avoidResponse = getLogPrefix() + "onFinish-->" + obj; LogUtils.i("Ad_SDK", avoidResponse); } String str = "1"; long j = 0; try { try { avoidResponse2 = new AvoidResponse(new JSONObject(obj)); try { str = avoidResponse2.isSuccess() ? BaseModuleDataItemBean.AD_DATA_SOURCE_TYPE_OFFLINE : "1"; j = avoidResponse2.getServerTimeStamp(); AvoidStatistic.uploadReqServer(this.mContext, str, j); this.mAvoidHttpListener.onAvoidFinish(avoidResponse2); avoidResponse = avoidResponse2; } catch (JSONException e) { e = e; LogUtils.w("Ad_SDK", getLogPrefix() + "onFinish-->", e); AvoidStatistic.uploadReqServer(this.mContext, str, 0L); this.mAvoidHttpListener.onAvoidFinish(avoidResponse2); avoidResponse = avoidResponse2; } } catch (Throwable th) { th = th; AvoidStatistic.uploadReqServer(this.mContext, str, j); this.mAvoidHttpListener.onAvoidFinish(avoidResponse); throw th; } } catch (JSONException e2) { e = e2; avoidResponse2 = null; } catch (Throwable th2) { th = th2; avoidResponse = 0; AvoidStatistic.uploadReqServer(this.mContext, str, j); this.mAvoidHttpListener.onAvoidFinish(avoidResponse); throw th; } } @Override public void onException(THttpRequest tHttpRequest, int i) { LogUtils.w("Ad_SDK", getLogPrefix() + "onException-->reason=" + i); AvoidStatistic.uploadReqServer(this.mContext, "3", 0L); this.mAvoidHttpListener.onAvoidFinish(null); } @Override public void onStart(THttpRequest tHttpRequest) { } @Override @Deprecated public void onException(THttpRequest tHttpRequest, HttpResponse httpResponse, int i) { onException(tHttpRequest, i); } @Override public JSONObject createHead() { JSONObject createHead = super.createHead(); try { createHead.put("cid", getCid()); createHead.put("pversion", 20); createHead.put("hasroot", RootTools.isRootAvailable() ? 1 : 0); createHead.put("istablet", Machine.isTablet(this.mContext) ? 1 : 0); } catch (JSONException e) { e.printStackTrace(); } return createHead; } protected JSONObject createShieldValidator(AvoidDetector.DetectInfo detectInfo) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("simCountry", detectInfo.mSIMCountry); jSONObject.put("localCountry", detectInfo.mLocalCountry); jSONObject.put("isVpn", detectInfo.mVpnConnected ? 1 : 0); jSONObject.put("isSim", detectInfo.mHasSIM ? 1 : 0); } catch (JSONException e) { e.printStackTrace(); } return jSONObject; } private int getCid() { int intValue = StringUtils.toInteger(AdSdkManager.getInstance().getCid(), -1).intValue(); if (intValue < 1) { String str = null; try { str = new ResourcesFinder(Product.getHostContext(this.mContext)).getString(Product.XML_NAME_PRODUCT_ID); } catch (Throwable th) { th.printStackTrace(); } return StringUtils.toInteger(str, -1).intValue(); } return intValue; } private THttpRequest createRequest(AvoidDetector.DetectInfo detectInfo) { THttpRequest tHttpRequest; Exception e; HashMap<String, String> hashMap = new HashMap<>(); JSONObject createHead = createHead(); int optInt = createHead.optInt("cid", -1); if (optInt < 1) { LogUtils.w("Ad_SDK", getLogPrefix() + "createRequest--> invalid cid:" + optInt); return null; } Des des = Des.get(Des.Which.Avoid); String stringUtils = StringUtils.toString(createShieldValidator(detectInfo)); hashMap.put("phead", StringUtils.toString(createHead)); hashMap.put("shieldValidator", des.encrypt(stringUtils)); if (LogUtils.isShowLog()) { LogUtils.i("Ad_SDK", getLogPrefix() + " url=" + URL + " shieldValidator=" + stringUtils + " param=" + hashMap.toString()); } try { tHttpRequest = new THttpRequest(URL, this); try { tHttpRequest.setParamMap(hashMap); tHttpRequest.setProtocol(1); tHttpRequest.setTimeoutValue(15000); tHttpRequest.setRequestPriority(10); tHttpRequest.setOperator(new AdvertJsonOperator(false).decrypt(des)); return tHttpRequest; } catch (Exception e2) { e = e2; LogUtils.w("Ad_SDK", getLogPrefix() + "createRequest-->error", e); return tHttpRequest; } } catch (Exception e3) { tHttpRequest = null; e = e3; } } private String getLogPrefix() { return "AvoidHttpHandler:"; } public static class AvoidResponse { private boolean mIsShield; private String mMsg; private long mServerTimeStamp; private String mShieldReason; private int mShieldType; private int mSuccess; AvoidResponse(JSONObject jSONObject) { JSONObject optJSONObject; this.mSuccess = jSONObject.optInt("success"); this.mMsg = jSONObject.optString("message"); if (isSuccess() && (optJSONObject = jSONObject.optJSONObject("data")) != null) { this.mIsShield = optJSONObject.optInt("isShield") == 1; this.mServerTimeStamp = optJSONObject.optLong("currentTime"); this.mShieldType = optJSONObject.optInt("shieldType"); this.mShieldReason = optJSONObject.optString("shieldReson"); } } public boolean isSuccess() { return 1 == this.mSuccess; } public String getMsg() { return this.mMsg; } public boolean isShield() { return this.mIsShield; } public long getServerTimeStamp() { return this.mServerTimeStamp; } public int getShieldType() { return this.mShieldType; } public String getShieldReason() { return this.mShieldReason; } } }