package p138.p176.p177.p242.p246;

import android.R;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import p000.p001.p002.p003.p004.C0567;
import p037.p065.p067.C1842;
import p037.p065.p067.C1843;
import p037.p065.p067.C1844;
import p037.p089.p090.AbstractC2014;
import p037.p089.p090.ActivityC1999;
import p138.p176.p177.p242.p245.C4188;
import p138.p176.p177.p242.p245.C4189;
import p138.p176.p177.p242.p246.p249.C4265;
import p138.p176.p177.p242.p246.p249.C4285;
import p138.p176.p177.p242.p246.p251.C4303;
import p138.p176.p177.p242.p258.p260.HandlerC4356;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ހ.ނ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C4194 extends C4196 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final Object f13401 = new Object();

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static final C4194 f13402 = new C4194();

    /* JADX INFO: renamed from: ދ.ހ.֏.ހ.ހ.ނ$֏, reason: contains not printable characters */
    @SuppressLint({"HandlerLeak"})
    public class HandlerC4195 extends HandlerC4356 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Context f13403;

        public HandlerC4195(Context context) {
            super(Looper.myLooper() == null ? Looper.getMainLooper() : Looper.myLooper());
            this.f13403 = context.getApplicationContext();
        }

        @Override // android.os.Handler
        public final void handleMessage(Message message) {
            int i = message.what;
            if (i != 1) {
                StringBuilder sb = new StringBuilder(50);
                sb.append("Don't know how to handle this message: ");
                sb.append(i);
                Log.w("GoogleApiAvailability", sb.toString());
                return;
            }
            int iMo6843 = C4194.this.mo6843(this.f13403);
            if (C4194.this == null) {
                throw null;
            }
            if (C4198.m6855(iMo6843)) {
                C4194 c4194 = C4194.this;
                Context context = this.f13403;
                Intent intentMo6845 = c4194.mo6845(context, iMo6843, "n");
                c4194.m6847(context, iMo6843, intentMo6845 != null ? PendingIntent.getActivity(context, 0, intentMo6845, 134217728) : null);
            }
        }
    }

    @Override // p138.p176.p177.p242.p246.C4196
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public int mo6843(Context context) {
        return mo6844(context, C4196.f13405);
    }

    @Override // p138.p176.p177.p242.p246.C4196
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public int mo6844(Context context, int i) {
        return super.mo6844(context, i);
    }

    @Override // p138.p176.p177.p242.p246.C4196
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public Intent mo6845(Context context, int i, String str) {
        return super.mo6845(context, i, str);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String m6846() {
        synchronized (f13401) {
        }
        return null;
    }

    @TargetApi(20)
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m6847(Context context, int i, PendingIntent pendingIntent) {
        int i2;
        if (i == 18) {
            new HandlerC4195(context).sendEmptyMessageDelayed(1, 120000L);
            return;
        }
        if (pendingIntent == null) {
            if (i == 6) {
                Log.w("GoogleApiAvailability", "Missing resolution for ConnectionResult.RESOLUTION_REQUIRED. Call GoogleApiAvailability#showErrorNotification(Context, ConnectionResult) instead.");
                return;
            }
            return;
        }
        String strM6949 = i == 6 ? C4265.m6949(context, "common_google_play_services_resolution_required_title") : C4265.m6952(context, i);
        if (strM6949 == null) {
            strM6949 = context.getResources().getString(C4189.common_google_play_services_notification_ticker);
        }
        String strM6950 = i == 6 ? C4265.m6950(context, "common_google_play_services_resolution_required_text", C4265.m6947(context)) : C4265.m6948(context, i);
        Resources resources = context.getResources();
        NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
        C1844 c1844 = new C1844(context, null);
        c1844.f6204 = true;
        c1844.f6221.flags |= 16;
        c1844.f6184 = C1844.m3640(strM6949);
        C1843 c1843 = new C1843();
        c1843.f6180 = C1844.m3640(strM6950);
        if (c1844.f6195 != c1843) {
            c1844.f6195 = c1843;
            if (c1843.f6224 != c1844) {
                c1843.f6224 = c1844;
                c1844.m3642(c1843);
            }
        }
        if (C4303.m7123(context)) {
            C0567.m1939(true);
            c1844.f6221.icon = context.getApplicationInfo().icon;
            c1844.f6192 = 2;
            if (C4303.m7170(context)) {
                c1844.f6182.add(new C1842(C4188.common_full_open_on_phone, resources.getString(C4189.common_open_on_phone), pendingIntent));
            } else {
                c1844.f6186 = pendingIntent;
            }
        } else {
            c1844.f6221.icon = R.drawable.stat_sys_warning;
            c1844.f6221.tickerText = C1844.m3640(resources.getString(C4189.common_google_play_services_notification_ticker));
            c1844.f6221.when = System.currentTimeMillis();
            c1844.f6186 = pendingIntent;
            c1844.f6185 = C1844.m3640(strM6950);
        }
        if (C4303.m7186()) {
            C0567.m1939(C4303.m7186());
            m6846();
            NotificationChannel notificationChannel = notificationManager.getNotificationChannel("com.google.android.gms.availability");
            String strM6951 = C4265.m6951(context);
            if (notificationChannel == null) {
                notificationManager.createNotificationChannel(new NotificationChannel("com.google.android.gms.availability", strM6951, 4));
            } else if (!strM6951.contentEquals(notificationChannel.getName())) {
                notificationChannel.setName(strM6951);
                notificationManager.createNotificationChannel(notificationChannel);
            }
            c1844.f6215 = "com.google.android.gms.availability";
        }
        Notification notificationM3641 = c1844.m3641();
        if (i == 1 || i == 2 || i == 3) {
            i2 = 10436;
            C4198.f13410.set(false);
        } else {
            i2 = 39789;
        }
        notificationManager.notify(i2, notificationM3641);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean m6848(Activity activity, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
        AlertDialog alertDialogCreate;
        C4285 c4285 = new C4285(super.mo6845(activity, i, "d"), activity, i2);
        if (i == 0) {
            alertDialogCreate = null;
        } else {
            TypedValue typedValue = new TypedValue();
            activity.getTheme().resolveAttribute(R.attr.alertDialogTheme, typedValue, true);
            AlertDialog.Builder builder = "Theme.Dialog.Alert".equals(activity.getResources().getResourceEntryName(typedValue.resourceId)) ? new AlertDialog.Builder(activity, 5) : null;
            if (builder == null) {
                builder = new AlertDialog.Builder(activity);
            }
            builder.setMessage(C4265.m6948(activity, i));
            if (onCancelListener != null) {
                builder.setOnCancelListener(onCancelListener);
            }
            Resources resources = activity.getResources();
            String string = i != 1 ? i != 2 ? i != 3 ? resources.getString(R.string.ok) : resources.getString(C4189.common_google_play_services_enable_button) : resources.getString(C4189.common_google_play_services_update_button) : resources.getString(C4189.common_google_play_services_install_button);
            if (string != null) {
                builder.setPositiveButton(string, c4285);
            }
            String strM6952 = C4265.m6952(activity, i);
            if (strM6952 != null) {
                builder.setTitle(strM6952);
            }
            alertDialogCreate = builder.create();
        }
        if (alertDialogCreate == null) {
            return false;
        }
        if (activity instanceof ActivityC1999) {
            AbstractC2014 supportFragmentManager = ((ActivityC1999) activity).getSupportFragmentManager();
            C4201 c4201 = new C4201();
            C0567.m1857(alertDialogCreate, (Object) "Cannot display null dialog");
            alertDialogCreate.setOnCancelListener(null);
            alertDialogCreate.setOnDismissListener(null);
            c4201.f13414 = alertDialogCreate;
            if (onCancelListener != null) {
                c4201.f13415 = onCancelListener;
            }
            c4201.mo3877(supportFragmentManager, "GooglePlayServicesErrorDialog");
        } else {
            FragmentManager fragmentManager = activity.getFragmentManager();
            DialogFragmentC4192 dialogFragmentC4192 = new DialogFragmentC4192();
            C0567.m1857(alertDialogCreate, (Object) "Cannot display null dialog");
            alertDialogCreate.setOnCancelListener(null);
            alertDialogCreate.setOnDismissListener(null);
            dialogFragmentC4192.f13396 = alertDialogCreate;
            if (onCancelListener != null) {
                dialogFragmentC4192.f13397 = onCancelListener;
            }
            dialogFragmentC4192.show(fragmentManager, "GooglePlayServicesErrorDialog");
        }
        return true;
    }
}
