CEEX v1.0.1版本的 MD5 值为:d20246587215ec3471b0d051724c6d34

以下内容为反编译后的 b.java 源代码,内容仅作参考


package com.ta.utdid2.a;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.view.PointerIconCompat;
import com.ta.utdid2.b.a.d;
import com.ta.utdid2.b.a.f;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
public class b {
    private static final String TAG = "com.ta.utdid2.a.b";
    private static b a;
    private Object f0a = new Object();
    private Context mContext;

    public b(Context context) {
        this.mContext = context;
    }

    private static String b(String str, String str2, String str3, String str4) {
        StringBuilder sb = new StringBuilder();
        try {
            str3 = URLEncoder.encode(str3, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        sb.append("http://hydra.alibaba.com/");
        sb.append(str);
        sb.append("/get_aid/");
        sb.append("?");
        sb.append("auth[token]=");
        sb.append(str2);
        sb.append("&type=");
        sb.append("utdid");
        sb.append("&id=");
        sb.append(str3);
        sb.append("&aid=");
        sb.append(str4);
        return sb.toString();
    }

    class a extends Thread {
        com.ut.device.a a;
        String f1a;
        HttpPost f2a;
        String f3b;
        String c;
        String d;

        public a(HttpPost httpPost) {
            this.f1a = "";
            this.d = "";
            this.f2a = httpPost;
        }

        public String b() {
            return this.f1a;
        }

        @Override
        public void run() {
            HttpResponse httpResponse;
            com.ut.device.a aVar = this.a;
            if (aVar != null) {
                aVar.a(1000, this.f3b);
            }
            BufferedReader bufferedReader = null;
            try {
                httpResponse = new DefaultHttpClient().execute(this.f2a);
            } catch (Exception e) {
                com.ut.device.a aVar2 = this.a;
                if (aVar2 != null) {
                    aVar2.a(PointerIconCompat.TYPE_HAND, this.f3b);
                }
                Log.e(b.TAG, e.toString());
                httpResponse = null;
            }
            try {
                if (httpResponse == null) {
                    Log.e(b.TAG, "response is null!");
                } else {
                    bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), Charset.forName("UTF-8")));
                }
            } catch (Exception e2) {
                com.ut.device.a aVar3 = this.a;
                if (aVar3 != null) {
                    aVar3.a(PointerIconCompat.TYPE_HAND, this.f3b);
                }
                Log.e(b.TAG, e2.toString());
            }
            try {
                if (bufferedReader != null) {
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        if (d.e) {
                            String unused = b.TAG;
                        }
                        this.f1a = readLine;
                    }
                } else {
                    Log.e(b.TAG, "BufferredReader is null!");
                }
            } catch (Exception e3) {
                com.ut.device.a aVar4 = this.a;
                if (aVar4 != null) {
                    aVar4.a(PointerIconCompat.TYPE_HAND, this.f3b);
                }
                Log.e(b.TAG, e3.toString());
            }
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                    if (d.e) {
                        String unused2 = b.TAG;
                    }
                } catch (IOException e4) {
                    Log.e(b.TAG, e4.toString());
                }
            }
            if (this.a != null) {
                String a = b.a(this.f1a, this.f3b);
                this.a.a(1001, a);
                c.a(b.this.mContext, this.c, a, this.d);
                return;
            }
            synchronized (b.this.f0a) {
                b.this.f0a.notifyAll();
            }
        }

        public a(HttpPost httpPost, com.ut.device.a aVar, String str, String str2, String str3) {
            this.f1a = "";
            this.d = "";
            this.f2a = httpPost;
            this.a = aVar;
            this.f3b = str;
            this.c = str2;
            this.d = str3;
        }
    }

    public static synchronized b a(Context context) {
        b bVar;
        synchronized (b.class) {
            if (a == null) {
                a = new b(context);
            }
            bVar = a;
        }
        return bVar;
    }

    public void a(String str, String str2, String str3, String str4, com.ut.device.a aVar) {
        String b = b(str, str2, str3, str4);
        if (d.e) {
            String str5 = "url:" + b + "; len:" + b.length();
        }
        new a(new HttpPost(b), aVar, str4, str, str2).start();
    }

    public String a(String str, String str2, String str3, String str4) {
        String b = b(str, str2, str3, str4);
        int i = f.b(this.mContext) ? 3000 : 1000;
        if (d.e) {
            String str5 = "url:" + b + "; timeout:" + i;
        }
        a aVar = new a(new HttpPost(b));
        aVar.start();
        try {
            synchronized (this.f0a) {
                this.f0a.wait(i);
            }
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
        String b2 = aVar.b();
        if (d.e) {
            String str6 = "mLine:" + b2;
        }
        return a(b2, str4);
    }

    public static String a(String str, String str2) {
        if (TextUtils.isEmpty(str)) {
            return str2;
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (jSONObject.has("data")) {
                JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                if (jSONObject2.has("action") && jSONObject2.has("aid")) {
                    String string = jSONObject2.getString("action");
                    return (string.equalsIgnoreCase("new") || string.equalsIgnoreCase("changed")) ? jSONObject2.getString("aid") : str2;
                }
                return str2;
            } else if (jSONObject.has("isError") && jSONObject.has("status")) {
                String string2 = jSONObject.getString("isError");
                String string3 = jSONObject.getString("status");
                if (string2.equalsIgnoreCase("true")) {
                    if (string3.equalsIgnoreCase("404") || string3.equalsIgnoreCase("401")) {
                        if (d.e) {
                            String str3 = "remove the AID, status:" + string3;
                        }
                        return "";
                    }
                    return str2;
                }
                return str2;
            } else {
                return str2;
            }
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
            return str2;
        } catch (Exception e2) {
            Log.e(TAG, e2.toString());
            return str2;
        }
    }
}