MD5 校验值:8df004f6dd2453bdf1d8ecd51cca1137
c.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package uf; 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.Bundle; import android.os.Handler; import android.text.TextUtils; import io.branch.referral.network.BranchRemoteInterface; import java.lang.ref.WeakReference; import java.util.Iterator; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import org.json.JSONException; import org.json.JSONObject; import uf.i0; import uf.y; public class c { static boolean A; static boolean B; private static c C; private static boolean D; static boolean E; private static final String[] F; public static String G; private static boolean H; private static String I; private static String J; private static final String f30204t; private static final String f30205u; static boolean f30206v; static String f30207w; private static boolean f30208x; static boolean f30209y; private static boolean f30210z; private JSONObject f30211a; final w f30213c; private final v f30214d; private final k f30215e; private final Context f30216f; private final m f30217g; public final d0 f30218h; WeakReference<Activity> f30223m; private uf.d f30227q; private final j0 f30228r; private g f30229s; final ConcurrentHashMap<uf.h, String> f30219i = new ConcurrentHashMap<>(); private f f30220j = f.PENDING; h f30221k = h.UNINITIALISED; public boolean f30222l = false; CountDownLatch f30224n = null; CountDownLatch f30225o = null; private boolean f30226p = false; private BranchRemoteInterface f30212b = new io.branch.referral.network.a(this); public class a implements Runnable { a() { } @Override public void run() { c.this.j0(); } } public class b implements i0.f { final y f30231a; b(y yVar) { this.f30231a = yVar; } @Override public void a() { this.f30231a.B(y.b.INSTALL_REFERRER_FETCH_WAIT_LOCK); c.this.f30218h.w("onInstallReferrersFinished"); } } public class C0602c implements i0.e { C0602c() { } @Override public void a() { c.this.f30218h.A(y.b.GAID_FETCH_WAIT_LOCK); c.this.f30218h.w("onAdsParamsFetchFinished"); } } public interface d { void a(JSONObject jSONObject, uf.f fVar); } public interface e { void a(sf.a aVar, vf.g gVar, uf.f fVar); } public enum f { PENDING, READY } public static class g { private d f30237a; private boolean f30238b; private int f30239c; private Uri f30240d; private Boolean f30241e; private boolean f30242f; g(Activity activity, a aVar) { this(activity); } private void a(g gVar) { c.L().f30229s = this; i.i("Session initialization deferred until plugin invokes notifyNativeToInit()\nCaching Session Builder " + c.L().f30229s + "\nuri: " + c.L().f30229s.f30240d + "\ncallback: " + c.L().f30229s.f30237a + "\nisReInitializing: " + c.L().f30229s.f30242f + "\ndelay: " + c.L().f30229s.f30239c + "\nisAutoInitialization: " + c.L().f30229s.f30238b + "\nignoreIntent: " + c.L().f30229s.f30241e); } public void b() { Intent intent; Uri uri; i.i("Beginning session initialization"); i.i("Session uri is " + this.f30240d); i.i("Callback is " + this.f30237a); i.i("Is auto init " + this.f30238b); i.i("Will ignore intent " + this.f30241e); i.i("Is reinitializing " + this.f30242f); if (c.E) { i.i("Session init is deferred until signaled by plugin."); a(this); return; } c L = c.L(); if (L == null) { i.d("Branch is not setup properly, make sure to call getAutoInstance in your application class or declare BranchApp in your manifest."); return; } Boolean bool = this.f30241e; if (bool != null) { c.j(bool.booleanValue()); } Activity F = L.F(); if (F != null) { intent = F.getIntent(); } else { intent = null; } if (F != null && intent != null && androidx.core.app.b.d(F) != null) { w.z(F).n0(androidx.core.app.b.d(F).toString()); } Uri uri2 = this.f30240d; if (uri2 != null) { L.h0(uri2, F); } else if (this.f30242f && L.c0(intent)) { if (intent != null) { uri = intent.getData(); } else { uri = null; } L.h0(uri, F); } else if (this.f30242f) { d dVar = this.f30237a; if (dVar != null) { dVar.a(null, new uf.f("", -119)); return; } return; } i.i("isInstantDeepLinkPossible " + L.f30226p); if (L.f30226p) { L.f30226p = false; d dVar2 = this.f30237a; if (dVar2 != null) { dVar2.a(L.M(), null); } c.L().f30218h.b(s.InstantDeepLinkSession.b(), "true"); L.k(); this.f30237a = null; } if (this.f30239c > 0) { c.w(true); } b0 K = L.K(this.f30237a, this.f30238b); i.a("Creating " + K + " from init on thread " + Thread.currentThread().getName()); L.V(K, this.f30239c); } public g c(boolean z10) { this.f30238b = z10; return this; } public void d() { this.f30242f = true; b(); } public g e(d dVar) { i.i("InitSessionBuilder setting BranchReferralInitListener withCallback with " + dVar); this.f30237a = dVar; return this; } public g f(e eVar) { i.i("InitSessionBuilder setting BranchUniversalReferralInitListener withCallback with " + eVar); this.f30237a = new n(eVar); return this; } public g g(Uri uri) { i.i("InitSessionBuilder setting withData with " + uri); this.f30240d = uri; return this; } private g(Activity activity) { c L = c.L(); if (activity != null) { if (L.F() == null || !L.F().getLocalClassName().equals(activity.getLocalClassName())) { L.f30223m = new WeakReference<>(activity); } } } } public enum h { INITIALISED, INITIALISING, UNINITIALISED } static { String str = "io.branch.sdk.android:library:" + Q(); f30204t = str; f30205u = "!SDK-VERSION-STRING!:" + str; f30207w = ""; f30209y = false; f30210z = false; B = false; D = false; E = false; F = new String[]{"extra_launch_uri", "branch_intent"}; G = null; H = false; I = null; J = null; } private c(Context context) { this.f30216f = context; this.f30213c = w.z(context); this.f30228r = new j0(context); this.f30214d = new v(context); this.f30215e = new k(context); this.f30217g = new m(context); this.f30218h = d0.h(context); } private void A(Uri uri, Activity activity) { i.i("extractExternalUriAndIntentExtras " + uri + " " + activity); try { if (!a0(activity)) { String e10 = k0.d(this.f30216f).e(uri.toString()); this.f30213c.k0(e10); if (e10.equals(uri.toString())) { Bundle extras = activity.getIntent().getExtras(); Set<String> keySet = extras.keySet(); if (keySet.isEmpty()) { return; } JSONObject jSONObject = new JSONObject(); for (String str : F) { if (keySet.contains(str)) { jSONObject.put(str, extras.get(str)); } } if (jSONObject.length() > 0) { this.f30213c.j0(jSONObject.toString()); } } } } catch (Exception e11) { i.a(e11.getMessage()); } } private void B(Uri uri, Activity activity) { if (activity != null && activity.getIntent() != null) { Intent intent = activity.getIntent(); if (uri != null) { try { if (!a0(activity)) { r rVar = r.BranchData; if (!TextUtils.isEmpty(intent.getStringExtra(rVar.b()))) { String stringExtra = intent.getStringExtra(rVar.b()); if (stringExtra != null) { JSONObject jSONObject = new JSONObject(stringExtra); jSONObject.put(s.Clicked_Branch_Link.b(), true); this.f30213c.B0(jSONObject.toString()); this.f30226p = true; } intent.removeExtra(rVar.b()); activity.setIntent(intent); return; } if (uri.isHierarchical() && Boolean.valueOf(uri.getQueryParameter(s.Instant.b())).booleanValue()) { JSONObject jSONObject2 = new JSONObject(); for (String str : uri.getQueryParameterNames()) { jSONObject2.put(str, uri.getQueryParameter(str)); } jSONObject2.put(s.Clicked_Branch_Link.b(), true); this.f30213c.B0(jSONObject2.toString()); this.f30226p = true; return; } return; } } catch (JSONException e10) { i.a(e10.getMessage()); return; } } if (!this.f30213c.y().equals("bnc_no_value")) { JSONObject jSONObject3 = new JSONObject(); jSONObject3.put(s.IsFirstSession.b(), false); this.f30213c.B0(jSONObject3.toString()); this.f30226p = true; } } } public static synchronized c D(Context context) { c cVar; synchronized (c.class) { try { if (C == null) { if (p.c(context)) { t(); } s(p.b(context)); p.g(p.a(context)); c T = T(context, p.e(context)); C = T; l.c(T, context); } cVar = C; } catch (Throwable th) { throw th; } } return cVar; } public static synchronized c L() { c cVar; synchronized (c.class) { try { if (C == null) { i.i("Branch instance is not created yet. Make sure you call getAutoInstance(Context)."); } cVar = C; } catch (Throwable th) { throw th; } } return cVar; } public static String N() { return J; } public static String O() { return I; } public static String Q() { return "5.10.0"; } private static synchronized c T(Context context, String str) { synchronized (c.class) { if (C != null) { i.j("Warning, attempted to reinitialize Branch SDK singleton!"); return C; } C = new c(context.getApplicationContext()); if (TextUtils.isEmpty(str)) { i.j("Warning: Please enter your branch_key in your project's Manifest file!"); C.f30213c.i0("bnc_no_value"); } else { C.f30213c.i0(str); } if (context instanceof Application) { C.l0((Application) context); } if (f30206v && v.e() != null) { v.e().h(context); } return C; } } private void U(y yVar, boolean z10) { i.i("initTasks " + yVar + " ignoreWaitLocks " + z10); if (!z10) { if (this.f30220j != f.READY && e0()) { i.i("Adding INTENT_PENDING_WAIT_LOCK"); yVar.b(y.b.INTENT_PENDING_WAIT_LOCK); } yVar.b(y.b.GAID_FETCH_WAIT_LOCK); if (yVar instanceof e0) { yVar.b(y.b.INSTALL_REFERRER_FETCH_WAIT_LOCK); this.f30214d.g().d(this.f30216f, new b(yVar)); } } this.f30214d.g().a(this.f30216f, new C0602c()); } public void V(b0 b0Var, int i10) { Intent intent; i.i("initializeSession " + b0Var + " delay " + i10); if (this.f30213c.n() != null && !this.f30213c.n().equalsIgnoreCase("bnc_no_value")) { if (p.d()) { i.j("Warning: You are using your test app's Branch Key. Remember to change it to live Branch Key during deployment."); } if (i10 > 0) { b0Var.b(y.b.USER_SET_WAIT_LOCK); new Handler().postDelayed(new a(), i10); } if (F() != null) { intent = F().getIntent(); } else { intent = null; } boolean c02 = c0(intent); h J2 = J(); i.i("Intent: " + intent + " forceBranchSession: " + c02 + " initState: " + J2); if (J2 != h.UNINITIALISED && !c02) { d dVar = b0Var.f30202k; if (dVar != null) { dVar.a(null, new uf.f("Warning.", -118)); return; } return; } if (c02 && intent != null) { intent.removeExtra(r.ForceNewBranchSession.b()); } i0(b0Var, false, c02); return; } n0(h.UNINITIALISED); d dVar2 = b0Var.f30202k; if (dVar2 != null) { dVar2.a(null, new uf.f("Trouble initializing Branch.", -114)); } i.j("Warning: Please enter your branch_key in your project's manifest"); } private boolean W(Activity activity) { if (activity != null && activity.getIntent() != null && (activity.getIntent().getFlags() & 1048576) != 0) { return true; } return false; } public static boolean X() { return f30208x; } private boolean a0(Activity activity) { boolean z10 = false; if (activity != null && activity.getIntent() != null && activity.getIntent().getBooleanExtra(r.BranchLinkUsed.b(), false)) { z10 = true; } i.i("isIntentParamsAlreadyConsumed " + z10); return z10; } public static boolean b0() { return B; } public static boolean e0() { return !f30209y; } private boolean g0(String str, String str2) { String[] split = str.split("\\?")[0].split("/"); String[] split2 = str2.split("\\?")[0].split("/"); if (split.length != split2.length) { return false; } for (int i10 = 0; i10 < split.length && i10 < split2.length; i10++) { String str3 = split[i10]; if (!str3.equals(split2[i10]) && !str3.contains("*")) { return false; } } return true; } private JSONObject h(JSONObject jSONObject) { if (jSONObject != null) { try { JSONObject jSONObject2 = this.f30211a; if (jSONObject2 != null) { if (jSONObject2.length() > 0) { i.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.f30211a.keys(); while (keys.hasNext()) { String next = keys.next(); jSONObject.put(next, this.f30211a.get(next)); } } } catch (Exception e10) { i.a(e10.getMessage()); } } return jSONObject; } public void h0(Uri uri, Activity activity) { boolean z10; Intent intent; i.i("Read params uri: " + uri + " bypassCurrentActivityIntentState: " + f30210z + " intent state: " + this.f30220j); if (H) { if (this.f30220j != f.READY && this.f30227q.a()) { z10 = false; } else { z10 = true; } if (activity != null) { intent = activity.getIntent(); } else { intent = null; } boolean z11 = !c0(intent); if (z10 && z11) { B(uri, activity); } } if (f30210z) { this.f30220j = f.READY; } if (this.f30220j == f.READY) { A(uri, activity); if (y(activity) || W(activity) || z(uri, activity)) { return; } x(uri, activity); } } public static boolean i() { return f30210z; } public static void j(boolean z10) { f30209y = z10; } public static g k0(Activity activity) { return new g(activity, null); } private boolean l(JSONObject jSONObject, ActivityInfo activityInfo) { if (activityInfo.metaData.getString("io.branch.sdk.auto_link_keys") != null) { for (String str : activityInfo.metaData.getString("io.branch.sdk.auto_link_keys").split(",")) { if (jSONObject.has(str)) { return true; } } } return false; } private void l0(Application application) { try { uf.d dVar = new uf.d(); this.f30227q = dVar; application.unregisterActivityLifecycleCallbacks(dVar); application.registerActivityLifecycleCallbacks(this.f30227q); D = true; } catch (NoClassDefFoundError | NoSuchMethodError unused) { D = false; i.i(new uf.f("", -108).a()); } } private boolean m(JSONObject jSONObject, ActivityInfo activityInfo) { String str = null; try { s sVar = s.AndroidDeepLinkPath; if (jSONObject.has(sVar.b())) { str = jSONObject.getString(sVar.b()); } else { s sVar2 = s.DeepLinkPath; if (jSONObject.has(sVar2.b())) { str = jSONObject.getString(sVar2.b()); } } } catch (JSONException e10) { i.a(e10.getMessage()); } if (activityInfo.metaData.getString("io.branch.sdk.auto_link_path") != null && str != null) { for (String str2 : activityInfo.metaData.getString("io.branch.sdk.auto_link_path").split(",")) { if (g0(str2.trim(), str)) { return true; } } } return false; } private boolean n(Intent intent) { if (intent == null) { return false; } return intent.getBooleanExtra(r.ForceNewBranchSession.b(), false); } private boolean o(Intent intent) { boolean z10; if (intent == null) { return false; } if (intent.getStringExtra(r.BranchURI.b()) != null) { z10 = true; } else { z10 = false; } boolean z11 = !intent.getBooleanExtra(r.BranchLinkUsed.b(), false); if (!z10 || !z11) { return false; } return true; } private JSONObject r(String str) { if (str.equals("bnc_no_value")) { return new JSONObject(); } try { return new JSONObject(str); } catch (JSONException unused) { try { return new JSONObject(new String(uf.b.a(str.getBytes(), 2))); } catch (JSONException e10) { e10.printStackTrace(); return new JSONObject(); } } } static void s(boolean z10) { i.i("deferInitForPluginRuntime " + z10); E = z10; if (z10) { w(z10); } } public static void t() { u(null); } public static void u(tf.a aVar) { i.e(aVar); i.d(f30205u); i.f(true); } private void v() { h hVar = this.f30221k; h hVar2 = h.UNINITIALISED; if (hVar != hVar2) { n0(hVar2); } } public static void w(boolean z10) { A = z10; } private void x(Uri uri, Activity activity) { if (uri != null && activity != null) { String scheme = uri.getScheme(); Intent intent = activity.getIntent(); if (scheme != null && intent != null) { if ((scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https")) && !TextUtils.isEmpty(uri.getHost()) && !a0(activity)) { if (uri.toString().equalsIgnoreCase(k0.d(this.f30216f).e(uri.toString()))) { this.f30213c.d0(uri.toString()); } intent.putExtra(r.BranchLinkUsed.b(), true); activity.setIntent(intent); } } } } private boolean y(Activity activity) { String str; i.i("extractBranchLinkFromIntentExtra " + activity); if (activity != null) { try { if (activity.getIntent() != null && activity.getIntent().getExtras() != null && !a0(activity)) { Object obj = activity.getIntent().getExtras().get(r.BranchURI.b()); if (obj instanceof String) { str = (String) obj; } else if (obj instanceof Uri) { str = ((Uri) obj).toString(); } else { str = null; } if (!TextUtils.isEmpty(str)) { this.f30213c.u0(str); Intent intent = activity.getIntent(); intent.putExtra(r.BranchLinkUsed.b(), true); activity.setIntent(intent); return true; } return false; } return false; } catch (Exception e10) { i.a(e10.getMessage()); return false; } } return false; } private boolean z(Uri uri, Activity activity) { String queryParameter; String str; if (uri != null) { try { if (!uri.isHierarchical() || (queryParameter = uri.getQueryParameter(s.LinkClickID.b())) == null) { return false; } this.f30213c.s0(queryParameter); String str2 = "link_click_id=" + queryParameter; String uri2 = uri.toString(); if (str2.equals(uri.getQuery())) { str = "\\?" + str2; } else if (uri2.length() - str2.length() == uri2.indexOf(str2)) { str = "&" + str2; } else { str = str2 + "&"; } activity.getIntent().setData(Uri.parse(uri2.replaceFirst(str, ""))); activity.getIntent().putExtra(r.BranchLinkUsed.b(), true); return true; } catch (Exception e10) { i.a(e10.getMessage()); } } return false; } public Context C() { return this.f30216f; } public BranchRemoteInterface E() { return this.f30212b; } public Activity F() { WeakReference<Activity> weakReference = this.f30223m; if (weakReference == null) { return null; } return weakReference.get(); } public JSONObject G() { JSONObject jSONObject = this.f30211a; if (jSONObject != null && jSONObject.length() > 0) { i.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.f30211a; } public v H() { return this.f30214d; } public JSONObject I() { return h(r(this.f30213c.y())); } public h J() { return this.f30221k; } b0 K(d dVar, boolean z10) { if (this.f30218h.n()) { return new f0(this.f30216f, dVar, z10); } return new e0(this.f30216f, dVar, z10); } public JSONObject M() { return h(r(this.f30213c.R())); } public w P() { return this.f30213c; } public h0 R() { return null; } public j0 S() { return this.f30228r; } public boolean Y() { return Boolean.parseBoolean(L().f30218h.f30256f.get(s.InstantDeepLinkSession.b())); } public boolean Z() { return this.f30226p; } boolean c0(Intent intent) { if (!n(intent) && !o(intent)) { return false; } return true; } public boolean d0() { return this.f30228r.a(); } public void f0(Activity activity) { i.i("onIntentReady " + activity + " removing INTENT_PENDING_WAIT_LOCK"); p0(f.READY); this.f30218h.A(y.b.INTENT_PENDING_WAIT_LOCK); if (activity.getIntent() != null && J() != h.INITIALISED) { h0(activity.getIntent().getData(), activity); } this.f30218h.w("onIntentReady"); } public c g(String str, String str2) { this.f30213c.a(str, str2); return this; } void i0(b0 b0Var, boolean z10, boolean z11) { i.i("registerAppInit " + b0Var); n0(h.INITIALISING); b0 i10 = this.f30218h.i(); i.i("Ordering init calls"); this.f30218h.v(); if (i10 != null && !z11) { i.i("Retrieved " + i10 + " with callback " + i10.f30202k + " in queue currently"); i10.f30202k = b0Var.f30202k; StringBuilder sb2 = new StringBuilder(); sb2.append(i10); sb2.append(" now has callback "); sb2.append(b0Var.f30202k); i.i(sb2.toString()); } else { i.i("Moving " + b0Var + " to front of the queue or behind network-in-progress request"); this.f30218h.p(b0Var); } i.i("Finished ordering init calls"); this.f30218h.v(); U(b0Var, z10); this.f30218h.w("registerAppInit"); } public void j0() { this.f30218h.A(y.b.USER_SET_WAIT_LOCK); this.f30218h.w("removeSessionInitializationDelay"); } public void k() { Bundle bundle; JSONObject M = M(); String str = null; try { s sVar = s.Clicked_Branch_Link; if (M.has(sVar.b()) && M.getBoolean(sVar.b())) { if (M.length() > 0) { Bundle bundle2 = this.f30216f.getPackageManager().getApplicationInfo(this.f30216f.getPackageName(), 128).metaData; if (bundle2 != null && bundle2.getBoolean("io.branch.sdk.auto_link_disable", false)) { return; } ActivityInfo[] activityInfoArr = this.f30216f.getPackageManager().getPackageInfo(this.f30216f.getPackageName(), 129).activities; int i10 = 1501; if (activityInfoArr != null) { for (ActivityInfo activityInfo : activityInfoArr) { if (activityInfo != null && (bundle = activityInfo.metaData) != null && ((bundle.getString("io.branch.sdk.auto_link_keys") != null || activityInfo.metaData.getString("io.branch.sdk.auto_link_path") != null) && (l(M, activityInfo) || m(M, activityInfo)))) { str = activityInfo.name; i10 = activityInfo.metaData.getInt("io.branch.sdk.auto_link_request_code", 1501); break; } } } if (str != null && F() != null) { i.i("deepLinkActivity " + str + " getCurrentActivity " + F()); Activity F2 = F(); Intent intent = new Intent(F2, Class.forName(str)); intent.putExtra(r.AutoDeepLinked.b(), "true"); intent.putExtra(s.ReferringData.b(), M.toString()); Iterator<String> keys = M.keys(); while (keys.hasNext()) { String next = keys.next(); intent.putExtra(next, M.getString(next)); } F2.startActivityForResult(intent, i10); return; } i.i("No activity reference to launch deep linked activity"); return; } return; } i.i("Does not have Clicked_Branch_Link or Clicked_Branch_Link is false, returning"); } catch (PackageManager.NameNotFoundException unused) { i.j("Warning: Please make sure Activity names set for auto deep link are correct!"); } catch (ClassNotFoundException unused2) { i.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 void m0(String str, d dVar) { if (str != null && !str.equals(this.f30213c.u())) { G = str; this.f30213c.m0(str); } if (dVar != null) { dVar.a(I(), null); } } public void n0(h hVar) { this.f30221k = hVar; } public void o0(boolean z10) { this.f30226p = z10; } public void p() { this.f30213c.f30463f.b(); } public void p0(f fVar) { this.f30220j = fVar; } public void q() { p(); v(); this.f30213c.B0("bnc_no_value"); this.f30213c.k0(null); this.f30228r.b(this.f30216f); } public c q0(String str) { g(t.campaign.b(), str); return this; } public c r0(String str) { g(t.partner.b(), str); return this; } public void s0(String str, String str2) { this.f30213c.z0(str, str2); } public void t0() { d0 d0Var = this.f30218h; if (d0Var == null) { return; } d0Var.u(); this.f30218h.A(y.b.SDK_INIT_WAIT_LOCK); this.f30218h.w("unlockSDKInitWaitLock"); } public void u0() { k0.d(this.f30216f).c(this.f30216f); } }