package com.seewo.ota.receiver;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
import f.e;
import f.g;
import f.p;
import f.u.c0;
import f.z.d.k;
import f.z.d.l;
import java.util.Map;

/* JADX INFO: compiled from: OTAUpdateInformationReceiver.kt */
/* JADX INFO: loaded from: classes.dex */
public final class c extends BroadcastReceiver {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final a f2245b = new a(null);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static Dialog f2246c;
    private final e a = g.a(b.f2247b);

    /* JADX INFO: compiled from: OTAUpdateInformationReceiver.kt */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(f.z.d.g gVar) {
            this();
        }
    }

    /* JADX INFO: compiled from: OTAUpdateInformationReceiver.kt */
    static final class b extends l implements f.z.c.a<Map<String, ? extends String>> {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public static final b f2247b = new b();

        b() {
            super(0);
        }

        @Override // f.z.c.a
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Map<String, String> invoke() {
            String str = com.seewo.ota.v.l.m;
            String str2 = com.seewo.ota.v.l.n;
            return c0.e(p.a(str, com.seewo.vcommons.data.d.l(str, "")), p.a("persist.sys.seewo.ota.url", com.seewo.vcommons.data.d.l("persist.sys.seewo.ota.url", "")), p.a(str2, com.seewo.vcommons.data.d.l(str2, "")));
        }
    }

    private final void a(Context context) {
        if (f2246c != null) {
            return;
        }
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(1);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(4000, -2));
        linearLayout.setPadding(40, 40, 40, 40);
        for (Map.Entry<String, String> entry : c().entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            TextView textView = new TextView(context);
            textView.setText(key + ":\n" + value);
            textView.setTextSize(12.0f);
            textView.setTextIsSelectable(true);
            linearLayout.addView(textView);
        }
        AlertDialog alertDialogCreate = new AlertDialog.Builder(context).setTitle("OTA Update Information").setView(linearLayout).setNegativeButton("Close", new DialogInterface.OnClickListener() { // from class: com.seewo.ota.receiver.a
            @Override // android.content.DialogInterface.OnClickListener
            public final void onClick(DialogInterface dialogInterface, int i2) {
                c.b(dialogInterface, i2);
            }
        }).create();
        Window window = alertDialogCreate.getWindow();
        if (window != null) {
            window.setType(2003);
        }
        alertDialogCreate.setCanceledOnTouchOutside(false);
        f2246c = alertDialogCreate;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void b(DialogInterface dialogInterface, int i2) {
        dialogInterface.dismiss();
    }

    private final Map<String, String> c() {
        return (Map) this.a.getValue();
    }

    private final void e(Context context) {
        Dialog dialog;
        a(context);
        Dialog dialog2 = f2246c;
        boolean z = false;
        if (dialog2 != null && !dialog2.isShowing()) {
            z = true;
        }
        if (!z || (dialog = f2246c) == null) {
            return;
        }
        dialog.show();
    }

    @Override // android.content.BroadcastReceiver
    public void onReceive(Context context, Intent intent) {
        k.e(context, "context");
        k.e(intent, "intent");
        String action = intent.getAction();
        d.e.h.e.e.a("OTAUpdateInformationReceiver", "onReceive: " + action);
        if (k.a(action, "com.seewo.ota.action.UPDATE_INFORMATION")) {
            e(context);
        }
    }
}
