MD5 校验值:27cf44ec6e0720408f5ef017a90a3331
BaseConnectHandle.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.gau.go.gostaticsdk.connect; import android.content.Context; import com.gau.go.gostaticsdk.StatisticsManager; import com.gau.go.gostaticsdk.beans.PostBean; import com.gau.go.gostaticsdk.utiltool.UtilTool; import com.jiubang.commerce.ad.AdSdkContants; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.protocol.HTTP; public abstract class BaseConnectHandle { public static final String BASIC_CONTROL = "&is_response_json=1"; public static final String CONTROL_STATUS = "control_status"; private static final int HTTP_REQUEST_TIMEOUT = 30000; public static final String JSON_IS_DISPLAY_MARKET = "is_display_market"; public static final String JSON_REPONSE_RESULT = "upload_status"; public static final String JSON_REPONSE_RESULT_OK = "OK"; private static final String POST_DATA_DEBUG_URL = "http://61.145.124.212:8084/GOClientData/DR?ptl=10&is_zip=1"; public static final int RET_ERRO_EXCEPTION = 1; public static final int RET_ERRO_MALFORMEDURLEXCEPTION = 2; public static final int RET_ERRO_NONE = 0; public static final String STATISTICS_DATA_CODE = "UTF-8"; public static final String UPLOAD_URL = "http://goupdate.3g.cn/GOClientData/DR?ptl=10&is_zip=1"; public static final String UPLOAD_USA_URL = "http://keyboard.goupdate.gomo.com/GOClientData/DR?ptl=10&is_zip=1"; protected Context mContext; private String mCurrentServiceUrl = UPLOAD_URL; protected HttpURLConnection mUrlConn; public abstract void onPost(PostBean postBean); public void postData(PostBean postBean) { this.mCurrentServiceUrl = UPLOAD_URL; if (isNeedUploadToUSAService(postBean)) { this.mCurrentServiceUrl = UPLOAD_USA_URL; UtilTool.log(StatisticsManager.TAG, "当前协议需要上传至美国服务器"); } if (2 == prepareConnect(postBean.mFunId, postBean.mData)) { postBean.mState = 2; } else { onPost(postBean); } } public StringBuilder buildData(PostBean postBean) { StringBuilder sb = new StringBuilder(postBean.mData); for (PostBean postBean2 = postBean.mNext; postBean2 != null; postBean2 = postBean2.mNext) { try { if (postBean2.mData == null) { break; } sb.append("\r\n"); sb.append(postBean2.mData); } catch (OutOfMemoryError e) { } } return sb; } public BaseConnectHandle(Context context) { this.mContext = context; } public int prepareConnect(int i, String str) { URL url; Proxy proxy; HttpURLConnection httpURLConnection; try { try { if (StatisticsManager.getInstance(this.mContext).getDebugMode()) { url = new URL(POST_DATA_DEBUG_URL); } else if (i == 19) { url = new URL(this.mCurrentServiceUrl + BASIC_CONTROL); } else { url = new URL(this.mCurrentServiceUrl); } URL url2 = i == 1030 ? new URL(str) : url; if (!UtilTool.isCWWAPConnect(this.mContext) || UtilTool.getNetWorkType(this.mContext) == 1) { proxy = null; } else { try { if (UtilTool.getNetWorkType(this.mContext) == 2) { proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(android.net.Proxy.getDefaultHost(), android.net.Proxy.getDefaultPort())); } else { proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(UtilTool.getProxyHost(this.mContext), UtilTool.getProxyPort(this.mContext))); } } catch (Exception e) { proxy = null; } } if (proxy != null) { httpURLConnection = (HttpURLConnection) url2.openConnection(proxy); } else { httpURLConnection = (HttpURLConnection) url2.openConnection(); } httpURLConnection.setDoOutput(true); httpURLConnection.setDoInput(true); httpURLConnection.setRequestMethod(HttpPost.METHOD_NAME); httpURLConnection.setUseCaches(false); httpURLConnection.setInstanceFollowRedirects(true); httpURLConnection.setConnectTimeout(30000); httpURLConnection.setReadTimeout(30000); httpURLConnection.setRequestProperty(HTTP.CONTENT_TYPE, URLEncodedUtils.CONTENT_TYPE); this.mUrlConn = httpURLConnection; return 0; } catch (Exception e2) { e2.printStackTrace(); return 1; } } catch (MalformedURLException e3) { return 2; } } private boolean isNeedUploadToUSAService(PostBean postBean) { String str; return postBean.mFunId == 776 && (str = postBean.mData) != null && !str.equals("") && Integer.parseInt(str.substring(0, str.indexOf(AdSdkContants.SYMBOL_DOUBLE_LINE))) == 101; } }