package com.chartboost.sdk.impl;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.ironsource.y8;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes2.dex */
public abstract class c8 {

    /* loaded from: classes2.dex */
    public /* synthetic */ class a {

        /* renamed from: a  reason: collision with root package name */
        public static final /* synthetic */ int[] f1670a;

        static {
            int[] iArr = new int[b8.values().length];
            try {
                iArr[b8.b.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[b8.g.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[b8.d.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[b8.f.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr[b8.c.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                iArr[b8.h.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                iArr[b8.e.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                iArr[b8.i.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            f1670a = iArr;
        }
    }

    public static final String b(Context context, b4 displayMeasurement) {
        Intrinsics.checkNotNullParameter(displayMeasurement, "displayMeasurement");
        switch (a.f1670a[a(context, displayMeasurement).ordinal()]) {
            case 1:
            case 2:
            case 3:
            case 4:
                return y8.h.D;
            case 5:
            case 6:
            case 7:
            case 8:
                return y8.h.C;
            default:
                throw new NoWhenBranchMatchedException();
        }
    }

    public static final boolean c(Context context, b4 displayMeasurement) {
        Intrinsics.checkNotNullParameter(displayMeasurement, "displayMeasurement");
        b8 a2 = a(context, displayMeasurement);
        return a2 == b8.b || a2 == b8.d || a2 == b8.f || a2 == b8.g;
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x002e, code lost:
        if (r6.b() < r6.a()) goto L11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x003b, code lost:
        if (r5 != false) goto L17;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final com.chartboost.sdk.impl.b8 a(android.content.Context r5, com.chartboost.sdk.impl.b4 r6) {
        /*
            if (r5 != 0) goto L5
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.b
            return r5
        L5:
            com.chartboost.sdk.impl.c4 r6 = r6.a()     // Catch: java.lang.Exception -> L6b
            int r0 = a(r5)     // Catch: java.lang.Exception -> L6b
            int r1 = r6.b()     // Catch: java.lang.Exception -> L6b
            int r2 = r6.a()     // Catch: java.lang.Exception -> L6b
            r3 = 1
            r4 = 2
            if (r1 != r2) goto L26
            android.content.res.Resources r5 = r5.getResources()     // Catch: java.lang.Exception -> L6b
            android.content.res.Configuration r5 = r5.getConfiguration()     // Catch: java.lang.Exception -> L6b
            int r5 = r5.orientation     // Catch: java.lang.Exception -> L6b
            if (r5 == r4) goto L32
            goto L30
        L26:
            int r5 = r6.b()     // Catch: java.lang.Exception -> L6b
            int r6 = r6.a()     // Catch: java.lang.Exception -> L6b
            if (r5 >= r6) goto L32
        L30:
            r5 = r3
            goto L33
        L32:
            r5 = 0
        L33:
            r6 = 3
            if (r0 == 0) goto L3b
            if (r0 == r4) goto L3b
            if (r5 != 0) goto L54
            goto L3d
        L3b:
            if (r5 == 0) goto L54
        L3d:
            if (r0 == 0) goto L51
            if (r0 == r3) goto L4e
            if (r0 == r4) goto L4b
            if (r0 == r6) goto L48
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.b     // Catch: java.lang.Exception -> L6b
            goto L6a
        L48:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.i     // Catch: java.lang.Exception -> L6b
            goto L6a
        L4b:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.d     // Catch: java.lang.Exception -> L6b
            goto L6a
        L4e:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.h     // Catch: java.lang.Exception -> L6b
            goto L6a
        L51:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.b     // Catch: java.lang.Exception -> L6b
            goto L6a
        L54:
            if (r0 == 0) goto L68
            if (r0 == r3) goto L65
            if (r0 == r4) goto L62
            if (r0 == r6) goto L5f
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.c     // Catch: java.lang.Exception -> L6b
            goto L6a
        L5f:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.g     // Catch: java.lang.Exception -> L6b
            goto L6a
        L62:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.e     // Catch: java.lang.Exception -> L6b
            goto L6a
        L65:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.f     // Catch: java.lang.Exception -> L6b
            goto L6a
        L68:
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.c     // Catch: java.lang.Exception -> L6b
        L6a:
            return r5
        L6b:
            r5 = move-exception
            java.lang.String r6 = "Cannot getOrientation"
            com.chartboost.sdk.impl.c7.b(r6, r5)
            com.chartboost.sdk.impl.b8 r5 = com.chartboost.sdk.impl.b8.c
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: com.chartboost.sdk.impl.c8.a(android.content.Context, com.chartboost.sdk.impl.b4):com.chartboost.sdk.impl.b8");
    }

    public static final int a(Context context) {
        Display defaultDisplay;
        WindowManager windowManager = (WindowManager) context.getSystemService("window");
        if (windowManager == null || (defaultDisplay = windowManager.getDefaultDisplay()) == null) {
            return 0;
        }
        return defaultDisplay.getRotation();
    }

    public static final void a(Activity activity, p9 p9Var, b4 displayMeasurement) {
        Intrinsics.checkNotNullParameter(displayMeasurement, "displayMeasurement");
        if (activity == null || a(activity) || p9Var == null) {
            return;
        }
        int i = 1;
        if (p9Var.h() && p9Var.j()) {
            switch (a.f1670a[a(activity, displayMeasurement).ordinal()]) {
                case 1:
                case 2:
                    break;
                case 3:
                case 4:
                    i = 9;
                    break;
                case 5:
                case 6:
                    i = 0;
                    break;
                default:
                    i = 8;
                    break;
            }
            activity.setRequestedOrientation(i);
        }
    }

    public static final boolean a(Activity activity) {
        Window window;
        View decorView;
        Drawable background;
        return activity == null || (Build.VERSION.SDK_INT == 26 && activity.getApplicationInfo().targetSdkVersion > 26 && ((window = activity.getWindow()) == null || (decorView = window.getDecorView()) == null || (background = decorView.getBackground()) == null || background.getAlpha() != 255));
    }

    public static final void a(Activity activity, p9 p9Var) {
        if (activity == null || a(activity) || p9Var == null || !p9Var.h() || !p9Var.j()) {
            return;
        }
        activity.setRequestedOrientation(-1);
    }
}
