package com.appsflyer.internal;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import com.appsflyer.AFExecutor;
import com.appsflyer.AFLogger;
import java.lang.ref.WeakReference;
import java.util.concurrent.RejectedExecutionException;

public final class ac implements Application.ActivityLifecycleCallbacks {

    /* renamed from: ˏ  reason: contains not printable characters */
    public static ac f1970;

    /* renamed from: ˊ  reason: contains not printable characters */
    public boolean f1971 = true;

    /* renamed from: ˋ  reason: contains not printable characters */
    public boolean f1972 = false;

    /* renamed from: ˎ  reason: contains not printable characters */
    public b f1973 = null;

    public class a extends AsyncTask<Void, Void, Void> {

        /* renamed from: ॱ  reason: contains not printable characters */
        public WeakReference<Context> f1975;

        public a(WeakReference<Context> weakReference) {
            this.f1975 = weakReference;
        }

        /* renamed from: ˋ  reason: contains not printable characters */
        private Void m1164() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                AFLogger.afErrorLog("Sleeping attempt failed (essential for background state verification)\n", e);
            }
            ac acVar = ac.this;
            if (acVar.f1972 && acVar.f1971) {
                acVar.f1972 = false;
                try {
                    acVar.f1973.m1166(this.f1975);
                } catch (Exception e2) {
                    AFLogger.afErrorLog("Listener threw exception! ", e2);
                    cancel(true);
                }
            }
            this.f1975.clear();
            return null;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object[]] */
        @Override // android.os.AsyncTask
        public final /* synthetic */ Void doInBackground(Void[] voidArr) {
            return m1164();
        }
    }

    public interface b {
        /* renamed from: ॱ  reason: contains not printable characters */
        void m1165(Activity activity);

        /* renamed from: ॱ  reason: contains not printable characters */
        void m1166(WeakReference<Context> weakReference);
    }

    public final void onActivityCreated(Activity activity, Bundle bundle) {
        g.m1228();
        Intent intent = activity.getIntent();
        if (g.m1227(intent) != null && intent.getData() != g.f2077) {
            g.f2077 = intent.getData();
        }
    }

    public final void onActivityDestroyed(Activity activity) {
    }

    public final void onActivityPaused(Activity activity) {
        this.f1971 = true;
        try {
            new a(new WeakReference(activity.getApplicationContext())).executeOnExecutor(AFExecutor.getInstance().getThreadPoolExecutor(), new Void[0]);
        } catch (RejectedExecutionException e) {
            AFLogger.afErrorLog("backgroundTask.executeOnExecutor failed with RejectedExecutionException Exception", e);
        } catch (Throwable th) {
            AFLogger.afErrorLog("backgroundTask.executeOnExecutor failed with Exception", th);
        }
    }

    public final void onActivityResumed(Activity activity) {
        this.f1971 = false;
        boolean z = !this.f1972;
        this.f1972 = true;
        if (z) {
            try {
                this.f1973.m1165(activity);
            } catch (Exception e) {
                AFLogger.afErrorLog("Listener threw exception! ", e);
            }
        }
    }

    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
    }

    public final void onActivityStarted(Activity activity) {
    }

    public final void onActivityStopped(Activity activity) {
    }
}
