射射AV v6.8.3版本的 MD5 值为:4b0475341d3c62fa7e762c41558fd25f

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


package com.tapjoy;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import com.igexin.assist.sdk.AssistPushConsts;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyErrorMessage;
import com.tapjoy.internal.aq;
import com.tapjoy.internal.bm;
import com.tapjoy.internal.bs;
import com.tapjoy.internal.ct;
import com.tapjoy.internal.dc;
import com.tapjoy.internal.dx;
import com.tapjoy.internal.ed;
import com.tapjoy.internal.ee;
import com.tapjoy.internal.ek;
import com.tapjoy.internal.er;
import com.tapjoy.internal.ev;
import com.tapjoy.internal.fd;
import com.tapjoy.internal.fh;
import com.tapjoy.internal.gc;
import com.tapjoy.internal.gf;
import com.tapjoy.internal.gq;
import com.tapjoy.internal.y;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import org.w3c.dom.Document;

public class TapjoyConnectCore {
    public static final float DEFAULT_CURRENCY_MULTIPLIER = 1.0f;
    private static Integer aA;
    private static Long aB;
    private static Long aC;
    private static Long aD;
    private static String aE;
    private static Integer aF;
    private static Double aG;
    private static Double aH;
    private static Long aI;
    private static Integer aJ;
    private static Integer aK;
    private static Integer aL;
    private static String aM;
    private static String aN;
    private static String aO;
    private static boolean ab;
    private static PackageManager ac;
    private static String ah;
    private static String ai;
    private static String aj;
    private static String ak;
    private static Integer al;
    private static String am;
    private static String an;
    private static Long ao;
    private static String ap;
    private static Integer aq;
    private static Integer ar;
    private static String as;
    private static String at;
    private static String au;
    private static String av;
    private static String aw;
    private static Set ax;
    private static Integer ay;
    private static Integer az;

    protected static boolean f12158d;

    private static Context f12161g;

    private static String f12162h;

    private static TapjoyConnectCore f12163i;

    private static TapjoyURLConnection f12164j;

    private static TJConnectListener f12165k;
    private static TJSetUserIDListener l;
    private long X;
    private boolean Y;
    private boolean aa;
    private TapjoyGpsHelper ad;
    private static Vector m = new Vector(Arrays.asList(TapjoyConstants.dependencyClassNames));
    private static String n = "";
    private static String o = "";
    private static String p = "";
    private static String q = "";
    private static String r = "";
    private static String s = "";
    private static String t = "";
    private static String u = "";
    private static String v = "";
    private static String w = "";
    private static String x = "";
    private static String y = "";
    private static int z = 1;
    private static float A = 1.0f;
    private static int B = 1;
    private static String C = "";
    private static String D = "";
    private static String E = "";
    private static String F = "";
    private static String G = "";
    private static String H = "";
    private static String I = "";
    private static String J = "";
    private static String K = "";
    private static String L = "";
    private static String M = "";
    private static String N = TapjoyConstants.TJC_PLUGIN_NATIVE;
    private static String O = "";
    private static String P = "";
    private static float Q = 1.0f;
    private static boolean R = false;
    private static String S = "";
    private static String T = "";
    private static String U = "";
    private static String V = "";
    private static String W = null;
    private static long Z = 0;
    protected static int a = 0;
    protected static int b = 0;
    protected static String c = "";

    protected static String f12159e = "";

    protected static String f12160f = "";
    private static Hashtable ae = TapjoyConnectFlag.CONNECT_FLAG_DEFAULTS;
    private static String af = "";
    private static Map ag = new ConcurrentHashMap();

    public class PPAThread implements Runnable {
        private Map b;

        public PPAThread(Map map) {
            this.b = map;
        }

        @Override
        public void run() {
            String str = TapjoyConnectCore.f12164j.getResponseFromURL(TapjoyConnectCore.getHostURL() + TapjoyConstants.TJC_CONNECT_URL_PATH, (Map) null, (Map) null, this.b).response;
            if (str != null) {
                TapjoyConnectCore.c(str);
            }
        }
    }

    public TapjoyConnectCore(Context context) {
        WifiInfo connectionInfo;
        Boolean bool = Boolean.FALSE;
        this.X = 0L;
        boolean z2 = false;
        this.Y = false;
        this.aa = false;
        f12161g = context;
        fh.a().a(context);
        fd.a().a(context);
        f12164j = new TapjoyURLConnection();
        ac = f12161g.getPackageManager();
        this.ad = new TapjoyGpsHelper(f12161g);
        try {
            if (ae == null) {
                ae = new Hashtable();
            }
            i();
            int identifier = f12161g.getResources().getIdentifier("raw/tapjoy_config", null, f12161g.getPackageName());
            Properties properties = new Properties();
            try {
                properties.load(f12161g.getResources().openRawResource(identifier));
                a(properties);
            } catch (Exception unused) {
            }
            if (ct.c(getConnectFlagValue("unit_test_mode"))) {
                j();
            }
            String string = Settings.Secure.getString(f12161g.getContentResolver(), TapjoyConstants.TJC_ANDROID_ID);
            n = string;
            if (string != null) {
                n = string.toLowerCase();
            }
            try {
                w = ac.getPackageInfo(f12161g.getPackageName(), 0).versionName;
                t = "android";
                D = "android";
                r = Build.MODEL;
                s = Build.MANUFACTURER;
                u = Build.VERSION.RELEASE;
                x = "11.12.2";
                y = TapjoyConstants.TJC_BRIDGE_VERSION_NUMBER;
                try {
                    if (Build.VERSION.SDK_INT > 3) {
                        TapjoyDisplayMetricsUtil tapjoyDisplayMetricsUtil = new TapjoyDisplayMetricsUtil(f12161g);
                        z = tapjoyDisplayMetricsUtil.getScreenDensityDPI();
                        A = tapjoyDisplayMetricsUtil.getScreenDensityScale();
                        B = tapjoyDisplayMetricsUtil.getScreenLayoutSize();
                    }
                } catch (Exception e2) {
                    TapjoyLog.e("TapjoyConnect", "Error getting screen density/dimensions/layout: " + e2.toString());
                }
                if (e("android.permission.ACCESS_WIFI_STATE")) {
                    try {
                        WifiManager wifiManager = (WifiManager) f12161g.getSystemService(TapjoyConstants.TJC_CONNECTION_TYPE_WIFI);
                        if (wifiManager != null && (connectionInfo = wifiManager.getConnectionInfo()) != null) {
                            String macAddress = connectionInfo.getMacAddress();
                            p = macAddress;
                            if (macAddress != null) {
                                p = macAddress.replace(":", "").toLowerCase();
                            }
                        }
                    } catch (Exception e3) {
                        TapjoyLog.e("TapjoyConnect", "Error getting device mac address: " + e3.toString());
                    }
                } else {
                    TapjoyLog.d("TapjoyConnect", "*** ignore macAddress");
                }
                TelephonyManager telephonyManager = (TelephonyManager) f12161g.getSystemService("phone");
                if (telephonyManager != null) {
                    E = telephonyManager.getNetworkOperatorName();
                    F = telephonyManager.getNetworkCountryIso();
                    String networkOperator = telephonyManager.getNetworkOperator();
                    if (networkOperator != null && (networkOperator.length() == 5 || networkOperator.length() == 6)) {
                        G = networkOperator.substring(0, 3);
                        H = networkOperator.substring(3);
                    }
                }
                SharedPreferences sharedPreferences = f12161g.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0);
                String string2 = sharedPreferences.getString(TapjoyConstants.PREF_INSTALL_ID, "");
                q = string2;
                if (string2 == null || string2.length() == 0) {
                    try {
                        q = TapjoyUtil.SHA256(UUID.randomUUID().toString() + System.currentTimeMillis());
                        SharedPreferences.Editor edit = sharedPreferences.edit();
                        edit.putString(TapjoyConstants.PREF_INSTALL_ID, q);
                        edit.commit();
                    } catch (Exception e4) {
                        TapjoyLog.e("TapjoyConnect", "Error generating install id: " + e4.toString());
                    }
                }
                if (getConnectFlagValue(TapjoyConnectFlag.STORE_NAME) != null && getConnectFlagValue(TapjoyConnectFlag.STORE_NAME).length() > 0) {
                    K = getConnectFlagValue(TapjoyConnectFlag.STORE_NAME);
                    if (!new ArrayList(Arrays.asList(TapjoyConnectFlag.STORE_ARRAY)).contains(K)) {
                        TapjoyLog.w("TapjoyConnect", "Warning -- undefined STORE_NAME: " + K);
                    }
                }
                try {
                    String str = K;
                    Intent intent = new Intent("android.intent.action.VIEW");
                    if (str.length() <= 0) {
                        intent.setData(Uri.parse("market://details"));
                        if (ac.queryIntentActivities(intent, 0).size() > 0) {
                            z2 = true;
                        }
                    } else if (str.equals(TapjoyConnectFlag.STORE_GFAN)) {
                        z2 = d("com.mappn.gfan");
                    } else if (str.equals(TapjoyConnectFlag.STORE_SKT)) {
                        z2 = d("com.skt.skaf.TSCINSTALL");
                    }
                    R = z2;
                } catch (Exception e5) {
                    TapjoyLog.e("TapjoyConnect", "Error trying to detect store intent on devicee: " + e5.toString());
                }
                g();
                if (getConnectFlagValue(TapjoyConnectFlag.DISABLE_PERSISTENT_IDS) != null && getConnectFlagValue(TapjoyConnectFlag.DISABLE_PERSISTENT_IDS).length() > 0) {
                    f12160f = getConnectFlagValue(TapjoyConnectFlag.DISABLE_PERSISTENT_IDS);
                }
                if (getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK) != null && getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK).length() > 0) {
                    f12159e = getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK);
                }
                if (getConnectFlagValue(TapjoyConnectFlag.USER_ID) != null && getConnectFlagValue(TapjoyConnectFlag.USER_ID).length() > 0) {
                    TapjoyLog.i("TapjoyConnect", "Setting userID to: " + getConnectFlagValue(TapjoyConnectFlag.USER_ID));
                    setUserID(getConnectFlagValue(TapjoyConnectFlag.USER_ID), null);
                }
                P = TapjoyUtil.getRedirectDomain(getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL));
                if (ae != null) {
                    h();
                }
                callConnect();
                this.aa = true;
            } catch (PackageManager.NameNotFoundException e6) {
                throw new TapjoyException(e6.getMessage());
            }
        } catch (TapjoyIntegrationException e7) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.INTEGRATION_ERROR, e7.getMessage()));
            d();
            ev.b.notifyObservers(bool);
        } catch (TapjoyException e8) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, e8.getMessage()));
            d();
            ev.b.notifyObservers(bool);
        }
    }

    private static void d() {
        if (!ct.c(M)) {
            gc.a().a(f12161g, f12162h, "11.12.2", TapjoyConfig.TJC_ANALYTICS_SERVICE_URL, M, L);
        }
        TJConnectListener tJConnectListener = f12165k;
        if (tJConnectListener != null) {
            tJConnectListener.onConnectFailure();
        }
    }

    private static Map e() {
        HashMap hashMap = new HashMap();
        HashMap hashMap2 = new HashMap();
        HashMap hashMap3 = new HashMap();
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_PLUGIN, N, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_SDK_TYPE, O, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_APP_ID, v, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_LIBRARY_VERSION, x, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_LIBRARY_REVISION, TapjoyRevision.GIT_REVISION, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_BRIDGE_VERSION, y, true);
        TapjoyUtil.safePut(hashMap3, TapjoyConstants.TJC_APP_VERSION_NAME, w, true);
        hashMap2.putAll(hashMap3);
        HashMap hashMap4 = new HashMap();
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_NAME, r, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_PLATFORM, D, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_OS_VERSION_NAME, u, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_MANUFACTURER, s, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_TYPE_NAME, t, true);
        StringBuilder sb = new StringBuilder();
        sb.append(B);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_SCREEN_LAYOUT_SIZE, sb.toString(), true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_STORE_NAME, K, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_STORE_VIEW, String.valueOf(R), true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_CARRIER_NAME, E, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_CARRIER_COUNTRY_CODE, F, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_MOBILE_NETWORK_CODE, H, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_MOBILE_COUNTRY_CODE, G, true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_COUNTRY_CODE, Locale.getDefault().getCountry(), true);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_LANGUAGE, Locale.getDefault().getLanguage(), true);
        String connectionType = getConnectionType();
        I = connectionType;
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_CONNECTION_TYPE, connectionType, true);
        String connectionSubType = getConnectionSubType();
        J = connectionSubType;
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_CONNECTION_SUBTYPE, connectionSubType, true);
        StringBuilder sb2 = new StringBuilder();
        sb2.append(z);
        TapjoyUtil.safePut(hashMap4, TapjoyConstants.TJC_DEVICE_SCREEN_DENSITY, sb2.toString(), true);
        hashMap2.putAll(hashMap4);
        HashMap hashMap5 = new HashMap();
        if (l()) {
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_ADVERTISING_ID, c, true);
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_AD_TRACKING_ENABLED, String.valueOf(f12158d), true);
        }
        if (!m()) {
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_ANDROID_ID, n, true);
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_DEVICE_MAC_ADDRESS, p, true);
        }
        TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_INSTALL_ID, q, true);
        TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_USER_ID, C, true);
        TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_ADVERTISING_ID_CHECK_DISABLED, f12159e, true);
        TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_PERSISTENT_ID_DISABLED, f12160f, true);
        int i2 = a;
        if (i2 != 0) {
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_PACKAGED_GOOGLE_PLAY_SERVICES_VERSION, Integer.toString(i2), true);
        }
        int i3 = b;
        if (i3 != 0) {
            TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_DEVICE_GOOGLE_PLAY_SERVICES_VERSION, Integer.toString(i3), true);
        }
        String str = o;
        if (str != null && str.length() != 0 && System.currentTimeMillis() - Z <= TapjoyConstants.SESSION_ID_INACTIVITY_TIME) {
            Z = System.currentTimeMillis();
        } else {
            o = n();
        }
        TapjoyUtil.safePut(hashMap5, TapjoyConstants.TJC_SESSION_ID, o, true);
        hashMap2.putAll(hashMap5);
        HashMap hashMap6 = new HashMap();
        TapjoyUtil.safePut(hashMap6, TapjoyConstants.TJC_APP_GROUP_ID, S, true);
        TapjoyUtil.safePut(hashMap6, TapjoyConstants.TJC_STORE, T, true);
        TapjoyUtil.safePut(hashMap6, TapjoyConstants.TJC_ANALYTICS_API_KEY, U, true);
        TapjoyUtil.safePut(hashMap6, TapjoyConstants.TJC_MANAGED_DEVICE_ID, V, true);
        hashMap2.putAll(hashMap6);
        fh a2 = fh.a();
        HashMap hashMap7 = new HashMap();
        Boolean bool = a2.a;
        if (bool != null) {
            TapjoyUtil.safePut(hashMap7, "gdpr", bool.booleanValue() ? "1" : AssistPushConsts.PUSHMESSAGE_ACTION_MULTI_BRAND_RECEIVE_NONE, true);
        }
        if (!aq.a(a2.b)) {
            TapjoyUtil.safePut(hashMap7, "cgdpr", a2.b, true);
        }
        hashMap2.putAll(hashMap7);
        if (TapjoyCache.getInstance() != null && TapjoyCache.getInstance().getCachedOfferIDs() != null && TapjoyCache.getInstance().getCachedOfferIDs().length() > 0) {
            TapjoyUtil.safePut(hashMap2, TapjoyConstants.TJC_CACHED_OFFERS, TapjoyCache.getInstance().getCachedOfferIDs(), true);
        }
        TapjoyUtil.safePut(hashMap2, TapjoyConstants.TJC_CURRENCY_MULTIPLIER, Float.toString(Q), true);
        hashMap.putAll(hashMap2);
        HashMap hashMap8 = new HashMap();
        g();
        HashMap hashMap9 = new HashMap();
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_ANALYTICS_ID, ah, true);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_PACKAGE_ID, ai, true);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_PACKAGE_SIGN, aj, true);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_DEVICE_DISPLAY_DENSITY, aJ);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_DEVICE_DISPLAY_WIDTH, aK);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_DEVICE_DISPLAY_HEIGHT, aL);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_DEVICE_COUNTRY_SIM, aM, true);
        TapjoyUtil.safePut(hashMap9, TapjoyConstants.TJC_DEVICE_TIMEZONE, aN, true);
        hashMap8.putAll(hashMap9);
        HashMap hashMap10 = new HashMap();
        TapjoyUtil.safePut(hashMap10, TapjoyConstants.TJC_PACKAGE_VERSION, ak, true);
        TapjoyUtil.safePut(hashMap10, TapjoyConstants.TJC_PACKAGE_REVISION, al);
        TapjoyUtil.safePut(hashMap10, TapjoyConstants.TJC_PACKAGE_DATA_VERSION, am, true);
        TapjoyUtil.safePut(hashMap10, TapjoyConstants.TJC_INSTALLER, an, true);
        if (ct.c(K)) {
            TapjoyUtil.safePut(hashMap10, TapjoyConstants.TJC_STORE_NAME, aO, true);
        }
        hashMap8.putAll(hashMap10);
        hashMap8.putAll(f());
        hashMap.putAll(hashMap8);
        return hashMap;
    }

    private static Map f() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_INSTALLED, ao);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_REFERRER, ap, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_LEVEL, aq);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_FRIEND_COUNT, ar);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_1, as, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_2, at, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_3, au, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_4, av, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_5, aw, true);
        Iterator it = ax.iterator();
        int i2 = 0;
        while (it.hasNext()) {
            TapjoyUtil.safePut(hashMap, "user_tags[" + i2 + "]", (String) it.next(), true);
            i2++;
        }
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_WEEKLY_FREQUENCY, ay);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_MONTHLY_FREQUENCY, az);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_TOTAL_COUNT, aA);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_TOTAL_LENGTH, aB);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_LAST_AT, aC);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_LAST_LENGTH, aD);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_CURRENCY, aE, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_TOTAL_COUNT, aF);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_TOTAL_PRICE, aG);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_LAST_PRICE, aH);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_LAST_AT, aI);
        return hashMap;
    }

    private static void g() {
        ee a2 = gc.a(f12161g).a(true);
        ed edVar = a2.f12324d;
        ah = edVar.f12312h;
        ai = edVar.r;
        aj = edVar.s;
        aJ = edVar.m;
        aK = edVar.n;
        aL = edVar.o;
        aM = edVar.u;
        aN = edVar.q;
        dx dxVar = a2.f12325e;
        ak = dxVar.f12272e;
        al = dxVar.f12273f;
        am = dxVar.f12274g;
        an = dxVar.f12275h;
        aO = dxVar.f12276i;
        ek ekVar = a2.f12326f;
        ao = ekVar.s;
        ap = ekVar.t;
        aq = ekVar.J;
        ar = ekVar.K;
        as = ekVar.L;
        at = ekVar.M;
        au = ekVar.N;
        av = ekVar.O;
        aw = ekVar.P;
        ax = new HashSet(ekVar.Q);
        ay = ekVar.u;
        az = ekVar.v;
        aA = ekVar.x;
        aB = ekVar.y;
        aC = ekVar.z;
        aD = ekVar.A;
        aE = ekVar.B;
        aF = ekVar.C;
        aG = ekVar.D;
        aH = ekVar.F;
        aI = ekVar.E;
    }

    public static String getAndroidID() {
        return n;
    }

    public static String getAppID() {
        return v;
    }

    public static String getAwardCurrencyVerifier(long j2, int i2, String str) {
        try {
            return TapjoyUtil.SHA256(v + ":" + o() + ":" + j2 + ":" + L + ":" + i2 + ":" + str);
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error in computing awardCurrencyVerifier -- " + e2.toString()));
            return "";
        }
    }

    public static String getCarrierName() {
        return E;
    }

    public static String getConnectFlagValue(String str) {
        Hashtable hashtable = ae;
        return (hashtable == null || hashtable.get(str) == null) ? "" : ae.get(str).toString();
    }

    public static String getConnectURL() {
        return TapjoyConfig.TJC_CONNECT_SERVICE_URL;
    }

    public static String getConnectionSubType() {
        String str = "";
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) f12161g.getSystemService("connectivity");
            if (connectivityManager == null) {
                return "";
            }
            str = connectivityManager.getActiveNetworkInfo().getSubtypeName();
            TapjoyLog.d("TapjoyConnect", "connection_sub_type: " + str);
            return str;
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "getConnectionSubType error: " + e2.toString());
            return str;
        }
    }

    public static String getConnectionType() {
        String str = "";
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) f12161g.getSystemService("connectivity");
            if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
                int type = connectivityManager.getActiveNetworkInfo().getType();
                str = (type == 1 || type == 6) ? TapjoyConstants.TJC_CONNECTION_TYPE_WIFI : TapjoyConstants.TJC_CONNECTION_TYPE_MOBILE;
                TapjoyLog.d("TapjoyConnect", "connectivity: " + connectivityManager.getActiveNetworkInfo().getType());
                TapjoyLog.d("TapjoyConnect", "connection_type: " + str);
            }
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "getConnectionType error: " + e2.toString());
        }
        return str;
    }

    public static Context getContext() {
        return f12161g;
    }

    public static float getDeviceScreenDensityScale() {
        return A;
    }

    public static Map getGenericURLParams() {
        Map e2 = e();
        TapjoyUtil.safePut(e2, TapjoyConstants.TJC_APP_ID, v, true);
        return e2;
    }

    public static String getHostURL() {
        return getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL);
    }

    public static TapjoyConnectCore getInstance() {
        return f12163i;
    }

    public static String getMacAddress() {
        return p;
    }

    public static String getPlacementURL() {
        return getConnectFlagValue(TapjoyConnectFlag.PLACEMENT_URL);
    }

    public static String getRedirectDomain() {
        return P;
    }

    public static String getSecretKey() {
        return L;
    }

    public static String getSha1MacAddress() {
        try {
            return TapjoyUtil.SHA1(p);
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "Error generating sha1 of macAddress: " + e2.toString());
            return null;
        }
    }

    public static String getSupportURL(String str) {
        if (str == null) {
            str = v;
        }
        return getHostURL() + "support_requests/new?currency_id=" + str + "&app_id=" + v + "&udid=" + V + "&language_code=" + Locale.getDefault().getLanguage();
    }

    public static Map getTimeStampAndVerifierParams() {
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        String a2 = a(currentTimeMillis);
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_TIMESTAMP, String.valueOf(currentTimeMillis), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_VERIFIER, a2, true);
        return hashMap;
    }

    public static Map getURLParams() {
        Map genericURLParams = getGenericURLParams();
        genericURLParams.putAll(getTimeStampAndVerifierParams());
        return genericURLParams;
    }

    public static String getUserID() {
        return C;
    }

    private static void h() {
        TapjoyLog.i("TapjoyConnect", "Connect Flags:");
        TapjoyLog.i("TapjoyConnect", "--------------------");
        for (Map.Entry entry : ae.entrySet()) {
            TapjoyLog.i("TapjoyConnect", "key: " + ((String) entry.getKey()) + ", value: " + Uri.encode(entry.getValue().toString()));
        }
        TapjoyLog.i("TapjoyConnect", "hostURL: [" + getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL) + "]");
        TapjoyLog.i("TapjoyConnect", "redirectDomain: [" + P + "]");
        TapjoyLog.i("TapjoyConnect", "--------------------");
    }

    private static void i() {
        try {
            PackageManager packageManager = ac;
            if (packageManager != null) {
                ApplicationInfo applicationInfo = packageManager.getApplicationInfo(f12161g.getPackageName(), 128);
                if (applicationInfo != null && applicationInfo.metaData != null) {
                    for (String str : TapjoyConnectFlag.FLAG_ARRAY) {
                        String string = applicationInfo.metaData.getString("tapjoy." + str);
                        if (string != null) {
                            TapjoyLog.d("TapjoyConnect", "Found manifest flag: " + str + ", " + string);
                            a(str, string);
                        }
                    }
                    TapjoyLog.d("TapjoyConnect", "Metadata successfully loaded");
                    return;
                }
                TapjoyLog.d("TapjoyConnect", "No metadata present.");
            }
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error reading manifest meta-data -- " + e2.toString()));
        }
    }

    public static boolean isConnected() {
        return ab;
    }

    public static boolean isFullScreenViewOpen() {
        Iterator it = ag.values().iterator();
        while (it.hasNext()) {
            int intValue = ((Integer) it.next()).intValue();
            if (intValue == 1 || intValue == 2) {
                return true;
            }
        }
        return false;
    }

    public static boolean isUnitTestMode() {
        return getConnectFlagValue("unit_test_mode") == "true";
    }

    public static boolean isViewOpen() {
        TapjoyLog.d("TapjoyConnect", "isViewOpen: " + ag.size());
        return !ag.isEmpty();
    }

    private void j() {
        try {
            List<ActivityInfo> asList = Arrays.asList(ac.getPackageInfo(f12161g.getPackageName(), 1).activities);
            if (asList != null) {
                for (ActivityInfo activityInfo : asList) {
                    if (m.contains(activityInfo.name)) {
                        int indexOf = m.indexOf(activityInfo.name);
                        try {
                            Class.forName((String) m.get(indexOf));
                            Vector vector = new Vector();
                            if ((activityInfo.configChanges & 128) != 128) {
                                vector.add(TJAdUnitConstants.String.ORIENTATION);
                            }
                            if ((activityInfo.configChanges & 32) != 32) {
                                vector.add("keyboardHidden");
                            }
                            if (vector.size() != 0) {
                                if (vector.size() == 1) {
                                    throw new TapjoyIntegrationException(vector.toString() + " property is not specified in manifest configChanges for " + ((String) m.get(indexOf)));
                                }
                                throw new TapjoyIntegrationException(vector.toString() + " properties are not specified in manifest configChanges for " + ((String) m.get(indexOf)));
                            }
                            int i2 = Build.VERSION.SDK_INT;
                            if (i2 >= 13 && (activityInfo.configChanges & 1024) != 1024) {
                                TapjoyLog.w("TapjoyConnect", "WARNING -- screenSize property is not specified in manifest configChanges for " + ((String) m.get(indexOf)));
                            }
                            if (i2 >= 11 && activityInfo.name.equals("com.tapjoy.TJAdUnitActivity") && (activityInfo.flags & 512) != 512) {
                                throw new TapjoyIntegrationException("'hardwareAccelerated' property not specified in manifest for " + ((String) m.get(indexOf)));
                            }
                            m.remove(indexOf);
                        } catch (ClassNotFoundException unused) {
                            throw new TapjoyIntegrationException("[ClassNotFoundException] Could not find dependency class " + ((String) m.get(indexOf)));
                        }
                    }
                }
            }
            if (m.size() != 0) {
                if (m.size() == 1) {
                    throw new TapjoyIntegrationException("Missing " + m.size() + " dependency class in manifest: " + m.toString());
                }
                throw new TapjoyIntegrationException("Missing " + m.size() + " dependency classes in manifest: " + m.toString());
            }
            k();
            try {
                try {
                    Class.forName("com.tapjoy.TJAdUnitJSBridge").getMethod(TJAdUnitConstants.String.CLOSE_REQUESTED, Boolean.class);
                    String str = (String) TapjoyUtil.getResource("mraid.js");
                    if (str == null) {
                        str = TapjoyUtil.copyTextFromJarIntoString("js/mraid.js", f12161g);
                    }
                    if (str == null) {
                        try {
                            InputStream openRawResource = f12161g.getResources().openRawResource(f12161g.getResources().getIdentifier("mraid", "raw", f12161g.getPackageName()));
                            byte[] bArr = new byte[openRawResource.available()];
                            openRawResource.read(bArr);
                            String str2 = new String(bArr);
                            try {
                                TapjoyUtil.setResource("mraid.js", str2);
                            } catch (Exception unused2) {
                            }
                            str = str2;
                        } catch (Exception unused3) {
                        }
                    }
                    if (str != null) {
                        if (getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK) != null && getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK).equals("true")) {
                            TapjoyLog.i("TapjoyConnect", "Skipping integration check for Google Play Services and Advertising ID. Do this only if you do not have access to Google Play Services.");
                            return;
                        } else {
                            this.ad.checkGooglePlayIntegration();
                            return;
                        }
                    }
                    throw new TapjoyIntegrationException("ClassNotFoundException: mraid.js was not found.");
                } catch (NoSuchMethodException unused4) {
                    throw new TapjoyIntegrationException("Try configuring Proguard or other code obfuscators to ignore com.tapjoy classes. Visit http://dev.tapjoy.comfor more information.");
                }
            } catch (ClassNotFoundException unused5) {
                throw new TapjoyIntegrationException("ClassNotFoundException: com.tapjoy.TJAdUnitJSBridge was not found.");
            }
        } catch (PackageManager.NameNotFoundException unused6) {
            throw new TapjoyIntegrationException("NameNotFoundException: Could not find package.");
        }
    }

    private static void k() {
        Vector vector = new Vector();
        for (String str : TapjoyConstants.dependencyPermissions) {
            if (!e(str)) {
                vector.add(str);
            }
        }
        if (vector.size() != 0) {
            if (vector.size() == 1) {
                throw new TapjoyIntegrationException("Missing 1 permission in manifest: " + vector.toString());
            }
            throw new TapjoyIntegrationException("Missing " + vector.size() + " permissions in manifest: " + vector.toString());
        }
        Vector vector2 = new Vector();
        for (String str2 : TapjoyConstants.optionalPermissions) {
            if (!e(str2)) {
                vector2.add(str2);
            }
        }
        if (vector2.size() != 0) {
            if (vector2.size() == 1) {
                TapjoyLog.w("TapjoyConnect", "WARNING -- " + vector2.toString() + " permission was not found in manifest. The exclusion of this permission could cause problems.");
                return;
            }
            TapjoyLog.w("TapjoyConnect", "WARNING -- " + vector2.toString() + " permissions were not found in manifest. The exclusion of these permissions could cause problems.");
        }
    }

    private static boolean l() {
        String str = c;
        return str != null && str.length() > 0;
    }

    private static boolean m() {
        return l() && getConnectFlagValue(TapjoyConnectFlag.DISABLE_PERSISTENT_IDS) != null && getConnectFlagValue(TapjoyConnectFlag.DISABLE_PERSISTENT_IDS).equals("true");
    }

    private static String n() {
        TapjoyLog.i("TapjoyConnect", "generating sessionID...");
        String str = null;
        try {
            str = TapjoyUtil.SHA256((System.currentTimeMillis() / 1000) + v);
            Z = System.currentTimeMillis();
            return str;
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "unable to generate session id: " + e2.toString());
            return str;
        }
    }

    private static String o() {
        if (m()) {
            return c;
        }
        String str = p;
        if (str != null && str.length() > 0) {
            return p;
        }
        if (l()) {
            return c;
        }
        String str2 = n;
        if (str2 != null && str2.length() > 0) {
            return n;
        }
        TapjoyLog.e("TapjoyConnect", "Error -- no valid device identifier");
        return null;
    }

    private static String p() {
        String str = v + w + x + c + q;
        try {
            return TapjoyUtil.SHA1(str);
        } catch (Exception unused) {
            return str;
        }
    }

    public static void requestTapjoyConnect(Context context, String str) {
        requestTapjoyConnect(context, str, null);
    }

    public static void setPlugin(String str) {
        N = str;
    }

    public static void setSDKType(String str) {
        O = str;
    }

    public static void setUserID(String str, TJSetUserIDListener tJSetUserIDListener) {
        C = str;
        l = tJSetUserIDListener;
        TapjoyLog.d("TapjoyConnect", "URL parameters: " + getURLParams());
        new Thread(new Runnable() {
            @Override
            public final void run() {
                TapjoyLog.i("TapjoyConnect", "Setting userID to " + TapjoyConnectCore.C);
                String str2 = TapjoyConnectCore.f12164j.getResponseFromURL(TapjoyConnectCore.getHostURL() + TapjoyConstants.TJC_USER_ID_URL_PATH, TapjoyConnectCore.getURLParams()).response;
                TapjoyConnectCore.a(str2 != null ? TapjoyConnectCore.a(str2) : false);
            }
        }).start();
    }

    public static void setViewShowing(boolean z2) {
        if (z2) {
            ag.put("", 1);
        } else {
            ag.clear();
        }
    }

    public static void viewDidClose(String str) {
        TapjoyLog.d("TapjoyConnect", "viewDidClose: " + str);
        ag.remove(str);
        ev.f12382e.notifyObservers();
    }

    public static void viewWillOpen(String str, int i2) {
        TapjoyLog.d("TapjoyConnect", "viewWillOpen: " + str);
        ag.put(str, Integer.valueOf(i2));
    }

    public void actionComplete(String str) {
        TapjoyLog.i("TapjoyConnect", "actionComplete: " + str);
        Map e2 = e();
        TapjoyUtil.safePut(e2, TapjoyConstants.TJC_APP_ID, str, true);
        e2.putAll(getTimeStampAndVerifierParams());
        TapjoyLog.d("TapjoyConnect", "PPA URL parameters: " + e2);
        new Thread(new PPAThread(e2)).start();
    }

    public void appPause() {
        this.Y = true;
    }

    public void appResume() {
        if (this.Y) {
            n();
            this.Y = false;
        }
    }

    public void callConnect() {
        fetchAdvertisingID();
    }

    public void completeConnectCall() {
        boolean z2;
        String connectResult;
        Boolean bool = Boolean.FALSE;
        TapjoyLog.d("TapjoyConnect", "starting connect call...");
        String hostURL = getHostURL() != TapjoyConfig.TJC_SERVICE_URL ? getHostURL() : TapjoyConfig.TJC_CONNECT_SERVICE_URL;
        if (isConnected() || (connectResult = TapjoyAppSettings.getInstance().getConnectResult(p(), y.b())) == null || !a(connectResult, true)) {
            z2 = false;
        } else {
            TapjoyLog.i("TapjoyConnect", "Connect using stored connect result");
            ab = true;
            TJConnectListener tJConnectListener = f12165k;
            if (tJConnectListener != null) {
                tJConnectListener.onConnectSuccess();
            }
            ev.a.notifyObservers();
            z2 = true;
        }
        TapjoyHttpURLResponse responseFromURL = f12164j.getResponseFromURL(hostURL + TapjoyConstants.TJC_CONNECT_URL_PATH, (Map) null, (Map) null, getURLParams());
        if (responseFromURL != null && responseFromURL.statusCode == 200) {
            if (a(responseFromURL.response, false)) {
                TapjoyLog.i("TapjoyConnect", "Successfully connected to Tapjoy");
                ab = true;
                for (Map.Entry entry : getGenericURLParams().entrySet()) {
                    TapjoyLog.d("TapjoyConnect", ((String) entry.getKey()) + ": " + ((String) entry.getValue()));
                }
                if (!z2) {
                    TJConnectListener tJConnectListener2 = f12165k;
                    if (tJConnectListener2 != null) {
                        tJConnectListener2.onConnectSuccess();
                    }
                    ev.a.notifyObservers();
                }
                ev.b.notifyObservers(Boolean.TRUE);
            } else {
                if (!z2) {
                    d();
                }
                ev.b.notifyObservers(bool);
            }
            if (af.length() > 0) {
                Map genericURLParams = getGenericURLParams();
                TapjoyUtil.safePut(genericURLParams, TapjoyConstants.TJC_PACKAGE_NAMES, af, true);
                long currentTimeMillis = System.currentTimeMillis() / 1000;
                String a2 = a(currentTimeMillis, af);
                TapjoyUtil.safePut(genericURLParams, TapjoyConstants.TJC_TIMESTAMP, String.valueOf(currentTimeMillis), true);
                TapjoyUtil.safePut(genericURLParams, TapjoyConstants.TJC_VERIFIER, a2, true);
                TapjoyHttpURLResponse responseFromURL2 = new TapjoyURLConnection().getResponseFromURL(getHostURL() + TapjoyConstants.TJC_SDK_LESS_CONNECT, genericURLParams);
                if (responseFromURL2 == null || responseFromURL2.statusCode != 200) {
                    return;
                }
                TapjoyLog.d("TapjoyConnect", "Successfully pinged sdkless api.");
                return;
            }
            return;
        }
        if (!z2) {
            d();
        }
        ev.b.notifyObservers(bool);
    }

    public void fetchAdvertisingID() {
        new Thread(new Runnable() {
            @Override
            public final void run() {
                TapjoyConnectCore.this.ad.loadAdvertisingId();
                if (TapjoyConnectCore.this.ad.isGooglePlayServicesAvailable() && TapjoyConnectCore.this.ad.isGooglePlayManifestConfigured()) {
                    TapjoyConnectCore.b = TapjoyConnectCore.this.ad.getDeviceGooglePlayServicesVersion();
                    TapjoyConnectCore.a = TapjoyConnectCore.this.ad.getPackagedGooglePlayServicesVersion();
                }
                if (TapjoyConnectCore.this.ad.isAdIdAvailable()) {
                    TapjoyConnectCore.f12158d = TapjoyConnectCore.this.ad.isAdTrackingEnabled();
                    TapjoyConnectCore.c = TapjoyConnectCore.this.ad.getAdvertisingId();
                    gc a2 = gc.a();
                    String str = TapjoyConnectCore.c;
                    boolean z2 = !TapjoyConnectCore.f12158d;
                    gf gfVar = a2.f12433f;
                    String a3 = gfVar.c.A.a();
                    ek.a aVar = gfVar.b;
                    aVar.q = str;
                    aVar.r = Boolean.valueOf(z2);
                    gfVar.c.A.a(str);
                    gfVar.c.B.a(z2);
                    gq.a(str, z2);
                    if (!ct.c(a3) && !str.equals(a3)) {
                        gfVar.c.a(false);
                    }
                }
                if (TapjoyConnectCore.a()) {
                    TapjoyLog.i("TapjoyConnect", "Disabling persistent IDs. Do this only if you are not using Tapjoy to manage currency.");
                }
                TapjoyConnectCore.this.completeConnectCall();
            }
        }).start();
    }

    public float getCurrencyMultiplier() {
        return Q;
    }

    public boolean isInitialized() {
        return this.aa;
    }

    public void release() {
        f12163i = null;
        f12164j = null;
        TapjoyLog.d("TapjoyConnect", "Releasing core static instance.");
    }

    public void setCurrencyMultiplier(float f2) {
        TapjoyLog.i("TapjoyConnect", "setVirtualCurrencyMultiplier: " + f2);
        Q = f2;
    }

    static boolean a() {
        return m();
    }

    public static boolean c(String str) {
        RuntimeException e2;
        bs bsVar;
        IOException e3;
        ?? r1 = 0;
        try {
            try {
                bsVar = bs.b(str);
                try {
                } catch (IOException e4) {
                    e3 = e4;
                    TapjoyLog.v("TapjoyConnect", e3.getMessage());
                    dc.a(bsVar);
                    TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Completed Pay-Per-Action call failed."));
                    return false;
                } catch (RuntimeException e5) {
                    e2 = e5;
                    TapjoyLog.v("TapjoyConnect", e2.getMessage());
                    dc.a(bsVar);
                    TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Completed Pay-Per-Action call failed."));
                    return false;
                }
            } catch (Throwable th) {
                th = th;
                r1 = str;
                dc.a(r1);
                throw th;
            }
        } catch (IOException e6) {
            e3 = e6;
            bsVar = null;
        } catch (RuntimeException e7) {
            e2 = e7;
            bsVar = null;
        } catch (Throwable th2) {
            th = th2;
            dc.a(r1);
            throw th;
        }
        if (bsVar.a()) {
            bsVar.s();
            TapjoyLog.d("TapjoyConnect", "Successfully sent completed Pay-Per-Action to Tapjoy server.");
            bsVar.close();
            dc.a(null);
            return true;
        }
        bsVar.close();
        dc.a(null);
        TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Completed Pay-Per-Action call failed."));
        return false;
    }

    public static void requestTapjoyConnect(Context context, String str, Hashtable hashtable) {
        requestTapjoyConnect(context, str, hashtable, null);
    }

    private static void a(Properties properties) {
        Enumeration keys = properties.keys();
        while (keys.hasMoreElements()) {
            try {
                String str = (String) keys.nextElement();
                a(str, (String) properties.get(str));
            } catch (ClassCastException unused) {
                TapjoyLog.e("TapjoyConnect", "Error parsing configuration properties in tapjoy_config.txt");
            }
        }
    }

    public static void requestTapjoyConnect(Context context, String str, Hashtable hashtable, TJConnectListener tJConnectListener) {
        try {
            er erVar = new er(str);
            if (erVar.a == er.a.SDK_ANDROID) {
                f12162h = str;
                v = erVar.b;
                L = erVar.c;
                M = erVar.f12376d;
                if (hashtable != null) {
                    ae.putAll(hashtable);
                    fd.b().a(hashtable);
                }
                gc.a(context).f12437j = str;
                f12165k = tJConnectListener;
                f12163i = new TapjoyConnectCore(context);
                return;
            }
            throw new IllegalArgumentException("The given API key was not for Android.");
        } catch (IllegalArgumentException e2) {
            throw new TapjoyIntegrationException(e2.getMessage());
        }
    }

    private static boolean d(String str) {
        Iterator<ApplicationInfo> it = ac.getInstalledApplications(0).iterator();
        while (it.hasNext()) {
            if (it.next().packageName.startsWith(str)) {
                return true;
            }
        }
        return false;
    }

    private static boolean a(String str, boolean z2) {
        bs bsVar;
        long j2;
        Object obj;
        try {
            try {
                bs b2 = bs.b(str);
                try {
                    Map d2 = b2.d();
                    String a2 = ct.a((String) d2.get(TapjoyConstants.TJC_APP_GROUP_ID));
                    String a3 = ct.a((String) d2.get(TapjoyConstants.TJC_STORE));
                    String a4 = ct.a((String) d2.get(TapjoyConstants.TJC_ANALYTICS_API_KEY));
                    String a5 = ct.a((String) d2.get(TapjoyConstants.TJC_MANAGED_DEVICE_ID));
                    String a6 = ct.a((String) d2.get(TapjoyConstants.TJC_PACKAGE_NAMES));
                    Object obj2 = d2.get("cache_max_age");
                    er erVar = new er(a4);
                    if (erVar.a == er.a.RPC_ANALYTICS) {
                        String str2 = erVar.b;
                        if (str2.regionMatches(13, "-8000-8000-", 0, 11)) {
                            StringBuffer stringBuffer = new StringBuffer();
                            stringBuffer.append(str2.substring(0, 8));
                            stringBuffer.append(str2.substring(24, 30));
                            stringBuffer.append(str2.substring(9, 13));
                            stringBuffer.append(str2.substring(30));
                            String stringBuffer2 = stringBuffer.toString();
                            String str3 = erVar.c;
                            if (a2 == null) {
                                a2 = stringBuffer2;
                            }
                            gc.a().a(f12161g, a4, "11.12.2", TapjoyConfig.TJC_ANALYTICS_SERVICE_URL, stringBuffer2, str3);
                            S = a2;
                            T = a3;
                            U = a4;
                            V = a5;
                            ArrayList arrayList = new ArrayList();
                            if (a6 != null) {
                                for (String str4 : a6.split(",")) {
                                    String trim = str4.trim();
                                    if (trim.length() > 0) {
                                        arrayList.add(trim);
                                    }
                                }
                            }
                            if (!arrayList.isEmpty()) {
                                a(arrayList);
                            }
                            b2.close();
                            if (!z2) {
                                try {
                                    try {
                                        if (obj2 instanceof String) {
                                            j2 = Long.parseLong(((String) obj2).trim());
                                        } else {
                                            if (obj2 instanceof Number) {
                                                j2 = ((Number) obj2).longValue();
                                            }
                                            j2 = 0;
                                            if (j2 > 0) {
                                                TapjoyAppSettings.getInstance().removeConnectResult();
                                            } else {
                                                TapjoyAppSettings.getInstance().saveConnectResultAndParams(str, p(), (j2 * 1000) + y.b());
                                            }
                                            fd a7 = fd.a();
                                            obj = d2.get(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS);
                                            if (!(obj instanceof Map)) {
                                                try {
                                                    a7.a.a((Map) obj);
                                                    a7.c().edit().putString(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS, bm.a(obj)).apply();
                                                } catch (Exception unused) {
                                                }
                                            } else if (obj == null) {
                                                a7.a.a((Map) null);
                                                a7.c().edit().remove(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS).apply();
                                            }
                                        }
                                        if (j2 > 0) {
                                        }
                                        fd a72 = fd.a();
                                        obj = d2.get(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS);
                                        if (!(obj instanceof Map)) {
                                        }
                                    } catch (Throwable th) {
                                        th = th;
                                        bsVar = null;
                                        dc.a(bsVar);
                                        throw th;
                                    }
                                } catch (IOException e2) {
                                    e = e2;
                                    bsVar = null;
                                    TapjoyLog.v("TapjoyConnect", e.getMessage());
                                    dc.a(bsVar);
                                    return false;
                                } catch (RuntimeException e3) {
                                    e = e3;
                                    bsVar = null;
                                    TapjoyLog.v("TapjoyConnect", e.getMessage());
                                    dc.a(bsVar);
                                    return false;
                                }
                            }
                            dc.a(null);
                            return true;
                        }
                        throw new IllegalArgumentException("The given UUID did not come from 5Rocks.");
                    }
                    throw new IOException("Invalid analytics_api_key");
                } catch (IOException e4) {
                    e = e4;
                    bsVar = b2;
                } catch (RuntimeException e5) {
                    e = e5;
                    bsVar = b2;
                } catch (Throwable th2) {
                    th = th2;
                    bsVar = b2;
                }
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (IOException e6) {
            e = e6;
            bsVar = null;
        } catch (RuntimeException e7) {
            e = e7;
            bsVar = null;
        } catch (Throwable th4) {
            th = th4;
            bsVar = null;
        }
    }

    private static synchronized void a(List list) {
        synchronized (TapjoyConnectCore.class) {
            af = "";
            for (ApplicationInfo applicationInfo : ac.getInstalledApplications(0)) {
                if ((applicationInfo.flags & 1) != 1 && list.contains(applicationInfo.packageName)) {
                    TapjoyLog.d("TapjoyConnect", "MATCH: installed packageName: " + applicationInfo.packageName);
                    if (af.length() > 0) {
                        af += ",";
                    }
                    af += applicationInfo.packageName;
                }
            }
        }
    }

    private static String a(long j2) {
        try {
            return TapjoyUtil.SHA256(v + ":" + o() + ":" + j2 + ":" + L);
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error in computing verifier value -- " + e2.toString()));
            return "";
        }
    }

    private static String a(long j2, String str) {
        try {
            return TapjoyUtil.SHA256(v + ":" + o() + ":" + j2 + ":" + L + ":" + str);
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error in computing packageNamesVerifier -- " + e2.toString()));
            return "";
        }
    }

    private static void a(String str, String str2) {
        if ((str.equals(TapjoyConnectFlag.SERVICE_URL) || str.equals(TapjoyConnectFlag.PLACEMENT_URL)) && !str2.endsWith("/")) {
            str2 = str2 + "/";
        }
        ae.put(str, str2);
    }

    static boolean a(String str) {
        Document buildDocument = TapjoyUtil.buildDocument(str);
        if (buildDocument == null) {
            return true;
        }
        String nodeTrimValue = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("PackageNames"));
        if (nodeTrimValue != null && nodeTrimValue.length() > 0) {
            Vector vector = new Vector();
            int i2 = 0;
            while (true) {
                int indexOf = nodeTrimValue.indexOf(44, i2);
                if (indexOf == -1) {
                    break;
                }
                TapjoyLog.d("TapjoyConnect", "parse: " + nodeTrimValue.substring(i2, indexOf).trim());
                vector.add(nodeTrimValue.substring(i2, indexOf).trim());
                i2 = indexOf + 1;
            }
            TapjoyLog.d("TapjoyConnect", "parse: " + nodeTrimValue.substring(i2).trim());
            vector.add(nodeTrimValue.substring(i2).trim());
            a(vector);
        }
        String nodeTrimValue2 = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("Success"));
        return nodeTrimValue2 != null && nodeTrimValue2.equals("true");
    }

    private static boolean e(String str) {
        return ac.checkPermission(str, f12161g.getPackageName()) == 0;
    }

    static void a(boolean z2) {
        if (z2) {
            TapjoyLog.i("TapjoyConnect", "Set userID is successful");
            TJSetUserIDListener tJSetUserIDListener = l;
            if (tJSetUserIDListener != null) {
                tJSetUserIDListener.onSetUserIDSuccess();
                return;
            }
            return;
        }
        TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Failed to set userID"));
        TJSetUserIDListener tJSetUserIDListener2 = l;
        if (tJSetUserIDListener2 != null) {
            tJSetUserIDListener2.onSetUserIDFailure("Failed to set userID");
        }
    }
}