package com.seewo.ota.m;

import android.R;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import com.seewo.libmyousdk.model.RomUpdateInfo;
import com.seewo.ota.data.UpdateInfo;
import com.seewo.ota.util.u;
import d.e.h.e.f;

/* JADX INFO: compiled from: BaseUpgradeDialog.kt */
/* JADX INFO: loaded from: classes.dex */
public abstract class q extends Dialog {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final RomUpdateInfo f2171b;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final int f2172f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final boolean f2173g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final String f2174h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private final boolean f2175i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private View f2176j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private String[] f2177k;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public q(Context context, RomUpdateInfo romUpdateInfo, int i2, boolean z, String str, boolean z2) {
        super(context);
        f.z.d.k.e(context, "context");
        f.z.d.k.e(romUpdateInfo, "mUpdateFile");
        f.z.d.k.e(str, "mUpdateSrcPath");
        this.f2171b = romUpdateInfo;
        this.f2172f = i2;
        this.f2173g = z;
        this.f2174h = str;
        this.f2175i = z2;
        new Handler(Looper.getMainLooper());
    }

    private final void a() {
        PackageManager packageManager = getContext().getPackageManager();
        try {
            String[] strArr = this.f2177k;
            if (strArr == null) {
                f.z.d.k.p("mGMSList");
                throw null;
            }
            for (String str : strArr) {
                packageManager.setApplicationEnabledSetting(str, 2, 0);
            }
        } catch (Exception e2) {
            Log.e("BaseUpgradeDialog", "disableGMS error: " + e2.getMessage());
        }
    }

    @SuppressLint({"WrongConstant"})
    private final void i() {
        Window window = getWindow();
        window.setLayout(-1, -1);
        window.setBackgroundDrawableResource(R.color.transparent);
        window.setType(2018);
        window.setFormat(1);
        window.setFlags(131840, 131840);
        window.setGravity(17);
    }

    private final boolean j() {
        if (u.a(getContext())) {
            f.a aVarA = d.e.h.e.f.a("enable-verity");
            Log.d("BaseUpgradeDialog", "unremount result: " + aVarA.a + " ,successMsg:" + aVarA.f3605b + "  ,errorMsg:" + aVarA.f3606c);
            z = aVarA.a == 0;
            if (z) {
                a();
                com.seewo.ota.data.a.g().S(new UpdateInfo(this.f2171b, g(), true, this.f2175i));
                u.i(getContext());
            }
        }
        return z;
    }

    protected final boolean b() {
        return this.f2173g;
    }

    protected final boolean c() {
        return this.f2175i;
    }

    protected final RomUpdateInfo d() {
        return this.f2171b;
    }

    protected final int e() {
        return this.f2172f;
    }

    protected final String f() {
        return this.f2174h;
    }

    @Override // android.app.Dialog
    public <T extends View> T findViewById(int i2) {
        if (this.f2176j == null) {
            this.f2176j = LayoutInflater.from(getContext()).inflate(h(), (ViewGroup) null, false);
        }
        View view = this.f2176j;
        f.z.d.k.c(view);
        return (T) view.findViewById(i2);
    }

    protected final String g() {
        if (!TextUtils.isEmpty(this.f2174h)) {
            return this.f2174h;
        }
        String strJ = this.f2172f == 1 ? com.seewo.ota.data.b.i().j() : com.seewo.ota.data.b.i().k();
        f.z.d.k.d(strJ, "{\n            if (mUpdat….slotUpdatePath\n        }");
        return strJ;
    }

    public abstract int h();

    public final void k(boolean z) {
        Log.d("BaseUpgradeDialog", "upgrade ota file:" + g());
        if (j()) {
            Log.i("BaseUpgradeDialog", "upgradeSystem: tryGMSUpgrade success, reboot.");
        } else {
            l(z);
        }
    }

    public void l(boolean z) {
    }

    @Override // android.app.Dialog
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (com.seewo.vcommons.data.d.m("sys.ota.interrupt_upgrade", false)) {
            com.seewo.ota.util.s.a().c(getContext(), com.seewo.ota.R.string.interrupt_upgrade);
            Log.d("BaseUpgradeDialog", "interrupt upgrade, finish.");
            dismiss();
        } else {
            requestWindowFeature(1);
            View viewInflate = LayoutInflater.from(getContext()).inflate(h(), (ViewGroup) null);
            this.f2176j = viewInflate;
            f.z.d.k.c(viewInflate);
            setContentView(viewInflate);
            i();
        }
    }
}
