MD5 校验值:5ef3f775189f42f146cf0788a99eebd7
AuthUI.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.firebase.ui.auth; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import c4.j; import com.facebook.login.LoginManager; import com.firebase.ui.auth.data.model.FlowParameters; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.tasks.Continuation; import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Tasks; import com.google.firebase.auth.ActionCodeSettings; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.e; import j4.g; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Set; public final class AuthUI { public static final Set<String> f8061e = Collections.unmodifiableSet(new HashSet(Arrays.asList("google.com", "facebook.com", "twitter.com", "github.com", "password", "phone", "anonymous", "emailLink"))); public static final Set<String> f8062f = Collections.unmodifiableSet(new HashSet(Arrays.asList("microsoft.com", "yahoo.com", "apple.com", "twitter.com", "github.com"))); public static final Set<String> f8063g = Collections.unmodifiableSet(new HashSet(Arrays.asList("google.com", "facebook.com"))); private static final IdentityHashMap<e, AuthUI> f8064h = new IdentityHashMap<>(); private static Context f8065i; private final e f8066a; private final FirebaseAuth f8067b; private String f8068c = null; private int f8069d = -1; public static final class IdpConfig implements Parcelable { public static final Parcelable.Creator<IdpConfig> CREATOR = new a(); private final String f8070a; private final Bundle f8071b; static class a implements Parcelable.Creator<IdpConfig> { a() { } @Override public IdpConfig createFromParcel(Parcel parcel) { return new IdpConfig(parcel, (com.firebase.ui.auth.a) null); } @Override public IdpConfig[] newArray(int i10) { return new IdpConfig[i10]; } } public static class b { private final Bundle f8072a = new Bundle(); private String f8073b; protected b(String str) { if (AuthUI.f8061e.contains(str) || AuthUI.f8062f.contains(str)) { this.f8073b = str; return; } throw new IllegalArgumentException("Unknown provider: " + str); } public IdpConfig b() { return new IdpConfig(this.f8073b, this.f8072a, null); } protected final Bundle c() { return this.f8072a; } } public static final class c extends b { public c() { super("password"); } @Override public IdpConfig b() { if (((b) this).f8073b.equals("emailLink")) { ActionCodeSettings actionCodeSettings = (ActionCodeSettings) c().getParcelable("action_code_settings"); i4.c.a(actionCodeSettings, "ActionCodeSettings cannot be null when using email link sign in.", new Object[0]); if (!actionCodeSettings.z0()) { throw new IllegalStateException("You must set canHandleCodeInApp in your ActionCodeSettings to true for Email-Link Sign-in."); } } return super.b(); } } public static class d extends b { public d(String str, String str2, int i10) { super(str); i4.c.a(str, "The provider ID cannot be null.", new Object[0]); i4.c.a(str2, "The provider name cannot be null.", new Object[0]); c().putString("generic_oauth_provider_id", str); c().putString("generic_oauth_provider_name", str2); c().putInt("generic_oauth_button_id", i10); } } public static final class e extends b { public e() { super("phone"); } private boolean d(List<String> list, String str) { String upperCase = str.toUpperCase(Locale.getDefault()); for (String str2 : list) { if (j4.e.q(str2)) { if (str2.equals(upperCase)) { return true; } } else if (j4.e.h(str2).contains(upperCase)) { return true; } } return false; } private String e() { if (c().containsKey("extra_country_iso")) { return c().getString("extra_country_iso"); } return null; } private List<String> f() { ArrayList arrayList = new ArrayList(); String string = c().getString("extra_phone_number"); if (string != null && string.startsWith("+")) { List<String> h10 = j4.e.h("+" + j4.e.l(string).a()); if (h10 != null) { arrayList.addAll(h10); } } return arrayList; } private boolean g(List<String> list, String str, boolean z10) { if (str == null) { return true; } boolean d10 = d(list, str); if (d10 && z10) { return true; } return (d10 || z10) ? false : true; } private void h(List<String> list) { for (String str : list) { if (!j4.e.q(str) && !j4.e.p(str)) { throw new IllegalArgumentException("Invalid input: You must provide a valid country iso (alpha-2) or code (e-164). e.g. 'us' or '+1'."); } } } private void i(List<String> list, boolean z10) { if (c().containsKey("extra_country_iso") || c().containsKey("extra_phone_number")) { if (!j(list, z10) || !k(list, z10)) { throw new IllegalArgumentException("Invalid default country iso. Make sure it is either part of the allowed list or that you haven't blocked it."); } } } private boolean j(List<String> list, boolean z10) { return g(list, e(), z10); } private boolean k(List<String> list, boolean z10) { List<String> f10 = f(); Iterator<String> it = f10.iterator(); while (it.hasNext()) { if (g(list, it.next(), z10)) { return true; } } return f10.isEmpty(); } private void l() { ArrayList<String> stringArrayList = c().getStringArrayList("allowlisted_countries"); ArrayList<String> stringArrayList2 = c().getStringArrayList("blocklisted_countries"); if (stringArrayList != null && stringArrayList2 != null) { throw new IllegalStateException("You can either allowlist or blocked country codes for phone authentication."); } if (stringArrayList != null) { m(stringArrayList, true); } else if (stringArrayList2 != null) { m(stringArrayList2, false); } } private void m(List<String> list, boolean z10) { h(list); i(list, z10); } @Override public IdpConfig b() { l(); return super.b(); } } private IdpConfig(Parcel parcel) { this.f8070a = parcel.readString(); this.f8071b = parcel.readBundle(IdpConfig.class.getClassLoader()); } IdpConfig(Parcel parcel, com.firebase.ui.auth.a aVar) { this(parcel); } private IdpConfig(String str, Bundle bundle) { this.f8070a = str; this.f8071b = new Bundle(bundle); } IdpConfig(String str, Bundle bundle, com.firebase.ui.auth.a aVar) { this(str, bundle); } public Bundle a() { return new Bundle(this.f8071b); } public String b() { return this.f8070a; } @Override public int describeContents() { return 0; } public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || IdpConfig.class != obj.getClass()) { return false; } return this.f8070a.equals(((IdpConfig) obj).f8070a); } public final int hashCode() { return this.f8070a.hashCode(); } public String toString() { return "IdpConfig{mProviderId='" + this.f8070a + "', mParams=" + this.f8071b + '}'; } @Override public void writeToParcel(Parcel parcel, int i10) { parcel.writeString(this.f8070a); parcel.writeBundle(this.f8071b); } } class a implements Continuation<Void, Void> { a() { } @Override public Void then(Task<Void> task) { Exception exception = task.getException(); if (!(exception instanceof ApiException) || ((ApiException) exception).getStatusCode() != 16) { return task.getResult(); } Log.w("AuthUI", "Could not disable auto-sign in, maybe there are no SmartLock accounts available?", exception); return null; } } class b implements Continuation<Void, Void> { b() { } @Override public Void then(Task<Void> task) { task.getResult(); AuthUI.this.f8067b.u(); return null; } } private abstract class c<T extends c> { final List<IdpConfig> f8076a; IdpConfig f8077b; int f8078c; int f8079d; String f8080e; String f8081f; boolean f8082g; boolean f8083h; boolean f8084i; boolean f8085j; AuthMethodPickerLayout f8086k; ActionCodeSettings f8087l; private c() { this.f8076a = new ArrayList(); this.f8077b = null; this.f8078c = -1; this.f8079d = AuthUI.g(); this.f8082g = false; this.f8083h = false; this.f8084i = true; this.f8085j = true; this.f8086k = null; this.f8087l = null; } c(AuthUI authUI, com.firebase.ui.auth.a aVar) { this(); } public Intent a() { if (this.f8076a.isEmpty()) { this.f8076a.add(new IdpConfig.c().b()); } return KickoffActivity.z0(AuthUI.this.f8066a.k(), b()); } protected abstract FlowParameters b(); public T c(List<IdpConfig> list) { i4.c.a(list, "idpConfigs cannot be null", new Object[0]); if (list.size() == 1 && list.get(0).b().equals("anonymous")) { throw new IllegalStateException("Sign in as guest cannot be the only sign in method. In this case, sign the user in anonymously your self; no UI is needed."); } this.f8076a.clear(); for (IdpConfig idpConfig : list) { if (this.f8076a.contains(idpConfig)) { throw new IllegalArgumentException("Each provider can only be set once. " + idpConfig.b() + " was set twice."); } this.f8076a.add(idpConfig); } return this; } public T d(int i10) { this.f8078c = i10; return this; } public T e(String str, String str2) { i4.c.a(str, "tosUrl cannot be null", new Object[0]); i4.c.a(str2, "privacyPolicyUrl cannot be null", new Object[0]); this.f8080e = str; this.f8081f = str2; return this; } } public final class d extends c<d> { private String f8089n; private boolean f8090o; private d() { super(AuthUI.this, null); } d(AuthUI authUI, com.firebase.ui.auth.a aVar) { this(); } @Override public Intent a() { return super.a(); } @Override protected FlowParameters b() { return new FlowParameters(AuthUI.this.f8066a.n(), this.f8076a, this.f8077b, this.f8079d, this.f8078c, this.f8080e, this.f8081f, this.f8084i, this.f8085j, this.f8090o, this.f8082g, this.f8083h, this.f8089n, this.f8087l, this.f8086k); } @Override public d c(List list) { return super.c(list); } @Override public d d(int i10) { return super.d(i10); } @Override public d e(String str, String str2) { return super.e(str, str2); } } private AuthUI(e eVar) { this.f8066a = eVar; FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(eVar); this.f8067b = firebaseAuth; try { firebaseAuth.p("7.2.0"); } catch (Exception e10) { Log.e("AuthUI", "Couldn't set the FUI version.", e10); } this.f8067b.w(); } public static Context e() { return f8065i; } public static int g() { return j.FirebaseUI; } public static AuthUI j() { return k(e.l()); } public static AuthUI k(e eVar) { AuthUI authUI; if (g.f31808c) { Log.w("AuthUI", String.format("Beginning with FirebaseUI 6.2.0 you no longer need to include %s to sign in with %s. Go to %s for more information", "the TwitterKit SDK", "Twitter", "https://github.com/firebase/FirebaseUI-Android/releases/tag/6.2.0")); } if (g.f31806a) { Log.w("AuthUI", String.format("Beginning with FirebaseUI 6.2.0 you no longer need to include %s to sign in with %s. Go to %s for more information", "com.firebaseui:firebase-ui-auth-github", "GitHub", "https://github.com/firebase/FirebaseUI-Android/releases/tag/6.2.0")); } IdentityHashMap<e, AuthUI> identityHashMap = f8064h; synchronized (identityHashMap) { authUI = identityHashMap.get(eVar); if (authUI == null) { authUI = new AuthUI(eVar); identityHashMap.put(eVar, authUI); } } return authUI; } public static AuthUI l(String str) { return k(e.m(str)); } public static void n(Context context) { f8065i = ((Context) i4.c.a(context, "App context cannot be null.", new Object[0])).getApplicationContext(); } private Task<Void> p(Context context) { if (g.f31807b) { LoginManager.getInstance().logOut(); } return i4.b.b(context) ? com.google.android.gms.auth.api.signin.a.a(context, GoogleSignInOptions.f9148z).v() : Tasks.forResult(null); } public d c() { return new d(this, null); } public e d() { return this.f8066a; } public FirebaseAuth f() { return this.f8067b; } public String h() { return this.f8068c; } public int i() { return this.f8069d; } public boolean m() { return this.f8068c != null && this.f8069d >= 0; } public Task<Void> o(Context context) { boolean b10 = i4.b.b(context); if (!b10) { Log.w("AuthUI", "Google Play services not available during signOut"); } Task<Void> u10 = b10 ? i4.b.a(context).u() : Tasks.forResult(null); u10.continueWith(new a()); return Tasks.whenAll((Task<?>[]) new Task[]{p(context), u10}).continueWith(new b()); } }