导航菜单

页面标题

页面副标题

Housing v14.7.8 - f.java 源代码

正在查看: Housing v14.7.8 应用的 f.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.branch.referral;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import com.newrelic.agent.android.api.v2.TraceFieldInterface;
import com.newrelic.agent.android.instrumentation.AsyncTaskInstrumentation;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.JSONObjectInstrumentation;
import com.newrelic.agent.android.instrumentation.LogInstrumentation;
import com.newrelic.agent.android.tracing.Trace;
import com.newrelic.agent.android.tracing.TraceMachine;
import com.quickblox.core.helper.ToStringHelper;
import com.quickblox.users.Consts;
import io.branch.referral.b;
import io.branch.referral.h0;
import io.branch.referral.l;
import io.branch.referral.z0;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.json.JSONException;
import org.json.JSONObject;

@Instrumented
public class f {
    public static final String ALWAYS_DEEPLINK = "$always_deeplink";
    private static final String AUTO_DEEP_LINK_DISABLE = "io.branch.sdk.auto_link_disable";
    private static final String AUTO_DEEP_LINK_KEY = "io.branch.sdk.auto_link_keys";
    private static final String AUTO_DEEP_LINK_PATH = "io.branch.sdk.auto_link_path";
    private static final String AUTO_DEEP_LINK_REQ_CODE = "io.branch.sdk.auto_link_request_code";
    public static final String DEEPLINK_PATH = "$deeplink_path";
    private static final int DEF_AUTO_DEEP_LINK_REQ_CODE = 1501;
    public static final String FEATURE_TAG_SHARE = "share";
    private static final int LATCH_WAIT_UNTIL = 2500;
    public static final int LINK_TYPE_ONE_TIME_USE = 1;
    public static final int LINK_TYPE_UNLIMITED_USE = 0;
    public static final String OG_APP_ID = "$og_app_id";
    public static final String OG_DESC = "$og_description";
    public static final String OG_IMAGE_URL = "$og_image_url";
    public static final String OG_TITLE = "$og_title";
    public static final String OG_URL = "$og_url";
    public static final String OG_VIDEO = "$og_video";
    public static final String REDIRECT_ANDROID_URL = "$android_url";
    public static final String REDIRECT_BLACKBERRY_URL = "$blackberry_url";
    public static final String REDIRECT_DESKTOP_URL = "$desktop_url";
    public static final String REDIRECT_FIRE_URL = "$fire_url";
    public static final String REDIRECT_IOS_URL = "$ios_url";
    public static final String REDIRECT_IPAD_URL = "$ipad_url";
    public static final String REDIRECT_WINDOWS_PHONE_URL = "$windows_phone_url";
    private static f branchReferral_;
    static boolean disableAutoSessionInitialization;
    private static boolean disableDeviceIDFetch_;
    static boolean userAgentSync;
    private io.branch.referral.g activityLifeCycleObserver;
    private final n branchPluginSupport_;
    private final q branchQRCodeCache_;
    private final Context context_;
    WeakReference<Activity> currentActivityReference_;
    private JSONObject deeplinkDebugParams_;
    private b deferredCallback;
    private C0033f deferredSessionBuilder;
    private Uri deferredUri;
    private final e0 deviceInfo_;
    final f0 prefHelper_;
    public final o0 requestQueue_;
    private s0 shareLinkManager_;
    private final y0 trackingController;
    private static final String BRANCH_LIBRARY_VERSION = "io.branch.sdk.android:library:5.13.0";
    private static final String GOOGLE_VERSION_TAG = a.l("!SDK-VERSION-STRING!:", BRANCH_LIBRARY_VERSION);
    public static String _userAgentString = "";
    static boolean bypassWaitingForIntent_ = false;
    private static boolean bypassCurrentActivityIntentState_ = false;
    static boolean referringLinkAttributionForPreinstalledAppsEnabled = false;
    private static boolean isActivityLifeCycleCallbackRegistered_ = false;
    static boolean deferInitForPluginRuntime = false;
    private static final String[] EXTERNAL_INTENT_EXTRA_KEY_WHITE_LIST = {"extra_launch_uri", "branch_intent"};
    public static String installDeveloperId = null;
    private static boolean enableInstantDeepLinking = false;
    private static String pluginVersion = null;
    private static String pluginName = null;
    final ConcurrentHashMap<k, String> linkCache_ = new ConcurrentHashMap<>();
    private e intentState_ = e.PENDING;
    g initState_ = g.UNINITIALISED;
    public boolean closeRequestNeeded = false;
    CountDownLatch getFirstReferringParamsLatch = null;
    CountDownLatch getLatestReferringParamsLatch = null;
    private boolean isInstantDeepLinkPossible = false;
    private io.branch.referral.network.a branchRemoteInterface_ = new io.branch.referral.network.b(this);

    public interface a {
        void a(String str, i iVar);
    }

    public interface b {
    }

    public interface c {
    }

    @Instrumented
    public class d extends AsyncTask implements TraceFieldInterface {
        public Trace _nr_trace;

        public d() {
        }

        public final void _nr_setTrace(Trace trace) {
            try {
                this._nr_trace = trace;
            } catch (Exception unused) {
            }
        }

        @Override
        public final Object doInBackground(Object[] objArr) {
            try {
                TraceMachine.enterMethod(this._nr_trace, "Branch$GetShortLinkTask#doInBackground", (ArrayList) null);
            } catch (NoSuchFieldError unused) {
                TraceMachine.enterMethod((Trace) null, "Branch$GetShortLinkTask#doInBackground", (ArrayList) null);
            }
            io.branch.referral.network.a aVar = f.this.branchRemoteInterface_;
            JSONObject e = ((h0[]) objArr)[0].e();
            StringBuilder sb = new StringBuilder();
            f.this.prefHelper_.getClass();
            sb.append(f0.b());
            b0 b0Var = b0.GetURL;
            sb.append(b0Var.getPath());
            r0 b = aVar.b(sb.toString(), e, b0Var.getPath(), f.this.prefHelper_.q("bnc_branch_key"));
            TraceMachine.exitMethod();
            return b;
        }
    }

    public static final class e {
        private static final e[] $VALUES;
        public static final e PENDING;
        public static final e READY;

        static {
            e eVar = new e("PENDING", 0);
            PENDING = eVar;
            e eVar2 = new e("READY", 1);
            READY = eVar2;
            $VALUES = new e[]{eVar, eVar2};
        }

        public static e valueOf(String str) {
            return (e) Enum.valueOf(e.class, str);
        }

        public static e[] values() {
            return (e[]) $VALUES.clone();
        }
    }

    public static class C0033f {
        private b callback;
        private int delay;
        private Boolean ignoreIntent;
        private boolean isAutoInitialization;
        private boolean isReInitializing;
        private Uri uri;

        public final void a() {
            l.i("Beginning session initialization");
            l.i("Session uri is " + this.uri);
            l.i("Callback is " + this.callback);
            l.i("Is auto init " + this.isAutoInitialization);
            l.i("Will ignore intent " + this.ignoreIntent);
            l.i("Is reinitializing " + this.isReInitializing);
            if (f.deferInitForPluginRuntime) {
                l.i("Session init is deferred until signaled by plugin.");
                f.u().deferredSessionBuilder = this;
                l.i("Session initialization deferred until plugin invokes notifyNativeToInit()\nCaching Session Builder " + f.u().deferredSessionBuilder + "\nuri: " + f.u().deferredSessionBuilder.uri + "\ncallback: " + f.u().deferredSessionBuilder.callback + "\nisReInitializing: " + f.u().deferredSessionBuilder.isReInitializing + "\ndelay: " + f.u().deferredSessionBuilder.delay + "\nisAutoInitialization: " + f.u().deferredSessionBuilder.isAutoInitialization + "\nignoreIntent: " + f.u().deferredSessionBuilder.ignoreIntent);
                return;
            }
            f u = f.u();
            if (u == null) {
                l.INSTANCE.getClass();
                LogInstrumentation.i("BranchSDK", "Branch is not setup properly, make sure to call getAutoInstance in your application class or declare BranchApp in your manifest.");
                return;
            }
            Boolean bool = this.ignoreIntent;
            if (bool != null) {
                f.bypassWaitingForIntent_ = bool.booleanValue();
            }
            Activity q = u.q();
            Intent intent = q != null ? q.getIntent() : null;
            if (q != null && intent != null && q.getReferrer() != null) {
                f0.h(q).E("bnc_initial_referrer", q.getReferrer().toString());
            }
            Uri uri = this.uri;
            if (uri != null) {
                u.F(q, uri);
            } else if (this.isReInitializing && f.C(intent)) {
                u.F(q, intent != null ? intent.getData() : null);
            } else if (this.isReInitializing) {
                b bVar = this.callback;
                if (bVar != null) {
                    ((s) bVar).a(new i("", i.ERR_IMPROPER_REINITIALIZATION));
                    return;
                }
                return;
            }
            l.i("isInstantDeepLinkPossible " + u.isInstantDeepLinkPossible);
            if (u.isInstantDeepLinkPossible) {
                u.isInstantDeepLinkPossible = false;
                b bVar2 = this.callback;
                if (bVar2 != null) {
                    u.v();
                    ((s) bVar2).a(null);
                }
                f.u().requestQueue_.a(y.InstantDeepLinkSession.getKey(), "true");
                u.h();
                this.callback = null;
            }
            if (this.delay > 0) {
                f.disableAutoSessionInitialization = true;
            }
            k0 t = u.t(this.callback, this.isAutoInitialization);
            l.a("Creating " + t + " from init on thread " + Thread.currentThread().getName());
            f.d(u, t, this.delay);
        }

        public final void b() {
            this.isAutoInitialization = true;
        }

        public final void c() {
            this.isReInitializing = true;
            a();
        }

        public final void d(c cVar) {
            l.i("InitSessionBuilder setting BranchUniversalReferralInitListener withCallback with " + cVar);
            this.callback = new s(cVar);
        }

        public final void e(Uri uri) {
            l.i("InitSessionBuilder setting withData with " + uri);
            this.uri = uri;
        }
    }

    public static final class g {
        private static final g[] $VALUES;
        public static final g INITIALISED;
        public static final g INITIALISING;
        public static final g UNINITIALISED;

        static {
            g gVar = new g("INITIALISED", 0);
            INITIALISED = gVar;
            g gVar2 = new g("INITIALISING", 1);
            INITIALISING = gVar2;
            g gVar3 = new g("UNINITIALISED", 2);
            UNINITIALISED = gVar3;
            $VALUES = new g[]{gVar, gVar2, gVar3};
        }

        public static g valueOf(String str) {
            return (g) Enum.valueOf(g.class, str);
        }

        public static g[] values() {
            return (g[]) $VALUES.clone();
        }
    }

    public f(Context context) {
        this.context_ = context;
        this.prefHelper_ = f0.h(context);
        this.trackingController = new y0(context);
        this.deviceInfo_ = new e0(context);
        this.branchPluginSupport_ = new n(context);
        this.branchQRCodeCache_ = new q(context);
        this.requestQueue_ = o0.e(context);
    }

    public static boolean B(Activity activity) {
        boolean z = false;
        if (activity != null && activity.getIntent() != null && activity.getIntent().getBooleanExtra(x.BranchLinkUsed.getKey(), false)) {
            z = true;
        }
        l.i("isIntentParamsAlreadyConsumed " + z);
        return z;
    }

    public static boolean C(Intent intent) {
        if (!(intent != null ? intent.getBooleanExtra(x.ForceNewBranchSession.getKey(), false) : false)) {
            if (intent != null) {
                boolean z = intent.getStringExtra(x.BranchURI.getKey()) != null;
                boolean booleanExtra = intent.getBooleanExtra(x.BranchLinkUsed.getKey(), false);
                if (!z || booleanExtra) {
                }
            }
            return false;
        }
        return true;
    }

    public static C0033f G(Activity activity) {
        C0033f c0033f = new C0033f();
        f u = u();
        if (activity != null && (u.q() == null || !u.q().getLocalClassName().equals(activity.getLocalClassName()))) {
            u.currentActivityReference_ = new WeakReference<>(activity);
        }
        return c0033f;
    }

    public static void d(f fVar, k0 k0Var, int i) {
        l.i("initializeSession " + k0Var + " delay " + i);
        if (fVar.prefHelper_.q("bnc_branch_key") == null || fVar.prefHelper_.q("bnc_branch_key").equalsIgnoreCase(f0.NO_STRING_VALUE)) {
            fVar.initState_ = g.UNINITIALISED;
            b bVar = k0Var.callback_;
            if (bVar != null) {
                ((s) bVar).a(new i("Trouble initializing Branch.", i.ERR_BRANCH_KEY_INVALID));
            }
            l.j("Warning: Please enter your branch_key in your project's manifest");
            return;
        }
        if (v.b()) {
            l.j("Warning: You are using your test app's Branch Key. Remember to change it to live Branch Key during deployment.");
        }
        if (i > 0) {
            k0Var.a(h0.b.USER_SET_WAIT_LOCK);
            new Handler().postDelayed(new io.branch.referral.c(fVar), i);
        }
        Intent intent = fVar.q() != null ? fVar.q().getIntent() : null;
        boolean C = C(intent);
        g gVar = fVar.initState_;
        l.i("Intent: " + intent + " forceBranchSession: " + C + " initState: " + gVar);
        if (gVar != g.UNINITIALISED && !C) {
            b bVar2 = k0Var.callback_;
            if (bVar2 != null) {
                ((s) bVar2).a(new i("Warning.", i.ERR_BRANCH_ALREADY_INITIALIZED));
                return;
            }
            return;
        }
        if (C && intent != null) {
            intent.removeExtra(x.ForceNewBranchSession.getKey());
        }
        l.i("registerAppInit " + k0Var);
        fVar.initState_ = g.INITIALISING;
        k0 f = fVar.requestQueue_.f();
        l.i("Ordering init calls");
        fVar.requestQueue_.m();
        if (f == null || C) {
            l.i("Moving " + k0Var + "  to front of the queue or behind network-in-progress request");
            o0 o0Var = fVar.requestQueue_;
            if (o0Var.networkCount_ == 0) {
                o0Var.i(k0Var, 0);
            } else {
                o0Var.i(k0Var, 1);
            }
        } else {
            l.i("Retrieved " + f + " with callback " + f.callback_ + " in queue currently");
            f.callback_ = k0Var.callback_;
            l.i(f + " now has callback " + k0Var.callback_);
        }
        l.i("Finished ordering init calls");
        fVar.requestQueue_.m();
        l.i("initTasks " + k0Var);
        if (fVar.intentState_ != e.READY && !bypassWaitingForIntent_) {
            k0Var.a(h0.b.INTENT_PENDING_WAIT_LOCK);
            l.i("Added INTENT_PENDING_WAIT_LOCK");
        }
        if (k0Var instanceof p0) {
            k0Var.a(h0.b.INSTALL_REFERRER_FETCH_WAIT_LOCK);
            l.i("Added INSTALL_REFERRER_FETCH_WAIT_LOCK");
            x0 f2 = fVar.deviceInfo_.f();
            Context context = fVar.context_;
            io.branch.referral.d dVar = new io.branch.referral.d(fVar, k0Var);
            f2.getClass();
            l.i("Begin fetchInstallReferrer");
            try {
                io.branch.coroutines.n.a(context, new w0(f2, context, dVar));
            } catch (Exception e2) {
                l.b("Caught Exception SystemObserver fetchInstallReferrer " + e2.getMessage());
                dVar.val$request.o(h0.b.INSTALL_REFERRER_FETCH_WAIT_LOCK);
                l.i("INSTALL_REFERRER_FETCH_WAIT_LOCK removed");
                dVar.this$0.requestQueue_.n("onInstallReferrersFinished");
            }
        }
        k0Var.a(h0.b.GAID_FETCH_WAIT_LOCK);
        l.i("Added GAID_FETCH_WAIT_LOCK");
        x0 f3 = fVar.deviceInfo_.f();
        Context context2 = fVar.context_;
        io.branch.referral.e eVar = new io.branch.referral.e(fVar);
        f3.getClass();
        if (Build.MANUFACTURER.equalsIgnoreCase("amazon")) {
            l.i("Begin setFireAdId");
            io.branch.coroutines.d.a(context2, new v0(f3, eVar));
        } else if (x0.k(context2)) {
            l.i("Begin fetchHuaweiAdId");
            if (io.branch.referral.util.g.a(io.branch.referral.util.g.huaweiAdvertisingIdClientClass)) {
                io.branch.coroutines.d.c(context2, new t0(f3, eVar));
            } else {
                eVar.a();
                l.i("Huawei advertising service not found. If not expected, import com.huawei.hms.ads.identifier.AdvertisingIdClient into your gradle dependencies");
            }
        } else {
            l.i("Begin fetchGoogleAdId");
            if (io.branch.referral.util.g.a(io.branch.referral.util.g.playStoreAdvertisingIdClientClass)) {
                io.branch.coroutines.d.b(context2, new u0(f3, eVar));
            } else {
                eVar.a();
                l.i("Play Store advertising service not found. If not expected, import com.google.android.gms.ads.identifier.AdvertisingIdClient into your gradle dependencies");
            }
        }
        fVar.requestQueue_.n("registerAppInit");
    }

    public static boolean g() {
        return bypassCurrentActivityIntentState_;
    }

    public static boolean i(JSONObject jSONObject, ActivityInfo activityInfo) {
        if (activityInfo.metaData.getString(AUTO_DEEP_LINK_KEY) != null) {
            for (String str : activityInfo.metaData.getString(AUTO_DEEP_LINK_KEY).split(ToStringHelper.COMMA_SEPARATOR)) {
                if (jSONObject.has(str)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean j(JSONObject jSONObject, ActivityInfo activityInfo) {
        int i;
        String str = null;
        try {
            y yVar = y.AndroidDeepLinkPath;
            if (jSONObject.has(yVar.getKey())) {
                str = jSONObject.getString(yVar.getKey());
            } else {
                y yVar2 = y.DeepLinkPath;
                if (jSONObject.has(yVar2.getKey())) {
                    str = jSONObject.getString(yVar2.getKey());
                }
            }
        } catch (JSONException e2) {
            l.a(e2.getMessage());
        }
        if (activityInfo.metaData.getString(AUTO_DEEP_LINK_PATH) != null && str != null) {
            for (String str2 : activityInfo.metaData.getString(AUTO_DEEP_LINK_PATH).split(ToStringHelper.COMMA_SEPARATOR)) {
                String[] split = str2.trim().split("\\?")[0].split("/");
                String[] split2 = str.split("\\?")[0].split("/");
                if (split.length == split2.length) {
                    for (0; i < split.length && i < split2.length; i + 1) {
                        String str3 = split[i];
                        i = (str3.equals(split2[i]) || str3.contains("*")) ? i + 1 : 0;
                    }
                    return true;
                }
            }
        }
        return false;
    }

    public static void l() {
        disableAutoSessionInitialization = true;
    }

    public static void o(Context context) {
        f fVar;
        String str = "key_live_fdJ7dmS2RIehpBYh1RavlnfmBsoN9MOB";
        if (branchReferral_ == null) {
            j f = j.f(context);
            if (f.i() ? Boolean.TRUE.equals(f.d()) : false) {
                l.f(l.a.DEBUG);
                l.e();
                String message = GOOGLE_VERSION_TAG;
                kotlin.jvm.internal.r.k(message, "message");
                if (message.length() > 0) {
                    l.INSTANCE.getClass();
                    LogInstrumentation.i("BranchSDK", message);
                }
            }
            j f2 = j.f(context);
            boolean equals = f2.i() ? Boolean.TRUE.equals(f2.c()) : false;
            l.i("deferInitForPluginRuntime " + equals);
            deferInitForPluginRuntime = equals;
            if (equals) {
                disableAutoSessionInitialization = equals;
            }
            String a2 = j.f(context).a();
            if (!TextUtils.isEmpty(a2)) {
                if (TextUtils.isEmpty(a2)) {
                    l.j("setAPIUrl: URL cannot be empty or null");
                } else {
                    if (!a2.endsWith("/")) {
                        a2 = a2.concat("/");
                    }
                    f0.w(a2);
                    l.i("setAPIUrl: Branch API URL was set to " + a2);
                }
            }
            String e2 = j.f(context).e();
            if (!TextUtils.isEmpty(e2)) {
                if (TextUtils.isEmpty(e2)) {
                    l.j("setFBAppID: fbAppID cannot be empty or null");
                } else {
                    f0.fbAppId_ = e2;
                    l.i("setFBAppID to " + e2);
                }
            }
            v.d(v.a(context));
            if (!"key_live_fdJ7dmS2RIehpBYh1RavlnfmBsoN9MOB".startsWith(v.b() ? "key_test_" : "key_")) {
                l.j("Warning, Invalid branch key passed! Branch key will be read from manifest instead!");
                str = v.c(context);
            }
            synchronized (f.class) {
                if (branchReferral_ != null) {
                    l.j("Warning, attempted to reinitialize Branch SDK singleton!");
                    fVar = branchReferral_;
                } else {
                    branchReferral_ = new f(context.getApplicationContext());
                    if (TextUtils.isEmpty(str)) {
                        l.j("Warning: Please enter your branch_key in your project's Manifest file!");
                        branchReferral_.prefHelper_.x(f0.NO_STRING_VALUE);
                    } else {
                        branchReferral_.prefHelper_.x(str);
                    }
                    if (context instanceof Application) {
                        f fVar2 = branchReferral_;
                        Application application = (Application) context;
                        fVar2.getClass();
                        try {
                            io.branch.referral.g gVar = new io.branch.referral.g();
                            fVar2.activityLifeCycleObserver = gVar;
                            application.unregisterActivityLifecycleCallbacks(gVar);
                            application.registerActivityLifecycleCallbacks(fVar2.activityLifeCycleObserver);
                            isActivityLifeCycleCallbackRegistered_ = true;
                        } catch (NoClassDefFoundError | NoSuchMethodError unused) {
                            isActivityLifeCycleCallbackRegistered_ = false;
                            l.i(new i("", i.ERR_API_LVL_14_NEEDED).errorMessage_);
                        }
                    }
                    fVar = branchReferral_;
                }
            }
            branchReferral_ = fVar;
            if (fVar != null) {
                String str2 = null;
                try {
                    str2 = (String) Class.forName("android.os.SystemProperties").getMethod(Consts.START_GETTERS_METHOD, String.class).invoke(null, "io.branch.preinstall.apps.path");
                } catch (Exception unused2) {
                }
                if (TextUtils.isEmpty(str2)) {
                    return;
                }
                new Thread(new o(str2, fVar, context)).start();
            }
        }
    }

    public static synchronized f u() {
        f fVar;
        synchronized (f.class) {
            try {
                if (branchReferral_ == null) {
                    l.i("Branch instance is not created yet. Make sure you call getAutoInstance(Context).");
                }
                fVar = branchReferral_;
            } catch (Throwable th) {
                throw th;
            }
        }
        return fVar;
    }

    public static String w() {
        return pluginName;
    }

    public static String x() {
        return pluginVersion;
    }

    public static boolean z() {
        return disableDeviceIDFetch_;
    }

    public final boolean A() {
        return this.isInstantDeepLinkPossible;
    }

    public final boolean D() {
        return this.trackingController.a();
    }

    public final void E(Activity activity) {
        l.i("onIntentReady " + activity + " removing INTENT_PENDING_WAIT_LOCK");
        this.intentState_ = e.READY;
        this.requestQueue_.p(h0.b.INTENT_PENDING_WAIT_LOCK);
        if (activity.getIntent() != null && this.initState_ != g.INITIALISED) {
            F(activity, activity.getIntent().getData());
        }
        this.requestQueue_.n("onIntentReady");
    }

    public final void F(Activity activity, Uri uri) {
        String queryParameter;
        l.i("Read params uri: " + uri + " bypassCurrentActivityIntentState: " + bypassCurrentActivityIntentState_ + " intent state: " + this.intentState_);
        String str = null;
        if (enableInstantDeepLinking) {
            boolean z = this.intentState_ == e.READY || !this.activityLifeCycleObserver.a();
            boolean C = C(activity != null ? activity.getIntent() : null);
            if (z && !C && activity != null && activity.getIntent() != null) {
                Intent intent = activity.getIntent();
                if (uri != null) {
                    try {
                        if (!B(activity)) {
                            x xVar = x.BranchData;
                            if (!TextUtils.isEmpty(intent.getStringExtra(xVar.getKey()))) {
                                String stringExtra = intent.getStringExtra(xVar.getKey());
                                if (stringExtra != null) {
                                    JSONObject jSONObject = new JSONObject(stringExtra);
                                    jSONObject.put(y.Clicked_Branch_Link.getKey(), true);
                                    this.prefHelper_.D(JSONObjectInstrumentation.toString(jSONObject));
                                    this.isInstantDeepLinkPossible = true;
                                }
                                intent.removeExtra(xVar.getKey());
                                activity.setIntent(intent);
                            } else if (uri.isHierarchical() && Boolean.valueOf(uri.getQueryParameter(y.Instant.getKey())).booleanValue()) {
                                JSONObject jSONObject2 = new JSONObject();
                                for (String str2 : uri.getQueryParameterNames()) {
                                    jSONObject2.put(str2, uri.getQueryParameter(str2));
                                }
                                jSONObject2.put(y.Clicked_Branch_Link.getKey(), true);
                                this.prefHelper_.D(JSONObjectInstrumentation.toString(jSONObject2));
                                this.isInstantDeepLinkPossible = true;
                            }
                        }
                    } catch (JSONException e2) {
                        l.a(e2.getMessage());
                    }
                }
                if (!this.prefHelper_.q("bnc_install_params").equals(f0.NO_STRING_VALUE)) {
                    JSONObject jSONObject3 = new JSONObject();
                    jSONObject3.put(y.IsFirstSession.getKey(), false);
                    this.prefHelper_.D(JSONObjectInstrumentation.toString(jSONObject3));
                    this.isInstantDeepLinkPossible = true;
                }
            }
        }
        if (bypassCurrentActivityIntentState_) {
            this.intentState_ = e.READY;
        }
        if (this.intentState_ == e.READY) {
            l.i("extractExternalUriAndIntentExtras " + uri + lr.f.SPACE + activity);
            try {
                if (!B(activity)) {
                    String d2 = z0.c(this.context_).d(uri.toString());
                    this.prefHelper_.E("bnc_external_intent_uri", d2);
                    if (d2.equals(uri.toString())) {
                        Bundle extras = activity.getIntent().getExtras();
                        Set<String> keySet = extras.keySet();
                        if (!keySet.isEmpty()) {
                            JSONObject jSONObject4 = new JSONObject();
                            for (String str3 : EXTERNAL_INTENT_EXTRA_KEY_WHITE_LIST) {
                                if (keySet.contains(str3)) {
                                    jSONObject4.put(str3, extras.get(str3));
                                }
                            }
                            if (jSONObject4.length() > 0) {
                                this.prefHelper_.E("bnc_external_intent_extra", JSONObjectInstrumentation.toString(jSONObject4));
                            }
                        }
                    }
                }
            } catch (Exception e3) {
                l.a(e3.getMessage());
            }
            l.i("extractBranchLinkFromIntentExtra " + activity);
            if (activity != null) {
                try {
                    if (activity.getIntent() != null && activity.getIntent().getExtras() != null && !B(activity)) {
                        Object obj = activity.getIntent().getExtras().get(x.BranchURI.getKey());
                        if (obj instanceof String) {
                            str = (String) obj;
                        } else if (obj instanceof Uri) {
                            str = ((Uri) obj).toString();
                        }
                        if (!TextUtils.isEmpty(str)) {
                            this.prefHelper_.E("bnc_push_identifier", str);
                            Intent intent2 = activity.getIntent();
                            intent2.putExtra(x.BranchLinkUsed.getKey(), true);
                            activity.setIntent(intent2);
                            return;
                        }
                    }
                } catch (Exception e4) {
                    l.a(e4.getMessage());
                }
            }
            if (activity == null || activity.getIntent() == null || (activity.getIntent().getFlags() & 1048576) == 0) {
                if (uri != null) {
                    try {
                        if (uri.isHierarchical() && (queryParameter = uri.getQueryParameter(y.LinkClickID.getKey())) != null) {
                            this.prefHelper_.E("bnc_link_click_identifier", queryParameter);
                            String concat = "link_click_id=".concat(queryParameter);
                            String uri2 = uri.toString();
                            activity.getIntent().setData(Uri.parse(uri2.replaceFirst(concat.equals(uri.getQuery()) ? "\\?".concat(concat) : uri2.length() - concat.length() == uri2.indexOf(concat) ? "&".concat(concat) : concat.concat("&"), "")));
                            activity.getIntent().putExtra(x.BranchLinkUsed.getKey(), true);
                            return;
                        }
                    } catch (Exception e5) {
                        l.a(e5.getMessage());
                    }
                }
                if (uri == null || activity == null) {
                    return;
                }
                String scheme = uri.getScheme();
                Intent intent3 = activity.getIntent();
                if (scheme == null || intent3 == null) {
                    return;
                }
                if ((!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) || TextUtils.isEmpty(uri.getHost()) || B(activity)) {
                    return;
                }
                if (uri.toString().equalsIgnoreCase(z0.c(this.context_).d(uri.toString()))) {
                    this.prefHelper_.E("bnc_app_link", uri.toString());
                }
                intent3.putExtra(x.BranchLinkUsed.getKey(), true);
                activity.setIntent(intent3);
            }
        }
    }

    public final void H() {
        this.isInstantDeepLinkPossible = false;
    }

    public final void I(e eVar) {
        this.intentState_ = eVar;
    }

    public final void J() {
        z0 c2 = z0.c(this.context_);
        Context context = this.context_;
        c2.getClass();
        try {
            new z0.a(context).a(new Void[0]);
        } catch (Exception e2) {
            l.a(e2.getMessage());
        }
    }

    public final void h() {
        Bundle bundle;
        JSONObject v = v();
        String str = null;
        try {
            y yVar = y.Clicked_Branch_Link;
            if (v.has(yVar.getKey()) && v.getBoolean(yVar.getKey())) {
                if (v.length() > 0) {
                    Bundle bundle2 = this.context_.getPackageManager().getApplicationInfo(this.context_.getPackageName(), 128).metaData;
                    if (bundle2 == null || !bundle2.getBoolean(AUTO_DEEP_LINK_DISABLE, false)) {
                        ActivityInfo[] activityInfoArr = this.context_.getPackageManager().getPackageInfo(this.context_.getPackageName(), 129).activities;
                        int i = DEF_AUTO_DEEP_LINK_REQ_CODE;
                        if (activityInfoArr != null) {
                            for (ActivityInfo activityInfo : activityInfoArr) {
                                if (activityInfo != null && (bundle = activityInfo.metaData) != null && ((bundle.getString(AUTO_DEEP_LINK_KEY) != null || activityInfo.metaData.getString(AUTO_DEEP_LINK_PATH) != null) && (i(v, activityInfo) || j(v, activityInfo)))) {
                                    str = activityInfo.name;
                                    i = activityInfo.metaData.getInt(AUTO_DEEP_LINK_REQ_CODE, DEF_AUTO_DEEP_LINK_REQ_CODE);
                                    break;
                                }
                            }
                        }
                        if (str == null || q() == null) {
                            l.i("No activity reference to launch deep linked activity");
                            return;
                        }
                        l.i("deepLinkActivity " + str + " getCurrentActivity " + q());
                        Activity q = q();
                        Intent intent = new Intent(q, Class.forName(str));
                        intent.putExtra(x.AutoDeepLinked.getKey(), "true");
                        intent.putExtra(y.ReferringData.getKey(), JSONObjectInstrumentation.toString(v));
                        Iterator<String> keys = v.keys();
                        while (keys.hasNext()) {
                            String next = keys.next();
                            intent.putExtra(next, v.getString(next));
                        }
                        q.startActivityForResult(intent, i);
                        return;
                    }
                    return;
                }
                return;
            }
            l.i("Does not have Clicked_Branch_Link or Clicked_Branch_Link is false, returning");
        } catch (PackageManager.NameNotFoundException unused) {
            l.j("Warning: Please make sure Activity names set for auto deep link are correct!");
        } catch (ClassNotFoundException unused2) {
            l.j("Warning: Please make sure Activity names set for auto deep link are correct! Error while looking for activity " + ((String) null));
        } catch (Exception unused3) {
        }
    }

    public final void k() {
        this.prefHelper_.partnerParams_.b();
        g gVar = this.initState_;
        g gVar2 = g.UNINITIALISED;
        if (gVar != gVar2) {
            this.initState_ = gVar2;
        }
        this.prefHelper_.D(f0.NO_STRING_VALUE);
        this.prefHelper_.E("bnc_external_intent_uri", null);
        this.trackingController.b(this.context_);
    }

    public final void m(i0 i0Var) {
        r0 r0Var;
        if (i0Var.constructError_ || i0Var.x(this.context_)) {
            return;
        }
        if (this.linkCache_.containsKey(i0Var.u())) {
            i0Var.A(this.linkCache_.get(i0Var.u()));
            return;
        }
        if (i0Var.y()) {
            this.requestQueue_.h(i0Var);
            return;
        }
        try {
            r0Var = (r0) AsyncTaskInstrumentation.execute(new d(), new h0[]{i0Var}).get(this.prefHelper_.s() + 2000, TimeUnit.MILLISECONDS);
        } catch (InterruptedException | ExecutionException | TimeoutException e2) {
            l.a(e2.getMessage());
            r0Var = null;
        }
        if (i0Var.z()) {
            i0Var.v();
        }
        if (r0Var == null || r0Var.c() != 200) {
            return;
        }
        try {
            String string = r0Var.b().getString("url");
            if (i0Var.u() != null) {
                this.linkCache_.put(i0Var.u(), string);
            }
        } catch (JSONException e3) {
            e3.printStackTrace();
        }
    }

    public final Context n() {
        return this.context_;
    }

    public final io.branch.referral.network.a p() {
        return this.branchRemoteInterface_;
    }

    public final Activity q() {
        WeakReference<Activity> weakReference = this.currentActivityReference_;
        if (weakReference == null) {
            return null;
        }
        return weakReference.get();
    }

    public final JSONObject r() {
        JSONObject jSONObject = this.deeplinkDebugParams_;
        if (jSONObject != null && jSONObject.length() > 0) {
            l.i("You're currently in deep link debug mode. Please comment out 'setDeepLinkDebugMode' to receive the deep link parameters from a real Branch link");
        }
        return this.deeplinkDebugParams_;
    }

    public final e0 s() {
        return this.deviceInfo_;
    }

    public final k0 t(b bVar, boolean z) {
        k0 p0Var;
        this.requestQueue_.getClass();
        if (u().prefHelper_.j().equals(f0.NO_STRING_VALUE)) {
            p0Var = new p0(this.context_, b0.RegisterInstall, z);
            p0Var.callback_ = bVar;
            try {
                p0Var.p(new JSONObject());
            } catch (JSONException e2) {
                com.quickblox.videochat.webrtc.b.C(e2, new StringBuilder("Caught JSONException "));
                p0Var.constructError_ = true;
            }
        } else {
            p0Var = new q0(this.context_, b0.RegisterOpen, z);
            p0Var.callback_ = bVar;
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put(y.RandomizedDeviceToken.getKey(), p0Var.prefHelper_.k());
                jSONObject.put(y.RandomizedBundleToken.getKey(), p0Var.prefHelper_.j());
                p0Var.p(jSONObject);
            } catch (JSONException e3) {
                com.quickblox.videochat.webrtc.b.C(e3, new StringBuilder("Caught JSONException "));
                p0Var.constructError_ = true;
            }
        }
        return p0Var;
    }

    public final JSONObject v() {
        JSONObject jSONObject;
        String q = this.prefHelper_.q("bnc_session_params");
        if (q.equals(f0.NO_STRING_VALUE)) {
            jSONObject = new JSONObject();
        } else {
            try {
                jSONObject = new JSONObject(q);
            } catch (JSONException unused) {
                byte[] bytes = q.getBytes();
                int length = bytes.length;
                b.C0032b c0032b = new b.C0032b(2, new byte[(length * 3) / 4]);
                if (!c0032b.a(length, bytes)) {
                    throw new IllegalArgumentException("bad base-64");
                }
                int i = c0032b.f14op;
                byte[] bArr = c0032b.output;
                if (i != bArr.length) {
                    byte[] bArr2 = new byte[i];
                    System.arraycopy(bArr, 0, bArr2, 0, i);
                    bArr = bArr2;
                }
                try {
                    jSONObject = new JSONObject(new String(bArr));
                } catch (JSONException e2) {
                    e2.printStackTrace();
                    jSONObject = new JSONObject();
                }
            }
        }
        try {
            JSONObject jSONObject2 = this.deeplinkDebugParams_;
            if (jSONObject2 != null) {
                if (jSONObject2.length() > 0) {
                    l.i("You're currently in deep link debug mode. Please comment out 'setDeepLinkDebugMode' to receive the deep link parameters from a real Branch link");
                }
                Iterator<String> keys = this.deeplinkDebugParams_.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    jSONObject.put(next, this.deeplinkDebugParams_.get(next));
                }
            }
        } catch (Exception e3) {
            l.a(e3.getMessage());
        }
        return jSONObject;
    }

    public final y0 y() {
        return this.trackingController;
    }
}