50度灰 v5.8.2版本的 MD5 值为:9fe3d350fdc75fa1a3ec45509fa0107e

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


package com.flurry.sdk;

import android.content.SharedPreferences;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Pair;
import com.flurry.android.FlurryConfigListener;
import com.flurry.sdk.b;
import com.flurry.sdk.g;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONObject;
public class d {
    private static final String f2961b = "d";
    private static volatile d f2962c;
    private static final Object j = new Object();
    private static n o;
    public e f2963a;
    private com.flurry.sdk.a f2964d;
    private h f2965e;
    private m f2966f;
    private s f2967g;
    private final Map<FlurryConfigListener, Pair<j, WeakReference<Handler>>> h;
    private final Map<j, Pair<Boolean, Boolean>> i;
    private volatile boolean k;
    private volatile boolean l;
    private volatile boolean m;
    private a n;

    static class AnonymousClass5 {
        static final int[] f2976a;

        static {
            int[] iArr = new int[a.values().length];
            f2976a = iArr;
            try {
                iArr[a.None.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f2976a[a.Complete.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f2976a[a.CompleteNoChange.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f2976a[a.Fail.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    public enum a {
        Complete("Complete", 3),
        CompleteNoChange("No Change", 2),
        Fail("Fail", 1),
        None("None", 0);
        
        int f2982e;
        private String f2983f;

        a(String str, int i) {
            this.f2983f = str;
            this.f2982e = i;
        }

        @Override
        public final String toString() {
            return this.f2983f;
        }
    }

    private d() {
        this((byte) 0);
    }

    static boolean e(d dVar) {
        dVar.l = false;
        return false;
    }

    static boolean f(d dVar) {
        dVar.m = true;
        return true;
    }

    private void i() {
        synchronized (j) {
            while (!this.k) {
                try {
                    j.wait();
                } catch (InterruptedException e2) {
                    db.a(f2961b, "Interrupted Exception!", e2);
                }
            }
        }
    }

    public final com.flurry.sdk.a c() {
        if (this.f2964d == null) {
            i();
            this.f2964d = new com.flurry.sdk.a(this.f2965e, this.f2966f);
        }
        return this.f2964d;
    }

    public String toString() {
        i();
        ArrayList arrayList = new ArrayList();
        List<l> f2 = f();
        if (f2 == null || f2.isEmpty()) {
            return "No variants were found!";
        }
        for (l lVar : f2) {
            arrayList.add(lVar.toString());
        }
        return TextUtils.join(",", arrayList);
    }

    private d(byte b2) {
        this.h = new ConcurrentHashMap();
        this.i = new HashMap();
        this.k = false;
        this.l = false;
        this.m = false;
        this.n = a.None;
        o = null;
        for (j jVar : j.a()) {
            Map<j, Pair<Boolean, Boolean>> map = this.i;
            Boolean bool = Boolean.FALSE;
            map.put(jVar, new Pair<>(bool, bool));
        }
        this.f2965e = new h();
        this.f2966f = new m();
        this.f2963a = new e();
        this.f2967g = new s();
        r.a(new Runnable() {
            @Override
            public final void run() {
                try {
                    try {
                        String b3 = t.b(ck.a().f2892a);
                        db.a(d.f2961b, "Cached Data: ".concat(String.valueOf(b3)));
                        if (b3 != null) {
                            String d2 = d.this.f2963a.d();
                            SharedPreferences sharedPreferences = d.this.f2963a.f3092b;
                            if (t.a(d2, b3, sharedPreferences != null ? sharedPreferences.getString("lastRSA", null) : null)) {
                                m mVar = d.this.f2966f;
                                try {
                                    mVar.a(f.a(new JSONObject(b3)));
                                } catch (Exception e2) {
                                    db.a(m.f3246a, "Cached variants parsing error: ", e2);
                                }
                                if (d.b() != null) {
                                    d.b();
                                    n.a(mVar);
                                }
                            } else {
                                db.b(d.f2961b, "Incorrect signature for cache.");
                                t.c(ck.a().f2892a);
                                d.this.f2963a.c();
                            }
                        }
                        d.c(d.this);
                        if (d.this.f2966f.e() > 0) {
                            for (j jVar2 : d.this.f2966f.d()) {
                                d.this.i.put(jVar2, new Pair(Boolean.TRUE, Boolean.FALSE));
                                d.this.a(jVar2, true);
                            }
                        }
                    } catch (Exception e3) {
                        db.a(d.f2961b, "Exception!", e3);
                        d.c(d.this);
                        if (d.this.f2966f.e() > 0) {
                            for (j jVar3 : d.this.f2966f.d()) {
                                d.this.i.put(jVar3, new Pair(Boolean.TRUE, Boolean.FALSE));
                                d.this.a(jVar3, true);
                            }
                        }
                    }
                } catch (Throwable th) {
                    d.c(d.this);
                    if (d.this.f2966f.e() > 0) {
                        for (j jVar4 : d.this.f2966f.d()) {
                            d.this.i.put(jVar4, new Pair(Boolean.TRUE, Boolean.FALSE));
                            d.this.a(jVar4, true);
                        }
                    }
                    throw th;
                }
            }
        });
    }

    public static n b() {
        return o;
    }

    private static synchronized d h() {
        d dVar;
        synchronized (d.class) {
            if (f2962c == null) {
                f2962c = new d((byte) 0);
            }
            dVar = f2962c;
        }
        return dVar;
    }

    public final void d() {
        if (this.l) {
            db.a(3, f2961b, "Preventing re-entry...");
            return;
        }
        this.l = true;
        db.a(3, f2961b, "Fetch started");
        new b(s.a(ck.a().f2892a, "https://cfg.flurry.com/sdk/v1/config"), new b.a() {
            @Override
            public final void a(g gVar, boolean z) {
                a aVar;
                if (!z) {
                    d.e(d.this);
                }
                g.a aVar2 = gVar.f3216d;
                if (aVar2 == g.a.SUCCEED) {
                    db.a(d.f2961b, "Fetch succeeded.");
                    aVar = a.Complete;
                    d.f(d.this);
                    for (j jVar : j.a()) {
                        boolean z2 = false;
                        if (d.this.i.containsKey(jVar)) {
                            z2 = ((Boolean) ((Pair) d.this.i.get(jVar)).first).booleanValue();
                        }
                        d.this.i.put(jVar, new Pair(Boolean.valueOf(z2), Boolean.FALSE));
                    }
                } else if (aVar2 == g.a.NO_CHANGE) {
                    db.a(d.f2961b, "Fetch finished.");
                    aVar = a.CompleteNoChange;
                } else {
                    db.a(d.f2961b, "Error occured while fetching: ".concat(String.valueOf(gVar)));
                    aVar = a.Fail;
                }
                if (d.this.n.f2982e <= aVar.f2982e) {
                    d.this.n = aVar;
                }
                d.b(d.this, aVar);
            }
        }, this.f2963a, this.f2966f).a();
    }

    public final synchronized void e() {
        t.c(ck.a().f2892a);
        m mVar = this.f2966f;
        if (mVar != null) {
            mVar.a();
        }
        this.f2963a.c();
        this.l = false;
        this.n = a.None;
        this.m = false;
        for (j jVar : j.a()) {
            Map<j, Pair<Boolean, Boolean>> map = this.i;
            Boolean bool = Boolean.FALSE;
            map.put(jVar, new Pair<>(bool, bool));
        }
    }

    public final List<l> f() {
        m mVar = this.f2966f;
        if (mVar != null) {
            return mVar.b();
        }
        return null;
    }

    public static synchronized d a() {
        d h;
        synchronized (d.class) {
            h = h();
        }
        return h;
    }

    static void b(d dVar, final a aVar) {
        synchronized (dVar.h) {
            for (Map.Entry<FlurryConfigListener, Pair<j, WeakReference<Handler>>> entry : dVar.h.entrySet()) {
                final FlurryConfigListener key = entry.getKey();
                Handler handler = (Handler) ((WeakReference) entry.getValue().second).get();
                eo eoVar = new eo() {
                    @Override
                    public final void a() {
                        int i = AnonymousClass5.f2976a[aVar.ordinal()];
                        if (i == 2) {
                            key.onFetchSuccess();
                        } else if (i == 3) {
                            key.onFetchNoChange();
                        } else if (i != 4) {
                        } else {
                            key.onFetchError(d.this.l);
                        }
                    }
                };
                if (handler == null) {
                    ck.a().a(eoVar);
                } else {
                    handler.post(eoVar);
                }
            }
        }
    }

    public final void a(FlurryConfigListener flurryConfigListener, j jVar, Handler handler) {
        if (flurryConfigListener == null) {
            return;
        }
        synchronized (this.h) {
            if (this.h.containsKey(flurryConfigListener)) {
                db.e(f2961b, "The listener is already registered");
                return;
            }
            this.h.put(flurryConfigListener, new Pair<>(jVar, new WeakReference(handler)));
            int i = AnonymousClass5.f2976a[this.n.ordinal()];
            if (i == 2) {
                flurryConfigListener.onFetchSuccess();
            } else if (i == 3) {
                flurryConfigListener.onFetchNoChange();
            } else if (i == 4) {
                flurryConfigListener.onFetchError(this.l);
            }
            if (this.i.containsKey(jVar)) {
                Pair<Boolean, Boolean> pair = this.i.get(jVar);
                if (((Boolean) pair.first).booleanValue() || ((Boolean) pair.second).booleanValue()) {
                    flurryConfigListener.onActivateComplete(!((Boolean) pair.second).booleanValue());
                }
            } else {
                Map<j, Pair<Boolean, Boolean>> map = this.i;
                Boolean bool = Boolean.FALSE;
                map.put(jVar, new Pair<>(bool, bool));
            }
        }
    }

    static void c(d dVar) {
        Object obj = j;
        synchronized (obj) {
            dVar.k = true;
            obj.notifyAll();
        }
    }

    public final void a(FlurryConfigListener flurryConfigListener) {
        if (flurryConfigListener == null) {
            return;
        }
        synchronized (this.h) {
            this.h.remove(flurryConfigListener);
        }
    }

    public final void a(j jVar, final boolean z) {
        synchronized (this.h) {
            for (Map.Entry<FlurryConfigListener, Pair<j, WeakReference<Handler>>> entry : this.h.entrySet()) {
                if (jVar == null || jVar == entry.getValue().first) {
                    final FlurryConfigListener key = entry.getKey();
                    Handler handler = (Handler) ((WeakReference) entry.getValue().second).get();
                    eo eoVar = new eo() {
                        @Override
                        public final void a() {
                            key.onActivateComplete(z);
                        }
                    };
                    if (handler == null) {
                        ck.a().a(eoVar);
                    } else {
                        handler.post(eoVar);
                    }
                }
            }
        }
    }

    public final boolean a(j jVar) {
        if (this.m) {
            boolean z = true;
            if (jVar == null) {
                boolean z2 = false;
                for (Map.Entry<j, Pair<Boolean, Boolean>> entry : this.i.entrySet()) {
                    Pair<Boolean, Boolean> value = entry.getValue();
                    if (!((Boolean) value.second).booleanValue()) {
                        entry.setValue(new Pair<>(value.first, Boolean.TRUE));
                        z2 = true;
                    }
                }
                z = z2;
            } else {
                Pair<Boolean, Boolean> pair = this.i.get(jVar);
                if (pair == null || !((Boolean) pair.second).booleanValue()) {
                    this.i.put(jVar, new Pair<>(Boolean.valueOf(pair == null ? false : ((Boolean) pair.first).booleanValue()), Boolean.TRUE));
                } else {
                    z = false;
                }
            }
            if (z) {
                this.f2966f.a(jVar);
                a(jVar, false);
            }
            return z;
        }
        return false;
    }
}