VegeFruits v7.1版本的 MD5 值为:2ff167dfba698c783e879938fe00b9ce

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


package com.chartboost.sdk;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.webkit.WebView;
import com.chartboost.sdk.Chartboost;
import com.chartboost.sdk.Libraries.CBLogging;
import com.chartboost.sdk.Libraries.CBUtility;
import com.chartboost.sdk.Libraries.j;
import com.chartboost.sdk.Model.CBError;
import com.chartboost.sdk.Model.a;
import com.chartboost.sdk.b;
import com.chartboost.sdk.c;
import com.chartboost.sdk.impl.af;
import com.chartboost.sdk.impl.ai;
import com.chartboost.sdk.impl.aj;
import com.chartboost.sdk.impl.ak;
import com.chartboost.sdk.impl.al;
import com.chartboost.sdk.impl.am;
import com.chartboost.sdk.impl.y;
import java.util.HashSet;
import java.util.concurrent.atomic.AtomicReference;

public class h {
    private static h q;
    final c a;
    public final com.chartboost.sdk.InPlay.a b;
    final com.chartboost.sdk.impl.h c;
    final y d;
    final com.chartboost.sdk.impl.e e;
    public final ak f;
    final com.chartboost.sdk.impl.i g;
    final AtomicReference<com.chartboost.sdk.Model.c> h;
    final Application.ActivityLifecycleCallbacks n;
    Runnable o;
    protected j p;
    private final com.chartboost.sdk.impl.b r;
    private final com.chartboost.sdk.impl.d s;
    private final ai t;
    private final SharedPreferences u;
    private final com.chartboost.sdk.Tracking.a v;
    private final e w;
    CBImpressionActivity i = null;
    private com.chartboost.sdk.Model.a x = null;
    private boolean y = false;
    private final HashSet<Integer> z = new HashSet<>();
    protected boolean j = true;
    protected boolean k = false;
    boolean l = true;
    boolean m = false;
    private boolean A = false;
    private final Runnable B = new Runnable() {
        @Override
        public void run() {
            h.this.d();
        }
    };

    public static h a() {
        return q;
    }

    public static void a(h hVar) {
        q = hVar;
    }

    public h(Activity activity, String str, String str2, com.chartboost.sdk.impl.b bVar, com.chartboost.sdk.impl.d dVar, af afVar, com.chartboost.sdk.impl.e eVar, ai aiVar, ak akVar, AtomicReference<com.chartboost.sdk.Model.c> atomicReference, SharedPreferences sharedPreferences, com.chartboost.sdk.Tracking.a aVar) {
        this.p = null;
        g a2 = g.a();
        this.a = (c) a2.a((g) new c(akVar, this, aVar, (al) a2.a((g) new al((c.b) a2.a((g) new c.b()), aiVar))));
        this.b = (com.chartboost.sdk.InPlay.a) a2.a((g) new com.chartboost.sdk.InPlay.a(this.a, afVar, akVar, atomicReference));
        this.w = (e) a2.a((g) new e(dVar, this.a, this, atomicReference));
        am amVar = (am) a2.a((g) new am(afVar, akVar, new com.chartboost.sdk.Libraries.g(true)));
        this.c = (com.chartboost.sdk.impl.h) a2.a((g) new com.chartboost.sdk.impl.h(bVar, dVar, this.a, afVar, eVar, aiVar, akVar, this, atomicReference, sharedPreferences, aVar, this.w, amVar));
        this.d = (y) a2.a((g) new y(bVar, dVar, this.a, afVar, aiVar, akVar, this, atomicReference, sharedPreferences, aVar, this.w, amVar));
        this.g = (com.chartboost.sdk.impl.i) a2.a((g) new com.chartboost.sdk.impl.i(bVar, dVar, this.a, afVar, eVar, aiVar, akVar, this, atomicReference, sharedPreferences, aVar, this.w, amVar));
        this.r = bVar;
        this.s = dVar;
        this.e = eVar;
        this.t = aiVar;
        this.f = akVar;
        this.h = atomicReference;
        this.u = sharedPreferences;
        this.v = aVar;
        if (!atomicReference.get().u) {
            i.w = "";
        } else {
            a(activity.getApplicationContext(), null, sharedPreferences);
        }
        if (com.chartboost.sdk.impl.g.a().a(14)) {
            this.n = new a();
        } else {
            this.n = null;
        }
        i.m = activity.getApplicationContext();
        i.k = str;
        i.l = str2;
        this.p = j.a(activity);
        aiVar.a(i.m);
        this.o = new b();
    }

    public void a(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            a(new Runnable() {
                @Override
                public void run() {
                    try {
                        h.this.b(activity);
                    } catch (Exception e) {
                        com.chartboost.sdk.Tracking.a.a(h.class, "onCreateCallback Runnable.run", e);
                    }
                }
            });
        }
    }

    void b(Activity activity) {
        if (this.p != null && !this.p.b(activity) && l()) {
            c(this.p);
            a(this.p, false);
        }
        com.chartboost.sdk.impl.g.a().a.removeCallbacks(this.o);
        this.p = j.a(activity);
    }

    public void c(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            final com.chartboost.sdk.impl.b bVar = this.r;
            final com.chartboost.sdk.impl.d dVar = this.s;
            final e eVar = this.w;
            com.chartboost.sdk.impl.h hVar = this.c;
            com.chartboost.sdk.impl.i iVar = this.g;
            y yVar = this.d;
            a(new Runnable() {
                @Override
                public void run() {
                    try {
                        com.chartboost.sdk.impl.g.a().a.removeCallbacks(h.this.o);
                        if (h.this.p != null && !h.this.p.b(activity) && h.this.l()) {
                            h.this.c(h.this.p);
                            h.this.a(h.this.p, false);
                        }
                        h.this.a(activity, true);
                        h.this.p = j.a(activity);
                        h.this.b();
                        if (com.chartboost.sdk.impl.g.a().a(23)) {
                            com.chartboost.sdk.b.b(activity);
                        }
                        if (!h.this.l) {
                            if (!eVar.c()) {
                                dVar.c();
                            } else {
                                bVar.e();
                            }
                        }
                        h.this.d(activity);
                    } catch (Exception e) {
                        com.chartboost.sdk.Tracking.a.a(h.class, "onStartCallback Runnable.run", e);
                    }
                }
            });
        }
    }

    public void d(Activity activity) {
        i.m = activity.getApplicationContext();
        if (!(activity instanceof CBImpressionActivity)) {
            this.p = j.a(activity);
            a(this.p, true);
        } else {
            a((CBImpressionActivity) activity);
        }
        com.chartboost.sdk.impl.g.a().a.removeCallbacks(this.o);
        boolean z = i.d != null && i.d.doesWrapperUseCustomBackgroundingBehavior();
        if (activity != null) {
            if (z || j(activity)) {
                b(j.a(activity), true);
                if (activity instanceof CBImpressionActivity) {
                    this.A = false;
                }
                if (this.a.a(activity, this.x)) {
                    this.x = null;
                }
                com.chartboost.sdk.Model.a c = this.a.c();
                if (c != null) {
                    c.u();
                }
            }
        }
    }

    protected void b() {
        if (i.m == null) {
            CBLogging.b("Sdk", "The context must be set through the Chartboost method onCreate() before calling startSession().");
        } else {
            p();
        }
    }

    protected void c() {
        com.chartboost.sdk.impl.g.a().a.postDelayed(this.B, 500L);
    }

    private void p() {
        this.v.c();
        this.v.a();
        if (!this.l) {
            final com.chartboost.sdk.impl.e eVar = this.e;
            final ak akVar = this.f;
            SharedPreferences sharedPreferences = this.u;
            com.chartboost.sdk.b.a(this, new b.a() {
                @Override
                public void a() {
                    aj ajVar = new aj("api/install", akVar);
                    ajVar.a(com.chartboost.sdk.Libraries.f.a("status", com.chartboost.sdk.Libraries.a.b));
                    ajVar.j();
                    eVar.a();
                }
            }, akVar, this.h, sharedPreferences);
        }
    }

    protected void d() {
        this.v.b();
    }

    public void e(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            if (!this.k) {
                if (i.c != null) {
                    i.c.didInitialize();
                }
                this.k = true;
            }
            a(new Runnable() {
                @Override
                public void run() {
                    try {
                        j a2 = j.a(activity);
                        if (h.this.e(a2)) {
                            h.this.a(a2);
                        } else if (CBUtility.a(Chartboost.CBFramework.CBFrameworkUnity)) {
                            h.this.b();
                        }
                    } catch (Exception e) {
                        com.chartboost.sdk.Tracking.a.a(h.class, "onResumeCallback Runnable.run", e);
                    }
                }
            });
        }
    }

    public void a(j jVar) {
        this.t.b(i.m);
        com.chartboost.sdk.Model.a c = this.a.c();
        if (CBUtility.a(Chartboost.CBFramework.CBFrameworkUnity)) {
            b();
        }
        if (c != null) {
            c.t();
        }
    }

    public void f(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            a(new Runnable() {
                @Override
                public void run() {
                    try {
                        j a2 = j.a(activity);
                        if (h.this.e(a2)) {
                            h.this.b(a2);
                        }
                    } catch (Exception e) {
                        com.chartboost.sdk.Tracking.a.a(h.class, "onPauseCallback Runnable.run", e);
                    }
                }
            });
        }
    }

    public void b(j jVar) {
        com.chartboost.sdk.Model.a c = this.a.c();
        if (c != null) {
            c.v();
        }
        this.t.c(i.m);
    }

    public void g(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            a(new Runnable() {
                @Override
                public void run() {
                    try {
                        j a2 = j.a(activity);
                        if (h.this.e(a2)) {
                            h.this.c(a2);
                        }
                    } catch (Exception e) {
                        com.chartboost.sdk.Tracking.a.a(h.class, "onStopCallback", e);
                    }
                }
            });
        }
    }

    void c(j jVar) {
        if (!(jVar.get() instanceof CBImpressionActivity)) {
            a(jVar, false);
        }
        c();
    }

    public void d(j jVar) {
        com.chartboost.sdk.Model.a c = this.a.c();
        if (c != null && c.b == a.b.NATIVE) {
            e m = m();
            if (f(jVar) && m != null) {
                m.c(c);
                this.x = c;
                b(jVar, false);
            }
            if (!(jVar.get() instanceof CBImpressionActivity)) {
                a(jVar, false);
            }
        }
    }

    public boolean e() {
        if (!com.chartboost.sdk.b.c()) {
            return false;
        }
        if (this.p == null) {
            CBLogging.b("Sdk", "The Chartboost methods onCreate(), onStart(), onStop(), and onDestroy() must be called in the corresponding methods of your activity in order for Chartboost to function properly.");
            return false;
        }
        if (!this.A) {
            return false;
        }
        this.A = false;
        f();
        return true;
    }

    public boolean f() {
        return g();
    }

    protected boolean g() {
        final c cVar = this.a;
        com.chartboost.sdk.Model.a c = cVar.c();
        if (c != null && c.d == a.e.DISPLAYED) {
            if (c.s()) {
                return true;
            }
            a(new Runnable() {
                @Override
                public void run() {
                    cVar.b();
                }
            });
            return true;
        }
        final e m = m();
        if (m != null && m.b()) {
            a(new Runnable() {
                @Override
                public void run() {
                    m.a(cVar.c(), true);
                }
            });
            return true;
        }
        return false;
    }

    public void h(final Activity activity) {
        if (com.chartboost.sdk.b.c() && com.chartboost.sdk.b.a(activity)) {
            a(new Runnable() {
                @Override
                public void run() {
                    if (h.this.p == null || h.this.p.b(activity)) {
                        h.this.o = new b();
                        h.this.o.run();
                    }
                    h.this.i(activity);
                }
            });
        }
    }

    public void i(Activity activity) {
        b(j.a(activity), false);
        com.chartboost.sdk.Model.a c = this.a.c();
        if (c == null && activity == this.i && this.x != null) {
            c = this.x;
        }
        e m = m();
        if (m != null && c != null) {
            m.d(c);
        }
        this.x = null;
    }

    public Activity h() {
        return this.i;
    }

    private boolean j(Activity activity) {
        return this.i == activity;
    }

    private boolean f(j jVar) {
        if (jVar == null) {
            return this.i == null;
        }
        return jVar.b(this.i);
    }

    public void a(CBImpressionActivity cBImpressionActivity) {
        if (!this.y) {
            i.m = cBImpressionActivity.getApplicationContext();
            this.i = cBImpressionActivity;
            this.y = true;
        }
        com.chartboost.sdk.impl.g.a().a.removeCallbacks(this.o);
    }

    public void i() {
        if (this.y) {
            this.i = null;
            this.y = false;
        }
    }

    public void a(com.chartboost.sdk.Model.a aVar) {
        boolean z = false;
        e m = m();
        if (m != null && m.c()) {
            aVar.a(CBError.CBImpressionError.IMPRESSION_ALREADY_VISIBLE);
            return;
        }
        if (this.y) {
            if (h() != null && m != null) {
                m.a(aVar);
                return;
            } else if (h() == null) {
                CBLogging.b("Sdk", "Activity not found. Cannot display the view");
                aVar.a(CBError.CBImpressionError.NO_HOST_ACTIVITY);
                return;
            } else {
                CBLogging.b("Sdk", "Missing view controller to manage the impression activity");
                aVar.a(CBError.CBImpressionError.ERROR_DISPLAYING_VIEW);
                return;
            }
        }
        if (!l()) {
            aVar.a(CBError.CBImpressionError.NO_HOST_ACTIVITY);
            return;
        }
        Activity j = j();
        if (j == null) {
            CBLogging.b("Sdk", "Failed to display impression as the host activity reference has been lost!");
            aVar.a(CBError.CBImpressionError.NO_HOST_ACTIVITY);
            return;
        }
        if (this.x != null && this.x != aVar) {
            aVar.a(CBError.CBImpressionError.IMPRESSION_ALREADY_VISIBLE);
            return;
        }
        this.x = aVar;
        Intent intent = new Intent(j, (Class<?>) CBImpressionActivity.class);
        boolean z2 = (j.getWindow().getAttributes().flags & 1024) != 0;
        boolean z3 = (j.getWindow().getAttributes().flags & 2048) != 0;
        if (z2 && !z3) {
            z = true;
        }
        intent.putExtra("paramFullscreen", z);
        intent.putExtra("isChartboost", true);
        try {
            j.startActivity(intent);
            this.A = true;
        } catch (ActivityNotFoundException e) {
            CBLogging.b("Sdk", "Chartboost impression activity not declared in manifest. Please add the following inside your manifest's <application> tag: \n<activity android:name=\"com.chartboost.sdk.CBImpressionActivity\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" android:excludeFromRecents=\"true\" />");
            this.x = null;
            CBLogging.b("Sdk", "CBImpression Activity is missing in the manifest");
            aVar.a(CBError.CBImpressionError.ACTIVITY_MISSING_IN_MANIFEST);
            this.v.a(aVar.q().d(), aVar.f, aVar.p(), CBError.CBImpressionError.ACTIVITY_MISSING_IN_MANIFEST);
        }
    }

    public Activity j() {
        if (this.p != null) {
            return (Activity) this.p.get();
        }
        return null;
    }

    public static void a(Runnable runnable) {
        com.chartboost.sdk.impl.g a2 = com.chartboost.sdk.impl.g.a();
        if (!a2.f()) {
            a2.a.post(runnable);
        } else {
            runnable.run();
        }
    }

    public Context k() {
        return this.p != null ? this.p.b() : i.m;
    }

    private static void b(j jVar, boolean z) {
    }

    private class b implements Runnable {
        private final int b;
        private final int c;
        private final int d;

        private com.chartboost.sdk.a a() {
            return i.c;
        }

        private b() {
            com.chartboost.sdk.a a = a();
            this.b = h.this.i == null ? -1 : h.this.i.hashCode();
            this.c = h.this.p == null ? -1 : h.this.p.hashCode();
            this.d = a != null ? a.hashCode() : -1;
        }

        @Override
        public void run() {
            com.chartboost.sdk.a a = a();
            if (h.this.p != null && h.this.p.hashCode() == this.c) {
                h.this.p = null;
            }
            if (a != null && a.hashCode() == this.d) {
                i.c = null;
            }
        }
    }

    boolean l() {
        return e(this.p);
    }

    boolean e(j jVar) {
        if (jVar == null) {
            return false;
        }
        return this.z.contains(Integer.valueOf(jVar.a()));
    }

    void a(Activity activity, boolean z) {
        if (activity != null) {
            a(activity.hashCode(), z);
        }
    }

    void a(j jVar, boolean z) {
        if (jVar != null) {
            a(jVar.a(), z);
        }
    }

    private void a(int i, boolean z) {
        if (z) {
            this.z.add(Integer.valueOf(i));
        } else {
            this.z.remove(Integer.valueOf(i));
        }
    }

    public e m() {
        if (h() == null) {
            return null;
        }
        return this.w;
    }

    public static boolean n() {
        h a2 = a();
        if (a2 == null || !a2.h.get().c) {
            return true;
        }
        try {
            throw new Exception("Chartboost Integration Warning: your account has been disabled for this session. This app has no active publishing campaigns, please create a publishing campaign in the Chartboost dashboard and wait at least 30 minutes to re-enable. If you need assistance, please visit http://chartboo.st/publishing .");
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean o() {
        return this.m;
    }

    @TargetApi(14)
    class a implements Application.ActivityLifecycleCallbacks {
        a() {
        }

        @Override
        public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
            CBLogging.a("Sdk", "######## onActivityCreated callback called");
            if (!(activity instanceof CBImpressionActivity)) {
                h.this.a(activity);
            }
        }

        @Override
        public void onActivityStarted(Activity activity) {
            if (!(activity instanceof CBImpressionActivity)) {
                CBLogging.a("Sdk", "######## onActivityStarted callback called from developer side");
                h.this.c(activity);
            } else {
                CBLogging.a("Sdk", "######## onActivityStarted callback called from CBImpressionactivity");
                h.this.d(activity);
            }
        }

        @Override
        public void onActivityResumed(Activity activity) {
            if (!(activity instanceof CBImpressionActivity)) {
                CBLogging.a("Sdk", "######## onActivityResumed callback called from developer side");
                h.this.e(activity);
            } else {
                CBLogging.a("Sdk", "######## onActivityResumed callback called from CBImpressionactivity");
                h.this.a(j.a(activity));
            }
        }

        @Override
        public void onActivityPaused(Activity activity) {
            if (!(activity instanceof CBImpressionActivity)) {
                CBLogging.a("Sdk", "######## onActivityPaused callback called from developer side");
                h.this.f(activity);
            } else {
                CBLogging.a("Sdk", "######## onActivityPaused callback called from CBImpressionactivity");
                h.this.b(j.a(activity));
            }
        }

        @Override
        public void onActivityStopped(Activity activity) {
            if (!(activity instanceof CBImpressionActivity)) {
                CBLogging.a("Sdk", "######## onActivityStopped callback called from developer side");
                h.this.g(activity);
            } else {
                CBLogging.a("Sdk", "######## onActivityStopped callback called from CBImpressionactivity");
                h.this.d(j.a(activity));
            }
        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        }

        @Override
        public void onActivityDestroyed(Activity activity) {
            if (!(activity instanceof CBImpressionActivity)) {
                CBLogging.a("Sdk", "######## onActivityDestroyed callback called from developer side");
                h.this.h(activity);
            } else {
                CBLogging.a("Sdk", "######## onActivityDestroyed callback called from CBImpressionactivity");
                h.this.i(activity);
            }
        }
    }

    public static void a(Context context, WebView webView, SharedPreferences sharedPreferences) {
        String str = i.w;
        try {
            if (webView == null) {
                if (!sharedPreferences.contains("user_agent")) {
                    str = new WebView(context.getApplicationContext()).getSettings().getUserAgentString();
                } else {
                    str = sharedPreferences.getString("user_agent", i.w);
                }
            } else {
                str = webView.getSettings().getUserAgentString();
            }
        } catch (Exception e) {
        }
        i.w = str;
        sharedPreferences.edit().putString("user_agent", str).apply();
    }
}