皇马.apk(点击下载) / FullscreenActivity.java


package com.empire.ggwin.app;

import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
import android.webkit.WebHistoryItem;
import android.webkit.WebStorage;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import c.a.a.a.p;
import c.a.a.a.q;
import c.a.a.a.r;
import c.a.a.a.s;
import c.a.a.a.t;
import c.a.a.b.g;
import c.a.a.b.i;
import c.a.a.b.k;
import c.a.a.b.m;
import c.a.a.b.n;
import c.a.a.d.e;
import c.a.a.d.h;
import c.a.a.d.j;
import c.a.a.d.l;
import c.a.a.d.o;
import com.empire.ggwin.net.f;
import com.emplre.hellogg.pkz.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipInputStream;
import org.acra.ACRA;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class FullscreenActivity extends s implements View.OnClickListener {
    private static final boolean[] G = {true, false, false, true};
    private long A = 1500;
    private long B = 20000;
    long C = 0;
    ArrayList<Boolean> D = new ArrayList<>();
    private Handler E = new c(this);
    private DialogInterface.OnClickListener F = f.f1862b;

    /* renamed from: e */
    private org.greenrobot.eventbus.c f1847e;

    /* renamed from: f */
    private Timer f1848f = new Timer("VersionCheck", true);
    private ValueCallback<Uri[]> g;
    private f h;
    private FrameLayout i;
    private View j;
    private View k;
    private RecyclerView l;
    private c.a.a.e.a m;
    private View n;
    private TextView o;
    private boolean p = false;
    private c.a.a.d.a q = new c.a.a.d.a(false);
    private c.a.a.d.a r = new c.a.a.d.a(false);
    private boolean s = true;
    private int t = 0;
    private long u = 0;
    private WeakReference<Toast> v = null;
    private HashMap<String, c.a.a.d.d> w = new HashMap<>();
    private String x = null;
    private long y = 0;
    private boolean z = true;

    public class b implements Callable<Boolean> {
        private b() {
            FullscreenActivity.this = r1;
        }

        /* JADX WARNING: Removed duplicated region for block: B:56:0x035e  */
        /* JADX WARNING: Removed duplicated region for block: B:68:0x0458  */
        /* renamed from: a */
        public Boolean call() {
            String str;
            String str2;
            String str3;
            com.empire.ggwin.net.d.b bVar;
            long j;
            long j2;
            boolean booleanValue;
            String str4;
            long currentTimeMillis = System.currentTimeMillis();
            ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
            c.a.a.d.c.b("AppInitialize", "STEP " + 1 + ": 緩存資料夾初始化");
            newSingleThreadExecutor.submit(new c.a.a.b.a(FullscreenActivity.this.getApplicationContext())).get();
            c.a.a.d.c.b("AppInitialize", "STEP " + 2 + ": 網路連線檢查中");
            while (!FullscreenActivity.this.o()) {
                newSingleThreadExecutor.submit(new c.a.a.b.c(3000)).get();
                c.a.a.d.c.b("AppInitialize", "waiting network");
                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(13, "網路尚未連接"));
            }
            ArrayList<String> m = o.p().m();
            boolean b2 = h.c().b("flags/startup/speed-test", false);
            StringBuilder sb = new StringBuilder();
            sb.append("STEP ");
            sb.append(3);
            sb.append(": 域名測速: ");
            sb.append(b2 ? "執行" : "略過");
            c.a.a.d.c.b("AppInitialize", sb.toString());
            if (b2) {
                if (m.size() == 0) {
                    m = c.a.a.c.a.f1615b;
                }
                str = (String) newSingleThreadExecutor.submit(new c.a.a.b.d((String[]) m.toArray(new String[0]))).get();
            } else {
                str = null;
            }
            if (str != null || m.size() <= 0) {
                str2 = "執行";
            } else {
                str2 = "執行";
                str = m.get((int) Math.floor(Math.random() * ((double) m.size())));
                if (b2) {
                    FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(12, new Object[]{FullscreenActivity.this.getString(R.string.tip), FullscreenActivity.this.getString(R.string.all_ping_timeout).concat(str), FullscreenActivity.this.getString(R.string.confirm), FullscreenActivity.this.F}));
                }
            }
            if (str != null && !"https://app-buildin".equals(str)) {
                c.a.a.d.c.c("AppInitialize", "Using domain: " + str);
            }
            boolean b3 = h.c().b("flags/startup/check-version-on-startup", false);
            StringBuilder sb2 = new StringBuilder();
            sb2.append("STEP ");
            sb2.append(4);
            sb2.append(": 版本檢查: ");
            if (b2) {
                str3 = str2;
            } else {
                str3 = "略過";
            }
            sb2.append(str3);
            c.a.a.d.c.b("AppInitialize", sb2.toString());
            if (b3) {
                bVar = (com.empire.ggwin.net.d.b) newSingleThreadExecutor.submit(new n(str, 10000)).get();
                if (!bVar.f1902a) {
                    throw new Exception("Connection failed");
                }
            } else {
                bVar = com.empire.ggwin.net.d.b.a(o.p().g(), o.p().i());
            }
            c.a.a.d.c.b("AppInitialize", "STEP " + 5 + ": App 版本檢查與更新");
            Context applicationContext = FullscreenActivity.this.getApplicationContext();
            String str5 = bVar.f1903b;
            String str6 = bVar.f1905d;
            l lVar = l.AUTO;
            File file = (File) newSingleThreadExecutor.submit(new k(applicationContext, str5, str6, lVar)).get();
            if (file != null) {
                c.a.a.d.c.b("AppInitialize", "Find Newer App Version, Reinstall: " + file.getName());
                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(2, file));
            }
            c.a.a.d.c.b("AppInitialize", "STEP " + 6 + ": Asset 版本檢查與更新");
            o.p().x((File) newSingleThreadExecutor.submit(new c.a.a.b.l(FullscreenActivity.this.getApplicationContext(), bVar.g, bVar.i, lVar)).get());
            c.a.a.d.c.b("AppInitialize", "STEP " + 7 + ": 設定版本檢查排程");
            FullscreenActivity.this.f1848f.schedule(new d(), 1000, 500);
            c.a.a.d.c.b("AppInitialize", "STEP " + 8 + ": 解析 Html 內置的 Options");
            FullscreenActivity.this.c0();
            long currentTimeMillis2 = System.currentTimeMillis();
            long currentTimeMillis3 = System.currentTimeMillis() + FullscreenActivity.this.A;
            if (o.p().p) {
                FullscreenActivity.this.z = false;
                j = System.currentTimeMillis() + FullscreenActivity.this.B;
            } else {
                j = currentTimeMillis3;
            }
            String e2 = o.p().e(true);
            c.a.a.d.c.b("AppInitialize", "STEP " + 9 + ": 開啟頁面: " + e2);
            int i = 0;
            while (true) {
                if (i > 0) {
                    StringBuilder sb3 = new StringBuilder();
                    j2 = currentTimeMillis2;
                    sb3.append("頁面載入失敗,重新載入 (");
                    sb3.append(i);
                    sb3.append(")");
                    c.a.a.d.c.b("AppInitialize", sb3.toString());
                } else {
                    j2 = currentTimeMillis2;
                }
                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(0, e2));
                booleanValue = ((Boolean) newSingleThreadExecutor.submit(new i(FullscreenActivity.this.r, true, 15000)).get()).booleanValue();
                i++;
                if (!booleanValue && i <= 2) {
                    currentTimeMillis2 = j2;
                    currentTimeMillis3 = currentTimeMillis3;
                } else if (!booleanValue) {
                    c.a.a.d.c.c("AppInitialize", "begin -> page loaded, cost: " + (System.currentTimeMillis() - currentTimeMillis) + " ms");
                    c.a.a.d.c.b("AppInitialize", "STEP " + 10 + ": 注入初始化腳本");
                    FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(1, "window['appVersion']=\"" + o.p().g() + "\""));
                    c.a.a.d.c.b("AppInitialize", "STEP " + 11 + ": 清理過期檔案 & 目錄");
                    newSingleThreadExecutor.submit(new c.a.a.b.b(FullscreenActivity.this.getApplication())).get();
                    c.a.a.d.c.b("AppInitialize", "初始化完成");
                    while (true) {
                        long currentTimeMillis4 = System.currentTimeMillis();
                        if (currentTimeMillis4 > currentTimeMillis3) {
                            if (currentTimeMillis4 > j) {
                                str4 = "Timeout/" + (currentTimeMillis4 - j2) + "ms";
                                break;
                            } else if (FullscreenActivity.this.z) {
                                str4 = "Flag";
                                break;
                            }
                        }
                        newSingleThreadExecutor.submit(new c.a.a.b.c(50)).get();
                    }
                    c.a.a.d.c.b("AppInitialize", "關閉 Splash 頁面 (" + str4 + ")");
                    FullscreenActivity.this.E.sendEmptyMessage(10);
                    return Boolean.TRUE;
                } else {
                    c.a.a.d.c.b("AppInitialize", "頁面載入失敗");
                    FullscreenActivity.this.E.sendEmptyMessage(96);
                    throw new Exception("Page Load Failed");
                }
            }
            if (!booleanValue) {
            }
        }
    }

    static class c extends Handler {

        /* renamed from: a */
        private WeakReference<FullscreenActivity> f1850a;

        c(FullscreenActivity fullscreenActivity) {
            this.f1850a = new WeakReference<>(fullscreenActivity);
        }

        public void handleMessage(Message message) {
            FullscreenActivity fullscreenActivity = this.f1850a.get();
            if (fullscreenActivity != null) {
                fullscreenActivity.B(message);
            }
        }
    }

    public class d extends TimerTask {

        /* renamed from: b */
        int f1851b;

        /* renamed from: c */
        long f1852c;

        /* renamed from: d */
        boolean f1853d;

        private d() {
            FullscreenActivity.this = r3;
            this.f1851b = 0;
            this.f1852c = 0;
            this.f1853d = false;
        }

        /* JADX WARNING: Removed duplicated region for block: B:109:0x04c1  */
        /* JADX WARNING: Removed duplicated region for block: B:128:0x05d4  */
        public void run() {
            com.empire.ggwin.net.d.b bVar;
            String str;
            String str2;
            String str3;
            String str4;
            File file;
            if (Looper.myLooper() == null) {
                Looper.prepare();
            }
            boolean z = System.currentTimeMillis() >= this.f1852c;
            boolean z2 = o.p().t.f1642b.f1654c == c.a.a.d.n.NONE;
            boolean z3 = o.p().t.f1642b.f1654c == c.a.a.d.n.PENDING;
            if (this.f1853d) {
                return;
            }
            if ((z && z2) || z3) {
                if (o.p().m <= 10 || z3) {
                    ArrayList<String> m = o.p().m();
                    if (m.isEmpty()) {
                        c.a.a.d.c.b("AppSync", "Skip update task, reason: domain list is empty.");
                        this.f1852c = System.currentTimeMillis() + 5000;
                        return;
                    }
                    this.f1853d = true;
                    o.p().t.a();
                    ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
                    int i = 0;
                    com.empire.ggwin.net.d.b bVar2 = null;
                    while (true) {
                        try {
                            if (m.isEmpty() || i >= 5) {
                                bVar = bVar2;
                                str = null;
                            } else {
                                if (i > 0) {
                                    Collections.shuffle(m);
                                }
                                str = m.remove(0);
                                c.a.a.d.c.c("AppSync", "版本檢查更新 (" + this.f1851b + ", " + i + "), test host = " + str);
                                bVar = (com.empire.ggwin.net.d.b) newSingleThreadExecutor.submit(new n(str, 30000)).get();
                                if (bVar.f1902a) {
                                    o.p().t.k(str);
                                    o.p().t.p(bVar);
                                    c.a.a.d.c.c("AppSync", bVar.toString());
                                    break;
                                }
                                c.a.a.d.c.c("AppSync", "Unreachable: " + str);
                                i++;
                                bVar2 = bVar;
                            }
                        } catch (Exception e2) {
                            o.p().m++;
                            o.p().t.i();
                            this.f1852c = System.currentTimeMillis() + 5000;
                            c.a.a.d.c.b("AppSync", e2.getMessage());
                            e2.printStackTrace();
                        } catch (Throwable th) {
                            this.f1851b++;
                            this.f1853d = false;
                            throw th;
                        }
                    }
                    bVar = bVar2;
                    str = null;
                    if (str != null) {
                        c.a.a.d.c.c("AppSync", "Sync versions using: " + str);
                        String g = o.p().g();
                        boolean z4 = j.e(g, bVar.f1904c) > 0;
                        if (j.e(g, bVar.f1903b) > 0) {
                            g = bVar.f1903b;
                            str2 = bVar.f1905d;
                            c.a.a.d.c.c("AppSync", "APK: find newer version (new): " + g);
                        } else {
                            str2 = null;
                        }
                        if (j.e(g, bVar.f1906e) > 0) {
                            g = bVar.f1906e;
                            str2 = bVar.f1907f;
                            c.a.a.d.c.c("AppSync", "APK: find newer version (rc): " + g);
                        }
                        if (str2 != null) {
                            c.a.a.d.c.c("AppSync", "app downloading: " + g);
                            if (z4) {
                                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 1, 0));
                            }
                            o.p().t.f();
                            File file2 = (File) newSingleThreadExecutor.submit(new k(FullscreenActivity.this.getApplicationContext(), g, str2, l.HARD)).get();
                            c.a.a.d.c.d("AppSync", "## 等待主程序同步 ##");
                            c.a.a.d.a aVar = new c.a.a.d.a(false);
                            org.greenrobot.eventbus.c.c().l(new c.a.a.a.n(aVar));
                            newSingleThreadExecutor.submit(new c.a.a.b.h(aVar, 5000)).get();
                            if (file2 != null) {
                                c.a.a.d.c.d("AppSync", "有新版本 App: " + file2.getAbsolutePath());
                                o.p().t.l();
                                if (z4) {
                                    c.a.a.d.a aVar2 = new c.a.a.d.a(false);
                                    FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 3, 0, aVar2));
                                    boolean booleanValue = ((Boolean) newSingleThreadExecutor.submit(new c.a.a.b.h(aVar2)).get()).booleanValue();
                                    FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 0, 0));
                                    if (booleanValue) {
                                        FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(2, file2));
                                    }
                                } else if (!o.p().q.contains(g) || o.p().t.g) {
                                    c.a.a.d.a aVar3 = new c.a.a.d.a(false);
                                    org.greenrobot.eventbus.c.c().l(new c.a.a.a.l("检测到版本更新", "最新的应用版本为 " + g + " 请更新以获得更好的体验", "更新", "取消", aVar3));
                                    if (((Boolean) newSingleThreadExecutor.submit(new c.a.a.b.h(aVar3)).get()).booleanValue()) {
                                        FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(2, file2));
                                    } else {
                                        o.p().q.add(g);
                                    }
                                } else {
                                    c.a.a.d.c.c("AppSync", "app update arrival, skip notification");
                                }
                            } else {
                                c.a.a.d.c.b("AppSync", "檔案異常: " + file2);
                                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 0, 0));
                            }
                        }
                        String i2 = o.p().i();
                        boolean z5 = j.e(i2, bVar.h) > 0;
                        if (j.e(i2, bVar.g) > 0) {
                            i2 = bVar.g;
                            str4 = bVar.i;
                            str3 = bVar.j;
                            c.a.a.d.c.c("AppSync", "Asset: find newer version (new): " + i2);
                        } else {
                            str4 = null;
                            str3 = null;
                        }
                        if (j.e(i2, bVar.k) > 0) {
                            i2 = bVar.k;
                            str4 = bVar.l;
                            str3 = bVar.m;
                            c.a.a.d.c.c("AppSync", "Asset: find newer version (rc): " + i2);
                        }
                        if (str3 != null && !str3.trim().isEmpty()) {
                            if (z5) {
                                FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 1, 0));
                            }
                            String str5 = str + str3;
                            c.a.a.d.c.d("AppSync", "loading manifest.json " + str5);
                            JSONObject jSONObject = (JSONObject) newSingleThreadExecutor.submit(new g(str5, 30000)).get();
                            if (jSONObject != null) {
                                o.p().t.e();
                                file = (File) newSingleThreadExecutor.submit(new m(FullscreenActivity.this.getApplicationContext(), i2, str, jSONObject, l.HARD)).get();
                                o.p().m = 0;
                                if (file != null) {
                                    c.a.a.d.a aVar4 = new c.a.a.d.a(false);
                                    if (z5) {
                                        FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 3, 0, aVar4));
                                        boolean booleanValue2 = ((Boolean) newSingleThreadExecutor.submit(new c.a.a.b.h(aVar4)).get()).booleanValue();
                                        FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 0, 0));
                                        if (booleanValue2) {
                                            o.p().y(i2);
                                            o.p().x(file);
                                            FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(3, 1, 0));
                                        } else {
                                            o.p().r.add(i2);
                                        }
                                    } else if (!o.p().r.contains(i2) || o.p().t.g) {
                                        org.greenrobot.eventbus.c.c().l(new c.a.a.a.l("检测到资源包更新", "最新的资源包版本为 " + i2 + " 请更新以获得更好的体验", "更新", z5 ? null : "取消", aVar4));
                                        if (((Boolean) newSingleThreadExecutor.submit(new c.a.a.b.h(aVar4)).get()).booleanValue()) {
                                            o.p().y(i2);
                                            o.p().x(file);
                                            o.p().t.d();
                                            FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(3, 1, 0));
                                        } else {
                                            o.p().r.add(i2);
                                        }
                                    } else {
                                        c.a.a.d.c.c("AppSync", "asset update arrival, skip notification");
                                    }
                                } else {
                                    FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 0, 0));
                                }
                                o.p().t.d();
                                this.f1852c = System.currentTimeMillis() + 30000;
                                this.f1851b++;
                                this.f1853d = false;
                                return;
                            }
                            FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 0, 0));
                            c.a.a.d.c.b("AppSync", "Cannot fetch manifest.json: " + str5);
                        }
                        if (str4 == null || str4.trim().isEmpty()) {
                            file = null;
                            if (file != null) {
                            }
                            o.p().t.d();
                            this.f1852c = System.currentTimeMillis() + 30000;
                            this.f1851b++;
                            this.f1853d = false;
                            return;
                        }
                        c.a.a.d.c.c("AppSync", "asset downloading: " + i2);
                        if (z5) {
                            FullscreenActivity.this.E.sendMessage(FullscreenActivity.this.E.obtainMessage(30, 1, 0));
                        }
                        if (!str4.toLowerCase().startsWith("https://") && !str4.toLowerCase().startsWith("http://")) {
                            str4 = str + str4;
                            c.a.a.d.c.d("AppSync", "Replace download url as " + str4);
                        }
                        o.p().t.e();
                        file = (File) newSingleThreadExecutor.submit(new c.a.a.b.l(FullscreenActivity.this.getApplicationContext(), i2, str4, l.HARD)).get();
                        if (file != null) {
                        }
                        o.p().t.d();
                        this.f1852c = System.currentTimeMillis() + 30000;
                        this.f1851b++;
                        this.f1853d = false;
                        return;
                    }
                    throw new Exception("Connection failed: Unreached hosts");
                }
            }
        }
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: C */
    public /* synthetic */ void D() {
        this.l.scrollBy(0, Integer.MAX_VALUE);
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: E */
    public /* synthetic */ void F(DialogInterface dialogInterface, int i2) {
        this.E.sendEmptyMessage(98);
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: G */
    public /* synthetic */ void H(DialogInterface dialogInterface, int i2) {
        c.a.a.d.c.b("FullscreenActivity", "頁面啟動失敗,清除暫存資料並重啟應用");
        org.greenrobot.eventbus.c.c().l(new c.a.a.a.m());
        e.f(o.p().j(), true);
        e.f(o.p().n(), true);
        e.f(o.p().o(), true);
        e.f(o.p().t(), true);
        WebStorage.getInstance().deleteAllData();
        o.p().z("");
        o.p().w("GGWeb");
        this.E.sendEmptyMessage(97);
        this.E.sendEmptyMessageDelayed(98, 3000);
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: K */
    public /* synthetic */ void L(DialogInterface dialogInterface, int i2) {
        if (!o.p().f1671e) {
            o.p().f1671e = true;
            new AlertDialog.Builder(this).setMessage("侦错模式已开启。关闭应用将恢复为一般模式").create().show();
        }
    }

    static /* synthetic */ void M(DialogInterface dialogInterface, int i2) {
    }

    static /* synthetic */ void N(DialogInterface dialogInterface, int i2) {
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: O */
    public /* synthetic */ void P() {
        this.l.scrollBy(0, Integer.MAX_VALUE);
    }

    static /* synthetic */ void Q(View view) {
    }

    static /* synthetic */ boolean R(View view) {
        return true;
    }

    static /* synthetic */ boolean S(View view, MotionEvent motionEvent) {
        return false;
    }

    static /* synthetic */ boolean T(View view, DragEvent dragEvent) {
        return true;
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: U */
    public /* synthetic */ void V() {
        try {
            Executors.newSingleThreadExecutor().submit(new b()).get();
        } catch (Exception e2) {
            StringBuilder sb = new StringBuilder();
            sb.append(e2.getMessage());
            sb.append(", SenderService");
            sb.append(ACRA.isACRASenderServiceProcess() ? "啟用" : "停用");
            c.a.a.d.c.b("PIPE", sb.toString());
            ACRA.getErrorReporter().handleSilentException(e2);
        }
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: W */
    public /* synthetic */ WindowInsets X(View view, WindowInsets windowInsets) {
        DisplayCutout displayCutout;
        o.p().n = 0;
        if (Build.VERSION.SDK_INT >= 28 && (displayCutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout()) != null && displayCutout.getSafeInsetTop() > 0) {
            o.p().n = displayCutout.getSafeInsetTop();
        }
        return view.onApplyWindowInsets(windowInsets);
    }

    /* access modifiers changed from: public */
    /* access modifiers changed from: private */
    /* renamed from: Y */
    public /* synthetic */ void Z() {
        this.l.scrollBy(0, Integer.MAX_VALUE);
    }

    /* JADX WARNING: Removed duplicated region for block: B:106:0x0256  */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x025b  */
    /* JADX WARNING: Removed duplicated region for block: B:110:0x0264  */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x0269  */
    /* JADX WARNING: Removed duplicated region for block: B:114:0x0272  */
    /* JADX WARNING: Removed duplicated region for block: B:115:0x0277  */
    /* JADX WARNING: Removed duplicated region for block: B:118:0x0280  */
    /* JADX WARNING: Removed duplicated region for block: B:119:0x0285  */
    /* JADX WARNING: Removed duplicated region for block: B:122:0x028e  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x019b  */
    private JSONObject a0(String str, JSONObject jSONObject) {
        String string;
        String string2;
        String string3;
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("method", str);
        if (!jSONObject.has("___AUTHORITY___") || !c.a.a.d.f.a().f1632a.equals(jSONObject.getString("___AUTHORITY___"))) {
            c.a.a.d.c.d("FullscreenActivity", "Warning: nativeCall require AUTHORITY");
            jSONObject2.put("error", "Unauthorized");
            return jSONObject2;
        }
        str.hashCode();
        char c2 = 65535;
        switch (str.hashCode()) {
            case -1935967925:
                if (str.equals("nativeStorageReset")) {
                    c2 = 0;
                    break;
                }
                break;
            case -1839544384:
                if (str.equals("nativeUpdate")) {
                    c2 = 1;
                    break;
                }
                break;
            case -1319506571:
                if (str.equals("nativeClipboardRead")) {
                    c2 = 2;
                    break;
                }
                break;
            case -1171037576:
                if (str.equals("nativeStorageKeys")) {
                    c2 = 3;
                    break;
                }
                break;
            case 80961351:
                if (str.equals("nativeConnectionAbilityTest")) {
                    c2 = 4;
                    break;
                }
                break;
            case 114367496:
                if (str.equals("nativeStorageRemove")) {
                    c2 = 5;
                    break;
                }
                break;
            case 319351750:
                if (str.equals("nativeExternalBrowser")) {
                    c2 = 6;
                    break;
                }
                break;
            case 347175497:
                if (str.equals("hideSplash")) {
                    c2 = 7;
                    break;
                }
                break;
            case 377862738:
                if (str.equals("nativeStorageGet")) {
                    c2 = '\b';
                    break;
                }
                break;
            case 377874270:
                if (str.equals("nativeStorageSet")) {
                    c2 = '\t';
                    break;
                }
                break;
            case 955534258:
                if (str.equals("methods")) {
                    c2 = '\n';
                    break;
                }
                break;
            case 2049982432:
                if (str.equals("nativeClipboardWrite")) {
                    c2 = 11;
                    break;
                }
                break;
        }
        String str2 = null;
        String str3 = "";
        switch (c2) {
            case 0:
                o.p().w("GGWeb");
                return jSONObject2;
            case 1:
                int i2 = !jSONObject.has("session") ? jSONObject.getInt("session") : 0;
                string = !jSONObject.has("assetVer") ? jSONObject.getString("assetVer") : str3;
                string2 = !jSONObject.has("assetUrl") ? jSONObject.getString("assetUrl") : str3;
                string3 = !jSONObject.has("appVer") ? jSONObject.getString("appVer") : str3;
                if (jSONObject.has("appUrl")) {
                    str3 = jSONObject.getString("appUrl");
                }
                if (!string.isEmpty() && !string2.isEmpty()) {
                    o.p().t.f1643c = string;
                    o.p().t.f1644d = string2;
                }
                if (!string3.isEmpty() && !str3.isEmpty()) {
                    o.p().t.f1645e = string3;
                    o.p().t.f1646f = str3;
                }
                jSONObject2.put("data", o.p().t.j(i2));
                return jSONObject2;
            case 2:
                ClipData primaryClip = ((ClipboardManager) getSystemService("clipboard")).getPrimaryClip();
                JSONObject jSONObject3 = new JSONObject();
                jSONObject3.put("text", str3);
                if (primaryClip != null) {
                    jSONObject3.put("text", primaryClip.getItemAt(0).getText().toString());
                }
                jSONObject2.put("data", jSONObject3);
                return jSONObject2;
            case 3:
                jSONObject2.put("data", new JSONArray(o.p().s("GGWeb")));
                return jSONObject2;
            case 4:
                String string4 = jSONObject.has("host") ? jSONObject.getString("host") : null;
                if (jSONObject.has("method")) {
                    str2 = jSONObject.getString("method");
                }
                try {
                    URL url = new URL(string4);
                    c.a.a.d.c.b("FullscreenActivity", "連線測試: " + url.toString());
                    if (str2.hashCode() == -363665238) {
                        str2.equals("PingPong");
                    }
                    jSONObject2.put("data", new com.empire.ggwin.net.e().c(url.toString()));
                    c.a.a.d.c.b("FullscreenActivity", "測試完成, 返回:" + jSONObject2.toString(4));
                    return jSONObject2;
                } catch (Exception unused) {
                    jSONObject2.put("error", "incorrect args");
                    return jSONObject2;
                }
            case 5:
                if (jSONObject.has("key")) {
                    o.p().a("GGWeb", jSONObject.getString("key"));
                    return jSONObject2;
                }
                jSONObject2.put("error", "incorrect args");
                if (!jSONObject2.has("error")) {
                    jSONObject2.put("error", "unknown method");
                }
                return jSONObject2;
            case 6:
                if (jSONObject.has("url")) {
                    c.a.a.d.c.c("FullscreenActivity", "JS/Interface: nativeExternalBrowser");
                    org.greenrobot.eventbus.c.c().l(new c.a.a.a.j(jSONObject.getString("url")));
                    return jSONObject2;
                }
                jSONObject2.put("error", "incorrect args");
                if (!jSONObject.has("session")) {
                }
                if (!jSONObject.has("assetVer")) {
                }
                if (!jSONObject.has("assetUrl")) {
                }
                if (!jSONObject.has("appVer")) {
                }
                if (jSONObject.has("appUrl")) {
                }
                o.p().t.f1643c = string;
                o.p().t.f1644d = string2;
                o.p().t.f1645e = string3;
                o.p().t.f1646f = str3;
                jSONObject2.put("data", o.p().t.j(i2));
                return jSONObject2;
            case 7:
                this.z = true;
                return jSONObject2;
            case '\b':
                if (jSONObject.has("key")) {
                    jSONObject2.put("data", o.p().r("GGWeb", jSONObject.getString("key"), null));
                    return jSONObject2;
                }
                jSONObject2.put("error", "incorrect args");
                if (!jSONObject2.has("error")) {
                }
                return jSONObject2;
            case '\t':
                if (!jSONObject.has("key") || !jSONObject.has("value")) {
                    jSONObject2.put("error", "incorrect args");
                    if (!jSONObject2.has("error")) {
                    }
                    return jSONObject2;
                }
                o.p().B("GGWeb", jSONObject.getString("key"), jSONObject.getString("value"));
                return jSONObject2;
            case '\n':
                jSONObject2.put("data", new JSONArray(new String[]{"methods", "nativeStorageSet", "nativeStorageGet", "nativeStorageRemove", "nativeStorageReset", "nativeStorageKeys", "hideSplash", "nativeExternalBrowser", "nativeUpdate", "nativeClipboardRead", "nativeClipboardWrite", "nativeConnectionAbilityTest"}));
                return jSONObject2;
            case 11:
                if (jSONObject.has("text")) {
                    str2 = jSONObject.getString("text");
                }
                if (str2 != null) {
                    ((ClipboardManager) getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("text", str2));
                }
                return jSONObject2;
            default:
                if (!jSONObject2.has("error")) {
                }
                return jSONObject2;
        }
    }

    private void b0(String str) {
        if (androidx.core.content.a.a(this, str) != 0) {
            androidx.core.app.a.m(this, new String[]{str}, 200);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0043, code lost:
        r4 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:?, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0048, code lost:
        r3 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x0049, code lost:
        r1.addSuppressed(r3);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x004c, code lost:
        throw r4;
     */
    private void c0() {
        File file = new File(o.p().h(), "index.html");
        HashMap hashMap = new HashMap();
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            Matcher matcher = Pattern.compile("<meta\\s+name=\"MobileContainer-([^\"]+)\"\\s+content=\"([^\"]+)\">", 42).matcher(e.k(fileInputStream));
            while (matcher.find()) {
                hashMap.put(matcher.group(1), matcher.group(2));
            }
            fileInputStream.close();
        } catch (IOException unused) {
        }
        for (String str : hashMap.keySet()) {
            c.a.a.d.c.c("resolveHtmlMetaData", "HtmlOption/" + str + " => " + ((String) hashMap.get(str)));
        }
        String str2 = (String) hashMap.get("Splash-Control");
        if (str2 != null && str2.equalsIgnoreCase("true")) {
            o.p().p = true;
        }
        c.a.a.d.c.c("resolveHtmlMetaData", "Options: SplashControl = " + o.p().p);
        String str3 = (String) hashMap.get("Cutout-Supported");
        if (str3 != null && str3.equalsIgnoreCase("true")) {
            o.p().o = true;
        }
        c.a.a.d.c.c("resolveHtmlMetaData", "Options: CutoutSupported = " + o.p().o);
    }

    private void d0() {
        c.a.a.d.d dVar;
        String str;
        String str2 = this.x;
        if (str2 != null && (dVar = this.w.get(str2)) != null) {
            long j2 = dVar.f1629c;
            if (j2 > this.y) {
                this.y = j2;
                double d2 = 0.0d;
                long j3 = dVar.f1628b;
                if (j3 > 0) {
                    d2 = (((double) dVar.f1627a) * 100.0d) / ((double) j3);
                }
                double a2 = dVar.a();
                StringBuilder sb = new StringBuilder();
                sb.append("Downloading (");
                sb.append(this.x);
                sb.append("): ");
                int i2 = 1;
                sb.append(String.format("%.1f", Double.valueOf(d2)));
                sb.append("% (speed: ");
                sb.append(String.format("%.2f", Double.valueOf(a2)));
                sb.append("KBs)");
                c.a.a.d.c.d("FullscreenActivity", sb.toString());
                ProgressBar progressBar = (ProgressBar) findViewById(R.id.prog_stats);
                TextView textView = (TextView) findViewById(R.id.prog_info);
                if (progressBar != null && textView != null) {
                    if (dVar.f1628b > 0) {
                        str = String.format("%.1f%%", Double.valueOf(d2));
                        i2 = (int) Math.round(d2);
                    } else {
                        str = "0%";
                    }
                    progressBar.setProgress(i2);
                    textView.setText(str);
                }
            }
        }
    }

    private void e0() {
        if (this.s) {
            this.t++;
            ((TextView) findViewById(R.id.loadingText)).setText(getString(R.string.load_resource) + "...".substring(0, this.t % 4));
            Handler handler = this.E;
            handler.sendMessageDelayed(handler.obtainMessage(11), 250);
        }
    }

    public void B(Message message) {
        int i2 = message.what;
        if (i2 != 0) {
            c.a.a.d.a aVar = null;
            boolean z2 = true;
            if (i2 == 1) {
                this.h.evaluateJavascript((String) message.obj, null);
            } else if (i2 == 2) {
                n((File) message.obj);
            } else if (i2 == 3) {
                if (message.arg1 == 1) {
                    this.h.clearCache(true);
                }
                this.h.loadUrl(o.p().e(true));
            } else if (i2 == 10) {
                this.s = false;
                findViewById(R.id.loadingContainer).setVisibility(8);
            } else if (i2 == 16) {
                ((AlertDialog) message.obj).show();
            } else if (i2 == 40) {
                Handler handler = this.E;
                handler.sendMessageDelayed(handler.obtainMessage(40), 250);
                if (this.s) {
                    e0();
                }
                if (this.x != null) {
                    d0();
                }
            } else if (i2 != 20) {
                if (i2 != 21) {
                    if (i2 == 30) {
                        int i3 = message.arg1;
                        if (i3 == 0) {
                            this.k.setVisibility(8);
                        } else if (i3 == 1) {
                            c.a.a.d.c.b("FullscreenActivity", "[強更頁] 顯示下載中");
                            ((TextView) this.k.findViewById(R.id.prog_info)).setText("0%");
                            ((ProgressBar) this.k.findViewById(R.id.prog_stats)).setProgress(1);
                            ((ImageView) this.k.findViewById(R.id.img_complete)).setVisibility(8);
                            TextView textView = (TextView) findViewById(R.id.text_update_msg);
                            textView.setTextColor(-16777216);
                            textView.setText("正在火速更新中...");
                            ((TextView) findViewById(R.id.text_update_notice)).setText("更新过程中请勿随意关闭应用程式,并保持在稳定的网路环境,以免更新不完整而导致 APP 异常!");
                            this.k.findViewById(R.id.btn_complete).setVisibility(8);
                            this.k.setVisibility(0);
                        } else if (i3 == 2) {
                            c.a.a.d.c.b("FullscreenActivity", "[強更頁] 顯示處理中");
                            TextView textView2 = (TextView) findViewById(R.id.text_update_msg);
                            textView2.setTextColor(getResources().getColor(R.color.download_page_1));
                            textView2.setText("资料处理中");
                            ((TextView) findViewById(R.id.text_update_notice)).setText("正在更新游戏资料中,请勿关闭应用程式,以免更新不完整而导致 APP 异常!");
                            this.k.findViewById(R.id.btn_complete).setVisibility(8);
                        } else if (i3 == 3) {
                            c.a.a.d.c.b("FullscreenActivity", "[強更頁] 顯示完成");
                            ((ImageView) this.k.findViewById(R.id.img_complete)).setVisibility(0);
                            TextView textView3 = (TextView) findViewById(R.id.text_update_msg);
                            textView3.setTextColor(getResources().getColor(R.color.download_page_1));
                            textView3.setText("太好了!更新完成了!");
                            ((TextView) findViewById(R.id.text_update_notice)).setText("赶快来享受极致的游戏体验吧!");
                            View findViewById = this.k.findViewById(R.id.btn_complete);
                            findViewById.setVisibility(0);
                            Object obj = message.obj;
                            if (obj instanceof c.a.a.d.a) {
                                aVar = (c.a.a.d.a) obj;
                            }
                            if (aVar != null) {
                                findViewById.setOnClickListener(new d(aVar));
                            }
                        }
                    } else if (i2 != 31) {
                        switch (i2) {
                            case 12:
                                Object[] objArr = (Object[]) message.obj;
                                new AlertDialog.Builder(this).setTitle((String) objArr[0]).setMessage((String) objArr[1]).setPositiveButton((String) objArr[2], (DialogInterface.OnClickListener) objArr[3]).setCancelable(false).create().show();
                                return;
                            case 13:
                                Toast.makeText(getApplicationContext(), (String) message.obj, 0).show();
                                return;
                            case 14:
                                int i4 = message.arg1;
                                if (i4 == 24 || i4 == 25) {
                                    if (o.p().f1671e) {
                                        if (i4 == 24) {
                                            this.E.sendEmptyMessage(20);
                                        } else {
                                            this.E.sendEmptyMessage(21);
                                        }
                                    }
                                    if (System.currentTimeMillis() - this.C > 800) {
                                        this.D.clear();
                                    }
                                    this.D.add(Boolean.valueOf(i4 == 24));
                                    this.C = System.currentTimeMillis();
                                    while (this.D.size() > 10) {
                                        this.D.remove(0);
                                    }
                                    if (this.D.size() >= G.length) {
                                        int i5 = 0;
                                        while (true) {
                                            boolean[] zArr = G;
                                            if (i5 < zArr.length) {
                                                if (zArr[i5] != this.D.get((this.D.size() - i5) - 1).booleanValue()) {
                                                    z2 = false;
                                                } else {
                                                    i5++;
                                                }
                                            }
                                        }
                                        if (z2 && !o.p().f1671e) {
                                            AlertDialog.Builder builder = new AlertDialog.Builder(this);
                                            builder.setMessage("开启侦错模式").setPositiveButton("开启", new g(this)).setNegativeButton("取消", i.f1865b);
                                            builder.create().show();
                                            return;
                                        }
                                        return;
                                    }
                                    return;
                                }
                                return;
                            default:
                                switch (i2) {
                                    case 95:
                                        c.a.a.d.c.d("FullscreenActivity", "## 進行主程序同步 ##");
                                        Object obj2 = message.obj;
                                        if (obj2 instanceof c.a.a.d.a) {
                                            aVar = (c.a.a.d.a) obj2;
                                        }
                                        if (aVar != null) {
                                            aVar.c(true);
                                            return;
                                        }
                                        return;
                                    case 96:
                                        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
                                        builder2.setMessage("页面载入失败,您可以尝试以下方式进行修复:1) 重启应用,2) 清除资料后重启,3) 卸载应用后重新下载安装").setPositiveButton("立即重启", new h(this)).setNegativeButton("清除资料", new o(this));
                                        builder2.create().show();
                                        return;
                                    case 97:
                                        f fVar = this.h;
                                        if (fVar != null) {
                                            fVar.evaluateJavascript("localStorage.clear();", null);
                                            return;
                                        }
                                        return;
                                    case 98:
                                        ((AlarmManager) getSystemService("alarm")).set(1, System.currentTimeMillis() + 1500, PendingIntent.getActivity(this, 1, new Intent(this, FullscreenActivity.class), 268435456));
                                        this.E.postDelayed(b.f1858b, 1000);
                                        return;
                                    case 99:
                                        int floor = (int) Math.floor(0.1d);
                                        c.a.a.d.c.b("FullscreenActivity", "suicide: " + (1 / floor));
                                        return;
                                    default:
                                        return;
                                }
                        }
                    } else {
                        p pVar = (p) message.obj;
                        if (!this.w.containsKey(pVar.f1569a)) {
                            HashMap<String, c.a.a.d.d> hashMap = this.w;
                            String str = pVar.f1569a;
                            hashMap.put(str, new c.a.a.d.d(str, pVar.f1570b, pVar.f1572d));
                        } else {
                            c.a.a.d.d dVar = this.w.get(pVar.f1569a);
                            if (dVar != null) {
                                dVar.f1627a = pVar.f1570b;
                                dVar.f1629c = System.currentTimeMillis();
                            }
                        }
                        String str2 = this.x;
                        if (str2 == null || !str2.equalsIgnoreCase(pVar.f1569a)) {
                            this.x = pVar.f1569a;
                            this.y = 0;
                        }
                    }
                } else if (this.j.getVisibility() != 8) {
                    this.m.y(false);
                    this.j.setVisibility(8);
                }
            } else if (this.j.getVisibility() != 0) {
                ArrayList<String> m2 = o.p().m();
                String a2 = m2.size() > 0 ? j.a(m2, "\n\t") : "";
                String b2 = o.p().b();
                c.a.a.d.c.c("FullscreenActivity", "Package: " + getApplication().getPackageName() + "\n\tAppVersion: " + o.p().g() + "\n\tAssetVersion(U): " + o.p().i() + "\n\tAssetVersion(O): " + o.p().q() + "\n\tDeviceId: " + o.p().k() + "\nHosts (" + m2.size() + "):\n\t" + a2 + "\nBundle Build Info:\n\t" + b2);
                this.j.setVisibility(0);
                this.m.y(true);
                runOnUiThread(new l(this));
            }
        } else {
            this.h.loadUrl((String) message.obj);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:34:0x00b2, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x00b3, code lost:
        if (r5 != null) goto L_0x00b5;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:?, code lost:
        r5.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x00b9, code lost:
        r5 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:39:0x00ba, code lost:
        r7.addSuppressed(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x00bd, code lost:
        throw r0;
     */
    @Override // b.h.a.d
    public void onActivityResult(int i2, int i3, Intent intent) {
        Uri data;
        if (i2 == 13 && this.g != null) {
            Uri data2 = (intent == null || i3 != -1) ? null : intent.getData();
            this.g.onReceiveValue(data2 == null ? new Uri[0] : new Uri[]{data2});
            this.g = null;
        } else if (i2 == 14 && intent != null && i3 == -1 && (data = intent.getData()) != null) {
            c.a.a.d.c.d("FullscreenActivity", "选择本地端的 AssetBundle 包, 开始进行解压缩");
            try {
                InputStream openInputStream = getContentResolver().openInputStream(data);
                e.m(new ZipInputStream(openInputStream), "asset_9999.9999.9999");
                File file = new File(o.p().j(), "asset_9999.9999.9999");
                if (file.exists()) {
                    file.isDirectory();
                }
                c.a.a.d.c.b("FullscreenActivity", "完成本地端 Asset Bundle 解壓縮, 开始进行置换");
                WebStorage.getInstance().deleteAllData();
                o.p().z("");
                o.p().w("GGWeb");
                this.E.sendEmptyMessage(97);
                o.p().y("9999.9999.9999");
                o.p().x(file);
                Handler handler = this.E;
                handler.sendMessage(handler.obtainMessage(3, 1, 0));
                c.a.a.d.c.b("FullscreenActivity", "完成本地端 Asset Bundle 置换 & 加载");
                if (openInputStream != null) {
                    openInputStream.close();
                }
            } catch (FileNotFoundException e2) {
                c.a.a.d.c.d("FullscreenActivity", "Import Failed, cause FileNotFoundException: " + e2.getMessage());
            } catch (IOException e3) {
                c.a.a.d.c.d("FullscreenActivity", "Import Failed, cause IOException: " + e3.getMessage());
            } catch (Exception e4) {
                c.a.a.d.c.d("FullscreenActivity", "Import Failed, ??: " + e4.getMessage());
            }
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.anchorBtn /*{ENCODED_INT: 2131165214}*/:
                boolean z2 = !this.p;
                this.p = z2;
                if (z2) {
                    this.n.setBackground(getResources().getDrawable(R.drawable.shape_circle_button_red, getTheme()));
                    return;
                }
                this.n.setBackground(getResources().getDrawable(R.drawable.shape_circle_button_default, getTheme()));
                runOnUiThread(new n(this));
                return;
            case R.id.closeBtn /*{ENCODED_INT: 2131165231}*/:
                this.m.t();
                return;
            case R.id.envBtn /*{ENCODED_INT: 2131165248}*/:
                c.a.a.d.b bVar = o.p().s;
                Button button = (Button) findViewById(R.id.envBtn);
                c.a.a.d.b bVar2 = c.a.a.d.b.PROD;
                if (bVar == bVar2) {
                    o.p().s = c.a.a.d.b.STAGING;
                    button.setText("灰");
                    button.setBackgroundResource(R.drawable.shape_circle_button_default);
                    button.setTextColor(Color.rgb(255, 255, 255));
                } else {
                    o.p().s = bVar2;
                    button.setText("正");
                    button.setBackgroundResource(R.drawable.shape_circle_button_green);
                    button.setTextColor(Color.rgb(0, 0, 0));
                }
                Handler handler = this.E;
                handler.sendMessage(handler.obtainMessage(3, 1, 0));
                return;
            case R.id.exportBtn /*{ENCODED_INT: 2131165251}*/:
                org.greenrobot.eventbus.c.c().l(new c.a.a.a.m());
                return;
            case R.id.importBtn /*{ENCODED_INT: 2131165268}*/:
                Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT");
                intent.addCategory("android.intent.category.OPENABLE");
                intent.setType("application/zip");
                startActivityForResult(intent, 14);
                return;
            case R.id.restartBtn /*{ENCODED_INT: 2131165302}*/:
                e.f(o.p().j(), true);
                e.f(o.p().n(), true);
                e.f(o.p().o(), true);
                e.f(o.p().t(), true);
                WebStorage.getInstance().deleteAllData();
                o.p().z("");
                o.p().w("GGWeb");
                this.E.sendEmptyMessage(97);
                this.E.sendEmptyMessageDelayed(98, 1000);
                return;
            case R.id.suicideBtn /*{ENCODED_INT: 2131165338}*/:
                this.E.sendEmptyMessage(99);
                return;
            default:
                return;
        }
    }

    @Override // androidx.core.app.d, androidx.appcompat.app.c, b.h.a.d
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_fullscreen_v2);
        getWindow().setFlags(16777216, 16777216);
        o.v(this);
        h.c().e(this);
        org.greenrobot.eventbus.c c2 = org.greenrobot.eventbus.c.c();
        this.f1847e = c2;
        c2.p(this);
        f fVar = new f(this);
        this.h = fVar;
        fVar.getSettings().setAllowFileAccessFromFileURLs(true);
        Log.w("WebViewActivity", "UA: " + this.h.getSettings().getUserAgentString());
        FrameLayout frameLayout = (FrameLayout) findViewById(R.id.webViewContainer);
        this.i = frameLayout;
        frameLayout.setBackgroundColor(-16777216);
        this.i.addView(this.h);
        ((TextView) findViewById(R.id.versionText)).setText("v".concat(o.p().g()));
        this.j = findViewById(R.id.debugContainer);
        View findViewById = findViewById(R.id.anchorBtn);
        this.n = findViewById;
        findViewById.setOnClickListener(this);
        TextView textView = (TextView) findViewById(R.id.txtCount);
        this.o = textView;
        textView.setText("0");
        findViewById(R.id.closeBtn).setOnClickListener(this);
        findViewById(R.id.exportBtn).setOnClickListener(this);
        findViewById(R.id.suicideBtn).setOnClickListener(this);
        findViewById(R.id.restartBtn).setOnClickListener(this);
        findViewById(R.id.importBtn).setOnClickListener(this);
        findViewById(R.id.envBtn).setOnClickListener(this);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        this.l = (RecyclerView) findViewById(R.id.recyclerView);
        this.m = new c.a.a.e.a(this);
        this.l.setLayoutManager(linearLayoutManager);
        this.l.setAdapter(this.m);
        this.m.x(500);
        View findViewById2 = findViewById(R.id.updateContainer);
        this.k = findViewById2;
        findViewById2.setOnClickListener(m.f1869b);
        this.k.setOnLongClickListener(j.f1866b);
        this.k.setOnTouchListener(q.f1873b);
        this.k.setOnDragListener(k.f1867a);
        this.k.setVisibility(8);
        b0("android.permission.WRITE_EXTERNAL_STORAGE");
        if (Build.VERSION.SDK_INT >= 23) {
            b0("android.permission.REQUEST_INSTALL_PACKAGES");
        }
        new Thread(new p(this)).start();
        this.E.sendEmptyMessage(21);
        Handler handler = this.E;
        handler.sendMessageDelayed(handler.obtainMessage(40), 250);
        findViewById(R.id.content_root).setOnApplyWindowInsetsListener(new c(this));
    }

    @Override // androidx.appcompat.app.c, b.h.a.d
    public void onDestroy() {
        super.onDestroy();
        this.f1847e.r(this);
        f fVar = this.h;
        if (fVar != null) {
            this.i.removeView(fVar);
            this.h.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
            this.h.clearHistory();
            this.h.removeAllViews();
            this.h.destroy();
        }
    }

    public void onEvent(s sVar) {
        this.q.c(true);
    }

    @Override // androidx.appcompat.app.c
    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        if (keyEvent.getAction() == 0 && i2 == 4) {
            WebBackForwardList copyBackForwardList = this.h.copyBackForwardList();
            WebHistoryItem currentItem = copyBackForwardList.getCurrentItem();
            if (currentItem != null) {
                String url = currentItem.getUrl();
                String c2 = o.p().c();
                c.a.a.d.c.d("FullscreenActivity", "檢測返回事件: " + url + " (" + copyBackForwardList.getCurrentIndex() + "/" + copyBackForwardList.getSize() + "), home is " + c2);
                if (this.h.canGoBack() && !c2.equalsIgnoreCase(url)) {
                    this.u = 0;
                    this.h.goBack();
                } else if (System.currentTimeMillis() - this.u > 4000) {
                    this.u = System.currentTimeMillis();
                    WeakReference<Toast> weakReference = new WeakReference<>(Toast.makeText(this, getString(R.string.ready_exit), 1));
                    this.v = weakReference;
                    weakReference.get().show();
                } else {
                    if (this.v.get() != null) {
                        this.v.get().cancel();
                    }
                    finish();
                }
            }
            return true;
        }
        if (keyEvent.getAction() == 0 && i2 == 25) {
            Handler handler = this.E;
            handler.sendMessage(handler.obtainMessage(14, i2, 0));
        } else if (keyEvent.getAction() == 0 && i2 == 24) {
            Handler handler2 = this.E;
            handler2.sendMessage(handler2.obtainMessage(14, i2, 0));
        }
        return super.onKeyDown(i2, keyEvent);
    }

    @Override // b.h.a.d
    public void onPause() {
        org.greenrobot.eventbus.c.c().r(this);
        this.h.onPause();
        this.h.pauseTimers();
        super.onPause();
    }

    @Override // b.h.a.d
    public void onResume() {
        if (!org.greenrobot.eventbus.c.c().j(this)) {
            org.greenrobot.eventbus.c.c().p(this);
        }
        this.h.onResume();
        this.h.resumeTimers();
        super.onResume();
    }

    public void onEvent(r rVar) {
        if (rVar.f1575a == this.h) {
            int i2 = 0;
            String[] strArr = {"https://app-buildin/", "http://local.ggwin.nocold.tw/", "https://nocold.tw/", o.p().d()};
            while (true) {
                if (i2 >= 4) {
                    break;
                }
                if (rVar.f1576b.toLowerCase().startsWith(strArr[i2])) {
                    String str = "window['appVersion']=\"" + o.p().g() + "\";";
                    JSONObject jSONObject = new JSONObject();
                    try {
                        jSONObject.put("appVersion", o.p().g());
                        jSONObject.put("assetVersion", o.p().i());
                        jSONObject.put("assetBuildInfo", o.p().b());
                    } catch (JSONException unused) {
                    }
                    Handler handler = this.E;
                    handler.sendMessage(handler.obtainMessage(1, (str + "window['GGVersion']=" + jSONObject.toString() + ";") + "window['BridgeAuthority']=\"" + c.a.a.d.f.a().f1632a + "\";"));
                    c.a.a.d.c.c("FullscreenActivity", "页面载入完成, 注入初始化脚本");
                    break;
                }
                i2++;
            }
            this.r.c(true);
        }
    }

    public void onEvent(q qVar) {
        String c2 = c.a.a.d.p.b().c(qVar.a());
        Intent intent = new Intent(this, WebViewActivity.class);
        intent.putExtra("pool-key", c2);
        startActivity(intent);
    }

    public void onEvent(c.a.a.a.m mVar) {
        String[] u2 = this.m.u(-1);
        String str = "Package: " + getApplication().getPackageName() + "\nAppVersion: " + o.p().g() + "\nAssetVersion(U): " + o.p().i() + "\nAssetVersion(O): " + o.p().q() + "\nDeviceId: " + o.p().k() + "\nTracker: " + o.p().u();
        if (u2.length <= 100) {
            StringBuilder sb = new StringBuilder(str);
            sb.append("\n--------\n");
            for (String str2 : u2) {
                sb.append(str2);
                sb.append('\n');
            }
            c.a.a.d.g.a().b(sb.toString());
        } else {
            c.a.a.d.g.a().b(str);
            String str3 = "Tracker: " + o.p().u() + "\n--------\n";
            for (int i2 = 0; i2 < u2.length; i2 += 100) {
                StringBuilder sb2 = new StringBuilder(str3);
                int i3 = i2;
                int i4 = 0;
                while (i4 < 100 && i3 < u2.length) {
                    sb2.append(u2[i3]);
                    sb2.append('\n');
                    i4++;
                    i3++;
                }
                c.a.a.d.g.a().b(sb2.toString());
            }
        }
        if (o.p().f1671e) {
            Handler handler = this.E;
            handler.sendMessage(handler.obtainMessage(13, "回报 Log (" + u2.length + ")到服务器"));
        }
    }

    public void onEvent(c.a.a.a.i iVar) {
        Uri uri;
        Intent intent = new Intent("android.intent.action.VIEW");
        if (Build.VERSION.SDK_INT >= 24) {
            uri = FileProvider.e(this, "com.emplre.hellogg.pkz.fileProvider", new File(iVar.f1559a));
            intent.setAction("android.intent.action.INSTALL_PACKAGE");
            intent.addFlags(1);
        } else {
            uri = Uri.fromFile(new File(iVar.f1559a));
            intent.setFlags(268435456);
        }
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
        startActivity(intent);
    }

    public void onEvent(t tVar) {
        this.g = tVar.f1577a;
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        intent.putExtra("return-data", true);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        startActivityForResult(Intent.createChooser(intent, getString(R.string.choose_picture)), 13);
    }

    public void onEvent(c.a.a.a.d dVar) {
        dVar.a(com.empire.ggwin.net.c.g.class);
        throw null;
    }

    public void onEvent(c.a.a.a.l lVar) {
        AlertDialog a2 = lVar.a(this);
        if (a2 != null) {
            a2.show();
        }
    }

    public void onEvent(c.a.a.a.e eVar) {
        c.a.a.e.a aVar = this.m;
        if (aVar != null) {
            if (aVar.s(eVar.f1553a, eVar.f1554b) && !this.p) {
                runOnUiThread(new e(this));
            }
            this.o.setText(String.valueOf(this.m.c()));
        }
    }

    public void onEvent(p pVar) {
        Handler handler = this.E;
        handler.sendMessage(handler.obtainMessage(31, pVar));
        o.p().t.g(pVar);
    }

    public void onEvent(c.a.a.a.o oVar) {
        Handler handler = this.E;
        handler.sendMessage(handler.obtainMessage(30, oVar.f1568a, 0));
    }

    public void onEvent(c.a.a.a.n nVar) {
        Handler handler = this.E;
        handler.sendMessage(handler.obtainMessage(95, nVar.f1567a));
    }

    public void onEvent(c.a.a.a.j jVar) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        intent.setData(Uri.parse(jVar.f1560a));
        startActivity(intent);
    }

    public void onEvent(c.a.a.a.h hVar) {
        Handler handler = this.E;
        handler.sendMessage(handler.obtainMessage(1, hVar.f1558a));
    }

    public void onEvent(c.a.a.a.c cVar) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject = a0(cVar.f1550a, new JSONObject(cVar.f1552c));
        } catch (JSONException e2) {
            Log.e("FullscreenActivity", e2.getMessage());
        }
        String str = cVar.f1551b;
        if (str != null && !str.isEmpty()) {
            if (jSONObject == null) {
                jSONObject = new JSONObject();
            }
            String str2 = "if(window && window.nativeCallback) window.nativeCallback('" + cVar.f1551b + "', '" + Base64.encodeToString(jSONObject.toString().getBytes(), 2).trim() + "');";
            Handler handler = this.E;
            handler.sendMessage(handler.obtainMessage(1, str2));
        }
    }
}