package com.tencent.mm.ipcinvoker;

import android.content.Context;
import android.os.Process;
import com.tencent.matrix.trace.core.AppMethodBeat;
import junit.framework.Assert;

public final class e {
    private static String eFZ;
    public static Context sContext;

    public static Context getContext() {
        AppMethodBeat.i(114021);
        Assert.assertNotNull("IPCInvoker not initialize.", sContext);
        Context context = sContext;
        AppMethodBeat.o(114021);
        return context;
    }

    public static boolean lg(String str) {
        AppMethodBeat.i(114022);
        if (str == null || !str.equals(PN())) {
            AppMethodBeat.o(114022);
            return false;
        }
        AppMethodBeat.o(114022);
        return true;
    }

    public static String PN() {
        AppMethodBeat.i(114023);
        if (eFZ == null || eFZ.length() == 0) {
            eFZ = z(sContext, Process.myPid());
        }
        String str = eFZ;
        AppMethodBeat.o(114023);
        return str;
    }

    /* JADX WARNING: Removed duplicated region for block: B:47:0x00ab A:{SYNTHETIC, Splitter:B:47:0x00ab} */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00a1 A:{SYNTHETIC, Splitter:B:41:0x00a1} */
    private static java.lang.String z(android.content.Context r8, int r9) {
        /*
        r6 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
        r1 = 0;
        r4 = 0;
        r7 = 114024; // 0x1bd68 float:1.59782E-40 double:5.63353E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r7);
        if (r8 != 0) goto L_0x0011;
    L_0x000c:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        r0 = r1;
    L_0x0010:
        return r0;
    L_0x0011:
        r0 = "activity";
        r0 = r8.getSystemService(r0);
        r0 = (android.app.ActivityManager) r0;
        if (r0 == 0) goto L_0x0042;
    L_0x001c:
        r0 = r0.getRunningAppProcesses();
        if (r0 == 0) goto L_0x0042;
    L_0x0022:
        r2 = r0.isEmpty();
        if (r2 != 0) goto L_0x0042;
    L_0x0028:
        r2 = r0.iterator();
    L_0x002c:
        r0 = r2.hasNext();
        if (r0 == 0) goto L_0x0042;
    L_0x0032:
        r0 = r2.next();
        r0 = (android.app.ActivityManager.RunningAppProcessInfo) r0;
        r3 = r0.pid;
        if (r3 != r9) goto L_0x002c;
    L_0x003c:
        r0 = r0.processName;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        goto L_0x0010;
    L_0x0042:
        r5 = new byte[r6];
        r2 = new java.io.FileInputStream;	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r0 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r3 = "/proc/";
        r0.<init>(r3);	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r0 = r0.append(r9);	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r3 = "/cmdline";
        r0 = r0.append(r3);	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r0 = r0.toString();	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r2.<init>(r0);	 Catch:{ Exception -> 0x008a, all -> 0x00a7 }
        r3 = r2.read(r5);	 Catch:{ Exception -> 0x00ba }
        if (r3 <= 0) goto L_0x0082;
    L_0x0066:
        r0 = r4;
    L_0x0067:
        if (r0 >= r3) goto L_0x0072;
    L_0x0069:
        r4 = r5[r0];	 Catch:{ Exception -> 0x00ba }
        if (r4 > r6) goto L_0x0071;
    L_0x006d:
        r4 = r5[r0];	 Catch:{ Exception -> 0x00ba }
        if (r4 > 0) goto L_0x007f;
    L_0x0071:
        r3 = r0;
    L_0x0072:
        r0 = new java.lang.String;	 Catch:{ Exception -> 0x00ba }
        r4 = 0;
        r0.<init>(r5, r4, r3);	 Catch:{ Exception -> 0x00ba }
        r2.close();	 Catch:{ Exception -> 0x00b2 }
    L_0x007b:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        goto L_0x0010;
    L_0x007f:
        r0 = r0 + 1;
        goto L_0x0067;
    L_0x0082:
        r2.close();	 Catch:{ Exception -> 0x00b4 }
    L_0x0085:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        r0 = r1;
        goto L_0x0010;
    L_0x008a:
        r0 = move-exception;
        r2 = r1;
    L_0x008c:
        r3 = "IPC.IPCInvokeLogic";
        r4 = "get running process error : %s";
        r5 = 1;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x00b8 }
        r6 = 0;
        r0 = android.util.Log.getStackTraceString(r0);	 Catch:{ all -> 0x00b8 }
        r5[r6] = r0;	 Catch:{ all -> 0x00b8 }
        com.tencent.mm.ipcinvoker.h.b.e(r3, r4, r5);	 Catch:{ all -> 0x00b8 }
        if (r2 == 0) goto L_0x0085;
    L_0x00a1:
        r2.close();	 Catch:{ Exception -> 0x00a5 }
        goto L_0x0085;
    L_0x00a5:
        r0 = move-exception;
        goto L_0x0085;
    L_0x00a7:
        r0 = move-exception;
        r2 = r1;
    L_0x00a9:
        if (r2 == 0) goto L_0x00ae;
    L_0x00ab:
        r2.close();	 Catch:{ Exception -> 0x00b6 }
    L_0x00ae:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        throw r0;
    L_0x00b2:
        r1 = move-exception;
        goto L_0x007b;
    L_0x00b4:
        r0 = move-exception;
        goto L_0x0085;
    L_0x00b6:
        r1 = move-exception;
        goto L_0x00ae;
    L_0x00b8:
        r0 = move-exception;
        goto L_0x00a9;
    L_0x00ba:
        r0 = move-exception;
        goto L_0x008c;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.ipcinvoker.e.z(android.content.Context, int):java.lang.String");
    }
}
