package com.tencent.mm.plugin.expt.hellhound.core.v2.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.IBinder;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.expt.hellhound.core.a.a;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

final class b implements InvocationHandler {
    static boolean lME = true;
    static int lMF = 0;
    Object lMB;
    private Method lMC;
    private d lMD;

    @SuppressLint({"PrivateApi"})
    b(d dVar) {
        AppMethodBeat.i(73392);
        this.lMD = dVar;
        try {
            this.lMC = a.bqr().getDeclaredMethod("getActivity", new Class[]{IBinder.class});
            this.lMC.setAccessible(true);
            AppMethodBeat.o(73392);
        } catch (Exception e) {
            ab.printErrStackTrace("ActivityHijack", e, "ActivityHijack", new Object[0]);
            h.pYm.a(932, 2, 1, false);
            AppMethodBeat.o(73392);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:46:0x013d A:{Catch:{ Exception -> 0x016b }} */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x0190 A:{Catch:{ Exception -> 0x01de }} */
    public final java.lang.Object invoke(java.lang.Object r11, java.lang.reflect.Method r12, java.lang.Object[] r13) {
        /*
        r10 = this;
        r0 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r0);
        r9 = r12.getName();
        r0 = "moveActivityTaskToBack";
        r0 = r0.equals(r9);	 Catch:{ Exception -> 0x0054 }
        if (r0 == 0) goto L_0x0041;
    L_0x0013:
        r3 = r10.o(r13);	 Catch:{ Exception -> 0x0054 }
        r1 = 0;
        r4 = r13.length;	 Catch:{ Exception -> 0x0054 }
        r0 = 0;
        r2 = r0;
    L_0x001b:
        if (r2 >= r4) goto L_0x0247;
    L_0x001d:
        r0 = r13[r2];	 Catch:{ Exception -> 0x0054 }
        if (r0 == 0) goto L_0x003d;
    L_0x0021:
        r5 = r0 instanceof java.lang.Boolean;	 Catch:{ Exception -> 0x0054 }
        if (r5 == 0) goto L_0x003d;
    L_0x0025:
        r0 = (java.lang.Boolean) r0;	 Catch:{ Exception -> 0x0054 }
        r0 = r0.booleanValue();	 Catch:{ Exception -> 0x0054 }
    L_0x002b:
        r1 = r10.lMD;	 Catch:{ Exception -> 0x0054 }
        r1.a(r3, r0);	 Catch:{ Exception -> 0x0054 }
    L_0x0030:
        r0 = r10.lMB;	 Catch:{ Exception -> 0x006e }
        r0 = r12.invoke(r0, r13);	 Catch:{ Exception -> 0x006e }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
    L_0x003c:
        return r0;
    L_0x003d:
        r0 = r2 + 1;
        r2 = r0;
        goto L_0x001b;
    L_0x0041:
        r0 = "finishActivity";
        r0 = r0.equals(r9);	 Catch:{ Exception -> 0x0054 }
        if (r0 == 0) goto L_0x00bd;
    L_0x004a:
        r0 = r10.o(r13);	 Catch:{ Exception -> 0x0054 }
        r1 = r10.lMD;	 Catch:{ Exception -> 0x0054 }
        r1.F(r0);	 Catch:{ Exception -> 0x0054 }
        goto L_0x0030;
    L_0x0054:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack.invoke-method";
        r3 = 0;
        r3 = new java.lang.Object[r3];	 Catch:{ Exception -> 0x006e }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);	 Catch:{ Exception -> 0x006e }
        r1 = com.tencent.mm.plugin.report.service.h.pYm;	 Catch:{ Exception -> 0x006e }
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 0;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);	 Catch:{ Exception -> 0x006e }
        goto L_0x0030;
    L_0x006e:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack.invoke-new";
        r3 = 0;
        r3 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 63;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);
        r0 = "isTopOfTask";
        r0 = r0.equals(r9);
        if (r0 == 0) goto L_0x0134;
    L_0x0090:
        r0 = r10.lMB;	 Catch:{ Exception -> 0x00d2 }
        r0 = r12.invoke(r0, r13);	 Catch:{ Exception -> 0x00d2 }
        r0 = (java.lang.Boolean) r0;	 Catch:{ Exception -> 0x00d2 }
        r1 = r0.booleanValue();	 Catch:{ Exception -> 0x00d2 }
        lME = r1;	 Catch:{ Exception -> 0x00d2 }
        r1 = "ActivityHijack";
        r2 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00d2 }
        r3 = "AHijack:isTopOfTask: ";
        r2.<init>(r3);	 Catch:{ Exception -> 0x00d2 }
        r3 = lME;	 Catch:{ Exception -> 0x00d2 }
        r2 = r2.append(r3);	 Catch:{ Exception -> 0x00d2 }
        r2 = r2.toString();	 Catch:{ Exception -> 0x00d2 }
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);	 Catch:{ Exception -> 0x00d2 }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x00bd:
        r0 = "getIntentForIntentSender";
        r0 = r0.equals(r9);	 Catch:{ Exception -> 0x0054 }
        if (r0 == 0) goto L_0x0030;
    L_0x00c6:
        r0 = r10.c(r12, r13);	 Catch:{ Exception -> 0x0054 }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x00d2:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack:isTopOfTask-e1 crash";
        r3 = 0;
        r3 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 80;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);
        r0 = r10.o(r13);	 Catch:{ Exception -> 0x0118 }
        if (r0 == 0) goto L_0x0134;
    L_0x00f1:
        r1 = android.app.Activity.class;
        r2 = "isTopOfTask";
        r3 = 0;
        r3 = new java.lang.Class[r3];	 Catch:{ Exception -> 0x0118 }
        r1 = r1.getDeclaredMethod(r2, r3);	 Catch:{ Exception -> 0x0118 }
        r2 = 1;
        r1.setAccessible(r2);	 Catch:{ Exception -> 0x0118 }
        r2 = 0;
        r2 = new java.lang.Object[r2];	 Catch:{ Exception -> 0x0118 }
        r0 = r1.invoke(r0, r2);	 Catch:{ Exception -> 0x0118 }
        r0 = (java.lang.Boolean) r0;	 Catch:{ Exception -> 0x0118 }
        r1 = r0.booleanValue();	 Catch:{ Exception -> 0x0118 }
        lME = r1;	 Catch:{ Exception -> 0x0118 }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x0118:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack:isTopOfTask-e2 crash";
        r3 = 0;
        r3 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 85;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);
        r0 = 1;
        lME = r0;
    L_0x0134:
        r0 = "startActivity";
        r0 = r0.equals(r9);	 Catch:{ Exception -> 0x016b }
        if (r0 == 0) goto L_0x0187;
    L_0x013d:
        r0 = r10.lMB;	 Catch:{ Exception -> 0x016b }
        r0 = r12.invoke(r0, r13);	 Catch:{ Exception -> 0x016b }
        r0 = (java.lang.Integer) r0;	 Catch:{ Exception -> 0x016b }
        r1 = r0.intValue();	 Catch:{ Exception -> 0x016b }
        lMF = r1;	 Catch:{ Exception -> 0x016b }
        r1 = "ActivityHijack";
        r2 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x016b }
        r3 = "AHijack:startActivityRet: ";
        r2.<init>(r3);	 Catch:{ Exception -> 0x016b }
        r3 = lMF;	 Catch:{ Exception -> 0x016b }
        r2 = r2.append(r3);	 Catch:{ Exception -> 0x016b }
        r2 = r2.toString();	 Catch:{ Exception -> 0x016b }
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);	 Catch:{ Exception -> 0x016b }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x016b:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack:startActivity crash-3";
        r3 = 0;
        r3 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 86;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);
        r0 = 0;
        lMF = r0;
    L_0x0187:
        r0 = "broadcastIntent";
        r0 = r0.equals(r9);	 Catch:{ Exception -> 0x01de }
        if (r0 == 0) goto L_0x01f7;
    L_0x0190:
        r1 = com.tencent.mm.plugin.report.service.h.pYm;	 Catch:{ Exception -> 0x01de }
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 64;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);	 Catch:{ Exception -> 0x01de }
        r0 = "ActivityHijack";
        r1 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x01de }
        r2 = "handleSonyBroadcastIntent Build.MODEL / Build.BRAND: ";
        r1.<init>(r2);	 Catch:{ Exception -> 0x01de }
        r2 = android.os.Build.MODEL;	 Catch:{ Exception -> 0x01de }
        r1 = r1.append(r2);	 Catch:{ Exception -> 0x01de }
        r2 = " / ";
        r1 = r1.append(r2);	 Catch:{ Exception -> 0x01de }
        r2 = android.os.Build.BRAND;	 Catch:{ Exception -> 0x01de }
        r1 = r1.append(r2);	 Catch:{ Exception -> 0x01de }
        r1 = r1.toString();	 Catch:{ Exception -> 0x01de }
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);	 Catch:{ Exception -> 0x01de }
        r0 = n(r13);	 Catch:{ Exception -> 0x01de }
        if (r0 != 0) goto L_0x0205;
    L_0x01c7:
        r0 = "ActivityHijack";
        r1 = "handleSonyBroadcastIntent intent == null";
        com.tencent.mm.sdk.platformtools.ab.d(r0, r1);	 Catch:{ Exception -> 0x01de }
        r0 = r10.lMB;	 Catch:{ Exception -> 0x01de }
        r0 = r12.invoke(r0, r13);	 Catch:{ Exception -> 0x01de }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);	 Catch:{ Exception -> 0x01de }
        goto L_0x003c;
    L_0x01de:
        r0 = move-exception;
        r1 = "ActivityHijack";
        r2 = "AHijack.broadcastIntent";
        r3 = 0;
        r3 = new java.lang.Object[r3];
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r1, r0, r2, r3);
        r1 = com.tencent.mm.plugin.report.service.h.pYm;
        r2 = 932; // 0x3a4 float:1.306E-42 double:4.605E-321;
        r4 = 65;
        r6 = 1;
        r8 = 0;
        r1.a(r2, r4, r6, r8);
    L_0x01f7:
        r0 = r10.lMB;
        r0 = r12.invoke(r0, r13);
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x0205:
        r0 = r0.getAction();	 Catch:{ Exception -> 0x01de }
        r1 = "ActivityHijack";
        r2 = "handleSonyBroadcastIntent action = ";
        r3 = java.lang.String.valueOf(r0);	 Catch:{ Exception -> 0x01de }
        r2 = r2.concat(r3);	 Catch:{ Exception -> 0x01de }
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);	 Catch:{ Exception -> 0x01de }
        r1 = "com.sonymobile.media.AUDIO_MODE_CHANGED_ACTION";
        r0 = r1.equals(r0);	 Catch:{ Exception -> 0x01de }
        if (r0 == 0) goto L_0x0239;
    L_0x0223:
        r0 = "ActivityHijack";
        r1 = "Sony-Phone, What the fuck !!!";
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);	 Catch:{ Exception -> 0x01de }
        r0 = 0;
        r0 = java.lang.Integer.valueOf(r0);	 Catch:{ Exception -> 0x01de }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);	 Catch:{ Exception -> 0x01de }
        goto L_0x003c;
    L_0x0239:
        r0 = r10.lMB;	 Catch:{ Exception -> 0x01de }
        r0 = r12.invoke(r0, r13);	 Catch:{ Exception -> 0x01de }
        r1 = 73393; // 0x11eb1 float:1.02845E-40 double:3.6261E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);
        goto L_0x003c;
    L_0x0247:
        r0 = r1;
        goto L_0x002b;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.expt.hellhound.core.v2.activity.b.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]):java.lang.Object");
    }

    private Intent c(Method method, Object[] objArr) {
        Intent intent;
        AppMethodBeat.i(73394);
        try {
            Object invoke = method.invoke(this.lMB, objArr);
            if (invoke instanceof Intent) {
                intent = (Intent) invoke;
                AppMethodBeat.o(73394);
                return intent;
            }
        } catch (Exception e) {
            ab.i("ActivityHijack", "AHijack: getIntentForIntentSender: %s", new Object[]{bo.dpG()});
            h.pYm.a(932, 96, 1, false);
        }
        h.pYm.a(932, 97, 1, false);
        intent = new Intent();
        AppMethodBeat.o(73394);
        return intent;
    }

    private static Intent n(Object[] objArr) {
        if (objArr == null || objArr.length <= 0) {
            return null;
        }
        int i = 0;
        while (i < objArr.length) {
            if (objArr[i] != null && (objArr[i] instanceof Intent)) {
                return (Intent) objArr[i];
            }
            i++;
        }
        return null;
    }

    private Activity o(Object[] objArr) {
        int i = 0;
        AppMethodBeat.i(73395);
        if (objArr == null || objArr.length <= 0) {
            AppMethodBeat.o(73395);
            return null;
        }
        IBinder iBinder;
        while (i < objArr.length) {
            if (objArr[i] != null && (objArr[i] instanceof IBinder)) {
                iBinder = (IBinder) objArr[i];
                break;
            }
            i++;
        }
        iBinder = null;
        if (iBinder == null) {
            AppMethodBeat.o(73395);
            return null;
        }
        Activity activity;
        try {
            Object bqq = a.bqq();
            activity = (Activity) this.lMC.invoke(bqq, new Object[]{iBinder});
        } catch (Exception e) {
            activity = null;
        }
        AppMethodBeat.o(73395);
        return activity;
    }
}
