GASPROM v1.3版本的 MD5 值为:f0a086ce6a5c1d2f9ed306efacaf2e90

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


package b.d.c.s;

import android.net.TrafficStats;
import android.text.TextUtils;
import android.util.Log;
import b.d.c.s.i;
import b.d.c.s.q.a;
import b.d.c.s.q.c;
import b.d.c.s.q.d;
import b.d.c.s.r.b;
import b.d.c.s.r.d;
import b.d.c.s.r.f;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import org.json.JSONException;
import org.json.JSONObject;

public class g implements h {
    public static final Object m = new Object();
    public static final ThreadFactory n = new a();
    public final b.d.c.g a;

    public final b.d.c.s.r.c f2131b;

    public final b.d.c.s.q.c f2132c;

    public final o f2133d;

    public final b.d.c.s.q.b f2134e;

    public final m f2135f;

    public final Object f2136g;

    public final ExecutorService f2137h;

    public final ExecutorService f2138i;

    public String f2139j;

    public Set<b.d.c.s.p.a> f2140k;
    public final List<n> l;

    public class a implements ThreadFactory {
        public final AtomicInteger a = new AtomicInteger(1);

        @Override
        public Thread newThread(Runnable runnable) {
            return new Thread(runnable, String.format("firebase-installations-executor-%d", Integer.valueOf(this.a.getAndIncrement())));
        }
    }

    public g(b.d.c.g gVar, b.d.c.r.b<b.d.c.v.h> bVar, b.d.c.r.b<b.d.c.p.f> bVar2) {
        TimeUnit timeUnit = TimeUnit.SECONDS;
        LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue();
        ThreadFactory threadFactory = n;
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 30L, timeUnit, linkedBlockingQueue, threadFactory);
        gVar.a();
        b.d.c.s.r.c cVar = new b.d.c.s.r.c(gVar.a, bVar, bVar2);
        b.d.c.s.q.c cVar2 = new b.d.c.s.q.c(gVar);
        o c2 = o.c();
        b.d.c.s.q.b bVar3 = new b.d.c.s.q.b(gVar);
        m mVar = new m();
        this.f2136g = new Object();
        this.f2140k = new HashSet();
        this.l = new ArrayList();
        this.a = gVar;
        this.f2131b = cVar;
        this.f2132c = cVar2;
        this.f2133d = c2;
        this.f2134e = bVar3;
        this.f2135f = mVar;
        this.f2137h = threadPoolExecutor;
        this.f2138i = new ThreadPoolExecutor(0, 1, 30L, timeUnit, new LinkedBlockingQueue(), threadFactory);
    }

    public static g f(b.d.c.g gVar) {
        b.d.a.d.d.a.e(true, "Null is not a valid value of FirebaseApp.");
        gVar.a();
        return (g) gVar.f2059d.a(h.class);
    }

    @Override
    public b.d.a.d.k.i<l> a(final boolean z) {
        h();
        b.d.a.d.k.j jVar = new b.d.a.d.k.j();
        j jVar2 = new j(this.f2133d, jVar);
        synchronized (this.f2136g) {
            this.l.add(jVar2);
        }
        b.d.a.d.k.i iVar = jVar.a;
        this.f2137h.execute(new Runnable() {
            @Override
            public final void run() {
                g.this.b(z);
            }
        });
        return iVar;
    }

    public final void b(final boolean z) {
        b.d.c.s.q.d b2;
        synchronized (m) {
            b.d.c.g gVar = this.a;
            gVar.a();
            f a2 = f.a(gVar.a, "generatefid.lock");
            try {
                b2 = this.f2132c.b();
                if (b2.i()) {
                    String i2 = i(b2);
                    b.d.c.s.q.c cVar = this.f2132c;
                    a.b bVar = (a.b) b2.k();
                    bVar.a = i2;
                    bVar.b(c.a.UNREGISTERED);
                    b2 = bVar.a();
                    cVar.a(b2);
                }
            } finally {
                if (a2 != null) {
                    a2.b();
                }
            }
        }
        if (z) {
            a.b bVar2 = (a.b) b2.k();
            bVar2.f2157c = null;
            b2 = bVar2.a();
        }
        l(b2);
        this.f2138i.execute(new Runnable() {
            @Override
            public final void run() {
                f a3;
                b.d.c.s.q.d b3;
                b.d.c.s.q.d j2;
                g gVar2 = g.this;
                boolean z2 = z;
                Objects.requireNonNull(gVar2);
                Object obj = g.m;
                synchronized (obj) {
                    b.d.c.g gVar3 = gVar2.a;
                    gVar3.a();
                    a3 = f.a(gVar3.a, "generatefid.lock");
                    try {
                        b3 = gVar2.f2132c.b();
                    } finally {
                        if (a3 != null) {
                            a3.b();
                        }
                    }
                }
                try {
                } catch (i e2) {
                    e = e2;
                }
                if (!b3.h()) {
                    if (!(b3.f() == c.a.UNREGISTERED)) {
                        if (z2 || gVar2.f2133d.d(b3)) {
                            j2 = gVar2.c(b3);
                            synchronized (obj) {
                                b.d.c.g gVar4 = gVar2.a;
                                gVar4.a();
                                a3 = f.a(gVar4.a, "generatefid.lock");
                                try {
                                    gVar2.f2132c.a(j2);
                                    if (a3 != null) {
                                        a3.b();
                                    }
                                } finally {
                                    if (a3 != null) {
                                        a3.b();
                                    }
                                }
                            }
                            synchronized (gVar2) {
                                if (gVar2.f2140k.size() != 0 && !b3.c().equals(j2.c())) {
                                    Iterator<b.d.c.s.p.a> it = gVar2.f2140k.iterator();
                                    while (it.hasNext()) {
                                        it.next().a(j2.c());
                                    }
                                }
                            }
                            if (j2.j()) {
                                String str = ((b.d.c.s.q.a) j2).f2149b;
                                synchronized (gVar2) {
                                    gVar2.f2139j = str;
                                }
                            }
                            if (j2.h()) {
                                e = new i(i.a.BAD_CONFIG);
                            } else {
                                if (!j2.i()) {
                                    gVar2.l(j2);
                                    return;
                                }
                                e = new IOException("Installation ID could not be validated with the Firebase servers (maybe it was deleted). Firebase Installations will need to create a new Installation ID and auth token. Please retry your last request.");
                            }
                            gVar2.k(e);
                            return;
                        }
                        return;
                    }
                }
                j2 = gVar2.j(b3);
                synchronized (obj) {
                }
            }
        });
    }

    public final b.d.c.s.q.d c(b.d.c.s.q.d dVar) {
        int responseCode;
        b.d.c.s.r.f f2;
        f.a a2;
        f.b bVar;
        i.a aVar = i.a.UNAVAILABLE;
        b.d.c.s.r.c cVar = this.f2131b;
        String d2 = d();
        b.d.c.s.q.a aVar2 = (b.d.c.s.q.a) dVar;
        String str = aVar2.f2149b;
        String g2 = g();
        String str2 = aVar2.f2152e;
        if (!cVar.f2182d.a()) {
            throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
        }
        URL a3 = cVar.a(String.format("projects/%s/installations/%s/authTokens:generate", g2, str));
        for (int i2 = 0; i2 <= 1; i2++) {
            TrafficStats.setThreadStatsTag(32771);
            HttpURLConnection c2 = cVar.c(a3, d2);
            try {
                c2.setRequestMethod("POST");
                c2.addRequestProperty("Authorization", "FIS_v2 " + str2);
                c2.setDoOutput(true);
                cVar.h(c2);
                responseCode = c2.getResponseCode();
                cVar.f2182d.b(responseCode);
            } catch (IOException | AssertionError unused) {
            } catch (Throwable th) {
                c2.disconnect();
                TrafficStats.clearThreadStatsTag();
                throw th;
            }
            if (responseCode >= 200 && responseCode < 300) {
                f2 = cVar.f(c2);
            } else {
                b.d.c.s.r.c.b(c2, null, d2, g2);
                if (responseCode != 401 && responseCode != 404) {
                    if (responseCode == 429) {
                        throw new i("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", i.a.TOO_MANY_REQUESTS);
                    }
                    if (responseCode < 500 || responseCode >= 600) {
                        Log.e("Firebase-Installations", "Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.");
                        a2 = b.d.c.s.r.f.a();
                        bVar = f.b.BAD_CONFIG;
                        b.C0033b c0033b = (b.C0033b) a2;
                        c0033b.f2177c = bVar;
                        f2 = c0033b.a();
                    } else {
                        c2.disconnect();
                        TrafficStats.clearThreadStatsTag();
                    }
                }
                a2 = b.d.c.s.r.f.a();
                bVar = f.b.AUTH_ERROR;
                b.C0033b c0033b2 = (b.C0033b) a2;
                c0033b2.f2177c = bVar;
                f2 = c0033b2.a();
            }
            c2.disconnect();
            TrafficStats.clearThreadStatsTag();
            b.d.c.s.r.b bVar2 = (b.d.c.s.r.b) f2;
            int ordinal = bVar2.f2175c.ordinal();
            if (ordinal == 0) {
                String str3 = bVar2.a;
                long j2 = bVar2.f2174b;
                long b2 = this.f2133d.b();
                a.b bVar3 = (a.b) dVar.k();
                bVar3.f2157c = str3;
                bVar3.f2159e = Long.valueOf(j2);
                bVar3.f2160f = Long.valueOf(b2);
                return bVar3.a();
            }
            if (ordinal == 1) {
                a.b bVar4 = (a.b) dVar.k();
                bVar4.f2161g = "BAD CONFIG";
                bVar4.b(c.a.REGISTER_ERROR);
                return bVar4.a();
            }
            if (ordinal == 2) {
                synchronized (this) {
                    this.f2139j = null;
                }
                d.a k2 = dVar.k();
                k2.b(c.a.NOT_GENERATED);
                return k2.a();
            }
            throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
        }
        throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
    }

    public String d() {
        b.d.c.g gVar = this.a;
        gVar.a();
        return gVar.f2058c.a;
    }

    public String e() {
        b.d.c.g gVar = this.a;
        gVar.a();
        return gVar.f2058c.f2065b;
    }

    public String g() {
        b.d.c.g gVar = this.a;
        gVar.a();
        return gVar.f2058c.f2070g;
    }

    @Override
    public b.d.a.d.k.i<String> getId() {
        String str;
        h();
        synchronized (this) {
            str = this.f2139j;
        }
        if (str != null) {
            return b.d.a.d.d.a.x(str);
        }
        b.d.a.d.k.j jVar = new b.d.a.d.k.j();
        k kVar = new k(jVar);
        synchronized (this.f2136g) {
            this.l.add(kVar);
        }
        b.d.a.d.k.i iVar = jVar.a;
        this.f2137h.execute(new Runnable() {
            @Override
            public final void run() {
                g.this.b(false);
            }
        });
        return iVar;
    }

    public final void h() {
        b.d.a.d.d.a.i(e(), "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
        b.d.a.d.d.a.i(g(), "Please set your Project ID. A valid Firebase Project ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
        b.d.a.d.d.a.i(d(), "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.Please refer to https://firebase.google.com/support/privacy/init-options.");
        String e2 = e();
        Pattern pattern = o.f2147c;
        b.d.a.d.d.a.e(e2.contains(":"), "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
        b.d.a.d.d.a.e(o.f2147c.matcher(d()).matches(), "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.Please refer to https://firebase.google.com/support/privacy/init-options.");
    }

    public final String i(b.d.c.s.q.d dVar) {
        String string;
        b.d.c.g gVar = this.a;
        gVar.a();
        if (!gVar.f2057b.equals("CHIME_ANDROID_SDK")) {
            b.d.c.g gVar2 = this.a;
            gVar2.a();
        }
        if (((b.d.c.s.q.a) dVar).f2150c == c.a.ATTEMPT_MIGRATION) {
            b.d.c.s.q.b bVar = this.f2134e;
            synchronized (bVar.a) {
                synchronized (bVar.a) {
                    string = bVar.a.getString("|S|id", null);
                }
                if (string == null) {
                    string = bVar.a();
                }
            }
            return TextUtils.isEmpty(string) ? this.f2135f.a() : string;
        }
        return this.f2135f.a();
    }

    public final b.d.c.s.q.d j(b.d.c.s.q.d dVar) {
        int responseCode;
        b.d.c.s.r.d e2;
        i.a aVar = i.a.UNAVAILABLE;
        b.d.c.s.q.a aVar2 = (b.d.c.s.q.a) dVar;
        String str = aVar2.f2149b;
        String str2 = null;
        if (str != null && str.length() == 11) {
            b.d.c.s.q.b bVar = this.f2134e;
            synchronized (bVar.a) {
                String[] strArr = b.d.c.s.q.b.f2162c;
                int length = strArr.length;
                int i2 = 0;
                while (true) {
                    if (i2 >= length) {
                        break;
                    }
                    String str3 = strArr[i2];
                    String string = bVar.a.getString("|T|" + bVar.f2163b + "|" + str3, null);
                    if (string == null || string.isEmpty()) {
                        i2++;
                    } else if (string.startsWith("{")) {
                        try {
                            str2 = new JSONObject(string).getString("token");
                        } catch (JSONException unused) {
                        }
                    } else {
                        str2 = string;
                    }
                }
            }
        }
        b.d.c.s.r.c cVar = this.f2131b;
        String d2 = d();
        String str4 = aVar2.f2149b;
        String g2 = g();
        String e3 = e();
        if (!cVar.f2182d.a()) {
            throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
        }
        URL a2 = cVar.a(String.format("projects/%s/installations", g2));
        for (int i3 = 0; i3 <= 1; i3++) {
            TrafficStats.setThreadStatsTag(32769);
            HttpURLConnection c2 = cVar.c(a2, d2);
            try {
                try {
                    c2.setRequestMethod("POST");
                    c2.setDoOutput(true);
                    if (str2 != null) {
                        c2.addRequestProperty("x-goog-fis-android-iid-migration-auth", str2);
                    }
                    cVar.g(c2, str4, e3);
                    responseCode = c2.getResponseCode();
                    cVar.f2182d.b(responseCode);
                } catch (IOException | AssertionError unused2) {
                }
                if (responseCode >= 200 && responseCode < 300) {
                    e2 = cVar.e(c2);
                } else {
                    b.d.c.s.r.c.b(c2, e3, d2, g2);
                    if (responseCode == 429) {
                        throw new i("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", i.a.TOO_MANY_REQUESTS);
                    }
                    if (responseCode < 500 || responseCode >= 600) {
                        Log.e("Firebase-Installations", "Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.");
                        b.d.c.s.r.a aVar3 = new b.d.c.s.r.a(null, null, null, null, d.a.BAD_CONFIG, null);
                        c2.disconnect();
                        TrafficStats.clearThreadStatsTag();
                        e2 = aVar3;
                    } else {
                        c2.disconnect();
                        TrafficStats.clearThreadStatsTag();
                    }
                }
                b.d.c.s.r.a aVar4 = (b.d.c.s.r.a) e2;
                int ordinal = aVar4.f2173e.ordinal();
                if (ordinal != 0) {
                    if (ordinal == 1) {
                        a.b bVar2 = (a.b) dVar.k();
                        bVar2.f2161g = "BAD CONFIG";
                        bVar2.b(c.a.REGISTER_ERROR);
                        return bVar2.a();
                    }
                    throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
                }
                String str5 = aVar4.f2170b;
                String str6 = aVar4.f2171c;
                long b2 = this.f2133d.b();
                String c3 = aVar4.f2172d.c();
                long d3 = aVar4.f2172d.d();
                a.b bVar3 = (a.b) dVar.k();
                bVar3.a = str5;
                bVar3.b(c.a.REGISTERED);
                bVar3.f2157c = c3;
                bVar3.f2158d = str6;
                bVar3.f2159e = Long.valueOf(d3);
                bVar3.f2160f = Long.valueOf(b2);
                return bVar3.a();
            } finally {
                c2.disconnect();
                TrafficStats.clearThreadStatsTag();
            }
        }
        throw new i("Firebase Installations Service is unavailable. Please try again later.", aVar);
    }

    public final void k(Exception exc) {
        synchronized (this.f2136g) {
            Iterator<n> it = this.l.iterator();
            while (it.hasNext()) {
                if (it.next().a(exc)) {
                    it.remove();
                }
            }
        }
    }

    public final void l(b.d.c.s.q.d dVar) {
        synchronized (this.f2136g) {
            Iterator<n> it = this.l.iterator();
            while (it.hasNext()) {
                if (it.next().b(dVar)) {
                    it.remove();
                }
            }
        }
    }
}