package com.chartboost.sdk.impl;

import android.content.Context;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import java.io.IOException;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes2.dex */
public final class n5 extends s0 {
    public final Context b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public n5(Context context) {
        super(context);
        Intrinsics.checkNotNullParameter(context, "context");
        this.b = context;
    }

    public r0 b() {
        String str = null;
        if (a()) {
            return new r0(ra.e, null);
        }
        ra raVar = ra.c;
        try {
            AdvertisingIdClient.Info advertisingIdInfo = AdvertisingIdClient.getAdvertisingIdInfo(this.b);
            if (advertisingIdInfo.isLimitAdTrackingEnabled()) {
                raVar = ra.e;
            } else {
                raVar = ra.d;
                String id = advertisingIdInfo.getId();
                try {
                    if (Intrinsics.areEqual("00000000-0000-0000-0000-000000000000", id)) {
                        raVar = ra.e;
                    } else {
                        str = id;
                    }
                } catch (GooglePlayServicesNotAvailableException e) {
                    e = e;
                    str = id;
                    c7.b("Google play service is not available.", e);
                    return new r0(raVar, str);
                } catch (GooglePlayServicesRepairableException e2) {
                    e = e2;
                    str = id;
                    c7.b("There was a recoverable error connecting to Google Play Services.", e);
                    return new r0(raVar, str);
                } catch (IOException e3) {
                    e = e3;
                    str = id;
                    c7.b("The connection to Google Play Services failed.", e);
                    return new r0(raVar, str);
                } catch (IllegalStateException e4) {
                    e = e4;
                    str = id;
                    c7.b("This should have been called off the main thread.", e);
                    return new r0(raVar, str);
                }
            }
        } catch (GooglePlayServicesNotAvailableException e5) {
            e = e5;
        } catch (GooglePlayServicesRepairableException e6) {
            e = e6;
        } catch (IOException e7) {
            e = e7;
        } catch (IllegalStateException e8) {
            e = e8;
        }
        return new r0(raVar, str);
    }
}
