Perfume Of Love v2.14.9版本的 MD5 值为:16011aefc5a55805771706ce3b259b4e

以下内容为反编译后的 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.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import com.facebook.internal.security.CertificateUtil;
import com.inmobi.unification.sdk.InitializationStatus;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyErrorMessage;
import com.tapjoy.internal.bb;
import com.tapjoy.internal.bh;
import com.tapjoy.internal.ce;
import com.tapjoy.internal.ew;
import com.tapjoy.internal.fc;
import com.tapjoy.internal.fd;
import com.tapjoy.internal.fj;
import com.tapjoy.internal.fq;
import com.tapjoy.internal.fu;
import com.tapjoy.internal.gd;
import com.tapjoy.internal.ge;
import com.tapjoy.internal.gi;
import com.tapjoy.internal.gq;
import com.tapjoy.internal.gt;
import com.tapjoy.internal.hk;
import com.tapjoy.internal.u;
import java.io.IOException;
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.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 String BEACON = "sdk_beacons";
    public static final String BEACON_ENABLED = "enabled";
    public static final float DEFAULT_CURRENCY_MULTIPLIER = 1.0f;
    private static Set<String> aA;
    private static Integer aB;
    private static Integer aC;
    private static Integer aD;
    private static Long aE;
    private static Long aF;
    private static Long aG;
    private static String aH;
    private static Integer aI;
    private static Double aJ;
    private static Double aK;
    private static Long aL;
    private static Integer aM;
    private static Integer aN;
    private static Integer aO;
    private static String aP;
    private static String aQ;
    private static String aR;
    private static boolean af;
    private static PackageManager ag;
    private static TapjoyGpsHelper ah;
    private static String ak;
    private static String al;
    private static String am;
    private static String an;
    private static Integer ao;
    private static String ap;
    private static String aq;
    private static Long ar;
    private static String as;
    private static Integer at;
    private static Integer au;
    private static String av;
    private static String aw;
    private static String ax;
    private static String ay;
    private static String az;
    protected static boolean d;
    private static Context h;
    private static String i;
    private static TapjoyConnectCore j;
    private static TapjoyURLConnection k;
    private static TJConnectListener l;
    private static TJSetUserIDListener m;
    private static boolean n;
    private static boolean o;
    private long ab = 0;
    private boolean ac = false;
    private boolean ae = false;
    private static Vector<String> p = new Vector<>(Arrays.asList(TapjoyConstants.dependencyClassNames));
    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 String z = "";
    private static String A = "";
    private static int B = 1;
    private static float C = 1.0f;
    private static int D = 1;
    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 = "";
    private static String O = "";
    private static String P = "";
    private static String Q = "native";
    private static String R = "";
    private static String S = "";
    private static float T = 1.0f;
    private static boolean U = false;
    private static String V = "";
    private static String W = "";
    private static String X = "";
    private static String Y = "";
    private static Map<String, Object> Z = new HashMap();
    private static String aa = null;
    private static long ad = 0;
    protected static int a = 0;
    protected static int b = 0;
    protected static String c = "";
    protected static String e = "";
    protected static String f = "";
    protected static String g = "";
    private static Hashtable<String, Object> ai = TapjoyConnectFlag.CONNECT_FLAG_DEFAULTS;
    private static Map<String, Integer> aj = new ConcurrentHashMap();
    private static String aS = "";
    private static String aT = "";
    private static String aU = "";
    private static boolean aV = false;
    private static TJConnectListener aW = null;
    private static boolean aX = false;

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

    static boolean f() {
        o = true;
        return true;
    }

    public static TapjoyConnectCore getInstance() {
        return j;
    }

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

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

    public static void requestTapjoyConnect(Context context, String str, Hashtable<String, ?> hashtable, TJConnectListener tJConnectListener) {
        try {
            fq fqVar = new fq(str);
            if (fqVar.a != fq.a.SDK_ANDROID) {
                throw new IllegalArgumentException("The given API key was not for Android.");
            }
            i = str;
            x = fqVar.b;
            O = fqVar.c;
            P = fqVar.d;
            if (hashtable != null) {
                ai.putAll(hashtable);
                ge.b().a(hashtable);
            }
            hk.a(context).i = str;
            l = tJConnectListener;
            if (j == null) {
                j = new TapjoyConnectCore();
            }
            TapjoyConnectCore tapjoyConnectCore = j;
            try {
                a(context);
                new Thread(new AnonymousClass1()).start();
                tapjoyConnectCore.ae = true;
            } catch (TapjoyIntegrationException e2) {
                TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.INTEGRATION_ERROR, e2.getMessage()));
                i();
                fu.b.notifyObservers(Boolean.FALSE);
            } catch (TapjoyException e3) {
                TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, e3.getMessage()));
                i();
                fu.b.notifyObservers(Boolean.FALSE);
            }
        } catch (IllegalArgumentException e4) {
            throw new TapjoyIntegrationException(e4.getMessage());
        }
    }

    public static void requestLimitedTapjoyConnect(Context context, String str, TJConnectListener tJConnectListener) {
        try {
            fq fqVar = new fq(str);
            if (fqVar.a != fq.a.SDK_ANDROID) {
                throw new IllegalArgumentException("The given API key was not for Android.");
            }
            aS = fqVar.b;
            aT = fqVar.c;
            if (j == null) {
                j = new TapjoyConnectCore();
            }
            aW = tJConnectListener;
            TapjoyConnectCore tapjoyConnectCore = j;
            try {
                a(context);
                new Thread(new AnonymousClass2()).start();
            } catch (TapjoyIntegrationException e2) {
                TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.INTEGRATION_ERROR, e2.getMessage()));
                j();
                fu.b.notifyObservers(Boolean.FALSE);
            } catch (TapjoyException e3) {
                TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, e3.getMessage()));
                j();
                fu.b.notifyObservers(Boolean.FALSE);
            }
            TapjoyLog.d("TapjoyConnect", "requestTapjoyConnect function complete");
        } catch (IllegalArgumentException e4) {
            TapjoyLog.d("TapjoyConnect", e4.getMessage());
            throw new TapjoyIntegrationException(e4.getMessage());
        }
    }

    private static void i() {
        if (!TextUtils.isEmpty(P)) {
            hk.a().a(h, i, "12.11.1", TapjoyConfig.TJC_ANALYTICS_SERVICE_URL, P, O);
        }
        TJConnectListener tJConnectListener = l;
        if (tJConnectListener != null) {
            tJConnectListener.onConnectFailure();
        }
    }

    private static void j() {
        TJConnectListener tJConnectListener = aW;
        if (tJConnectListener != null) {
            tJConnectListener.onConnectFailure();
        }
    }

    public final class AnonymousClass1 implements Runnable {
        AnonymousClass1() {
        }

        @Override
        public final void run() {
            TapjoyConnectCore.a();
            new TJAppSetId().fetch(TapjoyConnectCore.h, new TJTaskHandler<String>() {
                @Override
                public final void onComplete(String str) {
                    TapjoyConnectCore.g = str;
                    new Thread(new Runnable() {
                        @Override
                        public final void run() {
                            TapjoyConnectCore.this.completeConnectCall();
                        }
                    }).start();
                }
            });
        }
    }

    final class AnonymousClass2 implements Runnable {
        AnonymousClass2() {
        }

        @Override
        public final void run() {
            TapjoyConnectCore.a();
            new TJAppSetId().fetch(TapjoyConnectCore.h, new TJTaskHandler<String>() {
                @Override
                public final void onComplete(String str) {
                    TapjoyConnectCore.g = str;
                    new Thread(new Runnable() {
                        @Override
                        public final void run() {
                            TapjoyConnectCore.this.completeLimitedConnectCall();
                        }
                    }).start();
                }
            });
        }
    }

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

    public void appResume() {
        if (this.ac) {
            K();
            this.ac = false;
        }
    }

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

    public static Map<String, String> getLimitedURLParams() {
        Map<String, String> limitedGenericURLParams = getLimitedGenericURLParams();
        limitedGenericURLParams.putAll(getLimitedTimeStampAndVerifierParams());
        return limitedGenericURLParams;
    }

    public static Map<String, String> getGenericURLParams() {
        Map<String, String> k2 = k();
        TapjoyUtil.safePut(k2, "app_id", x, true);
        return k2;
    }

    public static Map<String, String> getLimitedGenericURLParams() {
        Map<String, String> k2 = k();
        TapjoyUtil.safePut(k2, "app_id", aS, true);
        TapjoyUtil.safePut(k2, TapjoyConstants.TJC_APP_GROUP_ID, aU, true);
        TapjoyUtil.safePut(k2, TapjoyConstants.TJC_LIMITED, "true", true);
        return k2;
    }

    private static Map<String, String> k() {
        HashMap hashMap = new HashMap();
        hashMap.putAll(l());
        hashMap.putAll(q());
        return hashMap;
    }

    private static Map<String, String> l() {
        HashMap hashMap = new HashMap();
        hashMap.putAll(m());
        hashMap.putAll(n());
        hashMap.putAll(o());
        hashMap.putAll(p());
        hashMap.putAll(gi.a().b());
        if (TapjoyCache.getInstance() != null && TapjoyCache.getInstance().getCachedOfferIDs() != null && TapjoyCache.getInstance().getCachedOfferIDs().length() > 0) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CACHED_OFFERS, TapjoyCache.getInstance().getCachedOfferIDs(), true);
        }
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_MULTIPLIER, Float.toString(T), true);
        return hashMap;
    }

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

    public static Map<String, String> getLimitedTimeStampAndVerifierParams() {
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        String b2 = b(currentTimeMillis);
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, "timestamp", String.valueOf(currentTimeMillis), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_VERIFIER, b2, true);
        return hashMap;
    }

    private static Map<String, String> m() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PLUGIN, Q, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SDK_TYPE, R, true);
        TapjoyUtil.safePut(hashMap, "app_id", x, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_LIBRARY_VERSION, z, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_LIBRARY_REVISION, TapjoyRevision.GIT_REVISION, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_BRIDGE_VERSION, A, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_OMSDK_VERSION, ce.a(), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_APP_VERSION_NAME, y, true);
        return hashMap;
    }

    private static Map<String, String> n() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_NAME, t, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PLATFORM, G, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_OS_VERSION_NAME, w, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_MANUFACTURER, u, true);
        TapjoyUtil.safePut(hashMap, "device_type", v, true);
        StringBuilder sb = new StringBuilder();
        sb.append(D);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_SCREEN_LAYOUT_SIZE, sb.toString(), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_STORE_NAME, N, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_STORE_VIEW, String.valueOf(U), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CARRIER_NAME, H, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CARRIER_COUNTRY_CODE, I, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_MOBILE_NETWORK_CODE, K, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_MOBILE_COUNTRY_CODE, J, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_COUNTRY_CODE, Locale.getDefault().getCountry(), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_LANGUAGE, Locale.getDefault().getLanguage(), true);
        String connectionType = getConnectionType();
        L = connectionType;
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CONNECTION_TYPE, connectionType, true);
        String connectionSubType = getConnectionSubType();
        M = connectionSubType;
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CONNECTION_SUBTYPE, connectionSubType, true);
        StringBuilder sb2 = new StringBuilder();
        sb2.append(B);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_SCREEN_DENSITY, sb2.toString(), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_VOLUME, TapjoyUtil.getVolume(h));
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_THEME, TapjoyUtil.getTheme(h), true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_SCREEN_BRIGHTNESS, TapjoyUtil.getScreenBrightness(h));
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_AVAILABLE_DISK_SPACE, TapjoyUtil.getAvailableDiskSpace());
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_TOTAL_DISK_SPACE, TapjoyUtil.getTotalDiskSpace());
        return hashMap;
    }

    private static Map<String, String> o() {
        HashMap hashMap = new HashMap();
        if (H()) {
            if (ah.isAdvertisingIdAllowed()) {
                TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_ADVERTISING_ID, c, true);
            }
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_AD_TRACKING_ENABLED, String.valueOf(d), true);
        }
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_ADVERTISING_ID_OPTOUT, String.valueOf(!ah.isAdvertisingIdAllowed()), true);
        if (!TextUtils.isEmpty(g)) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_APP_SET_ID, g, true);
        }
        if ((I() && !H()) || !J()) {
            TapjoyUtil.safePut(hashMap, "android_id", q, true);
        }
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_INSTALL_ID, s, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_ID, E, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_ADVERTISING_ID_CHECK_DISABLED, e, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_LEGACY_ID_FALLBACK_ALLOWED, f, true);
        int i2 = a;
        if (i2 != 0) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGED_GOOGLE_PLAY_SERVICES_VERSION, Integer.toString(i2), true);
        }
        int i3 = b;
        if (i3 != 0) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_GOOGLE_PLAY_SERVICES_VERSION, Integer.toString(i3), true);
        }
        String str = r;
        if (str == null || str.length() == 0 || System.currentTimeMillis() - ad > TapjoyConstants.SESSION_ID_INACTIVITY_TIME) {
            r = K();
        } else {
            ad = System.currentTimeMillis();
        }
        TapjoyUtil.safePut(hashMap, "session_id", r, true);
        return hashMap;
    }

    private static Map<String, String> p() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_APP_GROUP_ID, V, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_STORE, W, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_ANALYTICS_API_KEY, X, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_MANAGED_DEVICE_ID, Y, true);
        return hashMap;
    }

    private static Map<String, String> q() {
        HashMap hashMap = new HashMap();
        u();
        hashMap.putAll(r());
        hashMap.putAll(s());
        hashMap.putAll(t());
        return hashMap;
    }

    private static Map<String, String> r() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_ANALYTICS_ID, ak, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGE_ID, al, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGE_SIGN, am, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_DISPLAY_DENSITY, aM);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_DISPLAY_WIDTH, aN);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_DISPLAY_HEIGHT, aO);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_COUNTRY_SIM, aP, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_DEVICE_TIMEZONE, aQ, true);
        return hashMap;
    }

    private static Map<String, String> s() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGE_VERSION, an, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGE_REVISION, ao);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PACKAGE_DATA_VERSION, ap, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_INSTALLER, aq, true);
        if (TextUtils.isEmpty(N)) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_STORE_NAME, aR, true);
        }
        return hashMap;
    }

    private static Map<String, String> t() {
        HashMap hashMap = new HashMap();
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_INSTALLED, ar);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_REFERRER, as, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_LEVEL, at);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_FRIEND_COUNT, au);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_1, av, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_2, aw, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_3, ax, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_4, ay, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_VARIABLE_5, az, true);
        int i2 = 0;
        for (String str : aA) {
            StringBuilder sb = new StringBuilder("user_tags[");
            int i3 = i2 + 1;
            sb.append(i2);
            sb.append("]");
            TapjoyUtil.safePut(hashMap, sb.toString(), str, true);
            i2 = i3;
        }
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_WEEKLY_FREQUENCY, aB);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_USER_MONTHLY_FREQUENCY, aC);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_TOTAL_COUNT, aD);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_TOTAL_LENGTH, aE);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_LAST_AT, aF);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_SESSION_LAST_LENGTH, aG);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_CURRENCY, aH, true);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_TOTAL_COUNT, aI);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_TOTAL_PRICE, aJ);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_LAST_PRICE, aK);
        TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_PURCHASE_LAST_AT, aL);
        return hashMap;
    }

    private static boolean a(Context context) {
        h = context;
        ag = context.getPackageManager();
        gi.a().a(context);
        ge.a().a(context);
        ah = new TapjoyGpsHelper(h);
        if (k == null) {
            k = new TapjoyURLConnection();
        }
        B();
        if (TextUtils.isEmpty(getConnectFlagValue("unit_test_mode"))) {
            E();
        }
        w();
        u();
        if (getConnectFlagValue(TapjoyConnectFlag.ALLOW_LEGACY_ID_FALLBACK) != null && getConnectFlagValue(TapjoyConnectFlag.ALLOW_LEGACY_ID_FALLBACK).length() > 0) {
            f = getConnectFlagValue(TapjoyConnectFlag.ALLOW_LEGACY_ID_FALLBACK);
        }
        if (getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK) != null && getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK).length() > 0) {
            e = 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);
        }
        S = TapjoyUtil.getRedirectDomain(getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL));
        if (ai != null) {
            v();
            return true;
        }
        return true;
    }

    private static void u() {
        fd a2 = hk.a(h).a(true);
        fc fcVar = a2.d;
        ak = fcVar.h;
        al = fcVar.r;
        am = fcVar.s;
        aM = fcVar.m;
        aN = fcVar.n;
        aO = fcVar.o;
        aP = fcVar.u;
        aQ = fcVar.q;
        ew ewVar = a2.e;
        an = ewVar.e;
        ao = ewVar.f;
        ap = ewVar.g;
        aq = ewVar.h;
        aR = ewVar.i;
        fj fjVar = a2.f;
        ar = fjVar.s;
        as = fjVar.t;
        at = fjVar.J;
        au = fjVar.K;
        av = fjVar.L;
        aw = fjVar.M;
        ax = fjVar.N;
        ay = fjVar.O;
        az = fjVar.P;
        aA = new HashSet(fjVar.Q);
        aB = fjVar.u;
        aC = fjVar.v;
        aD = fjVar.x;
        aE = fjVar.y;
        aF = fjVar.z;
        aG = fjVar.A;
        aH = fjVar.B;
        aI = fjVar.C;
        aJ = fjVar.D;
        aK = fjVar.F;
        aL = fjVar.E;
    }

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

    private static void w() {
        String string = Settings.Secure.getString(h.getContentResolver(), "android_id");
        q = string;
        if (string != null) {
            q = string.toLowerCase();
        }
        try {
            y = ag.getPackageInfo(h.getPackageName(), 0).versionName;
            v = "android";
            G = "android";
            t = Build.MODEL;
            u = Build.MANUFACTURER;
            w = Build.VERSION.RELEASE;
            z = "12.11.1";
            A = TapjoyConstants.TJC_BRIDGE_VERSION_NUMBER;
            x();
            y();
            z();
            A();
        } catch (PackageManager.NameNotFoundException e2) {
            throw new TapjoyException(e2.getMessage());
        }
    }

    private static void x() {
        try {
            if (Build.VERSION.SDK_INT > 3) {
                TapjoyDisplayMetricsUtil tapjoyDisplayMetricsUtil = new TapjoyDisplayMetricsUtil(h);
                B = tapjoyDisplayMetricsUtil.getScreenDensityDPI();
                C = tapjoyDisplayMetricsUtil.getScreenDensityScale();
                D = tapjoyDisplayMetricsUtil.getScreenLayoutSize();
            }
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "Error getting screen density/dimensions/layout: " + e2.toString());
        }
    }

    private static void y() {
        TelephonyManager telephonyManager = (TelephonyManager) h.getSystemService("phone");
        if (telephonyManager != null) {
            try {
                H = telephonyManager.getNetworkOperatorName();
                I = telephonyManager.getNetworkCountryIso();
                String networkOperator = telephonyManager.getNetworkOperator();
                if (networkOperator != null) {
                    if (networkOperator.length() == 5 || networkOperator.length() == 6) {
                        J = networkOperator.substring(0, 3);
                        K = networkOperator.substring(3);
                    }
                }
            } catch (SecurityException unused) {
                TapjoyLog.i("TapjoyConnect", "Error accessing network operator info");
            }
        }
    }

    private static void z() {
        SharedPreferences sharedPreferences = h.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0);
        String string = sharedPreferences.getString(TapjoyConstants.PREF_INSTALL_ID, "");
        s = string;
        if (string == null || string.length() == 0) {
            try {
                s = TapjoyUtil.SHA256(UUID.randomUUID().toString() + System.currentTimeMillis());
                SharedPreferences.Editor edit = sharedPreferences.edit();
                edit.putString(TapjoyConstants.PREF_INSTALL_ID, s);
                edit.apply();
            } catch (Exception e2) {
                TapjoyLog.e("TapjoyConnect", "Error generating install id: " + e2.toString());
            }
        }
    }

    private static void A() {
        if (getConnectFlagValue(TapjoyConnectFlag.STORE_NAME) != null && getConnectFlagValue(TapjoyConnectFlag.STORE_NAME).length() > 0) {
            N = getConnectFlagValue(TapjoyConnectFlag.STORE_NAME);
            if (!new ArrayList(Arrays.asList(TapjoyConnectFlag.STORE_ARRAY)).contains(N)) {
                TapjoyLog.w("TapjoyConnect", "Warning -- undefined STORE_NAME: " + N);
            }
        }
        try {
            U = e(N);
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "Error trying to detect store intent on devicee: " + e2.toString());
        }
    }

    private static void B() {
        if (ai == null) {
            ai = new Hashtable<>();
        }
        C();
        D();
    }

    private static void C() {
        String[] strArr;
        try {
            PackageManager packageManager = ag;
            if (packageManager != null) {
                ApplicationInfo applicationInfo = packageManager.getApplicationInfo(h.getPackageName(), 128);
                if (applicationInfo != null && applicationInfo.metaData != null) {
                    for (String str : TapjoyConnectFlag.FLAG_ARRAY) {
                        String string = applicationInfo.metaData.getString("tapjoy.".concat(String.valueOf(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()));
        }
    }

    private static void D() {
        int identifier = h.getResources().getIdentifier("raw/tapjoy_config", null, h.getPackageName());
        Properties properties = new Properties();
        try {
            properties.load(h.getResources().openRawResource(identifier));
            a(properties);
        } catch (Exception unused) {
        }
    }

    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");
            }
        }
    }

    private static void E() {
        try {
            List<ActivityInfo> asList = Arrays.asList(ag.getPackageInfo(h.getPackageName(), 1).activities);
            if (asList != null) {
                for (ActivityInfo activityInfo : asList) {
                    a(activityInfo);
                }
            }
            if (p.size() != 0) {
                if (p.size() == 1) {
                    throw new TapjoyIntegrationException("Missing " + p.size() + " dependency class in manifest: " + p.toString());
                }
                throw new TapjoyIntegrationException("Missing " + p.size() + " dependency classes in manifest: " + p.toString());
            }
            F();
            G();
            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.");
            } else {
                ah.checkGooglePlayIntegration();
            }
        } catch (Exception unused) {
            throw new TapjoyIntegrationException("Error while getting package info.");
        }
    }

    private static void F() {
        Vector vector = new Vector();
        String[] strArr = TapjoyConstants.dependencyPermissions;
        int length = strArr.length;
        int i2 = 0;
        while (true) {
            if (i2 >= length) {
                break;
            }
            String str = strArr[i2];
            if (!(ag.checkPermission(str, h.getPackageName()) == 0)) {
                vector.add(str);
            }
            i2++;
        }
        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();
        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 void G() {
        try {
            try {
                Class.forName("com.tapjoy.TJAdUnitJSBridge").getMethod(TJAdUnitConstants.String.CLOSE_REQUESTED, Boolean.class);
            } catch (NoSuchMethodException unused) {
                throw new TapjoyIntegrationException("Try configuring Proguard or other code obfuscators to ignore com.tapjoy classes. Visit http://dev.tapjoy.comfor more information.");
            }
        } catch (ClassNotFoundException unused2) {
            throw new TapjoyIntegrationException("ClassNotFoundException: com.tapjoy.TJAdUnitJSBridge was not found.");
        }
    }

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

    private static boolean I() {
        return getConnectFlagValue(TapjoyConnectFlag.ALLOW_LEGACY_ID_FALLBACK) != null && getConnectFlagValue(TapjoyConnectFlag.ALLOW_LEGACY_ID_FALLBACK).equals("true");
    }

    private static boolean J() {
        return (ah.isGooglePlayServicesAvailable() && ah.isGooglePlayManifestConfigured()) || getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK) == null || !getConnectFlagValue(TapjoyConnectFlag.DISABLE_ADVERTISING_ID_CHECK).equals("true");
    }

    private static void a(ActivityInfo activityInfo) {
        if (p.contains(activityInfo.name)) {
            int indexOf = p.indexOf(activityInfo.name);
            try {
                Class.forName(p.get(indexOf));
                Vector vector = new Vector();
                if ((activityInfo.configChanges & 128) != 128) {
                    vector.add("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 " + p.get(indexOf));
                    }
                    throw new TapjoyIntegrationException(vector.toString() + " properties are not specified in manifest configChanges for " + p.get(indexOf));
                }
                if (Build.VERSION.SDK_INT >= 13 && (activityInfo.configChanges & 1024) != 1024) {
                    TapjoyLog.w("TapjoyConnect", "WARNING -- screenSize property is not specified in manifest configChanges for " + p.get(indexOf));
                }
                if (Build.VERSION.SDK_INT >= 11 && activityInfo.name.equals("com.tapjoy.TJAdUnitActivity") && (activityInfo.flags & 512) != 512) {
                    throw new TapjoyIntegrationException("'hardwareAccelerated' property not specified in manifest for " + p.get(indexOf));
                }
                p.remove(indexOf);
            } catch (ClassNotFoundException unused) {
                throw new TapjoyIntegrationException("[ClassNotFoundException] Could not find dependency class " + p.get(indexOf));
            }
        }
    }

    private static boolean a(String str, boolean z2) {
        bh bhVar;
        long j2;
        Object obj;
        Map<String, Object> map;
        try {
            try {
                bh b2 = bh.b(str);
                try {
                    Map<String, Object> d2 = b2.d();
                    String a2 = gt.a((String) d2.get("override_service_url"));
                    if (!TextUtils.isEmpty(a2)) {
                        getInstance();
                        a(TapjoyConnectFlag.SERVICE_URL, a2);
                    }
                    if (d2.containsKey(BEACON) && (map = (Map) d2.get(BEACON)) != null && map.containsKey("enabled") && (map.get("enabled") instanceof Boolean)) {
                        if (Boolean.TRUE.equals((Boolean) map.get("enabled"))) {
                            Map<String, String> uRLParams = getURLParams();
                            gd.a = gt.a((String) map.get("url"));
                            gd.c = true;
                            gd.b = uRLParams;
                            gd.d = map;
                        }
                    }
                    String a3 = gt.a((String) d2.get(TapjoyConstants.TJC_APP_GROUP_ID));
                    String a4 = gt.a((String) d2.get(TapjoyConstants.TJC_STORE));
                    String a5 = gt.a((String) d2.get(TapjoyConstants.TJC_ANALYTICS_API_KEY));
                    Object obj2 = d2.get("user_token_config");
                    String a6 = gt.a((String) d2.get(TapjoyConstants.TJC_MANAGED_DEVICE_ID));
                    Object obj3 = d2.get("cache_max_age");
                    fq fqVar = new fq(a5);
                    if (fqVar.a != fq.a.RPC_ANALYTICS) {
                        throw new IOException("Invalid analytics_api_key");
                    }
                    String a7 = fq.a(fqVar.b);
                    String str2 = fqVar.c;
                    if (a3 == null) {
                        a3 = a7;
                    }
                    hk.a().a(h, a5, "12.11.1", TapjoyConfig.TJC_ANALYTICS_SERVICE_URL, a7, str2);
                    V = a3;
                    W = a4;
                    X = a5;
                    Y = a6;
                    if (obj2 instanceof Map) {
                        Z = (Map) obj2;
                    }
                    if (!TextUtils.isEmpty(a2) && n) {
                        setUserID(E, null);
                    }
                    b2.close();
                    if (!z2) {
                        try {
                            try {
                                if (obj3 instanceof String) {
                                    j2 = Long.parseLong(((String) obj3).trim());
                                } else {
                                    if (obj3 instanceof Number) {
                                        j2 = ((Number) obj3).longValue();
                                    }
                                    j2 = 0;
                                    if (j2 > 0) {
                                        TapjoyAppSettings.getInstance().removeConnectResult();
                                    } else {
                                        TapjoyAppSettings.getInstance().saveConnectResultAndParams(str, M(), (j2 * 1000) + u.b());
                                    }
                                    ge a8 = ge.a();
                                    obj = d2.get(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS);
                                    if (!(obj instanceof Map)) {
                                        try {
                                            a8.a.a((Map) obj);
                                            a8.c().edit().putString(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS, bb.a(obj)).apply();
                                        } catch (Exception unused) {
                                        }
                                    } else if (obj == null) {
                                        a8.a.a((Map) null);
                                        a8.c().edit().remove(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS).apply();
                                    }
                                }
                                if (j2 > 0) {
                                }
                                ge a82 = ge.a();
                                obj = d2.get(TapjoyConstants.PREF_SERVER_PROVIDED_CONFIGURATIONS);
                                if (!(obj instanceof Map)) {
                                }
                            } catch (Throwable th) {
                                th = th;
                                bhVar = null;
                                gq.a(bhVar);
                                throw th;
                            }
                        } catch (IOException e2) {
                            e = e2;
                            bhVar = null;
                            TapjoyLog.v("TapjoyConnect", e.getMessage());
                            gq.a(bhVar);
                            return false;
                        } catch (RuntimeException e3) {
                            e = e3;
                            bhVar = null;
                            TapjoyLog.v("TapjoyConnect", e.getMessage());
                            gq.a(bhVar);
                            return false;
                        }
                    }
                    gq.a(null);
                    return true;
                } catch (IOException e4) {
                    e = e4;
                    bhVar = b2;
                } catch (RuntimeException e5) {
                    e = e5;
                    bhVar = b2;
                } catch (Throwable th2) {
                    th = th2;
                    bhVar = b2;
                }
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (IOException e6) {
            e = e6;
            bhVar = null;
        } catch (RuntimeException e7) {
            e = e7;
            bhVar = null;
        } catch (Throwable th4) {
            th = th4;
            bhVar = null;
        }
    }

    private static boolean c(String str) {
        RuntimeException e2;
        bh bhVar;
        IOException e3;
        ?? r1 = 0;
        try {
            try {
                bhVar = bh.b(str);
                try {
                    Map<String, Object> d2 = bhVar.d();
                    String a2 = gt.a((String) d2.get("override_service_url"));
                    if (!TextUtils.isEmpty(a2)) {
                        getInstance();
                        a(TapjoyConnectFlag.SERVICE_URL, a2);
                    }
                    String a3 = gt.a((String) d2.get(TapjoyConstants.TJC_APP_GROUP_ID));
                    String a4 = gt.a((String) d2.get(TapjoyConstants.TJC_STORE));
                    String a5 = gt.a((String) d2.get(TapjoyConstants.TJC_ANALYTICS_API_KEY));
                    Object obj = d2.get("user_token_config");
                    String a6 = gt.a((String) d2.get(TapjoyConstants.TJC_MANAGED_DEVICE_ID));
                    fq fqVar = new fq(a5);
                    if (fqVar.a != fq.a.RPC_ANALYTICS) {
                        throw new IOException("Invalid analytics_api_key");
                    }
                    String a7 = fq.a(fqVar.b);
                    if (a3 == null) {
                        a3 = a7;
                    }
                    aU = a3;
                    W = a4;
                    Y = a6;
                    if (obj instanceof Map) {
                        Z = (Map) obj;
                    }
                    bhVar.close();
                    gq.a(null);
                    return true;
                } catch (IOException e4) {
                    e3 = e4;
                    TapjoyLog.v("TapjoyConnect", e3.getMessage());
                    gq.a(bhVar);
                    return false;
                } catch (RuntimeException e5) {
                    e2 = e5;
                    TapjoyLog.v("TapjoyConnect", e2.getMessage());
                    gq.a(bhVar);
                    return false;
                }
            } catch (Throwable th) {
                th = th;
                r1 = str;
                gq.a(r1);
                throw th;
            }
        } catch (IOException e6) {
            e3 = e6;
            bhVar = null;
        } catch (RuntimeException e7) {
            e2 = e7;
            bhVar = null;
        } catch (Throwable th2) {
            th = th2;
            gq.a(r1);
            throw th;
        }
    }

    public static boolean d(String str) {
        RuntimeException e2;
        bh bhVar;
        IOException e3;
        ?? r1 = 0;
        try {
            try {
                bhVar = bh.b(str);
                try {
                } catch (IOException e4) {
                    e3 = e4;
                    TapjoyLog.v("TapjoyConnect", e3.getMessage());
                    gq.a(bhVar);
                    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());
                    gq.a(bhVar);
                    TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Completed Pay-Per-Action call failed."));
                    return false;
                }
            } catch (Throwable th) {
                th = th;
                r1 = str;
                gq.a(r1);
                throw th;
            }
        } catch (IOException e6) {
            e3 = e6;
            bhVar = null;
        } catch (RuntimeException e7) {
            e2 = e7;
            bhVar = null;
        } catch (Throwable th2) {
            th = th2;
            gq.a(r1);
            throw th;
        }
        if (!bhVar.a()) {
            bhVar.close();
            gq.a(null);
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Completed Pay-Per-Action call failed."));
            return false;
        }
        bhVar.s();
        TapjoyLog.d("TapjoyConnect", "Successfully sent completed Pay-Per-Action to Tapjoy server.");
        bhVar.close();
        gq.a(null);
        return true;
    }

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

    public static String getAppID() {
        return x;
    }

    public static String getLimitedAppID() {
        return aS;
    }

    public static String getUserID() {
        return E;
    }

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

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

    public static String getRedirectDomain() {
        return S;
    }

    public static String getCarrierName() {
        return H;
    }

    public static String getConnectionType() {
        String str = "";
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) h.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: ".concat(str));
            }
        } catch (Exception e2) {
            TapjoyLog.e("TapjoyConnect", "getConnectionType error: " + e2.toString());
        }
        return str;
    }

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

    private static boolean e(String str) {
        Intent intent = new Intent("android.intent.action.VIEW");
        if (str.length() <= 0) {
            intent.setData(Uri.parse("market://details"));
            return ag.queryIntentActivities(intent, 0).size() > 0;
        }
        return false;
    }

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

    public static Context getContext() {
        return h;
    }

    private static String L() {
        if (H()) {
            return c;
        }
        if (I() || !J()) {
            String str = q;
            if (str != null && str.length() > 0) {
                return q;
            }
        }
        TapjoyLog.e("TapjoyConnect", "Error -- no valid device identifier");
        return null;
    }

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

    private static String b(long j2) {
        try {
            return TapjoyUtil.SHA256(aS + CertificateUtil.DELIMITER + L() + CertificateUtil.DELIMITER + j2 + CertificateUtil.DELIMITER + aT);
        } catch (Exception e2) {
            TapjoyErrorMessage.ErrorType errorType = TapjoyErrorMessage.ErrorType.SDK_ERROR;
            TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(errorType, "Error in computing verifier value -- " + e2.toString()));
            return "";
        }
    }

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

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

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

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

    public static void setUserID(String str, TJSetUserIDListener tJSetUserIDListener) {
        E = str;
        m = tJSetUserIDListener;
        TapjoyLog.d("TapjoyConnect", "URL parameters: " + getURLParams());
        new Thread(new Runnable() {
            @Override
            public final void run() {
                TapjoyLog.i("TapjoyConnect", "Setting userID to " + TapjoyConnectCore.E);
                String hostURL = TapjoyConnectCore.getHostURL();
                TapjoyURLConnection tapjoyURLConnection = TapjoyConnectCore.k;
                TapjoyHttpURLResponse responseFromURL = tapjoyURLConnection.getResponseFromURL(hostURL + TapjoyConstants.TJC_USER_ID_URL_PATH, TapjoyConnectCore.getURLParams());
                boolean a2 = responseFromURL.response != null ? TapjoyConnectCore.a(responseFromURL.response) : false;
                if (!a2 && !TapjoyConnectCore.o && !hostURL.equalsIgnoreCase(TapjoyConnectCore.getHostURL())) {
                    TapjoyConnectCore.f();
                    TapjoyConnectCore.setUserID(TapjoyConnectCore.E, TapjoyConnectCore.m);
                    return;
                }
                TapjoyConnectCore.a(a2);
            }
        }).start();
    }

    public static void viewDidClose(String str) {
        TapjoyLog.d("TapjoyConnect", "viewDidClose: ".concat(String.valueOf(str)));
        aj.remove(str);
        fu.e.notifyObservers();
    }

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

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

    public static boolean isFullScreenViewOpen() {
        for (Integer num : aj.values()) {
            int intValue = num.intValue();
            if (intValue == 1 || intValue == 2) {
                return true;
            }
            while (r0.hasNext()) {
            }
        }
        return false;
    }

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

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

    public void actionComplete(String str) {
        TapjoyLog.i("TapjoyConnect", "actionComplete: ".concat(String.valueOf(str)));
        Map<String, String> k2 = k();
        TapjoyUtil.safePut(k2, "app_id", str, true);
        k2.putAll(getTimeStampAndVerifierParams());
        TapjoyLog.d("TapjoyConnect", "PPA URL parameters: ".concat(String.valueOf(k2)));
        new Thread(new PPAThread(k2)).start();
    }

    public void completeConnectCall() {
        boolean z2;
        String connectResult;
        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(M(), u.b())) == null || !a(connectResult, true)) {
            z2 = false;
        } else {
            TapjoyLog.i("TapjoyConnect", "Connect using stored connect result");
            af = true;
            TJConnectListener tJConnectListener = l;
            if (tJConnectListener != null) {
                tJConnectListener.onConnectSuccess();
            }
            fu.a.notifyObservers();
            z2 = true;
        }
        TapjoyURLConnection tapjoyURLConnection = k;
        TapjoyHttpURLResponse responseFromURL = tapjoyURLConnection.getResponseFromURL(hostURL + TapjoyConstants.TJC_CONNECT_URL_PATH, (Map<String, String>) null, (Map<String, String>) null, getURLParams());
        if (responseFromURL != null && responseFromURL.statusCode == 200) {
            if (a(responseFromURL.response, false)) {
                TapjoyLog.i("TapjoyConnect", "Successfully connected to Tapjoy");
                af = true;
                for (Map.Entry<String, String> entry : getGenericURLParams().entrySet()) {
                    TapjoyLog.d("TapjoyConnect", entry.getKey() + ": " + entry.getValue());
                }
                if (!z2) {
                    TJConnectListener tJConnectListener2 = l;
                    if (tJConnectListener2 != null) {
                        tJConnectListener2.onConnectSuccess();
                    }
                    fu.a.notifyObservers();
                }
                fu.b.notifyObservers(Boolean.TRUE);
                return;
            }
            if (!z2) {
                i();
            }
            fu.b.notifyObservers(Boolean.FALSE);
            return;
        }
        if (!z2) {
            i();
        }
        fu.b.notifyObservers(Boolean.FALSE);
    }

    public void completeLimitedConnectCall() {
        String hostURL = getHostURL() != TapjoyConfig.TJC_SERVICE_URL ? getHostURL() : TapjoyConfig.TJC_CONNECT_SERVICE_URL;
        Map<String, String> limitedURLParams = getLimitedURLParams();
        TapjoyURLConnection tapjoyURLConnection = k;
        TapjoyHttpURLResponse responseFromURL = tapjoyURLConnection.getResponseFromURL(hostURL + TapjoyConstants.TJC_CONNECT_URL_PATH, (Map<String, String>) null, (Map<String, String>) null, limitedURLParams);
        if (responseFromURL != null && responseFromURL.statusCode == 200) {
            if (c(responseFromURL.response)) {
                TapjoyLog.i("TapjoyConnect", "Successfully connected to Tapjoy");
                aV = true;
                for (Map.Entry<String, String> entry : getLimitedGenericURLParams().entrySet()) {
                    TapjoyLog.d("TapjoyConnect", entry.getKey() + ": " + entry.getValue());
                }
                TJConnectListener tJConnectListener = aW;
                if (tJConnectListener != null) {
                    tJConnectListener.onConnectSuccess();
                }
                fu.a.notifyObservers();
                fu.b.notifyObservers(Boolean.TRUE);
                return;
            }
            j();
            fu.b.notifyObservers(Boolean.FALSE);
            return;
        }
        j();
        fu.b.notifyObservers(Boolean.FALSE);
    }

    public class PPAThread implements Runnable {
        private Map<String, String> b;

        public PPAThread(Map<String, String> map) {
            this.b = map;
        }

        @Override
        public void run() {
            TapjoyURLConnection tapjoyURLConnection = TapjoyConnectCore.k;
            TapjoyHttpURLResponse responseFromURL = tapjoyURLConnection.getResponseFromURL(TapjoyConnectCore.getHostURL() + TapjoyConstants.TJC_CONNECT_URL_PATH, (Map<String, String>) null, (Map<String, String>) null, this.b);
            if (responseFromURL.response != null) {
                TapjoyConnectCore.d(responseFromURL.response);
            }
        }
    }

    public void setCurrencyMultiplier(float f2) {
        TapjoyLog.i("TapjoyConnect", "setVirtualCurrencyMultiplier: ".concat(String.valueOf(f2)));
        T = f2;
    }

    public float getCurrencyMultiplier() {
        return T;
    }

    public static String getConnectFlagValue(String str) {
        Hashtable<String, Object> hashtable = ai;
        return (hashtable == null || hashtable.get(str) == null) ? "" : ai.get(str).toString();
    }

    public static String getSecretKey() {
        return O;
    }

    public static String getAndroidID() {
        return q;
    }

    public static float getDeviceScreenDensityScale() {
        return C;
    }

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

    public static String getUserToken() {
        Map<String, Object> map = Z;
        if (map == null || map.isEmpty()) {
            if (!TextUtils.isEmpty(E)) {
                return Y + CertificateUtil.DELIMITER + E;
            }
            return Y;
        }
        Map<String, Object> map2 = Z;
        HashMap hashMap = new HashMap();
        for (String str : map2.keySet()) {
            TapjoyUtil.safePut(hashMap, str, String.valueOf(map2.get(str)), true);
        }
        if (!TextUtils.isEmpty(E)) {
            TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_TOKEN_PARAM_USER_ID, E, true);
        }
        return Base64.encodeToString(TapjoyUtil.convertURLParams((Map<String, String>) hashMap, false).getBytes(), 2);
    }

    public static boolean isConnected() {
        return af;
    }

    public static boolean isLimitedConnected() {
        return aV;
    }

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

    private static String M() {
        String str = x + y + z + c + s;
        try {
            return TapjoyUtil.SHA1(str);
        } catch (Exception unused) {
            return str;
        }
    }

    public static void optOutAdvertisingID(Context context, boolean z2) {
        if (context != null) {
            SharedPreferences.Editor edit = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0).edit();
            edit.putBoolean(TapjoyConstants.PREF_OPTOUT_ADVERTISING_ID, z2);
            edit.apply();
            if (Tapjoy.isConnected() || Tapjoy.isLimitedConnected()) {
                if (!z2) {
                    if (gt.c(c) || c.equals("00000000-0000-0000-0000-000000000000")) {
                        aX = false;
                        new Thread(new Runnable() {
                            @Override
                            public final void run() {
                                TapjoyConnectCore unused = TapjoyConnectCore.j;
                                TapjoyConnectCore.a();
                            }
                        }).start();
                        return;
                    }
                    return;
                }
                c = "";
                TapjoyGpsHelper tapjoyGpsHelper = ah;
                if (tapjoyGpsHelper != null) {
                    tapjoyGpsHelper.resetAdvertisingID();
                    hk.a().a(c, true);
                }
            }
        }
    }

    public static void setCustomParameter(String str) {
        F = str;
    }

    public static String getCustomParameter() {
        return F;
    }

    static void a() {
        if (aX) {
            return;
        }
        try {
            ah.loadAdvertisingId(!I());
            if (ah.isGooglePlayServicesAvailable() && ah.isGooglePlayManifestConfigured()) {
                b = ah.getDeviceGooglePlayServicesVersion();
                a = ah.getPackagedGooglePlayServicesVersion();
            }
            if (ah.isAdIdAvailable()) {
                d = ah.isAdTrackingEnabled();
                c = ah.getAdvertisingId();
                hk.a().a(c, d ? false : true);
            }
            aX = true;
        } catch (Exception e2) {
            TapjoyLog.i("TapjoyConnect", "Error fetching advertising id: " + e2.toString());
            e2.printStackTrace();
        }
    }

    static boolean a(String str) {
        Document buildDocument = TapjoyUtil.buildDocument(str);
        if (buildDocument != null) {
            String nodeTrimValue = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName(InitializationStatus.SUCCESS));
            return nodeTrimValue != null && nodeTrimValue.equals("true");
        }
        return true;
    }

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