Luскy*Patcher v11.1.8版本的 MD5 值为:260a307cc4cd8550bbc248b8d7c0bddc

以下内容为反编译后的 C2880.java 源代码,内容仅作参考


package p064;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.Looper;
import android.os.Process;
import android.os.UserHandle;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.provider.Settings;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.ScrollingMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.util.Linkify;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.app.C0560;
import androidx.core.content.FileProvider;
import com.android.apksig.ApkSigner;
import com.android.apksig.ApkVerifier;
import com.android.apksig.apk.ApkFormatException;
import com.android.apksig.apk.ApkUtils;
import com.android.apksig.apk.MinSdkVersionException;
import com.android.apksig.internal.apk.AndroidBinXmlParser;
import com.android.apksig.internal.apk.v1.V1SchemeVerifier;
import com.android.apksig.internal.asn1.Asn1BerParser;
import com.android.apksig.internal.asn1.Asn1DecodingException;
import com.android.apksig.internal.pkcs7.ContentInfo;
import com.android.apksig.internal.pkcs7.Pkcs7Constants;
import com.android.apksig.internal.pkcs7.SignedData;
import com.android.apksig.internal.pkcs7.SignerInfo;
import com.android.apksig.internal.util.Pair;
import com.android.apksig.internal.x509.Certificate;
import com.android.apksig.internal.zip.CentralDirectoryRecord;
import com.android.apksig.internal.zip.LocalFileRecord;
import com.android.apksig.internal.zip.ZipUtils;
import com.android.apksig.util.DataSource;
import com.android.apksig.util.DataSources;
import com.android.apksig.zip.ZipFormatException;
import com.android.apksigner.ApkSignerTool;
import com.android.apksigner.PasswordRetriever;
import com.android.apksigner.SignerParams;
import com.services.InterfaceC1827;
import com.services.MyService;
import com.unity3d.ads.IUnityAdsListener;
import com.unity3d.ads.UnityAds;
import com.unity3d.ads.metadata.MediationMetaData;
import com.unity3d.services.banners.BannerErrorInfo;
import com.unity3d.services.banners.BannerView;
import com.unity3d.services.banners.UnityBannerSize;
import dalvik.system.DexFile;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.lang.Thread;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.security.DigestException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.SignatureException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javaroot.utils.C1953;
import javaroot.utils.C1968;
import javaroot.utils.C1990;
import javaroot.utils.C2003;
import javaroot.utils.C2009;
import javaroot.utils.C2010;
import javaroot.utils.C2018;
import javaroot.utils.C2020;
import javaroot.utils.C2022;
import javaroot.utils.C2032;
import javaroot.utils.C2036;
import javaroot.utils.C2048;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.crypto.PBKDF2.BinTools;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.io.ZipInputStream;
import net.lingala.zip4j.model.FileHeader;
import net.lingala.zip4j.util.InternalZipConstants;
import org.jf.dexlib2.analysis.RegisterType;
import org.jf.dexlib2.dexbacked.DexBackedClassDef;
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.dexbacked.DexBackedMethod;
import org.jf.dexlib2.dexbacked.DexBackedMethodImplementation;
import org.jf.dexlib2.dexbacked.raw.ItemType;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.tukaani.xz.XZInputStream;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
import p029.C2163;
import p031.C2188;
import p032.C2226;
import p032.C2236;
import p032.C2242;
import p032.C2243;
import p038.InterfaceC2358;
import p050.C2568;
import p051.C2593;
import p054.C2612;
import p056.C2793;
import p058.C2799;
import p058.C2800;
import p058.C2806;
import p061.C2829;
import p063.InterfaceC2846;
import p064.C2851;
import p065.C2972;
import p066.C2979;
import p067.C2984;
import p067.C2986;
import p067.C2988;
import p067.C2990;
import p067.C2992;
import p067.C2993;
import p067.C2995;
import p067.C2997;
import p067.C2999;
import p067.C3001;
import p067.C3003;
import p067.C3004;
import p067.C3005;
import p067.C3008;
import p069.C3015;
import p112.C3286;
import p112.C3287;
import p112.C3306;
import p112.C3311;
import p112.C3312;
import p112.C3346;
import p112.C3348;
import p112.C3852;
import p112.C3870;
import p112.C3871;
import p113.C3923;
import p113.C4077;
import p113.C4083;
import p132.C4199;
import p132.C4201;
import p134.C4204;
import p137.C4298;
import p179.C4730;
import p179.EnumC4726;
import p179.EnumC4728;
import ru.aaaaabbd.installer.R;
import ru.sxbuIDfx.pFSOyagrF.App;
import ru.sxbuIDfx.pFSOyagrF.MainActivity;
import ru.sxbuIDfx.pFSOyagrF.PkgName;
import sun.security.util.DerValue;

public class C2880 {

    public static boolean f7699;

    public static Dialog f7700;

    public static boolean f7701;

    private static final ThreadLocal<char[]> f7702 = new C2956();

    public static byte[] f7703 = new byte[0];

    private static String f7704 = "";

    protected static final char[] f7705 = BinTools.hex.toCharArray();

    static ServiceConnection f7706 = null;

    static InterfaceC1827 f7707 = null;

    static Random f7708 = new Random();

    public static String f7709 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt8wG5ftmKv4q9OTMLDKwaejxXpSdGSwGuWue5fhMfeDNYJTloVpf89Hqg5Kjiq60HBdnPSXx6Evk4bTtdVZatAjYwJSfhEQQUKhRZT1yIlXonWkE5p+OrIPynU+Sa2guE77EJNFqzMopPIUyvVXVLsVJBrOU/7ywXep0vFCymM/9OtFDD9PXn+g7uFAIjoU48NN03BgAoqxOd1DMnZu184EjH2/gekA/eTWMF8H3XOmCCpPdXwHEpFwUwmjC+alNg/m5xy2ndlCoCej663UR0V8uW/tapDH+84wW5Y6wss9Ozp03Skj45oqL18mKVgTXeXg8tigquBlMMJbFQAoawwIDAQAB";

    static String f7710 = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC3zAbl+2Yq/ir05MwsMrBp6PFelJ0ZLAa5a57l+Ex94M1glOWhWl/z0eqDkqOKrrQcF2c9JfHoS+ThtO11Vlq0CNjAlJ+ERBBQqFFlPXIiVeidaQTmn46sg/KdT5JraC4TvsQk0WrMyik8hTK9VdUuxUkGs5T/vLBd6nS8ULKYz/060UMP09ef6Du4UAiOhTjw03TcGACirE53UMydm7XzgSMfb+B6QD95NYwXwfdc6YIKk91fAcSkXBTCaML5qU2D+bnHLad2UKgJ6PrrdRHRXy5b+1qkMf7zjBbljrCyz07OnTdKSPjmiovXyYpWBNd5eDy2KCq4GUwwlsVAChrDAgMBAAECggEABBM9pV6sJrOEt5T4MfE5aZQcRe98438U8rj6VDkxhJ7NNMQYZMWmY7diV2KqaUF/HNSzpUvNuJGNfT9KFgLYguhMZgRZ86Hl+rVMUuU8yeBJY7QXrBbU2kcYfmGD02aO2Sn0j2I+BiaSbyC5SXZ/MKXsQsP1qFMIJ4FJ2DpUu2jL2anV3WbRW+xAIkKYHKWYbNx7jKOTEvfxbw++/p1bzYH5r94mg0cj6Pe5p2XBfsb+Jf3M3h0iggtIBT0P2aImyoOVbLBN3j3IxiSPO6BBAC7RgkUKbGQzdn7SHKNjH3d+77gtO3ZnNYqJ31GWs/bH9Rg5ccm30aZjms3sy2CfgQKBgQDyhA+/Br+J0ktuadIe60B4aXSGXpfzzA34tzdO+Er966iGYJ/i51HgKV0taQYXryLZAceukK8mNygIXVgzCfQnf52Wtbde2hy+5IKod8au+4mjeFxA7OAWYDMqW0xy2Glqo8eB0xWTpYk7JQglA61hVEv3H2gs3/aLy9vEYJ0D5wKBgQDCBCstK77uwwO+MZEZLctrBNcr7BnavZ1NmPDVD8qnxBLL0/t0e0GrqED5Gncq/QBY2E9lFVZaaDYef1Ucd21SbJ9JdWrxOg3GHatVPO7Jxfpm0lLOYXXPXy5oFjsbx97eijC0T92XbQeRlpkgsRZSe8FqAdIH4rOitrggjBXWxQKBgQCUA5QUtAqtFGOjdQSgiFal5z8OT6eQTcdtOG2STip/BZiqw0hyVVp8ZOKQt5vXUrYDGnoEChxMR7ewO0B8jiOtA89rz2amhpqqy48PQWNLIwyjb+9mVOyD25z+yhBDu9/DDUjT7MAriAnUxkpNRQxJ7ggbQNj1IpA4TGjKV2kdmwKBgQCx34iGHTkrRPdFg8P3RZjdQM7Uod0CQhzZa4JAk/3D2WsyG+LJY8dNTTBkMPNYIiQTUB1aGznUIP6c7zhkpMlBa/yNKG0nQ4YlQEY4G2kA69UqN2FbfNa5jBXLr7X5PkEB3cfRR/dsQLVTsLIq2rAQZw1n1stsF1eBsesVS9kp0QKBgGV9FkWaG7Sl1znszyUQcMPv1rO3/e3q2MaOjlo64XLlLX86DdGzZTsbpuZOpEZnBKzmV1YiSo2W6OgIoaO5on7RWsJ1tSe2+GxCDsre8wEVWWVey+ChIU3FqVlzTHk2dCEQ6w+8SJee9w35KCEqN/WxFvg8Xf27ZwN2LongQfUc";

    float f7711 = 0.0f;

    public class C2881 extends TimerTask {

        final Runnable f7712;

        class RunnableC2882 implements Runnable {
            RunnableC2882() {
            }

            @Override
            public void run() {
                C3348.m12347("step1");
                if (!C2880.f7699) {
                    C3348.m12347("step2");
                    C2880.f7699 = true;
                    C2880.m11529(C2880.f7700);
                }
                C3348.m12356(11);
            }
        }

        C2881(Runnable runnable) {
            this.f7712 = runnable;
        }

        @Override
        public void run() {
            C3348.m12347("Cancel timer 2");
            if (C3348.f9870 != null) {
                C3348.m12347("run to main show ads dialog");
                C3348.m12359(new RunnableC2882());
            }
            Runnable runnable = this.f7712;
            if (runnable != null) {
                runnable.run();
            }
        }
    }

    public class RunnableC2883 implements Runnable {
        RunnableC2883() {
        }

        @Override
        public void run() {
            Toast.makeText(C3348.m12334(), C2880.m11423(R.string.reboot_message), 1).show();
        }
    }

    public class RunnableC2884 implements Runnable {

        final String f7714;

        final String f7715;

        final DialogInterface.OnClickListener f7716;

        final DialogInterface.OnClickListener f7717;

        final DialogInterface.OnCancelListener f7718;

        final String f7719;

        final CompoundButton.OnCheckedChangeListener f7720;

        final boolean f7721;

        final boolean f7722;

        RunnableC2884(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7714 = str;
            this.f7715 = str2;
            this.f7716 = onClickListener;
            this.f7717 = onClickListener2;
            this.f7718 = onCancelListener;
            this.f7719 = str3;
            this.f7720 = onCheckedChangeListener;
            this.f7721 = z;
            this.f7722 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C3287 c3287 = new C3287(C3348.f9870.mo2480());
                    c3287.m12266(this.f7714).m12282(this.f7715).m12279(R.drawable.ic_vopros).m12281(C2880.m11423(R.string.Yes), this.f7716).m12285(C2880.m11423(R.string.no), this.f7717).m12289(true).m12288(this.f7718).m12274(this.f7719, this.f7720, this.f7721);
                    try {
                        if (this.f7722) {
                            Linkify.addLinks(c3287.f9709, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m12261 = c3287.m12261();
                    C2880.m11532(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2885 implements Runnable {

        final String f7723;

        final String f7724;

        final String f7725;

        final DialogInterface.OnClickListener f7726;

        final DialogInterface.OnClickListener f7727;

        final DialogInterface.OnCancelListener f7728;

        final boolean f7729;

        RunnableC2885(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z) {
            this.f7723 = str;
            this.f7724 = str2;
            this.f7725 = str3;
            this.f7726 = onClickListener;
            this.f7727 = onClickListener2;
            this.f7728 = onCancelListener;
            this.f7729 = z;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C3287 c3287 = new C3287(C3348.f9870.mo2480());
                    c3287.m12266(this.f7723).m12282(this.f7724).m12279(R.drawable.ic_vopros).m12281(this.f7725, this.f7726).m12285(C2880.m11423(R.string.no), this.f7727).m12288(this.f7728);
                    try {
                        if (this.f7729) {
                            Linkify.addLinks(c3287.f9709, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m12261 = c3287.m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class C2886 {

        public String f7730;

        public int f7731;

        public int f7732;

        public C2886(String str, int i, int i2) {
            this.f7730 = str;
            this.f7731 = i;
            this.f7732 = i2;
        }
    }

    public class C2887 {

        public String f7734 = null;

        public ArrayList<C2886> f7735 = new ArrayList<>();

        public C2887() {
        }
    }

    public class C2888 extends TimerTask {

        C2889 f7737;

        public C2888(C2889 c2889) {
            this.f7737 = c2889;
        }

        @Override
        public void run() {
            if (System.currentTimeMillis() - this.f7737.f7744 < 300000) {
                C3348.m12347("LuckyPatcher: timeout cancel. Too long process...");
                return;
            }
            String str = "";
            if (C3348.f9927.equals("")) {
                C3348.m12347("LuckyPatcher: timeout for wait root. exit...");
                try {
                    this.f7737.interrupt();
                    this.f7737.f7743.close();
                    try {
                        if (C3348.f9870 != null) {
                            C3348.m12356(23);
                        }
                        C3348.m12356(1);
                        C3348.m12356(11);
                        try {
                            for (String str2 : this.f7737.f7740) {
                                str = "\n" + str2;
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        String str3 = C3348.f9859;
                        C3348.m12367("Root error", "Your root hung at commands:" + str + "\nTry restart operation or updating your superSu and binary su.");
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    try {
                        for (String str4 : this.f7737.f7740) {
                            C3348.m12347("Lucky Patcher: freezes root commands:" + str4);
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                    C2880.m11317();
                    C3348.f9934.release();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
        }
    }

    public class C2889 extends Thread {

        private String f7739;

        private String[] f7740;

        private InputStream f7741;

        private Integer f7742;

        public DataInputStream f7743;

        public long f7744;

        C2889(C2880 c2880, RunnableC2917 runnableC2917) {
            this();
        }

        @Override
        public void run() {
            Class<C2010> cls;
            String str;
            boolean z;
            String str2;
            boolean z2;
            char c;
            String str3;
            String str4;
            int length;
            int i;
            InputStream inputStream;
            String str5;
            String str6;
            String str7;
            String str8;
            String str9;
            boolean z3;
            String str10;
            DataInputStream dataInputStream;
            int i2;
            String str11;
            Class<C2010> cls2;
            String str12;
            String str13 = "env: not found";
            String[] strArr = this.f7740;
            int length2 = strArr.length;
            char c2 = 0;
            int i3 = 0;
            boolean z4 = false;
            boolean z5 = false;
            boolean z6 = false;
            while (true) {
                cls = C2010.class;
                str = " ";
                if (i3 >= length2) {
                    break;
                }
                String str14 = strArr[i3];
                if (str14.equals("skipOut")) {
                    z5 = true;
                }
                if (str14.contains("-Xbootclasspath:") || str14.contains("app_process")) {
                    z4 = true;
                }
                if (str14.contains(" " + cls.getName() + " ")) {
                    z6 = true;
                }
                str14.contains(" " + cls.getName() + " ");
                i3++;
            }
            boolean z7 = false;
            boolean z8 = false;
            while (true) {
                String str15 = "SU Java-Code Running!";
                if (this.f7739.contains("SU Java-Code Running!") || z8) {
                    break;
                }
                String str16 = this.f7740[c2];
                String str17 = "env LD_LIBRARY_PATH=";
                if (str16.contains("env LD_LIBRARY_PATH=")) {
                    StringBuilder sb = new StringBuilder();
                    z = z7;
                    sb.append("re-run Dalvik on root with environment ");
                    c = 0;
                    sb.append(this.f7740[0]);
                    C3348.m12347(sb.toString());
                } else {
                    z = z7;
                    c = 0;
                }
                try {
                    if (this.f7740[c].equals("checkRoot")) {
                        C3348.m12347("LuckyPatcher: test root.");
                        this.f7740[0] = "ps init";
                        z = true;
                    }
                    boolean z9 = z8;
                    int i4 = C3348.f9897 + 1;
                    C3348.f9897 = i4;
                    C3348.m12347("Block root thread" + C3348.f9897);
                    try {
                        str3 = str;
                        str4 = "";
                    } catch (InterruptedException e) {
                        e = e;
                        str3 = str;
                        str4 = "";
                    }
                    try {
                        if (!C3348.f9934.tryAcquire(300L, TimeUnit.SECONDS)) {
                            C3348.m12347("Root command timeout. Bad root.");
                            C2880.m11317();
                            C3348.f9934.release();
                        }
                    } catch (InterruptedException e2) {
                        e = e2;
                        e.printStackTrace();
                        C3348.f9897--;
                        C2880.m11403();
                        C3348.m12347("UNBlock root thread N" + i4);
                        String[] strArr2 = this.f7740;
                        length = strArr2.length;
                        i = 0;
                        while (i < length) {
                        }
                        String str18 = str17;
                        Class<C2010> cls3 = cls;
                        String str19 = str15;
                        inputStream = this.f7741;
                        if (inputStream != null) {
                        }
                        C3348.f9932.writeBytes("\n");
                        C3348.f9932.writeBytes("echo 'chelpus done!'\n");
                        C3348.f9932.flush();
                        if (!z5) {
                        }
                        str2 = str4;
                        z2 = z;
                        if (z2) {
                        }
                        if (!this.f7739.equals(str2)) {
                        }
                        if (this.f7739.equals(str2)) {
                        }
                        if (z4) {
                        }
                    }
                    C3348.f9897--;
                    C2880.m11403();
                    C3348.m12347("UNBlock root thread N" + i4);
                    String[] strArr22 = this.f7740;
                    length = strArr22.length;
                    i = 0;
                    while (i < length) {
                        String str20 = strArr22[i];
                        String[] strArr3 = strArr22;
                        if (z4 && !str20.contains("app_process")) {
                            i2 = length;
                            DataOutputStream dataOutputStream = C3348.f9932;
                            str12 = str15;
                            cls2 = cls;
                            StringBuilder sb2 = new StringBuilder();
                            str11 = str17;
                            sb2.append(C3348.f9875);
                            sb2.append("/busybox killall dalvikvm\n");
                            dataOutputStream.writeBytes(new String(sb2.toString().getBytes(), "ISO-8859-1"));
                        } else {
                            i2 = length;
                            str11 = str17;
                            cls2 = cls;
                            str12 = str15;
                        }
                        if (!str20.equals("skipOut")) {
                            C3348.f9932.writeBytes(new String((str20 + "\n").getBytes(), "ISO-8859-1"));
                        }
                        i++;
                        strArr22 = strArr3;
                        length = i2;
                        str15 = str12;
                        cls = cls2;
                        str17 = str11;
                    }
                    String str182 = str17;
                    Class<C2010> cls32 = cls;
                    String str192 = str15;
                    inputStream = this.f7741;
                    if (inputStream != null) {
                        try {
                            C2880.m11296(inputStream, C3348.f9932);
                            C3348.f9932.writeBytes("exit\n");
                            C3348.f9932.flush();
                            C3348.f9930.destroy();
                            C3348.f9930 = Runtime.getRuntime().exec("su");
                            C3348.f9932 = new DataOutputStream(C3348.f9930.getOutputStream());
                            C3348.f9931 = new DataInputStream(C3348.f9930.getInputStream());
                            C3348.f9933 = new DataInputStream(C3348.f9930.getErrorStream());
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                        try {
                            this.f7741.close();
                        } catch (Throwable th2) {
                            try {
                                th2.printStackTrace();
                            } catch (Throwable th3) {
                                this.f7741 = null;
                                throw th3;
                            }
                        }
                        this.f7741 = null;
                    }
                    C3348.f9932.writeBytes("\n");
                    C3348.f9932.writeBytes("echo 'chelpus done!'\n");
                    C3348.f9932.flush();
                    if (!z5) {
                        break;
                    }
                    this.f7739 = C2880.this.m11614(z6, this);
                    if (z6) {
                        z6 = false;
                    }
                    try {
                        dataInputStream = C3348.f9933;
                    } catch (IOException e3) {
                        e = e3;
                        str5 = str4;
                    } catch (Exception e4) {
                        e = e4;
                        str5 = str4;
                    }
                    if (dataInputStream == null) {
                        break;
                    }
                    byte[] bArr = new byte[dataInputStream.available()];
                    C3348.f9933.read(bArr);
                    String str21 = new String(bArr);
                    C3348.f9923 = str21;
                    if (str21.contains(str13)) {
                        C2880.m11317();
                    }
                    str5 = str4;
                    try {
                        if (!new String(bArr).trim().equals(str5)) {
                            C3348.m12347("LuckyApcther root errors: " + C3348.f9923);
                            C3348.f9923 = new String(bArr);
                        } else {
                            C3348.f9923 = str5;
                        }
                    } catch (IOException e5) {
                        e = e5;
                        e.printStackTrace();
                        C2880.m11317();
                        if (z4) {
                        }
                        c2 = 0;
                    } catch (Exception e6) {
                        e = e6;
                        e.printStackTrace();
                        if (z4) {
                        }
                        c2 = 0;
                    }
                    if (z4) {
                        z8 = z9;
                        int i5 = 0;
                        while (true) {
                            String[] strArr4 = this.f7740;
                            if (i5 < strArr4.length) {
                                if (!strArr4[i5].contains("-Xbootclasspath:") && !this.f7740[i5].contains("app_process")) {
                                    str9 = str13;
                                    z3 = z8;
                                    str7 = str3;
                                    str10 = str192;
                                    str8 = str182;
                                } else {
                                    str8 = str182;
                                    if (!this.f7740[i5].contains(str8)) {
                                        String str22 = this.f7740[i5];
                                        StringBuilder sb3 = new StringBuilder();
                                        str7 = str3;
                                        sb3.append(str7);
                                        sb3.append(C1990.class.getName());
                                        if (!str22.contains(sb3.toString())) {
                                            if (!this.f7740[i5].contains(str7 + C2009.class.getName() + str7)) {
                                                if (this.f7740[i5].contains(str7 + C1953.class.getName() + str7)) {
                                                    break;
                                                }
                                                if (this.f7740[i5].contains(str7 + cls32.getName() + str7)) {
                                                    break;
                                                }
                                                String str23 = System.getenv("LD_LIBRARY_PATH");
                                                String str24 = this.f7740[i5];
                                                if (C3348.f9923.contains(str13)) {
                                                    str9 = str13;
                                                    this.f7740[i5] = str8 + str23 + str7 + str24;
                                                    z3 = z8;
                                                } else {
                                                    str9 = str13;
                                                    z3 = true;
                                                }
                                                str10 = str192;
                                                if (this.f7739.contains(str10)) {
                                                    z3 = true;
                                                } else {
                                                    this.f7739 = str5;
                                                }
                                            } else {
                                                break;
                                            }
                                        } else {
                                            break;
                                        }
                                    } else {
                                        str6 = str13;
                                        str7 = str3;
                                        break;
                                    }
                                }
                                i5++;
                                str192 = str10;
                                z8 = z3;
                                str182 = str8;
                                str3 = str7;
                                str13 = str9;
                            } else {
                                str6 = str13;
                                str7 = str3;
                                break;
                            }
                        }
                        str6 = str13;
                        C3348.m12347("except");
                        z8 = true;
                        str = str7;
                        z7 = z;
                        str13 = str6;
                        cls = cls32;
                    } else {
                        z7 = z;
                        str = str3;
                        cls = cls32;
                        z8 = true;
                    }
                    c2 = 0;
                } catch (IOException e7) {
                    e7.printStackTrace();
                    C3348.m12347("LuckyPatcher (result root): root not found.");
                    C3348.f9934.release();
                    return;
                } catch (Exception e8) {
                    e8.printStackTrace();
                    C3348.f9934.release();
                    return;
                }
                z2 = z;
                if (z2) {
                    C3348.m12347("LuckyPatcher (result root): " + this.f7739);
                }
                if (!this.f7739.equals(str2) && z2) {
                    if (z4) {
                        C2880.m11317();
                    } else {
                        C3348.f9934.release();
                    }
                    this.f7739 = "lucky patcher root not found!";
                    return;
                }
                if (this.f7739.equals(str2)) {
                    this.f7739 = "~";
                }
                if (z4) {
                    C2880.m11317();
                    return;
                } else {
                    C3348.f9934.release();
                    return;
                }
            }
            z = z7;
            str2 = "";
            z2 = z;
            if (z2) {
            }
            if (!this.f7739.equals(str2)) {
            }
            if (this.f7739.equals(str2)) {
            }
            if (z4) {
            }
        }

        private C2889() {
            this.f7739 = "";
            this.f7740 = null;
            this.f7741 = null;
            this.f7742 = null;
            this.f7743 = null;
            this.f7744 = 0L;
        }
    }

    public class RunnableC2890 implements Runnable {

        final Timer f7746;

        final TimerTask f7747;

        RunnableC2890(Timer timer, TimerTask timerTask) {
            this.f7746 = timer;
            this.f7747 = timerTask;
        }

        @Override
        public void run() {
            C3348.m12347("Cancel timer");
            this.f7746.cancel();
            this.f7747.run();
        }
    }

    public class RunnableC2891 implements Runnable {

        final String f7748;

        final String f7749;

        final DialogInterface.OnClickListener f7750;

        final DialogInterface.OnClickListener f7751;

        final DialogInterface.OnCancelListener f7752;

        RunnableC2891(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7748 = str;
            this.f7749 = str2;
            this.f7750 = onClickListener;
            this.f7751 = onClickListener2;
            this.f7752 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    Dialog m12261 = new C3287(C3348.f9870.mo2480()).m12266(this.f7748).m12282(this.f7749).m12279(R.drawable.ic_vopros).m12281(C2880.m11423(R.string.Yes), this.f7750).m12285(C2880.m11423(R.string.no), this.f7751).m12289(true).m12288(this.f7752).m12261();
                    C2880.m11532(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2892 implements Runnable {

        final LinearLayout f7753;

        final Runnable f7754;

        final Timer f7755;

        final TimerTask f7756;

        class RunnableC2893 implements Runnable {
            RunnableC2893() {
            }

            @Override
            public void run() {
                RunnableC2892 runnableC2892 = RunnableC2892.this;
                C2880.m11456(runnableC2892.f7753, runnableC2892.f7754, runnableC2892.f7755, runnableC2892.f7756);
            }
        }

        RunnableC2892(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
            this.f7753 = linearLayout;
            this.f7754 = runnable;
            this.f7755 = timer;
            this.f7756 = timerTask;
        }

        @Override
        public void run() {
            C2880.m11456(this.f7753, new RunnableC2893(), this.f7755, this.f7756);
        }
    }

    public class RunnableC2894 implements Runnable {
        RunnableC2894() {
        }

        @Override
        public void run() {
            Toast.makeText(C3348.m12334(), C2880.m11423(R.string.reboot_message), 1).show();
        }
    }

    public class C2895 implements IUnityAdsListener {
        C2895() {
        }

        @Override
        public void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String str) {
            C3348.m12347("unityAdsError: " + str);
        }

        @Override
        public void onUnityAdsFinish(String str, UnityAds.FinishState finishState) {
            C3348.m12347("Unity ads: finished");
        }

        @Override
        public void onUnityAdsReady(String str) {
            C3348.m12347("Unity ads: ready:" + str);
        }

        @Override
        public void onUnityAdsStart(String str) {
            C3348.m12347("Unity ads: start:" + str);
        }
    }

    class C2896 implements Thread.UncaughtExceptionHandler {
        C2896() {
        }

        @Override
        public void uncaughtException(Thread thread, Throwable th) {
            StringWriter stringWriter = new StringWriter();
            th.printStackTrace(new PrintWriter(stringWriter));
            System.out.println("Root-java error:" + stringWriter.toString());
        }
    }

    public class C2897 implements BannerView.IListener {

        final Timer f7758;

        final TimerTask f7759;

        final LinearLayout f7760;

        final Runnable f7761;

        class RunnableC2898 implements Runnable {
            RunnableC2898() {
            }

            @Override
            public void run() {
                if (!C2880.f7699) {
                    C2880.f7699 = true;
                    C2880.m11529(C2880.f7700);
                }
                C3348.m12356(11);
            }
        }

        class RunnableC2899 implements Runnable {
            RunnableC2899() {
            }

            @Override
            public void run() {
                if (!C2880.f7699) {
                    C2880.f7699 = true;
                    C2880.m11529(C2880.f7700);
                }
                C3348.m12356(11);
            }
        }

        C2897(Timer timer, TimerTask timerTask, LinearLayout linearLayout, Runnable runnable) {
            this.f7758 = timer;
            this.f7759 = timerTask;
            this.f7760 = linearLayout;
            this.f7761 = runnable;
        }

        @Override
        public void onBannerClick(BannerView bannerView) {
            LinearLayout linearLayout = this.f7760;
            if (linearLayout != null && linearLayout.findViewWithTag("UnityBanner") != null) {
                LinearLayout linearLayout2 = this.f7760;
                linearLayout2.removeView(linearLayout2.findViewWithTag("UnityBanner"));
            }
        }

        @Override
        public void onBannerFailedToLoad(BannerView bannerView, BannerErrorInfo bannerErrorInfo) {
            C3348.m12347("UnityBannerOnAdFailedToLoad");
            if (this.f7760.findViewWithTag("UnityBanner") != null) {
                LinearLayout linearLayout = this.f7760;
                linearLayout.removeView(linearLayout.findViewWithTag("UnityBanner"));
            }
            Runnable runnable = this.f7761;
            if (runnable != null) {
                runnable.run();
            }
            if (!C2880.f7699 && C3348.f9870 != null) {
                C3348.m12359(new RunnableC2899());
            }
        }

        @Override
        public void onBannerLeftApplication(BannerView bannerView) {
        }

        @Override
        public void onBannerLoaded(BannerView bannerView) {
            C3348.m12347("Unity ad loaded");
            Timer timer = this.f7758;
            if (timer != null && this.f7759 != null) {
                timer.cancel();
                this.f7759.run();
            }
            if (!C2880.f7699 && C3348.f9870 != null) {
                C3348.m12359(new RunnableC2898());
            }
        }
    }

    public class RunnableC2900 implements Runnable {
        RunnableC2900() {
        }

        @Override
        public void run() {
            Toast.makeText(C3348.m12334(), C2880.m11423(R.string.reboot_message), 1).show();
        }
    }

    public class RunnableC2901 implements Runnable {

        final String f7764;

        final String f7765;

        final String f7766;

        final String f7767;

        final DialogInterface.OnClickListener f7768;

        final DialogInterface.OnClickListener f7769;

        final DialogInterface.OnCancelListener f7770;

        RunnableC2901(String str, String str2, String str3, String str4, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7764 = str;
            this.f7765 = str2;
            this.f7766 = str3;
            this.f7767 = str4;
            this.f7768 = onClickListener;
            this.f7769 = onClickListener2;
            this.f7770 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                C3287 c3287 = new C3287(C3348.f9884);
                String str = this.f7764;
                if (str != null && !str.equals("")) {
                    Dialog m12261 = c3287.m12266(this.f7765).m12282(this.f7766).m12279(R.drawable.ic_vopros).m12281(this.f7767, this.f7768).m12285(this.f7764, this.f7769).m12288(this.f7770).m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                } else {
                    Dialog m122612 = c3287.m12266(this.f7765).m12282(this.f7766).m12279(R.drawable.ic_vopros).m12281(this.f7767, this.f7768).m12288(this.f7770).m12261();
                    C2880.m11529(m122612);
                    m122612.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    class RunnableC2902 implements Runnable {

        int f7771 = 0;

        boolean f7772 = false;

        boolean f7773 = false;

        boolean f7774 = false;

        boolean f7775 = false;

        final String f7776;

        final Runnable f7777;

        final Runnable f7778;

        class RunnableC2903 implements Runnable {
            RunnableC2903() {
            }

            @Override
            public void run() {
                C3348.m12365(23);
            }
        }

        class RunnableC2904 implements Runnable {
            RunnableC2904() {
            }

            @Override
            public void run() {
                C3348.m12356(23);
            }
        }

        RunnableC2902(String str, Runnable runnable, Runnable runnable2) {
            this.f7776 = str;
            this.f7777 = runnable;
            this.f7778 = runnable2;
        }

        @Override
        public void run() {
            Runnable runnable;
            Runnable runnable2;
            C3348.m12359(new RunnableC2903());
            C2851 c2851 = null;
            try {
                c2851 = C2880.m11401(this.f7776);
                if (c2851 != null) {
                    this.f7773 = false;
                    int m11248 = c2851.m11248();
                    this.f7771 = m11248;
                    if (m11248 == 0) {
                        this.f7773 = true;
                    }
                    C3348.m12347(String.format("%s bytes found, %s Mb", Integer.valueOf(m11248), Float.valueOf(this.f7771 / 1048576.0f)));
                } else {
                    this.f7771 = 0;
                    this.f7773 = true;
                }
            } catch (Exception e) {
                e.printStackTrace();
                if (0 != 0) {
                    c2851.m11251();
                }
            }
            if (c2851 != null) {
                c2851.m11251();
            }
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12649(this.f7771 / 1024);
            }
            this.f7774 = false;
            if (new File(C3348.f9876 + "/Download/" + this.f7776).exists()) {
                if (!this.f7773) {
                    C3348.m12347(Long.valueOf(new File(C3348.f9876 + "/Download/" + this.f7776).length()));
                    C3348.m12347(Integer.valueOf(this.f7771));
                    long length = new File(C3348.f9876 + "/Download/" + this.f7776).length();
                    int i = this.f7771;
                    if (length == i || i == 0) {
                        this.f7774 = true;
                    }
                } else {
                    this.f7774 = true;
                }
            }
            if (!this.f7773 && !this.f7774) {
                try {
                    new C2863(this.f7776).m11270();
                } catch (Throwable th) {
                    th.printStackTrace();
                    if (c2851 != null) {
                        c2851.m11251();
                    }
                }
                if (new File(C3348.f9876 + "/Download/" + this.f7776).exists()) {
                    if (new File(C3348.f9876 + "/Download/" + this.f7776).length() == this.f7771) {
                        this.f7774 = true;
                        this.f7775 = true;
                    } else {
                        this.f7772 = true;
                        this.f7774 = false;
                    }
                }
            } else {
                if (new File(C3348.f9876 + "/Download/" + this.f7776).exists() && !this.f7774) {
                    new File(C3348.f9876 + "/Download/" + this.f7776).delete();
                }
            }
            C3348.m12359(new RunnableC2904());
            if (this.f7772) {
                C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.corrupt_download));
            }
            if (this.f7773 && !this.f7774) {
                C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.internet_not_found));
            }
            if (this.f7774) {
                if (new File(C3348.f9876 + "/Download/" + this.f7776).exists()) {
                    try {
                        if (this.f7774 && !this.f7775 && (runnable2 = this.f7777) != null) {
                            runnable2.run();
                        }
                        if (this.f7775 && (runnable = this.f7778) != null) {
                            runnable.run();
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.corrupt_download));
                    }
                }
            }
        }
    }

    public class RunnableC2905 implements Runnable {

        final Activity f7781;

        final String f7782;

        final String f7783;

        RunnableC2905(Activity activity, String str, String str2) {
            this.f7781 = activity;
            this.f7782 = str;
            this.f7783 = str2;
        }

        @Override
        public void run() {
            C3287 c3287 = new C3287(this.f7781);
            c3287.m12266(this.f7782);
            c3287.m12282(this.f7783);
            c3287.m12291(R.string.ok, null);
            try {
                C2880.m11529(c3287.m12261());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2906 implements Runnable {

        final boolean f7784;

        final String f7785;

        final File f7786;

        class DialogInterfaceOnClickListenerC2907 implements DialogInterface.OnClickListener {

            class RunnableC2908 implements Runnable {
                RunnableC2908() {
                }

                @Override
                public void run() {
                    if (RunnableC2906.this.f7784) {
                        new C2880("").m11618("pm uninstall " + RunnableC2906.this.f7785);
                    }
                    C2880.m11439(C3348.f9875 + "/pinapp.apk", "", true, false);
                    Context m12334 = C3348.m12334();
                    String str = C3348.f9862;
                    C2880.m11557(m12334, str, str);
                }
            }

            DialogInterfaceOnClickListenerC2907() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (C3348.f9908) {
                    new Thread(new RunnableC2908()).start();
                    return;
                }
                File file = new File(C3348.f9876 + "/tmp/pinapp.apk");
                C2880.m11292(RunnableC2906.this.f7786, file);
                if (RunnableC2906.this.f7786.exists() && file.exists() && RunnableC2906.this.f7786.length() == file.length()) {
                    if (RunnableC2906.this.f7784) {
                        C3348.f10011 = new C3312(C3348.m12334(), file, false);
                        C2880.m11564(C3348.f9884, RunnableC2906.this.f7785, Integer.valueOf(C3348.f10015));
                    } else {
                        C2880.m11437(C3348.f9884, file, Integer.valueOf(C3348.f10017));
                    }
                }
            }
        }

        class DialogInterfaceOnClickListenerC2909 implements DialogInterface.OnClickListener {
            DialogInterfaceOnClickListenerC2909() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                C3348.m12333().edit().putBoolean("dont_show_pinapp", true).commit();
            }
        }

        RunnableC2906(boolean z, String str, File file) {
            this.f7784 = z;
            this.f7785 = str;
            this.f7786 = file;
        }

        @Override
        public void run() {
            C2880.m11537(C2880.m11423(R.string.information), C2880.m11423(R.string.message_installation_inapp_proxy), new DialogInterfaceOnClickListenerC2907(), new DialogInterfaceOnClickListenerC2909(), null);
        }
    }

    public class RunnableC2910 implements Runnable {

        final Activity f7790;

        final String f7791;

        final SpannableStringBuilder f7792;

        RunnableC2910(Activity activity, String str, SpannableStringBuilder spannableStringBuilder) {
            this.f7790 = activity;
            this.f7791 = str;
            this.f7792 = spannableStringBuilder;
        }

        @Override
        public void run() {
            C3287 c3287 = new C3287(this.f7790);
            c3287.m12266(this.f7791);
            c3287.m12280(this.f7792);
            c3287.m12289(true);
            c3287.m12291(R.string.ok, null);
            try {
                C2880.m11532(c3287.m12261());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2911 implements Runnable {

        int f7793 = 0;

        boolean f7794 = false;

        boolean f7795 = false;

        boolean f7796 = false;

        boolean f7797 = false;

        final ArrayList f7798;

        final Runnable f7799;

        final Runnable f7800;

        class RunnableC2912 implements Runnable {
            RunnableC2912() {
            }

            @Override
            public void run() {
                C3348.m12365(23);
            }
        }

        class RunnableC2913 implements Runnable {
            RunnableC2913() {
            }

            @Override
            public void run() {
                C3348.m12356(23);
            }
        }

        RunnableC2911(ArrayList arrayList, Runnable runnable, Runnable runnable2) {
            this.f7798 = arrayList;
            this.f7799 = runnable;
            this.f7800 = runnable2;
        }

        @Override
        public void run() {
            Runnable runnable;
            Runnable runnable2;
            C3348.m12359(new RunnableC2912());
            Iterator it = this.f7798.iterator();
            while (it.hasNext()) {
                C2997 c2997 = (C2997) it.next();
                C2851 c2851 = null;
                try {
                    c2851 = C2880.m11401(c2997.f8122);
                    if (c2851 != null) {
                        this.f7795 = false;
                        int m11248 = c2851.m11248();
                        this.f7793 = m11248;
                        if (m11248 == 0) {
                            this.f7795 = true;
                        }
                        C3348.m12347(String.format("%s bytes found, %s Mb", Integer.valueOf(m11248), Float.valueOf(this.f7793 / 1048576.0f)));
                    } else {
                        this.f7793 = 0;
                        this.f7795 = true;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    if (c2851 != null) {
                        c2851.m11251();
                    }
                }
                if (c2851 != null) {
                    c2851.m11251();
                }
                C4083 c4083 = C3348.f9902;
                if (c4083 != null && c4083.m12645()) {
                    C3348.f9902.m12649(this.f7793 / 1024);
                }
                this.f7796 = false;
                if (new File(C3348.f9876 + "/Download/" + c2997.f8122).exists()) {
                    if (!this.f7795) {
                        C3348.m12347(Long.valueOf(new File(C3348.f9876 + "/Download/" + c2997.f8122).length()));
                        C3348.m12347(Integer.valueOf(this.f7793));
                        long length = new File(C3348.f9876 + "/Download/" + c2997.f8122).length();
                        int i = this.f7793;
                        if (length == i || i == 0) {
                            this.f7796 = true;
                        }
                    } else {
                        this.f7796 = true;
                    }
                }
                if (!this.f7795 && !this.f7796) {
                    try {
                        new C2863(c2997.f8122).m11270();
                    } catch (Throwable th) {
                        th.printStackTrace();
                        if (c2851 != null) {
                            c2851.m11251();
                        }
                    }
                    if (new File(C3348.f9876 + "/Download/" + c2997.f8122).exists()) {
                        if (new File(C3348.f9876 + "/Download/" + c2997.f8122).length() == this.f7793) {
                            this.f7796 = true;
                            this.f7797 = true;
                        } else {
                            this.f7794 = true;
                            this.f7796 = false;
                        }
                    }
                } else {
                    if (new File(C3348.f9876 + "/Download/" + c2997.f8122).exists() && !this.f7796) {
                        new File(C3348.f9876 + "/Download/" + c2997.f8122).delete();
                    }
                }
            }
            C3348.m12359(new RunnableC2913());
            if (this.f7794) {
                C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.corrupt_download));
                Iterator it2 = this.f7798.iterator();
                while (it2.hasNext()) {
                    C2997 c29972 = (C2997) it2.next();
                    if (new File(C3348.f9876 + "/Download/" + c29972.f8122).exists()) {
                        new File(C3348.f9876 + "/Download/" + c29972.f8122).delete();
                    }
                }
            }
            if (this.f7795 && !this.f7796) {
                C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.internet_not_found));
            }
            boolean z = this.f7796;
            if (z && !this.f7794) {
                if (z) {
                    try {
                        if (!this.f7797 && (runnable = this.f7799) != null) {
                            runnable.run();
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        C3348.m12367(C2880.m11423(R.string.warning), C2880.m11423(R.string.corrupt_download));
                        return;
                    }
                }
                if (this.f7797 && (runnable2 = this.f7800) != null) {
                    runnable2.run();
                }
            }
        }
    }

    public class RunnableC2914 implements Runnable {

        final Activity f7803;

        final String f7804;

        final String f7805;

        final String f7806;

        final DialogInterface.OnClickListener f7807;

        RunnableC2914(Activity activity, String str, String str2, String str3, DialogInterface.OnClickListener onClickListener) {
            this.f7803 = activity;
            this.f7804 = str;
            this.f7805 = str2;
            this.f7806 = str3;
            this.f7807 = onClickListener;
        }

        @Override
        public void run() {
            C3287 c3287 = new C3287(this.f7803);
            c3287.m12266(this.f7804);
            c3287.m12282(this.f7805);
            c3287.m12289(true);
            c3287.f9707 = true;
            c3287.m12273(false);
            c3287.m12281(this.f7806, this.f7807);
            try {
                C2880.m11532(c3287.m12261());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2915 implements Runnable {

        final File f7808;

        final Activity f7809;

        class DialogInterfaceOnClickListenerC2916 implements DialogInterface.OnClickListener {
            DialogInterfaceOnClickListenerC2916() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent();
                intent.setAction("android.settings.APPLICATION_SETTINGS");
                intent.setFlags(131072);
                if (C3348.f9870 != null) {
                    C3348.f10011 = new C3312(C3348.m12334(), RunnableC2915.this.f7808, false);
                    C3348.f9870.m2460(intent, C3348.f10019);
                }
            }
        }

        RunnableC2915(File file, Activity activity) {
            this.f7808 = file;
            this.f7809 = activity;
        }

        @Override
        public void run() {
            boolean canRequestPackageInstalls;
            if (C3348.f9924 < 26 && Settings.Secure.getInt(C3348.f9870.mo2480().getContentResolver(), "install_non_market_apps", 0) == 0) {
                C2880.m11537(C2880.m11423(R.string.warning), C2880.m11423(R.string.message_allow_non_market_app), new DialogInterfaceOnClickListenerC2916(), null, null);
            }
            if (C3348.f9924 >= 24) {
                Uri m1981 = FileProvider.m1981(this.f7809, PkgName.getPkgName() + ".provider", this.f7808);
                Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE");
                intent.setDataAndType(m1981, "application/vnd.android.package-archive");
                intent.putExtra("android.intent.extra.NOT_UNKNOWN_SOURCE", true);
                intent.putExtra("android.intent.extra.RETURN_RESULT", true);
                intent.setFlags(1);
                try {
                    this.f7809.startActivityForResult(intent, C3348.f10013);
                    return;
                } catch (Throwable th) {
                    if (C3348.f9924 >= 26) {
                        canRequestPackageInstalls = C3348.m12337().canRequestPackageInstalls();
                        if (!canRequestPackageInstalls) {
                            C3348.f10011 = new C3312(C3348.m12334(), this.f7808, false);
                            this.f7809.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C3348.f10019);
                        }
                    } else {
                        Intent intent2 = new Intent();
                        intent2.setAction("android.settings.APPLICATION_SETTINGS");
                        intent2.setFlags(131072);
                        if (C3348.f9870 != null) {
                            C3348.f10011 = new C3312(C3348.m12334(), this.f7808, false);
                            C3348.f9870.m2460(intent2, C3348.f10019);
                        }
                    }
                    th.printStackTrace();
                    return;
                }
            }
            Uri fromFile = Uri.fromFile(this.f7808);
            Intent intent3 = new Intent("android.intent.action.VIEW");
            intent3.setDataAndType(fromFile, "application/vnd.android.package-archive");
            intent3.putExtra("android.intent.extra.RETURN_RESULT", true);
            intent3.setFlags(131072);
            this.f7809.startActivity(intent3);
        }
    }

    public class RunnableC2917 implements Runnable {

        final Dialog f7811;

        RunnableC2917(Dialog dialog) {
            this.f7811 = dialog;
        }

        @Override
        public void run() {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                this.f7811.show();
            }
        }
    }

    public class RunnableC2918 implements Runnable {

        final File f7812;

        RunnableC2918(File file) {
            this.f7812 = file;
        }

        @Override
        public void run() {
            PackageInstaller packageInstaller;
            int createSession;
            OutputStream openWrite;
            try {
                packageInstaller = C3348.m12337().getPackageInstaller();
                PackageInstaller.Session session = null;
                try {
                    createSession = packageInstaller.createSession(new PackageInstaller.SessionParams(1));
                    session = packageInstaller.openSession(createSession);
                    C3923.m12599(C2880.m11423(R.string.wait), C2880.m11423(R.string.installer_slit_get_apk_from_apks), "", 1, 3, false);
                    if (!this.f7812.getAbsolutePath().toLowerCase().endsWith(".apk")) {
                        ZipFile zipFile = new ZipFile(this.f7812);
                        for (FileHeader fileHeader : zipFile.getFileHeaders()) {
                            String fileName = fileHeader.getFileName();
                            if (fileName.toLowerCase().endsWith(".apk")) {
                                C3348.m12347("for " + fileName);
                                C3348.m12347("size for entry:" + fileHeader.getUncompressedSize());
                                ZipInputStream inputStream = zipFile.getInputStream(fileHeader);
                                try {
                                    openWrite = session.openWrite(fileName, 0L, fileHeader.getUncompressedSize());
                                    try {
                                        C2880.m11296(inputStream, openWrite);
                                        session.fsync(openWrite);
                                        if (openWrite != null) {
                                            openWrite.close();
                                        }
                                        if (inputStream != null) {
                                            inputStream.close();
                                        }
                                        if (inputStream != null) {
                                            inputStream.close();
                                        }
                                    } catch (Throwable th) {
                                        throw th;
                                    }
                                } finally {
                                }
                            }
                        }
                    } else {
                        C3348.m12347("session apk installer:" + this.f7812.getAbsolutePath());
                        FileInputStream fileInputStream = new FileInputStream(this.f7812);
                        try {
                            openWrite = session.openWrite(this.f7812.getName(), 0L, this.f7812.length());
                            try {
                                C2880.m11296(fileInputStream, openWrite);
                                session.fsync(openWrite);
                                if (openWrite != null) {
                                    openWrite.close();
                                }
                                fileInputStream.close();
                                fileInputStream.close();
                            } finally {
                                if (openWrite != null) {
                                    try {
                                        openWrite.close();
                                    } catch (Throwable th2) {
                                        Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th, th2);
                                    }
                                }
                            }
                        } finally {
                        }
                    }
                    Intent intent = new Intent(C3348.m12334(), (Class<?>) MyService.class);
                    intent.putExtra("com.ui.extra.file_name_for_install", this.f7812.getAbsolutePath());
                    session.commit(PendingIntent.getService(C3348.m12334(), 0, intent, 0).getIntentSender());
                } catch (Throwable th3) {
                    try {
                        th3.printStackTrace();
                        C2880.m11543(C3348.f9884, C2880.m11423(R.string.error), C2880.m11425(R.string.installer_error_rootless, th3.getMessage()));
                        if (session != null) {
                            session.close();
                        }
                    } finally {
                        if (session != null) {
                            session.close();
                        }
                    }
                }
            } catch (Throwable th4) {
                th4.printStackTrace();
            }
        }
    }

    public class RunnableC2919 implements Runnable {

        final Activity f7814;

        final String f7815;

        final String f7816;

        RunnableC2919(Activity activity, String str, String str2) {
            this.f7814 = activity;
            this.f7815 = str;
            this.f7816 = str2;
        }

        @Override
        public void run() {
            C3287 c3287 = new C3287(this.f7814);
            c3287.m12266(this.f7815);
            c3287.m12282(this.f7816);
            c3287.m12289(true);
            c3287.m12291(R.string.ok, null);
            try {
                C2880.m11532(c3287.m12261());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2920 implements Runnable {

        final String f7817;

        final Activity f7818;

        RunnableC2920(String str, Activity activity) {
            this.f7817 = str;
            this.f7818 = activity;
        }

        @Override
        public void run() {
            if (C3348.f9924 >= 14) {
                Intent intent = new Intent("android.intent.action.UNINSTALL_PACKAGE", Uri.parse("package:" + this.f7817));
                intent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", true);
                intent.setFlags(131072);
                this.f7818.startActivity(intent);
                return;
            }
            Intent intent2 = new Intent("android.intent.action.DELETE", Uri.parse("package:" + this.f7817));
            intent2.setFlags(131072);
            this.f7818.startActivity(intent2);
        }
    }

    public class RunnableC2921 implements Runnable {
        RunnableC2921() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_progress_get_classes));
                C3348.f9902.m12648(false, C3348.f9870.mo2480());
            }
        }
    }

    public class RunnableC2922 implements Runnable {

        final File f7820;

        final Activity f7821;

        final Integer f7822;

        class DialogInterfaceOnClickListenerC2923 implements DialogInterface.OnClickListener {
            DialogInterfaceOnClickListenerC2923() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent();
                intent.setAction("android.settings.APPLICATION_SETTINGS");
                intent.setFlags(131072);
                C3348 c3348 = C3348.f9870;
                if (c3348 != null) {
                    c3348.m2458(intent);
                    C3348.f10011 = new C3312(C3348.m12334(), RunnableC2922.this.f7820, false);
                    C3348.f9870.m2460(intent, C3348.f10019);
                }
            }
        }

        RunnableC2922(File file, Activity activity, Integer num) {
            this.f7820 = file;
            this.f7821 = activity;
            this.f7822 = num;
        }

        @Override
        public void run() {
            boolean canRequestPackageInstalls;
            if (C3348.f9924 < 26 && Settings.Secure.getInt(C3348.f9870.mo2480().getContentResolver(), "install_non_market_apps", 0) == 0) {
                C2880.m11537(C2880.m11423(R.string.warning), C2880.m11423(R.string.message_allow_non_market_app), new DialogInterfaceOnClickListenerC2923(), null, null);
            }
            if (Build.VERSION.SDK_INT >= 24) {
                Uri m1981 = FileProvider.m1981(this.f7821, PkgName.getPkgName() + ".provider", this.f7820);
                C3348.m12347("api 24 install");
                Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE");
                intent.setDataAndType(m1981, "application/vnd.android.package-archive");
                intent.setFlags(1);
                try {
                    this.f7821.startActivityForResult(intent, this.f7822.intValue());
                    return;
                } catch (Throwable th) {
                    if (C3348.f9924 >= 26) {
                        canRequestPackageInstalls = C3348.m12337().canRequestPackageInstalls();
                        if (!canRequestPackageInstalls) {
                            C3348.f10011 = new C3312(C3348.m12334(), this.f7820, false);
                            this.f7821.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C3348.f10019);
                        } else {
                            Intent intent2 = new Intent();
                            intent2.setAction("android.settings.APPLICATION_SETTINGS");
                            intent2.setFlags(131072);
                            if (C3348.f9870 != null) {
                                C3348.f10011 = new C3312(C3348.m12334(), this.f7820, false);
                                C3348.f9870.m2460(intent2, C3348.f10019);
                            }
                        }
                    }
                    th.printStackTrace();
                    return;
                }
            }
            Uri fromFile = Uri.fromFile(this.f7820);
            Intent intent3 = new Intent("android.intent.action.VIEW");
            intent3.setDataAndType(fromFile, "application/vnd.android.package-archive");
            intent3.setFlags(131072);
            this.f7821.startActivityForResult(intent3, this.f7822.intValue());
        }
    }

    public class RunnableC2924 implements Runnable {
        RunnableC2924() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_progress_strings_analisis));
                C3348.f9902.m12648(false, C3348.f9870.mo2480());
            }
        }
    }

    public class RunnableC2925 implements Runnable {

        final String f7825;

        final String f7826;

        final DialogInterface.OnClickListener f7827;

        final String f7828;

        final CompoundButton.OnCheckedChangeListener f7829;

        final boolean f7830;

        final boolean f7831;

        RunnableC2925(String str, String str2, DialogInterface.OnClickListener onClickListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7825 = str;
            this.f7826 = str2;
            this.f7827 = onClickListener;
            this.f7828 = str3;
            this.f7829 = onCheckedChangeListener;
            this.f7830 = z;
            this.f7831 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C3287 c3287 = new C3287(C3348.f9870.mo2480());
                    c3287.m12266(this.f7825).m12282(this.f7826).m12279(R.drawable.ic_angel).m12281(C2880.m11423(R.string.ok), this.f7827).m12274(this.f7828, this.f7829, this.f7830);
                    try {
                        if (this.f7831) {
                            Linkify.addLinks(c3287.f9709, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m12261 = c3287.m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2926 implements Runnable {
        RunnableC2926() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_progress_data_parse));
                C3348.f9902.m12648(false, C3348.f9870.mo2480());
            }
        }
    }

    public class RunnableC2927 implements Runnable {

        final String f7833;

        RunnableC2927(String str) {
            this.f7833 = str;
        }

        @Override
        public void run() {
            try {
                try {
                    Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.parse("package:" + this.f7833));
                    intent.setFlags(131072);
                    C3348.f9870.m2458(intent);
                } catch (ActivityNotFoundException unused) {
                    Intent intent2 = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                    intent2.setData(Uri.parse("package:" + this.f7833));
                    intent2.setFlags(131072);
                    C3348.f9870.m2458(intent2);
                }
            } catch (ActivityNotFoundException unused2) {
                C3348.f9870.m2458(new Intent("android.settings.MANAGE_APPLICATIONS_SETTINGS"));
            }
        }
    }

    public class RunnableC2928 implements Runnable {

        final String f7834;

        RunnableC2928(String str) {
            this.f7834 = str;
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_step2));
                try {
                    C3348.f9902.m12651(Integer.valueOf(this.f7834.replace("Progress size:", "")).intValue());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    class C2929 implements Thread.UncaughtExceptionHandler {
        C2929() {
        }

        @Override
        public void uncaughtException(Thread thread, Throwable th) {
            StringWriter stringWriter = new StringWriter();
            th.printStackTrace(new PrintWriter(stringWriter));
            System.out.println("Root-java error:" + stringWriter.toString());
        }
    }

    public class RunnableC2930 implements Runnable {

        final String f7836;

        RunnableC2930(String str) {
            this.f7836 = str;
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_step2));
                try {
                    C3348.f9902.m12649(Integer.valueOf(this.f7836.replace("Size file:", "")).intValue());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                C3348.f9902.m12652("%1d/%2d bytes");
            }
        }
    }

    public class RunnableC2931 implements Runnable {

        final String f7838;

        final String f7839;

        final DialogInterface.OnClickListener f7840;

        final DialogInterface.OnClickListener f7841;

        final DialogInterface.OnCancelListener f7842;

        final String f7843;

        final CompoundButton.OnCheckedChangeListener f7844;

        final boolean f7845;

        final boolean f7846;

        RunnableC2931(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7838 = str;
            this.f7839 = str2;
            this.f7840 = onClickListener;
            this.f7841 = onClickListener2;
            this.f7842 = onCancelListener;
            this.f7843 = str3;
            this.f7844 = onCheckedChangeListener;
            this.f7845 = z;
            this.f7846 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C3287 c3287 = new C3287(C3348.f9870.mo2480());
                    c3287.m12266(this.f7838).m12282(this.f7839).m12279(R.drawable.ic_vopros).m12281(C2880.m11423(R.string.Yes), this.f7840).m12285(C2880.m11423(R.string.no), this.f7841).m12288(this.f7842).m12274(this.f7843, this.f7844, this.f7845);
                    try {
                        if (this.f7846) {
                            Linkify.addLinks(c3287.f9709, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m12261 = c3287.m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2932 implements Runnable {
        RunnableC2932() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_step3));
                C3348.f9902.m12649(6);
                C3348.f9902.m12651(3);
                C3348.f9902.m12652("%1d/%2d");
            }
        }
    }

    public class RunnableC2933 implements Runnable {

        final boolean f7848;

        class RunnableC2934 implements Runnable {
            RunnableC2934() {
            }

            @Override
            public void run() {
                try {
                    if (C3348.f9889 != null) {
                        C3348.m12356(11);
                        C3348.f9889.notifyDataSetChanged();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        RunnableC2933(boolean z) {
            this.f7848 = z;
        }

        @Override
        public void run() {
            ServiceInfo[] serviceInfoArr;
            new ArrayList();
            PackageInfo m11390 = C2880.m11390("com.android.vending", 516);
            if (m11390 != null && (serviceInfoArr = m11390.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = m11390.services;
                    if (i >= serviceInfoArr2.length) {
                        break;
                    }
                    try {
                        if (!this.f7848) {
                            if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || m11390.services[i].name.endsWith("MarketBillingService")) && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 2) {
                                new C2880("").m11618("pm disable 'com.android.vending/" + m11390.services[i].name + "'");
                            }
                        } else if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || m11390.services[i].name.endsWith("MarketBillingService")) && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 1) {
                            new C2880("").m11618("pm enable 'com.android.vending/" + m11390.services[i].name + "'");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    i++;
                }
                if (C3348.f9870 != null) {
                    C3348.m12359(new RunnableC2934());
                }
            }
        }
    }

    public class RunnableC2935 implements Runnable {
        RunnableC2935() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_step4));
                C3348.f9902.m12651(4);
            }
        }
    }

    public class RunnableC2936 implements Runnable {

        final boolean f7851;

        class RunnableC2937 implements Runnable {
            RunnableC2937() {
            }

            @Override
            public void run() {
                try {
                    if (C3348.f9889 != null) {
                        C3348.m12356(11);
                        C3348.f9889.notifyDataSetChanged();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        RunnableC2936(boolean z) {
            this.f7851 = z;
        }

        @Override
        public void run() {
            ServiceInfo[] serviceInfoArr;
            new ArrayList();
            PackageInfo m11390 = C2880.m11390("com.android.vending", 516);
            if (m11390 != null && (serviceInfoArr = m11390.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = m11390.services;
                    if (i >= serviceInfoArr2.length) {
                        break;
                    }
                    try {
                        if (!this.f7851) {
                            if (serviceInfoArr2[i].name.endsWith("LicensingService") && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 2) {
                                new C2880("").m11618("pm disable 'com.android.vending/" + m11390.services[i].name + "'");
                            }
                        } else if (serviceInfoArr2[i].name.endsWith("LicensingService") && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 1) {
                            new C2880("").m11618("pm enable 'com.android.vending/" + m11390.services[i].name + "'");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    i++;
                }
                if (C3348.f9870 != null) {
                    C3348.m12359(new RunnableC2937());
                }
            }
        }
    }

    public class RunnableC2938 implements Runnable {
        RunnableC2938() {
        }

        @Override
        public void run() {
            C4083 c4083 = C3348.f9902;
            if (c4083 != null && c4083.m12645()) {
                C3348.f9902.m12650(C2880.m11423(R.string.patch_step6));
                C3348.f9902.m12651(6);
            }
        }
    }

    public class RunnableC2939 implements Runnable {

        final String f7854;

        final String f7855;

        class ServiceConnectionC2940 implements ServiceConnection {

            boolean f7856 = false;

            class DialogInterfaceOnClickListenerC2941 implements DialogInterface.OnClickListener {

                class RunnableC2942 implements Runnable {

                    final Intent f7859;

                    RunnableC2942(Intent intent) {
                        this.f7859 = intent;
                    }

                    @Override
                    public void run() {
                        try {
                            MainActivity mainActivity = C3348.f9884;
                            if (mainActivity != null) {
                                mainActivity.startActivity(this.f7859);
                            }
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                    }
                }

                DialogInterfaceOnClickListenerC2941() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m11318 = C2880.m11318();
                    if (m11318 != null) {
                        C3348.m12359(new RunnableC2942(m11318));
                    } else {
                        C2880.m11528(RunnableC2939.this.f7855);
                    }
                }
            }

            class DialogInterfaceOnClickListenerC2943 implements DialogInterface.OnClickListener {

                class RunnableC2944 implements Runnable {

                    final Intent f7862;

                    RunnableC2944(Intent intent) {
                        this.f7862 = intent;
                    }

                    @Override
                    public void run() {
                        try {
                            MainActivity mainActivity = C3348.f9884;
                            if (mainActivity != null) {
                                mainActivity.startActivity(this.f7862);
                            }
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                    }
                }

                DialogInterfaceOnClickListenerC2943() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m11318 = C2880.m11318();
                    if (m11318 != null) {
                        C3348.m12359(new RunnableC2944(m11318));
                    } else {
                        C2880.m11528(RunnableC2939.this.f7855);
                    }
                }
            }

            class DialogInterfaceOnClickListenerC2945 implements DialogInterface.OnClickListener {

                class RunnableC2946 implements Runnable {

                    final Intent f7865;

                    RunnableC2946(Intent intent) {
                        this.f7865 = intent;
                    }

                    @Override
                    public void run() {
                        try {
                            MainActivity mainActivity = C3348.f9884;
                            if (mainActivity != null) {
                                mainActivity.startActivity(this.f7865);
                            }
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                    }
                }

                DialogInterfaceOnClickListenerC2945() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m11318 = C2880.m11318();
                    if (m11318 != null) {
                        C3348.m12359(new RunnableC2946(m11318));
                    } else {
                        C2880.m11528(RunnableC2939.this.f7855);
                    }
                }
            }

            ServiceConnectionC2940() {
            }

            @Override
            public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
                if (RunnableC2939.this.f7855.equals(C3348.f9862)) {
                    try {
                        if (InterfaceC2846.AbstractBinderC2847.m11221(iBinder).mo6633(3, C3348.m12334().getPackageName(), "inapp") == 0) {
                            C3348.m12367(C2880.m11423(R.string.information), C2880.m11423(R.string.test_services_for_work_success));
                            C3348.m12356(1);
                        } else {
                            try {
                                C2880.m11537(C2880.m11423(R.string.warning), C2880.m11425(R.string.test_services_for_work_failed, C3348.m12337().getApplicationInfo(RunnableC2939.this.f7855, ItemType.CLASS_DATA_ITEM).loadLabel(C3348.m12337()).toString()), new DialogInterfaceOnClickListenerC2941(), null, null);
                            } catch (PackageManager.NameNotFoundException e) {
                                e.printStackTrace();
                            }
                            String str = C3348.f9859;
                            C3348.m12356(1);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                        try {
                            C2880.m11537(C2880.m11423(R.string.warning), C2880.m11425(R.string.test_services_for_work_failed, C3348.m12337().getApplicationInfo(RunnableC2939.this.f7855, ItemType.CLASS_DATA_ITEM).loadLabel(C3348.m12337()).toString()), new DialogInterfaceOnClickListenerC2943(), null, null);
                        } catch (PackageManager.NameNotFoundException e2) {
                            e2.printStackTrace();
                        }
                        String str2 = C3348.f9859;
                        C3348.m12356(1);
                    }
                } else {
                    C3348.m12367(C2880.m11423(R.string.information), C2880.m11423(R.string.test_services_for_work_success));
                    C3348.m12356(1);
                }
                this.f7856 = true;
                C3348.m12334().unbindService(this);
            }

            @Override
            public void onServiceDisconnected(ComponentName componentName) {
                if (!this.f7856) {
                    try {
                        C2880.m11537(C2880.m11423(R.string.warning), C2880.m11425(R.string.test_services_for_work_failed, C3348.m12337().getApplicationInfo(RunnableC2939.this.f7855, ItemType.CLASS_DATA_ITEM).loadLabel(C3348.m12337()).toString()), new DialogInterfaceOnClickListenerC2945(), null, null);
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                    }
                }
                String str = C3348.f9859;
                C3348.m12356(1);
            }
        }

        class DialogInterfaceOnClickListenerC2947 implements DialogInterface.OnClickListener {

            class RunnableC2948 implements Runnable {

                final Intent f7868;

                RunnableC2948(Intent intent) {
                    this.f7868 = intent;
                }

                @Override
                public void run() {
                    try {
                        MainActivity mainActivity = C3348.f9884;
                        if (mainActivity != null) {
                            mainActivity.startActivity(this.f7868);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                }
            }

            DialogInterfaceOnClickListenerC2947() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent m11318 = C2880.m11318();
                if (m11318 != null) {
                    C3348.m12359(new RunnableC2948(m11318));
                } else {
                    C2880.m11528(RunnableC2939.this.f7855);
                }
            }
        }

        class DialogInterfaceOnClickListenerC2949 implements DialogInterface.OnClickListener {

            class RunnableC2950 implements Runnable {

                final Intent f7871;

                RunnableC2950(Intent intent) {
                    this.f7871 = intent;
                }

                @Override
                public void run() {
                    try {
                        MainActivity mainActivity = C3348.f9884;
                        if (mainActivity != null) {
                            mainActivity.startActivity(this.f7871);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                }
            }

            DialogInterfaceOnClickListenerC2949() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent m11318 = C2880.m11318();
                if (m11318 != null) {
                    C3348.m12359(new RunnableC2950(m11318));
                } else {
                    C2880.m11528(RunnableC2939.this.f7855);
                }
            }
        }

        RunnableC2939(String str, String str2) {
            this.f7854 = str;
            this.f7855 = str2;
        }

        @Override
        public void run() {
            if (C3348.f9870 != null) {
                C3348.m12365(1);
                C4077 c4077 = C3348.f9900;
                if (c4077 != null) {
                    c4077.m12633(true);
                    C3348.f9900.m12634(C2880.m11423(R.string.test_services_for_work_progress));
                }
                Intent intent = new Intent(this.f7854);
                intent.setPackage(this.f7855);
                try {
                    if (!C3348.m12334().bindService(intent, new ServiceConnectionC2940(), 1)) {
                        try {
                            C2880.m11537(C2880.m11423(R.string.warning), C2880.m11425(R.string.test_services_for_work_failed, C3348.m12337().getApplicationInfo(this.f7855, ItemType.CLASS_DATA_ITEM).loadLabel(C3348.m12337()).toString()), new DialogInterfaceOnClickListenerC2947(), null, null);
                        } catch (PackageManager.NameNotFoundException e) {
                            e.printStackTrace();
                        }
                        String str = C3348.f9859;
                        C3348.m12356(1);
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                    try {
                        C2880.m11537(C2880.m11423(R.string.warning), C2880.m11425(R.string.test_services_for_work_failed, C3348.m12337().getApplicationInfo(this.f7855, ItemType.CLASS_DATA_ITEM).loadLabel(C3348.m12337()).toString()), new DialogInterfaceOnClickListenerC2949(), null, null);
                    } catch (PackageManager.NameNotFoundException e2) {
                        e2.printStackTrace();
                    }
                    String str2 = C3348.f9859;
                    C3348.m12356(1);
                }
            }
        }
    }

    public class C2951 implements Comparator<C2992> {
        C2951() {
        }

        @Override
        public int compare(C2992 c2992, C2992 c29922) {
            if (c2992.f8082.equals(c29922.f8082)) {
                return 0;
            }
            if (c2992.f8082.length() < c29922.f8082.length()) {
                return -1;
            }
            if (c2992.f8082.length() > c29922.f8082.length()) {
                return 1;
            }
            if (c2992.f8082.length() != c29922.f8082.length()) {
                return 0;
            }
            return c2992.f8082.compareTo(c29922.f8082);
        }
    }

    public class RunnableC2952 implements Runnable {

        final String f7873;

        final Activity f7874;

        final Integer f7875;

        RunnableC2952(String str, Activity activity, Integer num) {
            this.f7873 = str;
            this.f7874 = activity;
            this.f7875 = num;
        }

        @Override
        public void run() {
            if (C3348.f9924 >= 14) {
                Intent intent = new Intent("android.intent.action.UNINSTALL_PACKAGE", Uri.parse("package:" + this.f7873));
                intent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", true);
                intent.setFlags(131072);
                this.f7874.startActivityForResult(intent, this.f7875.intValue());
                return;
            }
            Intent intent2 = new Intent("android.intent.action.DELETE", Uri.parse("package:" + this.f7873));
            intent2.setFlags(131072);
            this.f7874.startActivityForResult(intent2, this.f7875.intValue());
        }
    }

    public class RunnableC2953 implements Runnable {

        final String f7876;

        final String f7877;

        final DialogInterface.OnClickListener f7878;

        final DialogInterface.OnClickListener f7879;

        final DialogInterface.OnCancelListener f7880;

        RunnableC2953(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7876 = str;
            this.f7877 = str2;
            this.f7878 = onClickListener;
            this.f7879 = onClickListener2;
            this.f7880 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    Dialog m12261 = new C3287(C3348.f9870.mo2480()).m12266(this.f7876).m12282(this.f7877).m12279(R.drawable.ic_vopros).m12281(C2880.m11423(R.string.Yes), this.f7878).m12285(C2880.m11423(R.string.no), this.f7879).m12288(this.f7880).m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2954 implements Runnable {

        class C2955 implements CompoundButton.OnCheckedChangeListener {
            C2955() {
            }

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                if (z) {
                    C3348.m12333().edit().putBoolean("warning_magisk", false).commit();
                } else {
                    C3348.m12333().edit().putBoolean("warning_magisk", true).commit();
                }
            }
        }

        RunnableC2954() {
        }

        @Override
        public void run() {
            C2880.m11544(C2880.m11423(R.string.warning), C2880.m11423(R.string.magisk_warning2), C2880.m11423(R.string.warning_superSu_mount_name_space_separation_3), new C2955(), false, null, true);
        }
    }

    class C2956 extends ThreadLocal<char[]> {
        C2956() {
        }

        @Override
        public char[] initialValue() {
            return new char[256];
        }
    }

    public class C2957 extends ApplicationInfo {

        final File f7882;

        C2957(File file) {
            this.f7882 = file;
        }

        @Override
        public CharSequence loadLabel(PackageManager packageManager) {
            try {
                RandomAccessFile randomAccessFile = new RandomAccessFile(this.f7882, InternalZipConstants.READ_MODE);
                AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(C2880.m11330(DataSources.asDataSource(randomAccessFile)));
                for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                    if (eventType == 3 && androidBinXmlParser.getDepth() == 2 && "application".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                        C3348.m12347(androidBinXmlParser.getName());
                        for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                            if ("label".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                int attributeValueType = androidBinXmlParser.getAttributeValueType(i);
                                if (attributeValueType != 1) {
                                    if (attributeValueType == 3) {
                                        C4204 c4204 = new C4204(C2880.m11402(DataSources.asDataSource(randomAccessFile)));
                                        c4204.m12862();
                                        C4298 m12861 = c4204.m12861();
                                        return m12861.m13088(androidBinXmlParser.getAttributeIntValue(i)).get(0).m13090().mo13072(m12861, null);
                                    }
                                } else {
                                    return androidBinXmlParser.getAttributeStringValue(i);
                                }
                            }
                        }
                        return null;
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            return null;
        }
    }

    class ViewOnKeyListenerC2958 implements View.OnKeyListener {

        final WindowManager f7883;

        ViewOnKeyListenerC2958(WindowManager windowManager) {
            this.f7883 = windowManager;
        }

        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            C3348.m12347("keyCode " + i);
            if (i == 4) {
                this.f7883.removeView(view.getRootView());
                return false;
            }
            return false;
        }
    }

    public class RunnableC2959 implements Runnable {

        final String f7884;

        final String f7885;

        final DialogInterface.OnClickListener f7886;

        final DialogInterface.OnCancelListener f7887;

        RunnableC2959(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) {
            this.f7884 = str;
            this.f7885 = str2;
            this.f7886 = onClickListener;
            this.f7887 = onCancelListener;
        }

        @Override
        public void run() {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C3287 c3287 = new C3287(C3348.f9870.mo2480());
                c3287.m12266(this.f7884).m12282(this.f7885).m12279(R.drawable.ic_angel).m12281(C2880.m11423(R.string.ok), this.f7886).m12288(this.f7887);
                Dialog m12261 = c3287.m12261();
                C2880.m11529(m12261);
                m12261.findViewById(android.R.id.message);
            }
        }
    }

    class ViewOnClickListenerC2960 implements View.OnClickListener {

        final WindowManager f7888;

        ViewOnClickListenerC2960(WindowManager windowManager) {
            this.f7888 = windowManager;
        }

        @Override
        public void onClick(View view) {
            this.f7888.removeView(view.getRootView());
        }
    }

    public class RunnableC2961 implements Runnable {

        final String f7889;

        final String f7890;

        final DialogInterface.OnClickListener f7891;

        final DialogInterface.OnClickListener f7892;

        final DialogInterface.OnCancelListener f7893;

        final String f7894;

        final CompoundButton.OnCheckedChangeListener f7895;

        final boolean f7896;

        final String f7897;

        final CompoundButton.OnCheckedChangeListener f7898;

        final boolean f7899;

        final boolean f7900;

        RunnableC2961(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, String str4, CompoundButton.OnCheckedChangeListener onCheckedChangeListener2, boolean z2, boolean z3) {
            this.f7889 = str;
            this.f7890 = str2;
            this.f7891 = onClickListener;
            this.f7892 = onClickListener2;
            this.f7893 = onCancelListener;
            this.f7894 = str3;
            this.f7895 = onCheckedChangeListener;
            this.f7896 = z;
            this.f7897 = str4;
            this.f7898 = onCheckedChangeListener2;
            this.f7899 = z2;
            this.f7900 = z3;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C3348.f9884;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C3287 c3287 = new C3287(C3348.f9870.mo2480());
                    c3287.m12266(this.f7889).m12282(this.f7890).m12279(R.drawable.ic_vopros).m12281(C2880.m11423(R.string.Yes), this.f7891).m12285(C2880.m11423(R.string.no), this.f7892).m12288(this.f7893).m12274(this.f7894, this.f7895, this.f7896).m12275(this.f7897, this.f7898, this.f7899);
                    try {
                        if (this.f7900) {
                            Linkify.addLinks(c3287.f9709, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m12261 = c3287.m12261();
                    C2880.m11529(m12261);
                    m12261.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    class ViewOnKeyListenerC2962 implements View.OnKeyListener {

        final WindowManager f7901;

        ViewOnKeyListenerC2962(WindowManager windowManager) {
            this.f7901 = windowManager;
        }

        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            C3348.m12347("keyCode " + i);
            if (i == 4) {
                this.f7901.removeView(view.getRootView());
                return false;
            }
            return false;
        }
    }

    public class ServiceConnectionC2963 implements ServiceConnection {
        ServiceConnectionC2963() {
        }

        @Override
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            InterfaceC1827 m8603 = InterfaceC1827.AbstractBinderC1828.m8603(iBinder);
            C2880.f7707 = m8603;
            boolean z = false;
            if (m8603 != null) {
                try {
                    z = m8603.mo8602();
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
            C3348.m12347("TestService:" + z);
            C3348.m12347("TestService:" + z);
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            C3348.m12347("test service disconnected.");
            C2880.f7707 = null;
        }
    }

    public C2880(String str) {
    }

    public static boolean m11287(File file, String str) {
        File file2;
        byte[] bArr = new byte[InternalZipConstants.UFT8_NAMES_FLAG];
        File file3 = new File(str);
        if (!file3.exists() || file3.isFile()) {
            if (file3.isFile()) {
                file3.delete();
            }
            file3.mkdirs();
        }
        if (!file3.exists()) {
            C3348.m12347("not found dir for ectract xz.");
            return false;
        }
        if (str.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            file2 = new File(str + m11493(file.getName()));
        } else {
            file2 = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + m11493(file.getName()));
        }
        String str2 = null;
        try {
            str2 = file.getAbsolutePath();
            XZInputStream xZInputStream = new XZInputStream(new FileInputStream(file));
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            while (true) {
                int read = xZInputStream.read(bArr);
                if (read == -1) {
                    break;
                }
                fileOutputStream.write(bArr, 0, read);
            }
            if (file2.exists()) {
                return true;
            }
            file2.delete();
            return false;
        } catch (EOFException unused) {
            System.err.println("XZDec: Unexpected end of input on " + str2);
            file2.delete();
            return false;
        } catch (FileNotFoundException e) {
            System.err.println("XZDec: Cannot open " + str2 + ": " + e.getMessage());
            file2.delete();
            return false;
        } catch (IOException e2) {
            System.err.println("XZDec: Error decompressing from " + str2 + ": " + e2.getMessage());
            file2.delete();
            return false;
        }
    }

    public static boolean m11288() {
        long j;
        long j2;
        long length;
        PackageInfo m11390 = m11390("com.android.vending", 0);
        if (m11390 != null) {
            File file = new File(m11392(m11390.applicationInfo.sourceDir, true));
            File m11363 = m11363(m11390.applicationInfo.sourceDir);
            File file2 = null;
            if (m11363 != null) {
                try {
                    j = m11363.length();
                    try {
                        File file3 = new File(m11587(m11363.getAbsolutePath(), "vdex"));
                        try {
                            j2 = file3.length();
                            file2 = file3;
                        } catch (Exception e) {
                            e = e;
                            j2 = 0;
                            file2 = file3;
                            e.printStackTrace();
                            if (file2 != null) {
                            }
                            if (m11363 != null) {
                                j = m11363.length();
                            }
                            length = j2;
                            C3348.m12347("vdex=" + length + " odex=" + j);
                            if (j < 225280) {
                            }
                            return false;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        j2 = 0;
                    }
                } catch (Exception e3) {
                    e = e3;
                    j = 0;
                    j2 = 0;
                }
            } else {
                j = 0;
                j2 = 0;
            }
            try {
                j = file.length();
                length = new File(m11587(file.getAbsolutePath(), "vdex")).length();
            } catch (Exception e4) {
                e = e4;
                e.printStackTrace();
                if (file2 != null) {
                    try {
                    } catch (Exception e5) {
                        e5.printStackTrace();
                        length = j2;
                        C3348.m12347("vdex=" + length + " odex=" + j);
                        if (j < 225280) {
                        }
                        return false;
                    }
                    if (file2.exists()) {
                        length = file2.length();
                        C3348.m12347("vdex=" + length + " odex=" + j);
                        if (j < 225280) {
                            if (length != 0) {
                            }
                        }
                        return false;
                    }
                }
                if (m11363 != null && m11363.exists()) {
                    j = m11363.length();
                }
                length = j2;
                C3348.m12347("vdex=" + length + " odex=" + j);
                if (j < 225280) {
                }
                return false;
            }
            C3348.m12347("vdex=" + length + " odex=" + j);
            if (j < 225280 && j > 0) {
                if (length != 0) {
                    return true;
                }
                if (length > 0 && length < 1048576) {
                    return true;
                }
            }
        }
        return false;
    }

    public static void m11289(String str, String str2, byte[] bArr, byte[] bArr2, byte[] bArr3, byte[] bArr4) {
        boolean z;
        String trim = str.trim();
        String[] strArr = new String[trim.split("[ \t]+").length];
        String[] split = trim.split("[ \t]+");
        byte b = 0;
        int i = 0;
        while (i < split.length) {
            try {
                if (split[i].matches("\\?+")) {
                    split[i] = "60";
                    bArr2[i] = 1;
                } else {
                    bArr2[i] = b;
                }
                if (!split[i].toUpperCase().contains("R")) {
                    bArr[i] = Integer.valueOf(split[i], 16).byteValue();
                }
                if (split[i].toUpperCase().contains("R")) {
                    bArr[i] = Integer.valueOf(split[i].toUpperCase().replace("R", ""), 16).byteValue();
                    bArr2[i] = DerValue.tag_UtcTime;
                }
                i++;
                b = 0;
            } catch (Exception e) {
                e.printStackTrace();
                C3348.m12347(" " + e);
            }
        }
        String trim2 = str2.trim();
        String[] strArr2 = new String[trim2.split("[ \t]+").length];
        String[] split2 = trim2.split("[ \t]+");
        for (int i2 = 0; i2 < split2.length; i2++) {
            try {
                if (split2[i2].matches("\\?+")) {
                    split2[i2] = "60";
                    try {
                        bArr4[i2] = 0;
                    } catch (Exception e2) {
                        e = e2;
                        e.printStackTrace();
                        C3348.m12347(" " + e);
                        if (bArr4.length != bArr2.length) {
                        }
                        z = true;
                        if (!z) {
                        }
                    }
                } else {
                    bArr4[i2] = 1;
                }
                if (split2[i2].toUpperCase().contains("S1")) {
                    split2[i2] = "60";
                    bArr4[i2] = 21;
                }
                if (split2[i2].toUpperCase().contains("S0")) {
                    split2[i2] = "60";
                    bArr4[i2] = DerValue.tag_T61String;
                }
                if (!split2[i2].toUpperCase().contains("W")) {
                    bArr3[i2] = Integer.valueOf(split2[i2], 16).byteValue();
                }
                if (split2[i2].toUpperCase().contains("W")) {
                    bArr3[i2] = Integer.valueOf(split2[i2].toUpperCase().replace("W", ""), 16).byteValue();
                    bArr4[i2] = DerValue.tag_UtcTime;
                }
            } catch (Exception e3) {
                e = e3;
            }
        }
        if (bArr4.length != bArr2.length && bArr.length == bArr3.length && bArr3.length >= 4 && bArr.length >= 4) {
            z = false;
        } else {
            z = true;
        }
        if (!z) {
            C3348.m12347("" + trim);
            C3348.m12347("Error: Patterns original and replaced not valid!\n- Dimensions of the original hex-string and repleced must be >3.\n- Dimensions of the original hex-string and repleced must be equal.\n- Pattern hex must be: AF 11 4B ** AA **\nCheck the template file and try again!");
        }
    }

    public static String m11290(String str) {
        if (str != null) {
            return str.replaceAll(":", " ").replaceAll("\\s+", ".").replaceAll(InternalZipConstants.ZIP_FILE_SEPARATOR, ".");
        }
        return "null";
    }

    public static int m11291(byte b, byte b2) {
        return (b & 255) | ((b2 & 255) << 8);
    }

    public static void m11292(File file, File file2) {
        Throwable th;
        AbstractInterruptibleChannel abstractInterruptibleChannel;
        FileChannel channel;
        int i;
        boolean z;
        String[] strArr;
        m11590();
        if (!m11357(file2).exists()) {
            m11357(file2).mkdirs();
        }
        FileChannel fileChannel = null;
        try {
            try {
                FileChannel channel2 = new FileInputStream(file).getChannel();
                try {
                    channel = new FileOutputStream(file2).getChannel();
                    try {
                        for (long j = 0; j < channel2.size(); j += channel2.transferTo(j, 67076096, channel)) {
                            i = 1;
                            try {
                            } catch (IOException e) {
                                e = e;
                                e.printStackTrace();
                                z = e.toString().toLowerCase().contains("no space left");
                                if (!e.toString().toLowerCase().contains("no space left")) {
                                    C3348.m12347("try copy with root");
                                    if (C3348.f9908) {
                                        if (m11404()) {
                                            String file3 = file.getAbsoluteFile().toString();
                                            String file4 = file2.getAbsoluteFile().toString();
                                            String[] strArr2 = new String[i];
                                            strArr2[0] = "dd if=" + file3 + " of=" + file4;
                                            m11464(strArr2);
                                            String[] strArr3 = C3348.f9920;
                                            if (strArr3 != null) {
                                                int length = strArr3.length;
                                                int i2 = 0;
                                                while (i2 < length) {
                                                    String str = strArr3[i2];
                                                    if (new File(file4).exists() && file.length() == file2.length()) {
                                                        break;
                                                    }
                                                    String[] strArr4 = new String[i];
                                                    strArr4[0] = str + " dd if=" + file3 + " of=" + file4;
                                                    m11464(strArr4);
                                                    i2++;
                                                    i = 1;
                                                }
                                            }
                                            if (file.length() != file2.length()) {
                                                file2.delete();
                                            }
                                        } else {
                                            m11294(file.getAbsoluteFile().toString(), file2.getAbsoluteFile().toString(), true, true);
                                        }
                                    }
                                }
                                if (file.length() != file2.length()) {
                                }
                                if (channel2 != null) {
                                }
                                if (channel == null) {
                                }
                            }
                        }
                        z = false;
                    } catch (IOException e2) {
                        e = e2;
                        i = 1;
                    }
                    if (file.length() != file2.length()) {
                        file2.delete();
                        if (C3348.f9908 && !z) {
                            if (C3348.f9948.booleanValue()) {
                                String file5 = file.getAbsoluteFile().toString();
                                String file6 = file2.getAbsoluteFile().toString();
                                m11438("dd", "if=" + file5, "of=" + file6);
                                if ((!new File(file6).exists() || file.length() != file2.length()) && (strArr = C3348.f9920) != null) {
                                    for (String str2 : strArr) {
                                        m11438(str2, "dd", "if=" + file5, "of=" + file6);
                                        if (new File(file6).exists() && file.length() == file2.length()) {
                                            break;
                                        }
                                    }
                                }
                                if (file.length() != file2.length()) {
                                    file2.delete();
                                }
                            } else {
                                m11294(file.getAbsoluteFile().toString(), file2.getAbsoluteFile().toString(), true, true);
                            }
                        }
                    }
                    if (channel2 != null) {
                        try {
                            channel2.close();
                        } catch (IOException e3) {
                            e3.printStackTrace();
                        }
                    }
                } catch (Exception e4) {
                    e = e4;
                    abstractInterruptibleChannel = null;
                    fileChannel = channel2;
                    try {
                        e.printStackTrace();
                        if (fileChannel != null) {
                            try {
                                fileChannel.close();
                            } catch (IOException e5) {
                                e5.printStackTrace();
                            }
                        }
                        if (abstractInterruptibleChannel != null) {
                            abstractInterruptibleChannel.close();
                        }
                        return;
                    } catch (Throwable th2) {
                        th = th2;
                        if (fileChannel != null) {
                            try {
                                fileChannel.close();
                            } catch (IOException e6) {
                                e6.printStackTrace();
                            }
                        }
                        if (abstractInterruptibleChannel == null) {
                            try {
                                abstractInterruptibleChannel.close();
                                throw th;
                            } catch (IOException e7) {
                                e7.printStackTrace();
                                throw th;
                            }
                        }
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    abstractInterruptibleChannel = null;
                    fileChannel = channel2;
                    if (fileChannel != null) {
                    }
                    if (abstractInterruptibleChannel == null) {
                    }
                }
            } catch (IOException e8) {
                e8.printStackTrace();
                return;
            }
        } catch (Exception e9) {
            e = e9;
            abstractInterruptibleChannel = null;
        } catch (Throwable th4) {
            th = th4;
            abstractInterruptibleChannel = null;
        }
        if (channel == null) {
            channel.close();
        }
    }

    public static boolean m11293(InputStream inputStream, File file) {
        m11590();
        if (!m11357(file).exists()) {
            m11357(file).mkdirs();
        }
        try {
            byte[] bArr = new byte[10240];
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            while (true) {
                int read = inputStream.read(bArr);
                if (read != -1) {
                    fileOutputStream.write(bArr, 0, read);
                } else {
                    fileOutputStream.close();
                    return true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean m11294(String str, String str2, boolean z, boolean z2) {
        String str3 = "777";
        int i = 1;
        if (!C3348.f9948.booleanValue()) {
            try {
                if (m11315(str)) {
                    if (z) {
                        m11492(str2, "RW");
                    }
                    if (!z2) {
                        str3 = "";
                    } else {
                        String m11387 = m11387(str);
                        if (m11387 != null) {
                            try {
                                if (!m11387.equals("")) {
                                    str3 = m11387;
                                }
                            } catch (Exception unused) {
                            }
                        }
                    }
                    m11317();
                    new C2880("").m11618("dd if=" + str + " of=" + str2);
                    File file = new File(str);
                    File file2 = new File(str2);
                    String[] strArr = C3348.f9920;
                    if (strArr != null) {
                        int length = strArr.length;
                        int i2 = 0;
                        while (i2 < length) {
                            String str4 = strArr[i2];
                            if (m11315(str2) && file.length() == file2.length()) {
                                break;
                            }
                            C2880 c2880 = new C2880("");
                            String[] strArr2 = new String[i];
                            strArr2[0] = str4 + " dd if=" + str + " of=" + str2;
                            c2880.m11618(strArr2);
                            i2++;
                            i = 1;
                        }
                        if (!m11315(str2)) {
                            new C2880("").m11618(C3348.f9875 + "/busybox cp -fp " + str + " " + str2);
                        }
                    }
                    m11504(str2);
                    if (z2) {
                        m11506("chmod " + str3 + " " + str2);
                    }
                }
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
        File file3 = new File(str);
        File file4 = new File(str2);
        if (z) {
            m11492(str2, "RW");
        }
        if (!z2) {
            str3 = "";
        } else {
            String m113872 = m11387(str);
            if (m113872 != null) {
                try {
                    if (!m113872.equals("")) {
                        str3 = m113872;
                    }
                } catch (Exception unused2) {
                }
            }
        }
        m11438("dd", "if=" + str, "of=" + str2);
        String[] strArr3 = C3348.f9920;
        if (strArr3 != null) {
            for (String str5 : strArr3) {
                if (new File(str2).exists() && file3.length() == file4.length()) {
                    break;
                }
                m11438(str5, "dd", "if=" + str, "of=" + str2);
            }
            if (!new File(str2).exists() || file3.length() != file4.length()) {
                m11438(C3348.f9875 + "/busybox", "dd", "if=" + str, "of=" + str2);
            }
        }
        if (!new File(str2).exists() || file3.length() != file4.length()) {
            m11292(file3, file4);
        }
        m11504(str2);
        if (file3.length() == file4.length()) {
            if (z2) {
                m11508("chmod", str3, str2);
                return true;
            }
            return true;
        }
        file4.delete();
        C3348.m12347("LuckyPatcher (cmdCopy): error copy... not enougth space to destination.");
        return false;
    }

    public static void m11295(File file, File file2, String[] strArr) throws Exception {
        boolean z;
        boolean z2;
        m11590();
        if (file.isDirectory()) {
            if (strArr != null) {
                z = false;
                for (String str : strArr) {
                    if (file.getName().equals(str)) {
                        z = true;
                    }
                }
            } else {
                z = false;
            }
            if (!z) {
                if (!file2.exists()) {
                    file2.mkdir();
                    C3348.m12347("Directory copied from " + file + "  to " + file2);
                }
                String[] list = file.list();
                if (list.length > 0) {
                    for (String str2 : list) {
                        File file3 = new File(file, str2);
                        File file4 = new File(file2, str2);
                        if (strArr != null) {
                            z2 = false;
                            for (String str3 : strArr) {
                                if (str2.equals(str3)) {
                                    z2 = true;
                                }
                            }
                        } else {
                            z2 = false;
                        }
                        if (!z2) {
                            m11295(file3, file4, strArr);
                        }
                    }
                    return;
                }
                return;
            }
            return;
        }
        m11292(file, file2);
    }

    public static void m11296(InputStream inputStream, OutputStream outputStream) throws IOException {
        m11590();
        byte[] bArr = new byte[4096];
        while (true) {
            int read = inputStream.read(bArr);
            if (read > -1) {
                outputStream.write(bArr, 0, read);
            } else {
                return;
            }
        }
    }

    public static File m11297(String str) {
        File file = new File(m11385() + str);
        if (!new File(m11385()).exists()) {
            new File(m11385()).mkdirs();
        }
        String[] strArr = {"odex", "oat", "art", "vdex", "jar"};
        for (int i = 0; i < 5; i++) {
            String m11587 = m11587(str, strArr[i]);
            File file2 = new File(m11385() + m11587);
            if (new File(m11587).exists() && ((new File(m11587).length() != 0 && file2.exists() && file2.length() != new File(m11587).length()) || !file2.exists() || file2.length() == 0)) {
                m11294(m11587, file2.getAbsolutePath(), true, true);
                if (file2.length() == 0) {
                    file2.delete();
                } else {
                    m11301();
                    m11508("chmod", "0644", file.getAbsolutePath());
                    m11508("chown", "0:0", file.getAbsolutePath());
                    m11508("chmod", "0.0", file.getAbsolutePath());
                }
            }
        }
        return file;
    }

    public static File m11298(File file, ArrayList<File> arrayList, String str) throws Throwable {
        String str2;
        PackageManager.NameNotFoundException nameNotFoundException;
        String str3;
        String str4;
        Drawable loadIcon;
        FileOutputStream fileOutputStream;
        ZipOutputStream zipOutputStream;
        File file2;
        String[] strArr;
        String str5 = "";
        if (arrayList != null) {
            Iterator<File> it = arrayList.iterator();
            while (it.hasNext()) {
                File next = it.next();
                if (next.getName().toLowerCase().equals("base.apk")) {
                    PackageInfo m11338 = m11338(next.getAbsolutePath(), 1);
                    String str6 = m11338.packageName;
                    str4 = m11337(next.getAbsolutePath());
                    str2 = "" + m11338.versionName;
                    String str7 = "" + m11338.versionCode;
                    Drawable m11335 = m11335(next.getAbsolutePath());
                    C3348.m12347("iconka:" + m11335);
                    loadIcon = m11335;
                    str = str6;
                    str3 = str7;
                    break;
                }
            }
            str3 = "";
            str4 = str3;
            str2 = str4;
            loadIcon = null;
        } else {
            try {
                PackageInfo packageInfo = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM);
                str4 = packageInfo.applicationInfo.loadLabel(C3348.m12337()).toString();
                try {
                    str2 = "" + packageInfo.versionName;
                } catch (PackageManager.NameNotFoundException e) {
                    str2 = "";
                    nameNotFoundException = e;
                    str3 = str2;
                }
                try {
                    str5 = "" + packageInfo.versionCode;
                    str3 = str5;
                    loadIcon = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.loadIcon(C3348.m12337());
                } catch (PackageManager.NameNotFoundException e2) {
                    nameNotFoundException = e2;
                    str3 = str5;
                    str5 = str4;
                    nameNotFoundException.printStackTrace();
                    str4 = str5;
                    loadIcon = null;
                    if (file.exists()) {
                    }
                    fileOutputStream = new FileOutputStream(file);
                    try {
                        zipOutputStream = new ZipOutputStream(fileOutputStream);
                        ArrayList<File> arrayList2 = new ArrayList<>();
                        String str8 = (((str4 + "\n") + str + "\n") + str2 + "\n") + str3 + "\n";
                        if (arrayList == null) {
                        }
                        String str9 = m11421() + "tmp/";
                        new File(str9).mkdirs();
                        file2 = new File(str9 + "icon.png");
                        if (loadIcon != null) {
                        }
                        m11577(arrayList, zipOutputStream);
                        C3348.m12347(str8);
                        zipOutputStream.setComment(str8);
                        if (!file.exists()) {
                        }
                        file.delete();
                        file2.delete();
                        zipOutputStream.closeEntry();
                        zipOutputStream.close();
                    } catch (Throwable th) {
                        th = th;
                        zipOutputStream = null;
                    }
                    return null;
                }
            } catch (PackageManager.NameNotFoundException e3) {
                str2 = "";
                nameNotFoundException = e3;
                str3 = str2;
            }
        }
        if (file.exists()) {
            file.delete();
        }
        try {
            fileOutputStream = new FileOutputStream(file);
            zipOutputStream = new ZipOutputStream(fileOutputStream);
        } catch (Throwable th2) {
            th = th2;
            fileOutputStream = null;
            zipOutputStream = null;
        }
        try {
            ArrayList<File> arrayList22 = new ArrayList<>();
            String str82 = (((str4 + "\n") + str + "\n") + str2 + "\n") + str3 + "\n";
            if (arrayList == null) {
                arrayList22.add(new File(C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir));
                strArr = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.splitSourceDirs;
                for (String str10 : strArr) {
                    arrayList22.add(new File(str10));
                }
                arrayList = arrayList22;
            }
            String str92 = m11421() + "tmp/";
            new File(str92).mkdirs();
            file2 = new File(str92 + "icon.png");
            if (loadIcon != null) {
                Bitmap m11313 = m11313(loadIcon);
                C3348.m12347("image:" + m11313);
                if (m11313 != null) {
                    if (file2.exists()) {
                        file2.delete();
                    }
                    m11313.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(file2));
                    if (file2.exists() && file2.length() > 0) {
                        arrayList.add(file2);
                    }
                }
            }
            m11577(arrayList, zipOutputStream);
            C3348.m12347(str82);
            zipOutputStream.setComment(str82);
        } catch (Throwable th3) {
            th = th3;
            try {
                th.printStackTrace();
            } finally {
                if (zipOutputStream != null) {
                    zipOutputStream.closeEntry();
                }
                if (zipOutputStream != null) {
                    zipOutputStream.close();
                }
                if (fileOutputStream != null) {
                    fileOutputStream.close();
                }
            }
        }
        if (!file.exists() && file.length() > 0) {
            zipOutputStream.closeEntry();
            zipOutputStream.close();
            fileOutputStream.close();
            return file;
        }
        file.delete();
        file2.delete();
        zipOutputStream.closeEntry();
        zipOutputStream.close();
        return null;
    }

    public static String m11299(String str) {
        String sb;
        new File(C3348.f9876 + "/Backup/").mkdirs();
        try {
            if (C3348.m12333().getInt("apkname", 0) != 0) {
                sb = C3348.f9876 + "/Backup/" + str + ".ver." + m11290(m11391(str)) + ".build." + C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).versionCode + ".apks";
            } else {
                StringBuilder sb2 = new StringBuilder();
                sb2.append(C3348.f9876);
                sb2.append("/Backup/");
                sb2.append(m11290("" + ((Object) C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.loadLabel(C3348.m12337())) + ".ver." + m11391(str)));
                sb2.append(".build.");
                sb2.append(C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).versionCode);
                sb2.append(".apks");
                sb = sb2.toString();
            }
            if (new File(sb).exists()) {
                new File(sb).delete();
            }
            File m11298 = m11298(new File(sb), null, str);
            if (m11298 != null) {
                return m11298.getAbsolutePath();
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return "";
    }

    public static Element m11300(Document document, String str) {
        Element createElement = document.createElement("feature");
        Attr createAttribute = document.createAttribute(MediationMetaData.KEY_NAME);
        createAttribute.setValue(str);
        createElement.setAttributeNode(createAttribute);
        return createElement;
    }

    public static void m11301() {
        String m11385 = m11385();
        if (!new File(m11385 + "/module.prop").exists()) {
            long m11321 = m11321();
            m11514(new File(m11385 + "/module.prop"), "id=luckypatcher\nname=Patches to Android (Lucky Patcher Module)\nversion=" + m11321 + "\nversionCode=1\nauthor=Chelpus\ndescription=if you are updating the firmware, be sure to delete this module. Otherwise, there may be BootLoop.");
            StringBuilder sb = new StringBuilder();
            sb.append("write firmware crc:");
            sb.append(m11321);
            C3348.m12347(sb.toString());
            return;
        }
        long m11374 = m11374();
        if (m11321() != m11374) {
            C3348.m12347("firmware updated: need clear magisk module android patches");
        }
        if (m11374 == 0 && m11375().equals("1.0")) {
            long m113212 = m11321();
            m11514(new File(m11385 + "/module.prop"), "id=luckypatcher\nname=Patches to Android (Lucky Patcher Module)\nversion=" + m113212 + "\nversionCode=1\nauthor=Chelpus\ndescription=if you are updating the firmware, be sure to delete this module. Otherwise, there may be BootLoop.");
            StringBuilder sb2 = new StringBuilder();
            sb2.append("write firmware crc:");
            sb2.append(m113212);
            C3348.m12347(sb2.toString());
        }
    }

    public static void m11302() {
        String m11386 = m11386();
        if (!new File(m11386 + "/module.prop").exists()) {
            m11514(new File(m11386 + "/module.prop"), "id=luckypatcher\nname=System Apps (Lucky Patcher Module)\nversion=1.0\nversionCode=1\nauthor=Chelpus\ndescription=All applications moved to the system through the Lucky Patcher are here.");
        }
    }

    public static Element m11303(Document document, String str) {
        Element createElement = document.createElement("permission");
        Attr createAttribute = document.createAttribute(MediationMetaData.KEY_NAME);
        createAttribute.setValue(str);
        createElement.setAttributeNode(createAttribute);
        return createElement;
    }

    public static int m11304(String str, String str2, String str3, String str4, boolean z) {
        File file;
        String str5;
        boolean z2;
        DexFile dexFile;
        String str6;
        String str7;
        ?? r15;
        String str8;
        int i;
        String[] strArr;
        String str9;
        m11508("chmod", "777", str);
        m11508("chown", "0:0", str);
        m11508("chown", "0.0", str);
        try {
            file = m11364(str2);
        } catch (Exception e) {
            e.printStackTrace();
            file = null;
        }
        if (str4 == null) {
            str5 = m11381(str2, str3);
        } else {
            str5 = str4;
        }
        if (str5 != null && new File(str5).exists()) {
            m11492(str5, "RW");
            new File(str5).delete();
        }
        new File(str2).getName();
        m11381(str2, str3);
        m11364(str2);
        m11587(new File(str2).getName(), "odex");
        try {
            if (m11351().contains("ART")) {
                r15 = 1;
            } else {
                r15 = 0;
            }
            try {
                if (file.exists()) {
                    try {
                        file.delete();
                    } catch (Exception e2) {
                        e = e2;
                        z2 = false;
                        dexFile = null;
                        str6 = r15;
                        e.printStackTrace();
                        str7 = str6;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    }
                }
            } catch (Exception e3) {
                e = e3;
                boolean z3 = r15 == true ? 1 : 0;
            }
            try {
                if (r15 != 0) {
                    C3348.m12347("dex-opt-art");
                    try {
                        C3348.m12347("try create oat with DexFile:");
                        if (!file.getAbsolutePath().contains("/arm/")) {
                            str8 = "";
                        } else {
                            str8 = "arm";
                        }
                        if (file.getAbsolutePath().contains("/arm64/")) {
                            str8 = "arm64";
                        }
                        if (file.getAbsolutePath().contains("/x86/")) {
                            str8 = "x86";
                        }
                        if (file.getAbsolutePath().contains("/x86_64/")) {
                            str8 = "x86_64";
                        }
                        file.delete();
                        if (file.exists()) {
                            m11508("rm", file.getAbsolutePath());
                        }
                        C3348.m12347("try create oat with dex2oat:");
                        i = C3348.f9924;
                        str4 = r15 == true ? 1 : 0;
                    } catch (Exception e4) {
                        e = e4;
                        str4 = r15 == true ? 1 : 0;
                    }
                    try {
                        if (i >= 28) {
                            if (str8.equals("")) {
                                str8 = m11379(file, "--instruction-set");
                            }
                            C3348.m12347("classpath parametr:" + m11379(file, "classpath"));
                            String m11378 = m11378(file, "--class-loader-context");
                            C3348.m12347("class-loader_contex:" + m11378);
                            if (!m11378.equals("")) {
                                str9 = "--class-loader-context=" + m11378;
                            } else if (z) {
                                str9 = "--class-loader-context=PCL[]";
                            } else {
                                str9 = "--class-loader-context=PCL[/system/framework/org.apache.http.legacy.boot.jar]";
                            }
                            strArr = new String[]{"dex2oat", "--dex-file=" + str2, "--oat-file=" + file.getAbsolutePath(), str9, "--instruction-set=" + str8};
                        } else {
                            strArr = new String[]{"dex2oat", "--dex-file=" + str2, "--oat-file=" + file.getAbsolutePath(), "--instruction-set=" + str8};
                        }
                        C3348.m12347(m11438(strArr));
                        C3348.m12347("end");
                        if (file.exists() && file.length() != 0) {
                            C3348.m12347("oat created with dex2oat - length=" + file.length());
                        } else {
                            file.delete();
                            if (file.exists()) {
                                m11508("rm", file.getAbsolutePath());
                            }
                        }
                    } catch (Exception e5) {
                        e = e5;
                        e.printStackTrace();
                        z2 = false;
                        dexFile = null;
                        if (!m11462(str2)) {
                        }
                        str7 = str4;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    }
                    z2 = false;
                    dexFile = null;
                } else {
                    str4 = r15 == true ? 1 : 0;
                    try {
                        file.delete();
                        dexFile = DexFile.loadDex(str2, str + "/temp.dex", 0);
                    } catch (RuntimeException e6) {
                        e6.printStackTrace();
                        dexFile = null;
                        if (m11306(C3348.f9875, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        }
                        new File(str + "/temp.dex").delete();
                        if (file.exists()) {
                            file.delete();
                        }
                        if (!m11462(str2)) {
                        }
                        str7 = str4;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    } catch (Exception e7) {
                        e7.printStackTrace();
                        dexFile = null;
                        if (m11306(C3348.f9875, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        }
                        new File(str + "/temp.dex").delete();
                        if (file.exists()) {
                        }
                        if (!m11462(str2)) {
                        }
                        str7 = str4;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    }
                    if (m11306(C3348.f9875, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        C3348.m12347("Free space for dex enougth.");
                        z2 = true;
                    } else {
                        z2 = false;
                    }
                    new File(str + "/temp.dex").delete();
                    if (file.exists() && file.length() == 0) {
                        file.delete();
                    }
                }
                if (!m11462(str2)) {
                    m11508("chmod", "0644", file.getAbsolutePath());
                    m11508("chown", "0.0", file.getAbsolutePath());
                    m11508("chown", "0:0", file.getAbsolutePath());
                } else {
                    m11508("chmod", "0644", file.getAbsolutePath());
                    m11508("chown", "1000." + str3, file.getAbsolutePath());
                    m11508("chown", "1000:" + str3, file.getAbsolutePath());
                }
                str7 = str4;
            } catch (Exception e8) {
                e = e8;
                r15 = str4;
                z2 = false;
                dexFile = null;
                str6 = r15;
                e.printStackTrace();
                str7 = str6;
                if (dexFile != null) {
                }
                if (str7 == null) {
                }
                if (str7 != null) {
                }
                return 1;
            }
        } catch (Exception e9) {
            e = e9;
            z2 = false;
            dexFile = null;
            str6 = null;
        }
        if (dexFile != null) {
            try {
                dexFile.close();
            } catch (IOException e10) {
                e10.printStackTrace();
            }
        }
        if (str7 == null && !z2) {
            return 1;
        }
        if ((str7 != null || !z2) && str7 == null && !z2) {
            return 1;
        }
        return 0;
    }

    public static int m11305(String str, ArrayList<File> arrayList, String str2, String str3, String str4, boolean z, File file) {
        String str5;
        String str6;
        Exception exc;
        boolean z2;
        boolean z3;
        DexFile dexFile;
        boolean z4;
        boolean z5;
        DexFile dexFile2;
        Object obj;
        File m11364;
        String str7;
        boolean z6;
        String str8;
        String str9;
        String str10;
        String str11;
        String str12;
        File file2;
        String str13;
        String str14;
        boolean z7;
        boolean z8;
        String str15;
        String m11438;
        boolean z9;
        String str16;
        String str17;
        String[] strArr;
        File file3;
        String str18;
        String str19;
        boolean z10;
        boolean z11;
        boolean z12;
        boolean z13;
        String str20;
        File[] listFiles;
        File file4;
        String str21;
        String sb;
        String str22;
        File file5;
        String str23;
        m11508("chmod", "777", str);
        m11508("chown", "0:0", str);
        String str24 = "0.0";
        m11508("chown", "0.0", str);
        String m11381 = str4 == null ? m11381(str2, str3) : str4;
        String name = new File(str2).getName();
        String m113812 = m11381(str2, str3);
        File m113642 = m11364(str2);
        String name2 = new File(str2).getName();
        String m11587 = m11587(name2, "odex");
        m11587(name2, "dex");
        String str25 = str + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587;
        File file6 = new File(str + "/AndroidManifest.xml");
        ArrayList arrayList2 = new ArrayList();
        Iterator<File> it = arrayList.iterator();
        while (true) {
            str5 = str24;
            if (!it.hasNext()) {
                break;
            }
            it.next();
            arrayList2.add(null);
            str24 = str5;
        }
        Iterator<File> it2 = arrayList.iterator();
        while (true) {
            str6 = "";
            if (!it2.hasNext()) {
                break;
            }
            String str26 = m11381;
            File next = it2.next();
            String str27 = str25;
            String replaceAll = next.getName().toLowerCase().replaceAll("classes", "").replaceAll(".dex", "");
            if (replaceAll.equals("")) {
                arrayList2.set(0, next);
            } else {
                try {
                    arrayList2.set(new Integer(replaceAll).intValue() - 1, next);
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
            m11381 = str26;
            str25 = str27;
        }
        String str28 = str25;
        String str29 = m11381;
        arrayList.clear();
        Iterator it3 = arrayList2.iterator();
        while (it3.hasNext()) {
            arrayList.add((File) it3.next());
        }
        try {
            z3 = m11351().contains("ART");
            try {
                Iterator<File> it4 = arrayList.iterator();
                while (it4.hasNext()) {
                    try {
                        File next2 = it4.next();
                        Iterator<File> it5 = it4;
                        String str30 = str6;
                        m11508("chmod", "777", str + InternalZipConstants.ZIP_FILE_SEPARATOR + next2.getName());
                        if (!next2.exists()) {
                            return 4;
                        }
                        m11508("chmod", "777", str + InternalZipConstants.ZIP_FILE_SEPARATOR + next2.getName());
                        m11508("chown", "1000." + str3, str + InternalZipConstants.ZIP_FILE_SEPARATOR + next2.getName());
                        it4 = it5;
                        str6 = str30;
                    } catch (Exception e) {
                        e = e;
                        exc = e;
                        z2 = false;
                        z5 = true;
                        z4 = false;
                        dexFile2 = null;
                        exc.printStackTrace();
                        dexFile = dexFile2;
                        if (dexFile != null) {
                        }
                        if (z5) {
                        }
                    }
                }
                obj = str6;
                m11508("chmod", "777", str + "/AndroidManifest.xml");
                m11508("chown", "1000." + str3, str + "/AndroidManifest.xml");
                StringBuilder sb2 = new StringBuilder();
                sb2.append(str);
                sb2.append(InternalZipConstants.ZIP_FILE_SEPARATOR);
                sb2.append(name);
                new File(sb2.toString()).delete();
                if (new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + name).exists()) {
                    m11508("rm", str + InternalZipConstants.ZIP_FILE_SEPARATOR + name);
                }
                m11364 = m11364(str2);
                m11364.getName();
            } catch (Exception e2) {
                e = e2;
            }
        } catch (Exception e3) {
            exc = e3;
            z2 = false;
            z3 = false;
        }
        try {
        } catch (Exception e4) {
            exc = e4;
            z3 = z6;
            z2 = false;
            z5 = true;
            z4 = false;
            dexFile2 = null;
            exc.printStackTrace();
            dexFile = dexFile2;
            if (dexFile != null) {
            }
            if (z5) {
            }
        }
        if (z3) {
            C3348.m12347("dex-opt-art");
            z6 = z3;
            String m11576 = m11576(name, str, arrayList, file6, str2);
            if (!m11576.equals(obj) && new File(m11576).exists()) {
                StringBuilder sb3 = new StringBuilder();
                str16 = "1000:";
                sb3.append("apk found and copy created apk size ");
                str9 = "chown";
                str10 = "art";
                sb3.append(new File(m11576).length());
                C3348.m12347(sb3.toString());
                String str31 = !m11364.getAbsolutePath().contains("/arm/") ? "arm" : obj;
                if (m11364.getAbsolutePath().contains("/arm64/")) {
                    str31 = "arm64";
                }
                if (m11364.getAbsolutePath().contains("/x86/")) {
                    str31 = "x86";
                }
                if (m11364.getAbsolutePath().contains("/x86_64/")) {
                    str31 = "x86_64";
                }
                if (C3348.f9924 < 28) {
                    if (file != null) {
                        m11364 = file;
                    }
                    if (str31.equals(obj)) {
                        str31 = m11379(m11364, "--instruction-set");
                    }
                    C3348.m12347("classpath parametr:" + m11379(m11364, "classpath"));
                    String m11378 = m11378(m11364, "--class-loader-context");
                    C3348.m12347("class-loader_contex:" + m11378);
                    if (m11378.equals(obj)) {
                        str23 = z != 0 ? "--class-loader-context=PCL[]" : "--class-loader-context=PCL[/system/framework/org.apache.http.legacy.boot.jar]";
                    } else {
                        str23 = "--class-loader-context=" + m11378;
                    }
                    StringBuilder sb4 = new StringBuilder();
                    sb4.append("--oat-file=");
                    str17 = str28;
                    sb4.append(str17);
                    strArr = new String[]{"dex2oat", "--dex-file=" + m11576, sb4.toString(), str23, "--instruction-set=" + str31};
                } else {
                    str17 = str28;
                    strArr = new String[]{"dex2oat", "--dex-file=" + m11576, "--oat-file=" + str17, "--instruction-set=" + str31};
                }
                new File(str17).delete();
                if (new File(str17).exists()) {
                    try {
                        m11508("rm", str17);
                    } catch (Exception e5) {
                        Exception exc2 = e5;
                        z = strArr;
                        exc2.printStackTrace();
                        file3 = new File(str17);
                        if (file3.exists()) {
                        }
                        if (!new File(file3.getAbsolutePath()).exists()) {
                        }
                        z2 = false;
                        z10 = true;
                        z11 = true;
                        m11508("chmod", "777", "/data/tmp");
                        listFiles = new File("/data/tmp").listFiles();
                        if (listFiles != null) {
                        }
                        z13 = z2;
                        str20 = str18;
                        z12 = z10;
                        z2 = z13;
                        str15 = str20;
                        str13 = str19;
                        str12 = name;
                        dexFile = null;
                        z4 = z11;
                        z5 = z12;
                        if (m11462(str2)) {
                        }
                        new File(str7 + str11 + m113642.getName()).delete();
                        new File(str7 + str11 + m113642.getName()).delete();
                        new File(str7 + str11 + str12).delete();
                        if (new File(str7 + str11 + str12).exists()) {
                        }
                        z2 = z9;
                        z3 = z6;
                        if (dexFile != null) {
                        }
                        if (z5) {
                        }
                    }
                }
                C3348.m12347("try create oat with dex2oat:");
                C3348.m12347("rebuild_apk:" + m11576);
                C3348.m12347("oatFile:" + str17);
                C3348.m12347("instructions:" + str31);
                C3348.m12347(m11438(strArr));
                C3348.m12347("end");
                if (!new File(str17).exists() && new File(str17).length() != 0) {
                    StringBuilder sb5 = new StringBuilder();
                    sb5.append("oat created with dex2oat - length=");
                    z = strArr;
                    sb5.append(new File(str17).length());
                    C3348.m12347(sb5.toString());
                    m11322(new File(str17), arrayList, str2, m11576, false);
                } else {
                    String[] strArr2 = strArr;
                    new File(str17).delete();
                    z = strArr2;
                    if (new File(str17).exists()) {
                        m11508("rm", str17);
                        z = strArr2;
                    }
                }
                file3 = new File(str17);
                if (file3.exists() && file3.length() == 0) {
                    file3.delete();
                }
                if (!new File(file3.getAbsolutePath()).exists()) {
                    C3348.m12347("oat file found. try copy and permission apply.");
                    str18 = str29;
                    String m115872 = m11587(str18, "vdex");
                    str8 = "vdex";
                    String str32 = str10;
                    String m115873 = m11587(str18, str32);
                    if (new File(m115873).exists()) {
                        C3348.m12347("generated " + new File(m115873) + " found");
                    }
                    if (new File(m115872).exists()) {
                        C3348.m12347("generated " + new File(m115872) + " found");
                    }
                    String absolutePath = (str18.startsWith("/mnt/asec/") && m113642.exists()) ? m113642.getAbsolutePath() : str18;
                    new File(absolutePath).delete();
                    if (new File(absolutePath).exists()) {
                        str21 = m11576;
                        m11508("rm", absolutePath);
                    } else {
                        str21 = m11576;
                    }
                    if (new File(m11587(absolutePath, str32)).exists()) {
                        m11508("chmod", "777", m11587(absolutePath, str32));
                        new File(m11587(absolutePath, str32)).delete();
                    }
                    C3348.m12347("try copy to:" + absolutePath);
                    str10 = str32;
                    if (m11306(C3348.f9875, file3.getAbsolutePath(), absolutePath, true, true)) {
                        C3348.m12347("Free space for odex enougth.");
                        C3348.m12347("odex is (" + absolutePath + ") enougth.");
                        try {
                            if (str18.startsWith("/mnt/asec/") && m113642.exists()) {
                                m11508("chmod", "0644", absolutePath);
                                m11508(str9, "1000." + str3, absolutePath);
                                StringBuilder sb6 = new StringBuilder();
                                str19 = str16;
                                sb6.append(str19);
                                sb6.append(str3);
                                m11508(str9, sb6.toString(), absolutePath);
                                m11508("chmod", "0644", m115872);
                                m11508(str9, "1000." + str3, m115872);
                                m11508(str9, str19 + str3, m115872);
                                m11508("chmod", "0644", m115873);
                                m11508(str9, "1000." + str3, m115873);
                                m11508(str9, str19 + str3, m115873);
                                z2 = false;
                            } else {
                                str19 = str16;
                                z2 = true;
                            }
                        } catch (Exception e6) {
                            exc = e6;
                            z3 = z6;
                            z2 = true;
                        }
                        try {
                            if ((C3348.f9924 >= 23 && !m113642.exists()) || m113642.getAbsolutePath().equals(absolutePath)) {
                                str7 = str;
                                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                            } else if (m11306(C3348.f9875, str17, m113642.getAbsolutePath(), true, true)) {
                                m113642.getAbsolutePath();
                                if (new File(absolutePath + ".art").exists()) {
                                    new File(absolutePath + ".art").delete();
                                }
                                if (m11462(str2)) {
                                    m11508("chmod", "0644", absolutePath);
                                    m11508(str9, str5, absolutePath);
                                    m11508(str9, "0:0", absolutePath);
                                    m11508("chmod", "0644", m115872);
                                    m11508(str9, str5, m115872);
                                    m11508(str9, "0:0", m115872);
                                    m11508("chmod", "0644", m115873);
                                    m11508(str9, str5, m115873);
                                    m11508(str9, "0:0", m115873);
                                } else {
                                    m11508("chmod", "0644", absolutePath);
                                    m11508(str9, "1000." + str3, absolutePath);
                                    m11508(str9, str19 + str3, absolutePath);
                                    m11508("chmod", "0644", m115872);
                                    m11508(str9, "1000." + str3, m115872);
                                    m11508(str9, str19 + str3, m115872);
                                    m11508("chmod", "0644", m115873);
                                    m11508(str9, "1000." + str3, m115873);
                                    m11508(str9, str19 + str3, m115873);
                                }
                                str7 = str;
                                str18 = m11381(str2, str3);
                                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                                z2 = true;
                            } else {
                                new File(m113812).delete();
                                if (new File(m113812).exists()) {
                                    m11508("rm", m113812);
                                }
                                boolean startsWith = m113812.startsWith("/mnt/asec");
                                str7 = str;
                                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                            }
                            z10 = true;
                            z11 = false;
                        } catch (Exception e7) {
                            exc = e7;
                            z3 = z6;
                            z5 = true;
                            z4 = false;
                            dexFile2 = null;
                            exc.printStackTrace();
                            dexFile = dexFile2;
                            if (dexFile != null) {
                            }
                            if (z5) {
                            }
                        }
                    } else {
                        str19 = str16;
                        C3348.m12347("Error:Free space for odex not enougth.");
                        if (file3.exists()) {
                            file3.delete();
                        }
                        if (file3.exists()) {
                            m11508("rm", file3.getAbsolutePath());
                        }
                        new File(m113812).delete();
                        if (new File(m113812).exists()) {
                            m11508("rm", m113812);
                        }
                        if (new File(m11381(str2, str3)).exists()) {
                            C3348.m12347("Error:dont delete corrupt odex.");
                        }
                        String absolutePath2 = m113642.getAbsolutePath();
                        String str33 = str21;
                        if (!str33.equals(obj) && new File(str33).exists()) {
                            C3348.m12347("apk found and copy created apk2");
                            C3348.m12347("try create oat with DexFile2:");
                            StringBuilder sb7 = new StringBuilder();
                            str7 = str;
                            sb7.append(str7);
                            str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                            sb7.append(str11);
                            sb7.append(m113642.getName());
                            sb = sb7.toString();
                            new File(sb).delete();
                            if (new File(sb).exists()) {
                                m11508("rm", sb);
                            }
                            C3348.m12347("try create oat with dex2oat:");
                            C3348.m12347(m11438(z));
                            C3348.m12347("end");
                            if (new File(sb).exists()) {
                                str22 = absolutePath2;
                            } else {
                                C3348.m12347("oat2 created with dex2oat - length=" + new File(sb).length());
                                str22 = absolutePath2;
                                m11322(new File(sb), arrayList, str2, str33, false);
                            }
                            file5 = new File(sb);
                            if (file5.exists() && file5.length() == 0) {
                                file5.delete();
                            }
                            if (new File(file5.getAbsolutePath()).exists()) {
                                str18 = str22;
                            } else {
                                C3348.m12347("oat file found. try copy and permission apply.");
                                if (m11306(C3348.f9875, sb, m113642.getAbsolutePath(), true, true)) {
                                    str18 = m113642.getAbsolutePath();
                                    z2 = false;
                                    z10 = true;
                                    z11 = false;
                                } else {
                                    new File(m113812).delete();
                                    if (new File(m113812).exists()) {
                                        m11508("rm", m113812);
                                    }
                                    str18 = str22;
                                    z2 = false;
                                    z10 = false;
                                    z11 = false;
                                }
                            }
                        }
                        C3348.m12347("Error: dont create rebuild apk to /data/tmp/");
                        C3348.m12347("try create oat with DexFile2:");
                        StringBuilder sb72 = new StringBuilder();
                        str7 = str;
                        sb72.append(str7);
                        str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                        sb72.append(str11);
                        sb72.append(m113642.getName());
                        sb = sb72.toString();
                        new File(sb).delete();
                        if (new File(sb).exists()) {
                        }
                        C3348.m12347("try create oat with dex2oat:");
                        C3348.m12347(m11438(z));
                        C3348.m12347("end");
                        if (new File(sb).exists()) {
                        }
                        file5 = new File(sb);
                        if (file5.exists()) {
                            file5.delete();
                        }
                        if (new File(file5.getAbsolutePath()).exists()) {
                        }
                    }
                    m11508("chmod", "777", "/data/tmp");
                    listFiles = new File("/data/tmp").listFiles();
                    if (listFiles != null) {
                        int length = listFiles.length;
                        int i = 0;
                        while (i < length) {
                            z13 = z2;
                            try {
                                file4 = listFiles[i];
                                str20 = str18;
                            } catch (Exception e8) {
                                e = e8;
                                str20 = str18;
                                z12 = z10;
                                try {
                                    e.printStackTrace();
                                    z2 = z13;
                                    str15 = str20;
                                    str13 = str19;
                                    str12 = name;
                                    dexFile = null;
                                    z4 = z11;
                                    z5 = z12;
                                    if (m11462(str2)) {
                                    }
                                    new File(str7 + str11 + m113642.getName()).delete();
                                    new File(str7 + str11 + m113642.getName()).delete();
                                    new File(str7 + str11 + str12).delete();
                                    if (new File(str7 + str11 + str12).exists()) {
                                    }
                                    z2 = z9;
                                    z3 = z6;
                                } catch (Exception e9) {
                                    e = e9;
                                    z2 = z13;
                                    exc = e;
                                    z4 = z11;
                                    z3 = z6;
                                    dexFile2 = null;
                                    z5 = z12;
                                    exc.printStackTrace();
                                    dexFile = dexFile2;
                                    if (dexFile != null) {
                                    }
                                    if (z5) {
                                    }
                                }
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            }
                            try {
                                z12 = z10;
                            } catch (Exception e10) {
                                e = e10;
                                z12 = z10;
                                e.printStackTrace();
                                z2 = z13;
                                str15 = str20;
                                str13 = str19;
                                str12 = name;
                                dexFile = null;
                                z4 = z11;
                                z5 = z12;
                                if (m11462(str2)) {
                                }
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + str12).delete();
                                if (new File(str7 + str11 + str12).exists()) {
                                }
                                z2 = z9;
                                z3 = z6;
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            }
                            try {
                                C2880 c2880 = new C2880("1");
                                file4.delete();
                                if (file4.exists()) {
                                    c2880.m11605(file4);
                                }
                                i++;
                                z2 = z13;
                                str18 = str20;
                                z10 = z12;
                            } catch (Exception e11) {
                                e = e11;
                                e.printStackTrace();
                                z2 = z13;
                                str15 = str20;
                                str13 = str19;
                                str12 = name;
                                dexFile = null;
                                z4 = z11;
                                z5 = z12;
                                if (m11462(str2)) {
                                }
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + str12).delete();
                                if (new File(str7 + str11 + str12).exists()) {
                                }
                                z2 = z9;
                                z3 = z6;
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            }
                        }
                    }
                    z13 = z2;
                    str20 = str18;
                    z12 = z10;
                    z2 = z13;
                    str15 = str20;
                    str13 = str19;
                    str12 = name;
                    dexFile = null;
                    z4 = z11;
                    z5 = z12;
                    if (m11462(str2)) {
                        try {
                            m11508("chmod", "0644", str15);
                            m11508(str9, str5, str15);
                            m11508(str9, "0:0", str15);
                            String str34 = str8;
                            m11508("chmod", "0644", m11587(str15, str34));
                            m11508(str9, str5, m11587(str15, str34));
                            m11508(str9, "0:0", m11587(str15, str34));
                            String str35 = str10;
                            m11508("chmod", "0644", m11587(str15, str35));
                            m11508(str9, str5, m11587(str15, str35));
                            m11508(str9, "0:0", m11587(str15, str35));
                            z9 = z2;
                        } catch (Exception e12) {
                            e = e12;
                            exc = e;
                            dexFile2 = dexFile;
                            z3 = z6;
                            exc.printStackTrace();
                            dexFile = dexFile2;
                            if (dexFile != null) {
                            }
                            if (z5) {
                            }
                        }
                    } else {
                        String str36 = str8;
                        String str37 = str10;
                        m11508("chmod", "0644", str15);
                        m11508(str9, "1000." + str3, str15);
                        String[] strArr3 = new String[3];
                        strArr3[0] = str9;
                        StringBuilder sb8 = new StringBuilder();
                        z9 = z2;
                        String str38 = str13;
                        try {
                            sb8.append(str38);
                            sb8.append(str3);
                            strArr3[1] = sb8.toString();
                            strArr3[2] = str15;
                            m11508(strArr3);
                            m11508("chmod", "0644", m11587(str15, str36));
                            m11508(str9, "1000." + str3, m11587(str15, str36));
                            m11508(str9, str38 + str3, m11587(str15, str36));
                            m11508("chmod", "0644", m11587(str15, str37));
                            m11508(str9, "1000." + str3, m11587(str15, str37));
                            m11508(str9, str38 + str3, m11587(str15, str37));
                        } catch (Exception e13) {
                            e = e13;
                            z2 = z9;
                            exc = e;
                            dexFile2 = dexFile;
                            z3 = z6;
                            exc.printStackTrace();
                            dexFile = dexFile2;
                            if (dexFile != null) {
                            }
                            if (z5) {
                            }
                        }
                    }
                    new File(str7 + str11 + m113642.getName()).delete();
                    new File(str7 + str11 + m113642.getName()).delete();
                    new File(str7 + str11 + str12).delete();
                    if (new File(str7 + str11 + str12).exists()) {
                        m11508("rm", str7 + str11 + str12);
                    }
                    z2 = z9;
                    z3 = z6;
                    if (dexFile != null) {
                        try {
                            dexFile.close();
                        } catch (IOException e14) {
                            e14.printStackTrace();
                        }
                    }
                    if (z5) {
                        return 3;
                    }
                    if (z3 && z4) {
                        return 2;
                    }
                    if (!z3 || z2) {
                        return ((z3 && z2) || z3 || z2) ? 0 : 1;
                    }
                    return 1;
                }
                str7 = str;
                str8 = "vdex";
                str18 = str29;
                str19 = str16;
                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                z2 = false;
                z10 = true;
                z11 = true;
                m11508("chmod", "777", "/data/tmp");
                listFiles = new File("/data/tmp").listFiles();
                if (listFiles != null) {
                }
                z13 = z2;
                str20 = str18;
                z12 = z10;
                z2 = z13;
                str15 = str20;
                str13 = str19;
                str12 = name;
                dexFile = null;
                z4 = z11;
                z5 = z12;
                if (m11462(str2)) {
                }
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + str12).delete();
                if (new File(str7 + str11 + str12).exists()) {
                }
                z2 = z9;
                z3 = z6;
                if (dexFile != null) {
                }
                if (z5) {
                }
            }
            str9 = "chown";
            str10 = "art";
            str16 = "1000:";
            C3348.m12347("Error: dont create rebuild apk to /data/tmp/");
            if (!m11364.getAbsolutePath().contains("/arm/")) {
            }
            if (m11364.getAbsolutePath().contains("/arm64/")) {
            }
            if (m11364.getAbsolutePath().contains("/x86/")) {
            }
            if (m11364.getAbsolutePath().contains("/x86_64/")) {
            }
            if (C3348.f9924 < 28) {
            }
            new File(str17).delete();
            if (new File(str17).exists()) {
            }
            C3348.m12347("try create oat with dex2oat:");
            C3348.m12347("rebuild_apk:" + m11576);
            C3348.m12347("oatFile:" + str17);
            C3348.m12347("instructions:" + str31);
            C3348.m12347(m11438(strArr));
            C3348.m12347("end");
            if (!new File(str17).exists()) {
            }
            String[] strArr22 = strArr;
            new File(str17).delete();
            z = strArr22;
            if (new File(str17).exists()) {
            }
            file3 = new File(str17);
            if (file3.exists()) {
                file3.delete();
            }
            if (!new File(file3.getAbsolutePath()).exists()) {
            }
            z2 = false;
            z10 = true;
            z11 = true;
            m11508("chmod", "777", "/data/tmp");
            listFiles = new File("/data/tmp").listFiles();
            if (listFiles != null) {
            }
            z13 = z2;
            str20 = str18;
            z12 = z10;
            z2 = z13;
            str15 = str20;
            str13 = str19;
            str12 = name;
            dexFile = null;
            z4 = z11;
            z5 = z12;
            if (m11462(str2)) {
            }
            new File(str7 + str11 + m113642.getName()).delete();
            new File(str7 + str11 + m113642.getName()).delete();
            new File(str7 + str11 + str12).delete();
            if (new File(str7 + str11 + str12).exists()) {
            }
            z2 = z9;
            z3 = z6;
            if (dexFile != null) {
            }
            if (z5) {
            }
        } else {
            str7 = str;
            z6 = z3;
            str8 = "vdex";
            str9 = "chown";
            str10 = "art";
            String str39 = str29;
            str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
            StringBuilder sb9 = new StringBuilder();
            sb9.append(str7);
            sb9.append(str11);
            str12 = name;
            sb9.append(str12);
            m11575(str12, str7, arrayList, sb9.toString());
            m11508("chmod", "777", str7 + str11 + str12);
            m11508(str9, "1000." + str3, str7 + str11 + str12);
            m11508(str9, "1000:" + str3, str7 + str11 + str12);
            if (new File(str7 + str11 + str12).exists()) {
                if (new File(str7 + str11 + str12).length() != 0) {
                    C3348.m12347("LuckyPatcher (CustomPatch): foundreworked apk " + str7 + str11 + str12);
                }
            }
            if (new File(str7 + str11 + str12).exists()) {
                if (new File(str7 + str11 + str12).length() == 0) {
                    new File(str7 + str11 + str12).delete();
                }
            }
            try {
                new File(str7 + str11 + m113642.getName()).delete();
                dexFile = DexFile.loadDex(str7 + str11 + str12, str7 + str11 + m113642.getName(), 0);
            } catch (RuntimeException e15) {
                e15.printStackTrace();
                dexFile = null;
                String name3 = m113642.getName();
                C3348.m12347(name3);
                C3348.m12347(str7 + str11 + name3);
                file2 = new File(str7 + str11 + name3);
                if (file2.exists()) {
                    file2.delete();
                }
                str13 = "1000:";
                if (new File(file2.getAbsolutePath()).exists()) {
                }
                str14 = str39;
                z7 = false;
                if (z7) {
                }
                z8 = z7;
                z2 = z8;
                str15 = str14;
                z5 = true;
                z4 = false;
                if (m11462(str2)) {
                }
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + str12).delete();
                if (new File(str7 + str11 + str12).exists()) {
                }
                z2 = z9;
                z3 = z6;
                if (dexFile != null) {
                }
                if (z5) {
                }
            } catch (Exception e16) {
                e16.printStackTrace();
                dexFile = null;
                String name32 = m113642.getName();
                C3348.m12347(name32);
                C3348.m12347(str7 + str11 + name32);
                file2 = new File(str7 + str11 + name32);
                if (file2.exists()) {
                }
                str13 = "1000:";
                if (new File(file2.getAbsolutePath()).exists()) {
                }
                str14 = str39;
                z7 = false;
                if (z7) {
                }
                z8 = z7;
                z2 = z8;
                str15 = str14;
                z5 = true;
                z4 = false;
                if (m11462(str2)) {
                }
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + m113642.getName()).delete();
                new File(str7 + str11 + str12).delete();
                if (new File(str7 + str11 + str12).exists()) {
                }
                z2 = z9;
                z3 = z6;
                if (dexFile != null) {
                }
                if (z5) {
                }
            }
            String name322 = m113642.getName();
            C3348.m12347(name322);
            C3348.m12347(str7 + str11 + name322);
            file2 = new File(str7 + str11 + name322);
            if (file2.exists() && file2.length() == 0) {
                file2.delete();
            }
            str13 = "1000:";
            if (new File(file2.getAbsolutePath()).exists()) {
                m11325(file2, str2);
                if (m11306(C3348.f9875, str7 + str11 + name322, str39, true, true)) {
                    C3348.m12347("Free space for odex enougth.");
                    str14 = str39;
                    z7 = true;
                    if (z7 && !z6) {
                        try {
                        } catch (Exception e17) {
                            e = e17;
                            z8 = z7;
                        }
                        if (!new File(m113812).exists()) {
                            C3348.m12347("lackypatch: dexopt-wrapper used!");
                            m11508(str9, str5, str7 + "/dexopt-wrapper");
                            m11508(str9, "0:0", str7 + "/dexopt-wrapper");
                            m11508("chmod", "777", str7 + "/dexopt-wrapper");
                            String[] strArr4 = new String[3];
                            StringBuilder sb10 = new StringBuilder();
                            z8 = z7;
                            try {
                                sb10.append(C3348.f9875);
                                sb10.append("/dexopt-wrapper");
                                strArr4[0] = sb10.toString();
                                strArr4[1] = str7 + str11 + str12;
                                strArr4[2] = m113812;
                                m11438 = m11438(strArr4);
                                C3348.m12347(m11438);
                            } catch (Exception e18) {
                                e = e18;
                                z2 = z8;
                                exc = e;
                                dexFile2 = dexFile;
                                z3 = z6;
                                z5 = true;
                                z4 = false;
                                exc.printStackTrace();
                                dexFile = dexFile2;
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            }
                            if (m11438.contains("succes") && !m11438.contains("failed")) {
                                m11325(new File(m113812), str2);
                                z2 = z8;
                                str15 = str14;
                                z5 = true;
                                z4 = false;
                                if (m11462(str2)) {
                                }
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + str12).delete();
                                if (new File(str7 + str11 + str12).exists()) {
                                }
                                z2 = z9;
                                z3 = z6;
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            } else {
                                new File(m113812).delete();
                                m11508("rm", m113812);
                                str15 = m113642.getAbsolutePath();
                                if (new File(m113812).exists()) {
                                    m11508("rm", str15);
                                }
                                m11508("rm", str7 + str11 + name322);
                                m11438(C3348.f9875 + "/dexopt-wrapper", str7 + str11 + str12, str7 + str11 + name322);
                                StringBuilder sb11 = new StringBuilder();
                                sb11.append(str7);
                                sb11.append(str11);
                                sb11.append(name322);
                                m11508("chmod", "777", sb11.toString());
                                StringBuilder sb12 = new StringBuilder();
                                sb12.append(str7);
                                sb12.append(str11);
                                sb12.append(name322);
                                m11508(str9, str5, sb12.toString());
                                m11508(str9, "0:0", str7 + str11 + name322);
                                m11325(new File(str7 + str11 + name322), str2);
                                m11294(str7 + str11 + name322, str15, false, true);
                                z2 = z8;
                                z5 = true;
                                z4 = false;
                                if (m11462(str2)) {
                                }
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + m113642.getName()).delete();
                                new File(str7 + str11 + str12).delete();
                                if (new File(str7 + str11 + str12).exists()) {
                                }
                                z2 = z9;
                                z3 = z6;
                                if (dexFile != null) {
                                }
                                if (z5) {
                                }
                            }
                        }
                    }
                    z8 = z7;
                    z2 = z8;
                    str15 = str14;
                    z5 = true;
                    z4 = false;
                    if (m11462(str2)) {
                    }
                    new File(str7 + str11 + m113642.getName()).delete();
                    new File(str7 + str11 + m113642.getName()).delete();
                    new File(str7 + str11 + str12).delete();
                    if (new File(str7 + str11 + str12).exists()) {
                    }
                    z2 = z9;
                    z3 = z6;
                    if (dexFile != null) {
                    }
                    if (z5) {
                    }
                } else {
                    new File(m113812).delete();
                    if (new File(m113812).exists()) {
                        m11508("rm", m113812);
                    }
                    str14 = str39;
                    if (m11306(C3348.f9875, str7 + str11 + name322, m113642.getAbsolutePath(), true, true)) {
                        str39 = m113642.getAbsolutePath();
                    } else {
                        new File(m113812).delete();
                        if (new File(m113812).exists()) {
                            m11508("rm", m113812);
                        }
                        z7 = false;
                        if (z7) {
                            if (!new File(m113812).exists()) {
                            }
                        }
                        z8 = z7;
                        z2 = z8;
                        str15 = str14;
                        z5 = true;
                        z4 = false;
                        if (m11462(str2)) {
                        }
                        new File(str7 + str11 + m113642.getName()).delete();
                        new File(str7 + str11 + m113642.getName()).delete();
                        new File(str7 + str11 + str12).delete();
                        if (new File(str7 + str11 + str12).exists()) {
                        }
                        z2 = z9;
                        z3 = z6;
                        if (dexFile != null) {
                        }
                        if (z5) {
                        }
                    }
                }
            }
            str14 = str39;
            z7 = false;
            if (z7) {
            }
            z8 = z7;
            z2 = z8;
            str15 = str14;
            z5 = true;
            z4 = false;
            if (m11462(str2)) {
            }
            new File(str7 + str11 + m113642.getName()).delete();
            new File(str7 + str11 + m113642.getName()).delete();
            new File(str7 + str11 + str12).delete();
            if (new File(str7 + str11 + str12).exists()) {
            }
            z2 = z9;
            z3 = z6;
            if (dexFile != null) {
            }
            if (z5) {
            }
        }
    }

    public static boolean m11306(String str, String str2, String str3, boolean z, boolean z2) {
        File file = new File(str2);
        String m11587 = m11587(str2, "vdex");
        String m115872 = m11587(str3, "vdex");
        File file2 = new File(m11587);
        File file3 = new File(m115872);
        String m115873 = m11587(str2, "art");
        String m115874 = m11587(str3, "art");
        File file4 = new File(m115873);
        new File(m115874);
        File file5 = new File(str3);
        int i = 0;
        if (file.exists()) {
            m11492(str3, "RW");
            if (z && file2.exists()) {
                m11438("dd", "if=" + m11587, "of=" + m115872);
                String[] strArr = C3348.f9920;
                if (strArr != null) {
                    for (int length = strArr.length; i < length; length = length) {
                        String str4 = strArr[i];
                        String[] strArr2 = strArr;
                        if (new File(m115872).exists() && file2.length() == file3.length()) {
                            break;
                        }
                        m11438(str4, "dd", "if=" + m11587, "of=" + m115872);
                        i++;
                        strArr = strArr2;
                    }
                }
            }
            if (z2 && file4.exists()) {
                m11438("dd", "if=" + m115873, "of=" + m115874);
                String[] strArr3 = C3348.f9920;
                if (strArr3 != null) {
                    int length2 = strArr3.length;
                    int i2 = 0;
                    while (i2 < length2) {
                        String str5 = strArr3[i2];
                        if (new File(m115872).exists() && file2.length() == file3.length()) {
                            break;
                        }
                        m11438(str5, "dd", "if=" + m115873, "of=" + m115874);
                        i2++;
                        strArr3 = strArr3;
                    }
                }
            }
            m11438("dd", "if=" + str2, "of=" + str3);
            String[] strArr4 = C3348.f9920;
            if (strArr4 != null) {
                for (String str6 : strArr4) {
                    if (new File(m115872).exists() && file2.length() == file3.length()) {
                        break;
                    }
                    m11438(str6, "dd", "if=" + str2, "of=" + str3);
                }
            }
            if (file.length() != file5.length() && file.length() != 0) {
                file5.delete();
                C3348.m12347("Length of Files not equals. Destination deleted!");
                return false;
            }
            if (z && file2.exists()) {
                if (file2.length() != file3.length() && file2.length() != 0) {
                    file3.delete();
                    C3348.m12347("Length of Files not equals. Destination deleted!");
                    return false;
                }
                C3348.m12347(Long.valueOf(file3.length()));
                C3348.m12347("File copied!");
                return true;
            }
            C3348.m12347(Long.valueOf(file5.length()));
            C3348.m12347("File copied!");
            return true;
        }
        C3348.m12347("Source File not Found!");
        return false;
    }

    public static int m11307(String str, String str2, String str3, String str4, Boolean bool, boolean z) {
        String str5;
        boolean z2;
        boolean z3;
        int i;
        File[] listFiles;
        String str6;
        String str7;
        String str8;
        int i2;
        File file;
        String str9;
        String m11379;
        StringBuilder sb;
        String str10;
        String[] strArr;
        C3348.m12347(str2);
        new File(str2).mkdirs();
        m11508("chmod", "777", str);
        m11508("chmod", "777", m11357(new File(str2)).getAbsolutePath());
        m11508("chown", "0:0", m11357(new File(str2)).getAbsolutePath());
        m11508("chown", "0.0", m11357(new File(str2)).getAbsolutePath());
        m11508("chmod", "777", str2);
        m11508("chown", "0:0", str2);
        m11508("chown", "0.0", str2);
        if (str3 == null) {
            str5 = m11381(str, str4);
        } else {
            str5 = str3;
        }
        if (str5 != null) {
            m11492(str5, InternalZipConstants.WRITE_MODE);
        }
        String m11381 = m11381(str, str4);
        String name = new File(str).getName();
        m11587(name, "odex");
        String str11 = str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587(name, "dex");
        try {
            File m11364 = m11364(str);
            m11364.getName();
            C3348.m12347("dex-opt-art");
            if (new File(str11).exists()) {
                try {
                    new File(str11).delete();
                } catch (Exception e) {
                    e = e;
                    z2 = false;
                    e.printStackTrace();
                    z3 = z2;
                    i = 4;
                    if (new File(str11).exists()) {
                    }
                    listFiles = new File(str2).listFiles();
                    if (listFiles != null) {
                    }
                    if (new File(str2).exists()) {
                    }
                    m11508("chmod", "644", str);
                    if (z3) {
                    }
                }
            }
            try {
            } catch (Exception e2) {
                e = e2;
                str6 = "chown";
                str7 = "0:0";
                str8 = "0.0";
            }
            try {
                if (!bool.booleanValue()) {
                    str6 = "chown";
                    str7 = "0:0";
                    str8 = "0.0";
                    C3348.m12347("try create oat with DexFile.");
                    try {
                        new File(str11).delete();
                        DexFile.loadDex(str, str11, 0).close();
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    } catch (UnsatisfiedLinkError unused) {
                        C3348.m12347("withoutFramework");
                    }
                    C3348.m12347("end. check file. ");
                    if (new File(str11).exists()) {
                        C3348.m12347("found file " + str11 + " " + new File(str11).length());
                    }
                    if (new File(str5).exists()) {
                        C3348.m12347("found file " + str5 + " " + new File(str5).length());
                    }
                    if (new File(str11).exists() && new File(str11).length() != 0) {
                        C3348.m12347("odex file create to tmp dir.");
                    }
                    new File(str11).delete();
                    if (new File(str11).exists()) {
                        m11508("rm", str11);
                    }
                    if (!new File(str11).exists() || new File(str11).length() == 0) {
                        new File(str11).delete();
                        if (new File(str11).exists()) {
                            m11508("rm", str11);
                        }
                    }
                } else {
                    if (!m11364.getAbsolutePath().contains("/arm/")) {
                        str9 = "";
                    } else {
                        str9 = "arm";
                    }
                    if (m11364.getAbsolutePath().contains("/arm64/")) {
                        str9 = "arm64";
                    }
                    if (m11364.getAbsolutePath().contains("/x86/")) {
                        str9 = "x86";
                    }
                    if (m11364.getAbsolutePath().contains("/x86_64/")) {
                        str9 = "x86_64";
                    }
                    str7 = "0:0";
                    str8 = "0.0";
                    if (C3348.f9924 < 28) {
                        str6 = "chown";
                        strArr = new String[]{"dex2oat", "--dex-file=" + str, "--oat-file=" + str11, "--instruction-set=" + str9};
                    } else {
                        try {
                            if (str9.equals("")) {
                                str9 = m11379(m11364, "--instruction-set");
                            }
                            m11379 = m11379(m11364, "classpath");
                            sb = new StringBuilder();
                            str6 = "chown";
                        } catch (Exception e4) {
                            e = e4;
                            str6 = "chown";
                        }
                        try {
                            sb.append("classpath parametr:");
                            sb.append(m11379);
                            C3348.m12347(sb.toString());
                            String m11378 = m11378(m11364, "--class-loader-context");
                            C3348.m12347("class-loader_contex:" + m11378);
                            if (!m11378.equals("")) {
                                str10 = "--class-loader-context=" + m11378;
                            } else if (z) {
                                str10 = "--class-loader-context=PCL[]";
                            } else {
                                str10 = "--class-loader-context=PCL[/system/framework/org.apache.http.legacy.boot.jar]";
                            }
                            strArr = new String[]{"dex2oat", "--dex-file=" + str, "--oat-file=" + str11, str10, "--instruction-set=" + str9};
                        } catch (Exception e5) {
                            e = e5;
                            try {
                                e.printStackTrace();
                                i2 = 4;
                                file = new File(str11);
                                C3348.m12347(str11);
                                C3348.m12347(str5);
                                if (file.exists()) {
                                }
                                if (file.exists()) {
                                }
                                i = i2;
                            } catch (Exception e6) {
                                e = e6;
                                z2 = false;
                                e.printStackTrace();
                                z3 = z2;
                                i = 4;
                                if (new File(str11).exists()) {
                                }
                                listFiles = new File(str2).listFiles();
                                if (listFiles != null) {
                                    while (r4 < r3) {
                                    }
                                }
                                if (new File(str2).exists()) {
                                }
                                m11508("chmod", "644", str);
                                if (z3) {
                                }
                            }
                            if (new File(str11).exists()) {
                            }
                            listFiles = new File(str2).listFiles();
                            if (listFiles != null) {
                            }
                            if (new File(str2).exists()) {
                            }
                            m11508("chmod", "644", str);
                            if (z3) {
                            }
                        }
                    }
                    C3348.m12347("try create oat with dex2oat:");
                    C3348.m12347(m11438(strArr));
                    C3348.m12347("end");
                    if (new File(str11).exists() && new File(str11).length() != 0) {
                        C3348.m12347("odex file create to tmp dir.");
                    }
                    new File(str11).delete();
                    if (new File(str11).exists()) {
                        m11508("rm", str11);
                    }
                }
                i2 = 0;
            } catch (Exception e7) {
                e = e7;
                e.printStackTrace();
                i2 = 4;
                file = new File(str11);
                C3348.m12347(str11);
                C3348.m12347(str5);
                if (file.exists()) {
                    file.delete();
                }
                if (file.exists()) {
                }
                i = i2;
                if (new File(str11).exists()) {
                }
                listFiles = new File(str2).listFiles();
                if (listFiles != null) {
                }
                if (new File(str2).exists()) {
                }
                m11508("chmod", "644", str);
                if (z3) {
                }
            }
            file = new File(str11);
            C3348.m12347(str11);
            C3348.m12347(str5);
            if (file.exists() && file.length() == 0) {
                file.delete();
            }
            if (file.exists()) {
                C3348.m12347("oat file found. try copy and permission apply.");
                new File(m11381).delete();
                if (new File(m11381).exists()) {
                    m11508("rm", m11381);
                }
                if (m11306(C3348.f9875, file.getAbsolutePath(), str5, true, true)) {
                    C3348.m12347("Free space for odex enougth.");
                    z2 = true;
                } else {
                    C3348.m12347("Error:Free space for odex not enougth.");
                    if (file.exists()) {
                        file.delete();
                    }
                    if (file.exists()) {
                        m11508("rm", file.getAbsolutePath());
                    }
                    new File(m11381).delete();
                    if (new File(m11381).exists()) {
                        m11508("rm", m11381);
                    }
                    if (new File(m11381(str, str4)).exists()) {
                        C3348.m12347("Error:dont delete corrupt odex.");
                    }
                    z2 = false;
                }
                try {
                    if (m11462(str)) {
                        m11508("chmod", "0644", str5);
                        m11508(str6, str8, str5);
                        m11508(str6, str7, str5);
                    } else {
                        m11508("chmod", "0644", str5);
                        m11508(str6, "1000." + str4, str5);
                        m11508(str6, "1000:" + str4, str5);
                    }
                    z3 = z2;
                } catch (Exception e8) {
                    e = e8;
                    e.printStackTrace();
                    z3 = z2;
                    i = 4;
                    if (new File(str11).exists()) {
                    }
                    listFiles = new File(str2).listFiles();
                    if (listFiles != null) {
                    }
                    if (new File(str2).exists()) {
                    }
                    m11508("chmod", "644", str);
                    if (z3) {
                    }
                }
            } else {
                z3 = false;
            }
            i = i2;
        } catch (Exception e9) {
            e = e9;
        }
        if (new File(str11).exists()) {
            new File(str11).delete();
        }
        listFiles = new File(str2).listFiles();
        if (listFiles != null && listFiles.length > 0) {
            for (File file2 : listFiles) {
                file2.delete();
            }
        }
        if (new File(str2).exists()) {
            new File(str2).delete();
        }
        m11508("chmod", "644", str);
        if (z3) {
            return 1;
        }
        return i;
    }

    public static void m11308() {
        int i;
        File file = new File(C3348.f9875 + "/dexopt-wrapper");
        String str = Build.CPU_ABI;
        if (str.toLowerCase().trim().equals("x86")) {
            i = R.raw.dexoptx86;
        } else if (str.toUpperCase().trim().equals("MIPS")) {
            i = R.raw.dexoptmips;
        } else {
            i = R.raw.dexopt;
        }
        if (file.exists() && file.length() == m11399(i)) {
            m11506("chmod 777 " + C3348.f9875 + "/dexopt-wrapper");
            m11506("chown 0.0 " + C3348.f9875 + "/dexopt-wrapper");
            m11506("chmod 0:0 " + C3348.f9875 + "/dexopt-wrapper");
            return;
        }
        try {
            m11400(i, new File(C3348.f9875 + "/dexopt-wrapper"));
        } catch (Exception unused) {
        }
        try {
            m11384(new File(C3348.f9875 + "/dexopt-wrapper"), 777);
        } catch (Exception e) {
            C3348.m12347(e);
            e.printStackTrace();
        }
        m11506("chmod 777 " + C3348.f9875 + "/dexopt-wrapper");
        m11506("chown 0.0 " + C3348.f9875 + "/dexopt-wrapper");
        m11506("chmod 0:0 " + C3348.f9875 + "/dexopt-wrapper");
    }

    public static void m11309(String str, Runnable runnable, Runnable runnable2) {
        Thread thread = new Thread(new RunnableC2902(str, runnable2, runnable));
        thread.setPriority(10);
        thread.start();
    }

    public static void m11310(ArrayList<C2997> arrayList, Runnable runnable, Runnable runnable2) {
        Thread thread = new Thread(new RunnableC2911(arrayList, runnable2, runnable));
        thread.setPriority(10);
        thread.start();
    }

    public static float m11311(float f) {
        return f / C3348.m12334().getResources().getDisplayMetrics().density;
    }

    public static final void m11312() {
        Intent intent = new Intent(C3348.f9870.mo2480(), C3348.f9870.m2466().getClass());
        intent.setFlags(131072);
        C3348.f9870.mo2480().startActivity(intent);
    }

    public static Bitmap m11313(Drawable drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        int intrinsicWidth = drawable.getIntrinsicWidth();
        int i = 1;
        if (intrinsicWidth <= 0) {
            intrinsicWidth = 1;
        }
        int intrinsicHeight = drawable.getIntrinsicHeight();
        if (intrinsicHeight > 0) {
            i = intrinsicHeight;
        }
        Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, i, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(createBitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return createBitmap;
    }

    public static boolean m11314(boolean z) {
        return C3348.f9924 < 24;
    }

    public static boolean m11315(String str) {
        if (new File(str).exists() && new File(str).canRead()) {
            return true;
        }
        if (C3348.f9908 && !C3348.f9948.booleanValue()) {
            if (new C2880("").m11618(C3348.f9909 + C2003.class.getName() + " '" + str + "'").contains("file found!")) {
                return true;
            }
        }
        return false;
    }

    public static void m11316() {
        boolean booleanValue = C3348.f9948.booleanValue();
        C3348.f9948 = Boolean.FALSE;
        if (booleanValue) {
            System.exit(0);
        }
    }

    public static void m11317() {
        if (!C3348.f9948.booleanValue()) {
            C3348.m12347("LuckyPatcher: exit root.");
            try {
                DataOutputStream dataOutputStream = C3348.f9932;
                if (dataOutputStream != null) {
                    dataOutputStream.writeBytes("exit\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                Process process = C3348.f9930;
                if (process != null) {
                    process.destroy();
                }
                try {
                    DataOutputStream dataOutputStream2 = C3348.f9932;
                    if (dataOutputStream2 != null) {
                        dataOutputStream2.close();
                    }
                } catch (IOException unused) {
                }
                try {
                    DataInputStream dataInputStream = C3348.f9931;
                    if (dataInputStream != null) {
                        dataInputStream.close();
                    }
                } catch (IOException unused2) {
                }
                try {
                    DataInputStream dataInputStream2 = C3348.f9933;
                    if (dataInputStream2 != null) {
                        dataInputStream2.close();
                    }
                } catch (IOException unused3) {
                }
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            C3348.f9930 = null;
            C3348.f9932 = null;
            C3348.f9931 = null;
            C3348.f9933 = null;
        }
        C3348.f9934.release();
    }

    public static Intent m11318() {
        Intent[] intentArr = {new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")), new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")), new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")), new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")), new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")), new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")), new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")), new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")), new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")), new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")), new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity")), new Intent().setComponent(new ComponentName("com.htc.pitroad", "com.htc.pitroad.landingpage.activity.LandingPageActivity")), new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.MainActivity"))};
        for (int i = 0; i < 13; i++) {
            Intent intent = intentArr[i];
            if (C3348.m12337().resolveActivity(intent, 65536) != null) {
                return intent;
            }
        }
        return null;
    }

    private static C3346 m11319(String str) {
        m11590();
        try {
            ArrayList<C3346> m11377 = m11377();
            File file = new File(str);
            Iterator<C3346> it = m11377.iterator();
            while (it.hasNext()) {
                C3346 next = it.next();
                if (next.m12313().equals(file)) {
                    return next;
                }
            }
            ArrayList arrayList = new ArrayList();
            Iterator<C3346> it2 = m11377.iterator();
            while (it2.hasNext()) {
                C3346 next2 = it2.next();
                if (next2 != null && next2.m12313() != null && !next2.m12313().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                    String[] split = next2.m12313().getAbsolutePath().split(InternalZipConstants.ZIP_FILE_SEPARATOR);
                    String[] split2 = str.split(InternalZipConstants.ZIP_FILE_SEPARATOR);
                    if (split2.length >= split.length) {
                        boolean z = false;
                        for (int i = 1; i < split.length; i++) {
                            if (!split2[i].equals(split[i])) {
                                z = true;
                            }
                        }
                        if (!z) {
                            arrayList.add(next2);
                        }
                    }
                }
            }
            Iterator it3 = arrayList.iterator();
            C3346 c3346 = null;
            while (it3.hasNext()) {
                C3346 c33462 = (C3346) it3.next();
                if (c3346 == null) {
                    c3346 = c33462;
                }
                if (c3346.m12313().getAbsolutePath().length() < c33462.m12313().getAbsolutePath().length()) {
                    c3346 = c33462;
                }
            }
            if (c3346 != null) {
                C3348.m12347("recursive mount " + c3346.m12313().getAbsolutePath());
            } else if (f7701) {
                C3348.m12347("magisk mounts found");
                if (str.startsWith("/system")) {
                    Iterator<C3346> it4 = m11377.iterator();
                    while (it4.hasNext()) {
                        C3346 next3 = it4.next();
                        if (next3.m12313().getAbsolutePath().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                            c3346 = next3;
                        }
                    }
                }
            }
            return c3346;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ApkUtils.ZipSections m11320(DataSource dataSource) throws IOException, ZipFormatException {
        Pair<ByteBuffer, Long> findZipEndOfCentralDirectoryRecord = ZipUtils.findZipEndOfCentralDirectoryRecord(dataSource);
        if (findZipEndOfCentralDirectoryRecord != null) {
            ByteBuffer first = findZipEndOfCentralDirectoryRecord.getFirst();
            long longValue = findZipEndOfCentralDirectoryRecord.getSecond().longValue();
            first.order(ByteOrder.LITTLE_ENDIAN);
            long zipEocdCentralDirectoryOffset = ZipUtils.getZipEocdCentralDirectoryOffset(first);
            if (zipEocdCentralDirectoryOffset <= longValue) {
                long zipEocdCentralDirectorySizeBytes = ZipUtils.getZipEocdCentralDirectorySizeBytes(first);
                long j = zipEocdCentralDirectoryOffset + zipEocdCentralDirectorySizeBytes;
                if (j <= longValue) {
                    return new ApkUtils.ZipSections(zipEocdCentralDirectoryOffset, zipEocdCentralDirectorySizeBytes, ZipUtils.getZipEocdCentralDirectoryTotalRecordCount(first), longValue, first);
                }
                throw new ZipFormatException("ZIP Central Directory overlaps with End of Central Directory. CD end: " + j + ", EoCD start: " + longValue);
            }
            throw new ZipFormatException("ZIP Central Directory start offset out of range: " + zipEocdCentralDirectoryOffset + ". ZIP End of Central Directory offset: " + longValue);
        }
        throw new ZipFormatException("ZIP End of Central Directory record not found");
    }

    public static long m11321() {
        CRC32 crc32 = new CRC32();
        if (C3348.f9948.booleanValue()) {
            return C3348.f9949;
        }
        try {
            crc32.update((Build.FINGERPRINT + Build.DEVICE + Build.MODEL + Build.BRAND + Build.PRODUCT + Build.MANUFACTURER + Build.HARDWARE).getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return crc32.getValue();
    }

    public static void m11322(File file, ArrayList<File> arrayList, String str, String str2, boolean z) {
        java.util.zip.ZipInputStream zipInputStream;
        FileInputStream fileInputStream;
        C4201 c4201;
        int i;
        String m11587;
        int i2;
        byte[] bytes;
        String str3;
        String str4;
        boolean z2;
        byte[] bArr;
        int i3;
        String str5 = ".dex";
        String str6 = "classes";
        ArrayList arrayList2 = new ArrayList();
        int i4 = 0;
        m11508("chmod", "777", file.getAbsolutePath());
        if (str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        C3348.m12347(str);
                        m11508("chmod", "644", str);
                        int i5 = -1;
                        try {
                            fileInputStream = new FileInputStream(str);
                            try {
                                zipInputStream = new java.util.zip.ZipInputStream(fileInputStream);
                                try {
                                    for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
                                        String name = nextEntry.getName();
                                        if (name.startsWith("classes") && name.endsWith(".dex")) {
                                            try {
                                                i3 = (int) nextEntry.getCrc();
                                                if (i3 == -1) {
                                                    CRC32 crc32 = new CRC32();
                                                    crc32.reset();
                                                    byte[] bArr2 = new byte[4096];
                                                    while (true) {
                                                        int read = zipInputStream.read(bArr2);
                                                        if (read == -1) {
                                                            break;
                                                        } else {
                                                            crc32.update(bArr2, 0, read);
                                                        }
                                                    }
                                                    i3 = (int) crc32.getValue();
                                                }
                                            } catch (Exception e) {
                                                e.printStackTrace();
                                                i3 = 0;
                                            }
                                            C3348.m12347("crc " + name + ":" + i3);
                                            arrayList2.add(new C2992(name, i3));
                                            zipInputStream.closeEntry();
                                            if (arrayList != null && arrayList.size() == arrayList2.size()) {
                                                break;
                                            }
                                        }
                                    }
                                    zipInputStream.close();
                                    fileInputStream.close();
                                } catch (Throwable unused) {
                                    if (zipInputStream != null) {
                                        zipInputStream.close();
                                    }
                                    if (fileInputStream != null) {
                                        fileInputStream.close();
                                    }
                                    arrayList2.clear();
                                    C3348.m12347("Start alternative method.");
                                    try {
                                        C3348.m12347("start");
                                        c4201 = C4201.m12846(str);
                                    } catch (Exception e2) {
                                        e = e2;
                                        c4201 = null;
                                    }
                                    try {
                                        try {
                                            for (C4199 c4199 : c4201.m12848().values()) {
                                                if (c4199.m12835().startsWith("classes") && c4199.m12835().endsWith(".dex")) {
                                                    try {
                                                        i = c4199.m12830();
                                                        C3348.m12347("CRC32:" + i);
                                                        if (i == i5) {
                                                            CRC32 crc322 = new CRC32();
                                                            crc322.reset();
                                                            byte[] m12831 = c4199.m12831();
                                                            crc322.update(m12831, 0, m12831.length);
                                                            i = (int) crc322.getValue();
                                                            C3348.m12347("CRC32:" + i);
                                                        }
                                                    } catch (Exception e3) {
                                                        e3.printStackTrace();
                                                        i = 0;
                                                    }
                                                    arrayList2.add(new C2992(c4199.m12835(), i));
                                                    if (arrayList != null && arrayList.size() == arrayList2.size()) {
                                                        break;
                                                    }
                                                }
                                                i5 = -1;
                                            }
                                        } catch (Exception e4) {
                                            e = e4;
                                            e.printStackTrace();
                                            if (c4201 != null) {
                                            }
                                            arrayList2.sort(new C2951());
                                            if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                            }
                                            if (file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                            }
                                            if (new File(m11587).exists()) {
                                            }
                                        }
                                        if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                        }
                                        if (file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                        }
                                        if (new File(m11587).exists()) {
                                        }
                                    } catch (Exception e5) {
                                        e5.printStackTrace();
                                        return;
                                    }
                                    if (c4201 != null) {
                                        c4201.m12847();
                                    }
                                    arrayList2.sort(new C2951());
                                }
                            } catch (Throwable unused2) {
                                zipInputStream = null;
                            }
                        } catch (Throwable unused3) {
                            zipInputStream = null;
                            fileInputStream = null;
                        }
                        if (arrayList2.size() == 0) {
                            throw new Exception("Alternative method for crc");
                        }
                        arrayList2.sort(new C2951());
                        if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                            m11518(file.getAbsolutePath());
                            FileChannel channel = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                            MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                            map.position(4096);
                            new File(str2).getName();
                            byte[] bytes2 = str2.getBytes();
                            (str2 + ":classes").getBytes();
                            (str2 + "!classes").getBytes();
                            if (z) {
                                bytes = str2.getBytes();
                            } else {
                                bytes = str.getBytes();
                            }
                            int i6 = 0;
                            int i7 = -1;
                            while (map.hasRemaining()) {
                                try {
                                    map.position(i7 + 1);
                                    i7 = map.position();
                                    if (map.get() == bytes2[i4]) {
                                        map.position(i7 + 1);
                                        byte b = map.get();
                                        int i8 = 1;
                                        while (true) {
                                            if (b == bytes2[i8]) {
                                                i8++;
                                                if (i8 == bytes2.length) {
                                                    int position = map.position();
                                                    byte[] bArr3 = new byte[7];
                                                    for (int i9 = 7; i4 < i9; i9 = 7) {
                                                        bArr3[i4] = map.get(position + i4 + 1);
                                                        i4++;
                                                    }
                                                    if (new String(bArr3, "UTF-8").equals(str6)) {
                                                        C3348.m12347("found android 8.1 skip marker");
                                                        map.position(position + 8);
                                                        z2 = true;
                                                    } else {
                                                        z2 = false;
                                                    }
                                                    if (!z2 && map.get(i7 - 1) != 61 && map.get(i7 - 2) != 101) {
                                                        Iterator it = arrayList2.iterator();
                                                        while (it.hasNext()) {
                                                            C2992 c2992 = (C2992) it.next();
                                                            String str7 = str6;
                                                            if (c2992.f8082.equals("classes.dex")) {
                                                                C3348.m12347(c2992.f8082 + " " + c2992.f8083);
                                                                int i10 = c2992.f8083;
                                                                if (i10 != 0) {
                                                                    map.put((byte) i10);
                                                                    map.force();
                                                                    map.put((byte) (c2992.f8083 >> 8));
                                                                    map.force();
                                                                    map.put((byte) (c2992.f8083 >> 16));
                                                                    map.force();
                                                                    map.put((byte) (c2992.f8083 >> 24));
                                                                    map.force();
                                                                }
                                                            }
                                                            str6 = str7;
                                                        }
                                                        str4 = str6;
                                                        map.position(i7);
                                                        map.put(bytes);
                                                        map.force();
                                                        i6++;
                                                    } else {
                                                        str4 = str6;
                                                    }
                                                    if (z2) {
                                                        byte[] bytes3 = str5.getBytes();
                                                        String str8 = str4;
                                                        int i11 = 0;
                                                        while (i11 < 7) {
                                                            i11++;
                                                            byte b2 = map.get();
                                                            str8 = str8 + ((char) b2);
                                                            int i12 = i6;
                                                            if (b2 == bytes3[0]) {
                                                                byte b3 = map.get();
                                                                String str9 = str5;
                                                                int i13 = i7;
                                                                int i14 = 1;
                                                                String str10 = str8;
                                                                int i15 = i12;
                                                                while (i14 < bytes3.length && b3 == bytes3[i14]) {
                                                                    str10 = str10 + ((char) b3);
                                                                    i14++;
                                                                    if (i14 == bytes3.length) {
                                                                        Iterator it2 = arrayList2.iterator();
                                                                        while (it2.hasNext()) {
                                                                            C2992 c29922 = (C2992) it2.next();
                                                                            Iterator it3 = it2;
                                                                            if (c29922.f8082.equals(str10)) {
                                                                                StringBuilder sb = new StringBuilder();
                                                                                bArr = bytes3;
                                                                                sb.append("oat ");
                                                                                sb.append(c29922.f8082);
                                                                                sb.append(" ");
                                                                                sb.append(c29922.f8083);
                                                                                C3348.m12347(sb.toString());
                                                                                int i16 = c29922.f8083;
                                                                                if (i16 != 0) {
                                                                                    map.put((byte) i16);
                                                                                    map.force();
                                                                                    map.put((byte) (c29922.f8083 >> 8));
                                                                                    map.force();
                                                                                    map.put((byte) (c29922.f8083 >> 16));
                                                                                    map.force();
                                                                                    map.put((byte) (c29922.f8083 >> 24));
                                                                                    map.force();
                                                                                }
                                                                                map.position(i13);
                                                                                map.put(bytes);
                                                                                map.force();
                                                                                i13 = map.position();
                                                                                map.get();
                                                                                i15++;
                                                                                b3 = map.get();
                                                                                bytes3 = bArr;
                                                                            } else {
                                                                                it2 = it3;
                                                                            }
                                                                        }
                                                                    }
                                                                    bArr = bytes3;
                                                                    b3 = map.get();
                                                                    bytes3 = bArr;
                                                                }
                                                                bytes3 = bytes3;
                                                                i6 = i15;
                                                                str8 = str10;
                                                                i7 = i13;
                                                                str5 = str9;
                                                            } else {
                                                                i6 = i12;
                                                            }
                                                        }
                                                    }
                                                    str3 = str5;
                                                } else {
                                                    str3 = str5;
                                                    str4 = str6;
                                                    b = map.get();
                                                    if (i6 == arrayList2.size()) {
                                                        break;
                                                    }
                                                    str6 = str4;
                                                    str5 = str3;
                                                    i4 = 0;
                                                }
                                            } else {
                                                str3 = str5;
                                                str4 = str6;
                                                break;
                                            }
                                        }
                                        str6 = str4;
                                        str5 = str3;
                                        i4 = 0;
                                    }
                                } catch (Exception e6) {
                                    e6.printStackTrace();
                                }
                            }
                            channel.close();
                        }
                        if (file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                            m11587 = file.getAbsolutePath();
                        } else {
                            m11587 = m11587(file.getAbsolutePath(), "vdex");
                        }
                        if (new File(m11587).exists()) {
                            m11518(m11587);
                            FileChannel channel2 = new RandomAccessFile(m11587, InternalZipConstants.WRITE_MODE).getChannel();
                            MappedByteBuffer map2 = channel2.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel2.size());
                            map2.position(4);
                            try {
                                String str11 = new String(new byte[]{map2.get(4), map2.get(5), map2.get(6)}, "utf-8");
                                C3348.m12347("VDEX version string:" + str11);
                                int intValue = new Integer(str11).intValue();
                                C3348.m12347("VDEX version:" + intValue);
                                i2 = intValue;
                            } catch (Throwable th) {
                                th.printStackTrace();
                                i2 = 19;
                            }
                            if (i2 < 19) {
                                map2.position(24);
                                try {
                                    Iterator it4 = arrayList2.iterator();
                                    while (it4.hasNext()) {
                                        C2992 c29923 = (C2992) it4.next();
                                        C3348.m12347("vdex " + c29923.f8082 + " " + c29923.f8083);
                                        int i17 = c29923.f8083;
                                        if (i17 != 0) {
                                            map2.put((byte) i17);
                                            map2.force();
                                            map2.put((byte) (c29923.f8083 >> 8));
                                            map2.force();
                                            map2.put((byte) (c29923.f8083 >> 16));
                                            map2.force();
                                            map2.put((byte) (c29923.f8083 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e7) {
                                    e7.printStackTrace();
                                }
                            }
                            if (i2 >= 19 && i2 < 21) {
                                map2.position(20);
                                try {
                                    Iterator it5 = arrayList2.iterator();
                                    while (it5.hasNext()) {
                                        C2992 c29924 = (C2992) it5.next();
                                        C3348.m12347("vdex " + c29924.f8082 + " " + c29924.f8083);
                                        int i18 = c29924.f8083;
                                        if (i18 != 0) {
                                            map2.put((byte) i18);
                                            map2.force();
                                            map2.put((byte) (c29924.f8083 >> 8));
                                            map2.force();
                                            map2.put((byte) (c29924.f8083 >> 16));
                                            map2.force();
                                            map2.put((byte) (c29924.f8083 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e8) {
                                    e8.printStackTrace();
                                }
                            }
                            if (i2 >= 21 && i2 < 27) {
                                map2.position(28);
                                try {
                                    Iterator it6 = arrayList2.iterator();
                                    while (it6.hasNext()) {
                                        C2992 c29925 = (C2992) it6.next();
                                        C3348.m12347("vdex " + c29925.f8082 + " " + c29925.f8083);
                                        int i19 = c29925.f8083;
                                        if (i19 != 0) {
                                            map2.put((byte) i19);
                                            map2.force();
                                            map2.put((byte) (c29925.f8083 >> 8));
                                            map2.force();
                                            map2.put((byte) (c29925.f8083 >> 16));
                                            map2.force();
                                            map2.put((byte) (c29925.f8083 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e9) {
                                    e9.printStackTrace();
                                }
                            }
                            if (i2 >= 27) {
                                map2.position(60);
                                try {
                                    Iterator it7 = arrayList2.iterator();
                                    while (it7.hasNext()) {
                                        C2992 c29926 = (C2992) it7.next();
                                        C3348.m12347("vdex " + c29926.f8082 + " " + c29926.f8083);
                                        int i20 = c29926.f8083;
                                        if (i20 != 0) {
                                            map2.put((byte) i20);
                                            map2.force();
                                            map2.put((byte) (c29926.f8083 >> 8));
                                            map2.force();
                                            map2.put((byte) (c29926.f8083 >> 16));
                                            map2.force();
                                            map2.put((byte) (c29926.f8083 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e10) {
                                    e10.printStackTrace();
                                }
                            }
                            channel2.close();
                        }
                    } catch (Exception e11) {
                        e11.printStackTrace();
                    }
                }
            } catch (Exception e12) {
                C3348.m12347(e12);
            }
        }
    }

    public static void m11323(String str) {
        String[] strArr;
        int i;
        C3348.m12347("fix selinux lp " + str);
        String str2 = "u:object_r:system_data_file:s0";
        String str3 = "u:object_r:media_rw_data_file:s0";
        if (C3348.f9948.booleanValue()) {
            String[] strArr2 = {"ls", "-dZ", "/data/media"};
            String[] strArr3 = {"ls", "-dZ", "/data"};
            String[] strArr4 = {"ls", "-dZ", "/data/local/tmp"};
            if (new File("/system/bin/toybox").exists()) {
                C3348.m12347("use toybox");
                i = 3;
                strArr2 = new String[]{"toybox", "ls", "-dZ", "/data/media"};
                strArr3 = new String[]{"toybox", "ls", "-dZ", "/data"};
            } else {
                i = 3;
            }
            String m11438 = m11438(strArr2);
            String m114382 = m11438(strArr3);
            String m114383 = m11438(strArr4);
            String[] strArr5 = new String[i];
            strArr5[0] = "restorecon";
            strArr5[1] = "-v";
            strArr5[2] = str;
            m11508(strArr5);
            String[] strArr6 = new String[i];
            strArr6[0] = "chmod";
            strArr6[1] = "777";
            strArr6[2] = str;
            m11508(strArr6);
            if (!str.startsWith("/data/ru")) {
                m114382 = "";
            }
            if (!str.startsWith("/data/data/")) {
                m11438 = m114382;
            }
            if (!str.startsWith("/data/local/tmp")) {
                m114383 = m11438;
            }
            if (m114383 != null && !m114383.equals("")) {
                String[] split = m114383.split("\\s+");
                if (split.length > 4 && !split[0].contains(":") && !split[3].contains(":")) {
                    C3348.m12347("0:" + split[0]);
                    C3348.m12347("1:" + split[1]);
                    C3348.m12347("2:" + split[2]);
                    C3348.m12347("3:" + split[3]);
                    C3348.m12347(m114383);
                }
                if (split.length > 1) {
                    if (split[0].contains(":")) {
                        C3348.m12347(split[0]);
                        m11508("chcon", split[0].trim(), str);
                        return;
                    } else {
                        if (split.length > 4 && split[3].contains(":")) {
                            C3348.m12347(split[3]);
                            m11508("chcon", split[3].trim(), str);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (!str.startsWith("/data/ru")) {
                str2 = m114383;
            }
            if (!str.startsWith("/data/data/")) {
                str3 = str2;
            }
            if (str.startsWith("/data/local/tmp")) {
                str3 = "u:object_r:shell_data_file:s0";
            }
            if (str.startsWith("/data/misc/")) {
                str3 = "u:object_r:magisk_file:s0";
            }
            C3348.m12347("manual:" + str3);
            m11508("chcon", str3, str);
            return;
        }
        if (C3348.f9908) {
            String[] strArr7 = {"ls", "-dZ", "/data/media"};
            String[] strArr8 = {"ls", "-dZ", "/data"};
            String[] strArr9 = {"ls", "-dZ", "/data/local/tmp"};
            if (new File("/system/bin/toybox").exists()) {
                C3348.m12347("use toybox");
                strArr = new String[]{"toybox", "ls", "-dZ", "/data/media"};
                strArr8 = new String[]{"toybox", "ls", "-dZ", "/data"};
            } else {
                strArr = strArr7;
            }
            String m114384 = m11438(strArr);
            String m114385 = m11438(strArr8);
            String m114386 = m11438(strArr9);
            m11506("restorecon -v " + str);
            m11506("chmod 777 " + str);
            if (!str.startsWith("/data/ru")) {
                m114385 = "";
            }
            if (!str.startsWith("/data/data/")) {
                m114384 = m114385;
            }
            if (!str.startsWith("/data/local/tmp")) {
                m114386 = m114384;
            }
            if (m114386 != null && !m114386.equals("")) {
                String[] split2 = m114386.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":") && !split2[3].contains(":")) {
                    C3348.m12347("0:" + split2[0]);
                    C3348.m12347("1:" + split2[1]);
                    C3348.m12347("2:" + split2[2]);
                    C3348.m12347("3:" + split2[3]);
                    C3348.m12347(m114386);
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        C3348.m12347(split2[0]);
                        m11506("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        C3348.m12347(split2[3]);
                        m11506("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            if (str.startsWith("/data/ru")) {
                m114386 = "u:object_r:system_data_file:s0";
            }
            if (!str.startsWith("/data/data/")) {
                str3 = m114386;
            }
            if (str.startsWith("/data/local/tmp")) {
                str3 = "u:object_r:shell_data_file:s0";
            }
            if (str.startsWith("/data/misc/")) {
                str3 = "u:object_r:magisk_file:s0";
            }
            C3348.m12347("manual:" + str3);
            m11506("chcon " + str3 + " " + str);
        }
    }

    public static void m11324(File file) {
        m11590();
        try {
            if (C3348.f9948.booleanValue()) {
                m11438("chmod", "777", file.getAbsolutePath());
            }
            m11585(file);
            m11581(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11325(File file, String str) {
        java.util.zip.ZipInputStream zipInputStream;
        ZipEntry nextEntry;
        int i;
        int i2;
        int crc;
        int i3;
        int i4;
        m11590();
        byte[] bArr = {100, 101, 121, 10, 48, 51, 53, 0};
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] bArr2 = new byte[40];
            fileInputStream.read(bArr2);
            fileInputStream.close();
            for (int i5 = 0; i5 < 4; i5++) {
                if (bArr2[i5] != bArr[i5]) {
                    C3348.m12347("The magic value is not the expected value " + new String(bArr2));
                    return;
                }
            }
            try {
                ByteBuffer wrap = ByteBuffer.wrap(bArr2);
                wrap.order(ByteOrder.LITTLE_ENDIAN);
                wrap.position(8);
                int i6 = wrap.getInt();
                wrap.position(12);
                int i7 = wrap.getInt();
                wrap.position(16);
                int i8 = wrap.getInt();
                wrap.position(20);
                wrap.getInt();
                wrap.position(24);
                wrap.getInt();
                wrap.position(28);
                wrap.getInt();
                wrap.position(32);
                wrap.getInt();
                m11583(i6, i7, file);
                if (C3348.f9948.booleanValue()) {
                    m11508("chmod", "644", str);
                } else {
                    m11506("chmod 644 " + str);
                }
                if (str != null && new File(str).exists() && new File(str).length() != 0) {
                    try {
                        C4201 m12846 = C4201.m12846(str);
                        for (C4199 c4199 : m12846.m12848().values()) {
                            if (c4199.m12835().equals("classes.dex")) {
                                try {
                                    int m11466 = (int) m11466(c4199.m12837());
                                    C3348.m12347("Time:" + m11466);
                                    i3 = m11466;
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    i3 = 0;
                                }
                                try {
                                    i4 = c4199.m12830();
                                    C3348.m12347("CRC32:" + i4);
                                    if (i4 == -1) {
                                        CRC32 crc32 = new CRC32();
                                        crc32.reset();
                                        byte[] m12831 = c4199.m12831();
                                        crc32.update(m12831, 0, m12831.length);
                                        i4 = (int) crc32.getValue();
                                        C3348.m12347("CRC32:" + i4);
                                    }
                                } catch (Exception e2) {
                                    e2.printStackTrace();
                                    i4 = 0;
                                }
                                try {
                                    FileChannel channel = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                                    MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                    if (i3 != 0) {
                                        map.position(i8);
                                        map.put((byte) i3);
                                        map.force();
                                        map.position(i8 + 1);
                                        map.put((byte) (i3 >> 8));
                                        map.force();
                                        map.position(i8 + 2);
                                        map.put((byte) (i3 >> 16));
                                        map.force();
                                        map.position(i8 + 3);
                                        map.put((byte) (i3 >> 24));
                                        map.force();
                                    }
                                    if (i4 != 0) {
                                        map.position(i8 + 4);
                                        map.put((byte) i4);
                                        map.force();
                                        map.position(i8 + 5);
                                        map.put((byte) (i4 >> 8));
                                        map.force();
                                        map.position(i8 + 6);
                                        map.put((byte) (i4 >> 16));
                                        map.force();
                                        map.position(i8 + 7);
                                        map.put((byte) (i4 >> 24));
                                        map.force();
                                    }
                                    channel.close();
                                } catch (FileNotFoundException e3) {
                                    e3.printStackTrace();
                                } catch (IOException e4) {
                                    e4.printStackTrace();
                                }
                                m12846.m12847();
                                return;
                            }
                        }
                        return;
                    } catch (Exception e5) {
                        C3348.m12347("alternative method");
                        e5.printStackTrace();
                        try {
                            C3348.m12347("start");
                            C3348.m12347(str);
                            FileInputStream fileInputStream2 = new FileInputStream(str);
                            zipInputStream = new java.util.zip.ZipInputStream(fileInputStream2);
                            nextEntry = zipInputStream.getNextEntry();
                            while (true) {
                                if (nextEntry == null) {
                                    break;
                                }
                                if (nextEntry.getName().equals("classes.dex")) {
                                    try {
                                        break;
                                    } catch (Exception e6) {
                                        e6.printStackTrace();
                                        i = 0;
                                    }
                                } else {
                                    nextEntry = zipInputStream.getNextEntry();
                                }
                            }
                            zipInputStream.close();
                            fileInputStream2.close();
                        } catch (Exception e7) {
                            e7.printStackTrace();
                            return;
                        }
                    }
                }
                return;
                try {
                    crc = (int) nextEntry.getCrc();
                } catch (Exception e8) {
                    e = e8;
                }
                if (crc == -1) {
                    CRC32 crc322 = new CRC32();
                    crc322.reset();
                    byte[] bArr3 = new byte[4096];
                    while (true) {
                        int read = zipInputStream.read(bArr3);
                        if (read == -1) {
                            break;
                        }
                        try {
                            crc322.update(bArr3, 0, read);
                        } catch (Exception e9) {
                            e = e9;
                            e.printStackTrace();
                            i2 = 0;
                            FileChannel channel2 = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                            MappedByteBuffer map2 = channel2.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel2.size());
                            if (i != 0) {
                                map2.position(i8);
                                byte b = (byte) i;
                                map2.put(b);
                                map2.force();
                                C3348.m12347("for file:" + file);
                                C3348.m12347("time0:" + ((int) b));
                                map2.position(i8 + 1);
                                map2.put((byte) (i >> 8));
                                map2.force();
                                C3348.m12347("time1:" + (b >> 8));
                                map2.position(i8 + 2);
                                map2.put((byte) (i >> 16));
                                map2.force();
                                C3348.m12347("time2:" + (b >> RegisterType.UNINIT_REF));
                                map2.position(i8 + 3);
                                map2.put((byte) (i >> 24));
                                map2.force();
                                C3348.m12347("time3:" + (b >> DerValue.tag_GeneralizedTime));
                            }
                            if (i2 != 0) {
                                map2.position(i8 + 4);
                                map2.put((byte) i2);
                                map2.force();
                                map2.position(i8 + 5);
                                map2.put((byte) (i2 >> 8));
                                map2.force();
                                map2.position(i8 + 6);
                                map2.put((byte) (i2 >> 16));
                                map2.force();
                                map2.position(i8 + 7);
                                map2.put((byte) (i2 >> 24));
                                map2.force();
                            }
                            channel2.close();
                            zipInputStream.closeEntry();
                            zipInputStream.close();
                            fileInputStream2.close();
                        }
                        e = e9;
                        e.printStackTrace();
                        i2 = 0;
                        FileChannel channel22 = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                        MappedByteBuffer map22 = channel22.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel22.size());
                        if (i != 0) {
                        }
                        if (i2 != 0) {
                        }
                        channel22.close();
                        zipInputStream.closeEntry();
                        zipInputStream.close();
                        fileInputStream2.close();
                    }
                    crc = (int) crc322.getValue();
                }
                i2 = crc;
                FileChannel channel222 = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                MappedByteBuffer map222 = channel222.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel222.size());
                if (i != 0) {
                }
                if (i2 != 0) {
                }
                channel222.close();
                zipInputStream.closeEntry();
                zipInputStream.close();
                fileInputStream2.close();
            } catch (Exception e10) {
                C3348.m12347(e10);
            }
        } catch (Exception e11) {
            e11.printStackTrace();
        }
    }

    public static boolean m11326(File file, File file2, String str) {
        String m11383;
        String str2;
        try {
            m11383 = m11383(file);
            while (true) {
                file2 = m11357(file2);
                if (file2.getAbsolutePath().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                    str2 = "";
                    break;
                }
                File file3 = new File(file2.getAbsolutePath() + "/etc/permissions");
                if (file3.exists()) {
                    C3348.m12347("found dir for allow permissions:" + file3.getAbsolutePath());
                    str2 = file3.getAbsolutePath();
                    break;
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (!str2.equals("")) {
            File file4 = new File(str + str2 + "/privapp_whitelist_" + m11383 + ".xml");
            m11492(file4.getAbsolutePath(), "RW");
            File m11357 = m11357(file4);
            if (!m11357.exists()) {
                m11357.mkdirs();
            }
            ArrayList<String> m11388 = m11388(file);
            ArrayList<String> m11359 = m11359(file);
            Document newDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            newDocument.appendChild(newDocument.createTextNode("\n"));
            Element createElement = newDocument.createElement("permissions");
            newDocument.appendChild(createElement);
            newDocument.normalize();
            Element createElement2 = newDocument.createElement("privapp-permissions");
            Attr createAttribute = newDocument.createAttribute("package");
            createAttribute.setValue(m11383);
            createElement2.setAttributeNode(createAttribute);
            createElement.appendChild(createElement2);
            createElement.normalize();
            Iterator<String> it = m11388.iterator();
            while (it.hasNext()) {
                createElement2.appendChild(m11303(newDocument, it.next()));
                createElement2.normalize();
            }
            Iterator<String> it2 = m11359.iterator();
            while (it2.hasNext()) {
                createElement2.appendChild(m11300(newDocument, it2.next()));
                createElement2.normalize();
            }
            newDocument.normalizeDocument();
            Transformer newTransformer = TransformerFactory.newInstance().newTransformer();
            DOMSource dOMSource = new DOMSource(newDocument);
            if (file4.exists()) {
                file4.delete();
            }
            StreamResult streamResult = new StreamResult(file4.getAbsolutePath());
            newTransformer.setOutputProperty("indent", "yes");
            newTransformer.transform(dOMSource, streamResult);
            m11508("chmod", "755", file4.getAbsolutePath());
            m11508("chown", "0:0", file4.getAbsolutePath());
            m11508("chown", "0.0", file4.getAbsolutePath());
            return true;
        }
        C3348.m12347("Not found dir for allow permissions.");
        return false;
    }

    public static int m11327(int i, int i2) {
        return new Random().nextInt(i2 - i) + i;
    }

    public static ArrayList<C2993> m11328(String str, ArrayList<C2993> arrayList, boolean z, boolean z2) {
        m11590();
        C3348.m12347("Get all methods scan: " + str);
        ArrayList<C2993> arrayList2 = new ArrayList<>();
        char c = 2;
        char c2 = 3;
        if (C3348.f9948.booleanValue()) {
            m11508("chmod", "777", str);
        } else if (C3348.f9908) {
            m11506("chmod 777 " + str);
        }
        new ArrayList();
        if (!z && str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        if (new File(str).exists()) {
                            try {
                                FileChannel channel = new RandomAccessFile(str, InternalZipConstants.READ_MODE).getChannel();
                                MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
                                map.position(0);
                                if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                    map.position(88);
                                    int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                    map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                    byte[] bArr = new byte[m11592];
                                    int i = 0;
                                    int i2 = 0;
                                    while (i < m11592) {
                                        byte[] bArr2 = new byte[8];
                                        bArr2[0] = map.get();
                                        bArr2[1] = map.get();
                                        bArr2[c] = map.get();
                                        bArr2[c2] = map.get();
                                        char c3 = 4;
                                        bArr2[4] = map.get();
                                        bArr2[5] = map.get();
                                        bArr2[6] = map.get();
                                        bArr2[7] = map.get();
                                        Iterator<C2993> it = arrayList.iterator();
                                        while (it.hasNext()) {
                                            C2993 next = it.next();
                                            if (m11569(map, next, m11291(bArr2[c], bArr2[c2]))) {
                                                byte b = bArr2[c3];
                                                byte[] bArr3 = next.f8088;
                                                if (b == bArr3[0] && bArr2[5] == bArr3[1]) {
                                                    if (bArr2[6] == bArr3[2] && bArr2[7] == bArr3[c2]) {
                                                        C2993 c2993 = new C2993("", next.f8085, next.f8086);
                                                        byte[] bArr4 = c2993.f8090;
                                                        byte b2 = (byte) i2;
                                                        bArr4[0] = b2;
                                                        byte b3 = (byte) (i2 >> 8);
                                                        bArr4[1] = b3;
                                                        byte[] bArr5 = next.f8090;
                                                        bArr5[0] = b2;
                                                        bArr5[1] = b3;
                                                        next.f8092 = true;
                                                        next.f8096 = true;
                                                        arrayList2.add(c2993);
                                                    }
                                                    c = 2;
                                                    c2 = 3;
                                                    c3 = 4;
                                                }
                                            }
                                            c = 2;
                                            c2 = 3;
                                            c3 = 4;
                                        }
                                        i2++;
                                        i++;
                                        c = 2;
                                        c2 = 3;
                                    }
                                }
                                channel.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            } catch (Exception e3) {
                C3348.m12347(e3);
            }
        }
        return arrayList2;
    }

    public static String m11329(Context context, String str) {
        m11590();
        if (C3348.f9924 < 26) {
            return Settings.Secure.getString(context.getContentResolver(), "android_id");
        }
        File file = new File("/data/system/users/" + ("" + (Process.myUid() / 100000)) + "/settings_ssaid.xml");
        try {
            try {
                m11506("chmod 0777 " + file.getAbsolutePath());
                C3348.m12347(new C2880("").m11618(C3348.f9909 + C2018.class.getName() + " " + file.getAbsolutePath() + " " + context.getDir("packages", 0).getAbsolutePath() + "/settings_ssaid.xml"));
                StringBuilder sb = new StringBuilder();
                sb.append(context.getDir("packages", 0).getAbsolutePath());
                sb.append("/settings_ssaid.xml");
                String sb2 = sb.toString();
                StringBuilder sb3 = new StringBuilder();
                sb3.append(context.getDir("packages", 0).getAbsolutePath());
                sb3.append("/settings_ssaid.xml");
                m11518(sb3.toString());
                NodeList elementsByTagName = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new FileInputStream(sb2)).getElementsByTagName("setting");
                for (int i = 0; i < elementsByTagName.getLength(); i++) {
                    elementsByTagName.item(i);
                    Element element = (Element) elementsByTagName.item(i);
                    C3348.m12347(element.getAttribute("package"));
                    if (element.getAttribute("package").equals(C3348.f9878.f10669)) {
                        return element.getAttribute("value");
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
        } catch (DOMException unused) {
            m11506("chmod 0777 " + file.getAbsolutePath());
            C3348.m12347(new C2880("").m11618(C3348.f9909 + C2018.class.getName() + " " + file.getAbsolutePath() + " " + context.getDir("packages", 0).getAbsolutePath() + "/settings_ssaid.xml"));
            StringBuilder sb4 = new StringBuilder();
            sb4.append(context.getDir("packages", 0).getAbsolutePath());
            sb4.append("/settings_ssaid.xml");
            String sb5 = sb4.toString();
            StringBuilder sb6 = new StringBuilder();
            sb6.append(context.getDir("packages", 0).getAbsolutePath());
            sb6.append("/settings_ssaid.xml");
            m11518(sb6.toString());
            XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
            newInstance.setNamespaceAware(true);
            XmlPullParser newPullParser = newInstance.newPullParser();
            newPullParser.setInput(new FileReader(sb5));
            for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
                if (eventType == 0) {
                    System.out.println("Start document");
                } else {
                    if (eventType == 2) {
                        try {
                            if (newPullParser.getName().toLowerCase().equals("setting")) {
                                try {
                                    if (m11432(newPullParser, "package").equals(str)) {
                                        return m11432(newPullParser, "value");
                                    }
                                    continue;
                                } catch (Throwable th2) {
                                    th = th2;
                                    th.printStackTrace();
                                }
                            }
                        } catch (Throwable th3) {
                            th = th3;
                        }
                    } else if (eventType == 3) {
                        System.out.println("End tag " + newPullParser.getName());
                    } else if (eventType == 4) {
                        System.out.println("Text " + newPullParser.getText());
                    }
                }
            }
            System.out.println("End document");
        } catch (Exception e) {
            e.printStackTrace();
        }
        C3348.m12347("Android_ID is empty.");
        return "";
    }

    public static ByteBuffer m11330(DataSource dataSource) throws IOException, ApkFormatException {
        CentralDirectoryRecord centralDirectoryRecord;
        m11590();
        try {
            ApkUtils.ZipSections m11320 = m11320(dataSource);
            Iterator<CentralDirectoryRecord> it = V1SchemeVerifier.parseZipCentralDirectory(dataSource, m11320).iterator();
            while (true) {
                if (it.hasNext()) {
                    centralDirectoryRecord = it.next();
                    if (ApkUtils.ANDROID_MANIFEST_ZIP_ENTRY_NAME.equals(centralDirectoryRecord.getName())) {
                        break;
                    }
                } else {
                    centralDirectoryRecord = null;
                    break;
                }
            }
            if (centralDirectoryRecord != null) {
                DataSource slice = dataSource.slice(0L, m11320.getZipCentralDirectoryOffset());
                try {
                    return ByteBuffer.wrap(LocalFileRecord.getUncompressedData(slice, centralDirectoryRecord, slice.size()));
                } catch (ZipFormatException e) {
                    throw new ApkFormatException("Failed to read AndroidManifest.xml", e);
                }
            }
            throw new ApkFormatException("Missing AndroidManifest.xml");
        } catch (ZipFormatException e2) {
            throw new ApkFormatException("Not a valid ZIP archive", e2);
        }
    }

    public static void m11331(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
        if (C3348.f9924 >= 19) {
            m11456(linearLayout, new RunnableC2892(linearLayout, runnable, timer, timerTask), timer, timerTask);
        }
    }

    public static String m11332() {
        switch (C3348.f9924) {
            case 9:
                return "Android 2.3";
            case 10:
                return "Android 2.3.3";
            case 11:
                return "Android 3";
            case 12:
                return "Android 3.1";
            case 13:
                return "Android 3.2";
            case 14:
                return "Android 4.0";
            case 15:
                return "Android 4.0.3";
            case 16:
                return "Android 4.1";
            case 17:
                return "Android 4.2";
            case 18:
                return "Android 4.3";
            case 19:
                return "Android 4.4";
            case 20:
                return "Android 4.4W";
            case 21:
                return "Android 5.0";
            case 22:
                return "Android 5.1";
            case 23:
                return "Android 6.0";
            case 24:
                return "Android 7.0";
            case 25:
                return "Android 7.1";
            case 26:
                return "Android 8.0";
            case 27:
                return "Android 8.1";
            case 28:
                return "Android 9";
            case 29:
                return "Android 10";
            default:
                return "Android (api " + C3348.f9924 + ")";
        }
    }

    public static String m11333() {
        UserHandle myUserHandle;
        String userHandle;
        myUserHandle = Process.myUserHandle();
        userHandle = myUserHandle.toString();
        String substring = userHandle.substring(userHandle.lastIndexOf(123) + 1, userHandle.lastIndexOf(125));
        C3348.m12347("android_user_id:" + substring);
        return substring;
    }

    public static String m11334(String str) {
        if (C3348.f9924 < 19) {
            return "DALVIK";
        }
        try {
            FileInputStream fileInputStream = new FileInputStream(m11363(str));
            byte[] bArr = new byte[7];
            fileInputStream.read(bArr);
            fileInputStream.close();
            byte[] bArr2 = {100, 101, 120};
            byte[] bArr3 = {100, 101, 121};
            for (int i = 0; i < 3; i++) {
                byte b = bArr[i];
                if (b != bArr2[i] && b != bArr3[i]) {
                    C3348.m12347("The magic value is not the expected value " + new String(bArr));
                    return "ART";
                }
            }
            return "DALVIK";
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return "UNKNOWN";
        } catch (IOException e2) {
            e2.printStackTrace();
            return "UNKNOWN";
        } catch (Exception e3) {
            e3.printStackTrace();
            try {
                C3348.m12347("Althernative runtime check with java.vm.version");
                if (Integer.parseInt("" + System.getProperty("java.vm.version").charAt(0)) > 1) {
                    return "ART";
                }
                return "DALVIK";
            } catch (Exception e4) {
                e4.printStackTrace();
                if (C3348.f9924 >= 21) {
                    return "ART";
                }
                return "DALVIK";
            }
        }
    }

    public static Drawable m11335(String str) {
        m11590();
        PackageManager m12337 = C3348.m12337();
        PackageInfo packageArchiveInfo = m12337.getPackageArchiveInfo(str, 1);
        if (packageArchiveInfo != null) {
            ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo.loadIcon(m12337);
        }
        return null;
    }

    public static ApplicationInfo m11336(String str) {
        m11590();
        PackageInfo packageArchiveInfo = C3348.m12337().getPackageArchiveInfo(str, 1);
        if (packageArchiveInfo != null) {
            ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo;
        }
        try {
            ApplicationInfo applicationInfo2 = new ApplicationInfo();
            applicationInfo2.packageName = m11383(new File(str));
            return applicationInfo2;
        } catch (Throwable th) {
            th.printStackTrace();
            return null;
        }
    }

    public static String m11337(String str) {
        m11590();
        PackageManager m12337 = C3348.m12337();
        PackageInfo packageArchiveInfo = m12337.getPackageArchiveInfo(str, 1);
        if (packageArchiveInfo != null) {
            ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo.loadLabel(m12337).toString();
        }
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(str, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(randomAccessFile)));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 2 && "application".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    C3348.m12347(androidBinXmlParser.getName());
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("label".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            C3348.m12347(Integer.valueOf(androidBinXmlParser.getAttributeValueType(i)));
                            int attributeValueType = androidBinXmlParser.getAttributeValueType(i);
                            if (attributeValueType != 1) {
                                if (attributeValueType == 3) {
                                    C4204 c4204 = new C4204(m11402(DataSources.asDataSource(randomAccessFile)));
                                    c4204.m12862();
                                    C4298 m12861 = c4204.m12861();
                                    try {
                                        return m12861.m13088(androidBinXmlParser.getAttributeIntValue(i)).get(0).m13090().mo13072(m12861, null);
                                    } catch (Throwable unused) {
                                        return null;
                                    }
                                }
                            } else {
                                return androidBinXmlParser.getAttributeStringValue(i);
                            }
                        }
                    }
                    return null;
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return null;
    }

    public static PackageInfo m11338(String str, int i) {
        PackageInfo packageInfo;
        m11590();
        PackageManager m12337 = C3348.m12337();
        try {
            C3348.m12347(str);
            packageInfo = m12337.getPackageArchiveInfo(str, i);
        } catch (Throwable th) {
            th.printStackTrace();
            packageInfo = null;
        }
        if (packageInfo != null) {
            return packageInfo;
        }
        try {
            C3348.m12347("Alternative method get PackageInfo used");
            return m11382(new File(str));
        } catch (Throwable th2) {
            th2.printStackTrace();
            return null;
        }
    }

    public static String m11339(File file) {
        String str;
        String comment;
        try {
            comment = new ZipFile(file).getComment();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (comment != null) {
            String[] split = comment.split("\n");
            if (split.length >= 4 && split.length <= 5) {
                str = split[0];
                if (!str.equals("")) {
                    try {
                        return m11337(m11344(file).getAbsolutePath());
                    } catch (Throwable th2) {
                        th2.printStackTrace();
                        return "Unknown";
                    }
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m11340(File file) {
        String str;
        String comment;
        try {
            comment = new ZipFile(file).getComment();
            C3348.m12347(comment);
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (comment != null) {
            String[] split = comment.split("\n");
            if (split.length >= 4 && split.length <= 5) {
                str = split[1];
                if (!str.equals("")) {
                    return m11338(m11344(file).getAbsolutePath(), 1).packageName;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m11341(File file) {
        String str;
        String comment;
        try {
            comment = new ZipFile(file).getComment();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (comment != null) {
            String[] split = comment.split("\n");
            if (split.length >= 4 && split.length <= 5) {
                str = split[3];
                if (!str.equals("")) {
                    return "" + m11338(m11344(file).getAbsolutePath(), 1).versionCode;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m11342(File file) {
        String str;
        String comment;
        try {
            comment = new ZipFile(file).getComment();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (comment != null) {
            String[] split = comment.split("\n");
            if (split.length >= 4 && split.length <= 5) {
                str = split[2];
                if (!str.equals("")) {
                    return "" + m11338(m11344(file).getAbsolutePath(), 1).versionName;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static void m11343(String str, String str2) throws IOException {
        m11590();
        new File(str2).mkdirs();
        InputStream open = C3348.m12338().getAssets().open(str);
        FileOutputStream fileOutputStream = new FileOutputStream(str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + str);
        byte[] bArr = new byte[ItemType.CLASS_DATA_ITEM];
        while (true) {
            int read = open.read(bArr);
            if (read != -1) {
                fileOutputStream.write(bArr, 0, read);
            } else {
                open.close();
                fileOutputStream.flush();
                fileOutputStream.close();
                return;
            }
        }
    }

    public static File m11344(File file) {
        File file2 = new File(m11421() + "tmp/");
        file2.mkdirs();
        try {
            ZipFile zipFile = new ZipFile(file);
            File file3 = new File(file2.getAbsolutePath() + "/base.apk");
            if (file3.exists()) {
                for (FileHeader fileHeader : zipFile.getFileHeaders()) {
                    if (!fileHeader.getFileName().contains("split") && fileHeader.getFileName().toLowerCase().endsWith("apk") && file3.length() != fileHeader.getUncompressedSize()) {
                        byte[] bArr = new byte[4096];
                        ZipInputStream inputStream = zipFile.getInputStream(fileHeader);
                        try {
                            FileOutputStream fileOutputStream = new FileOutputStream(file3);
                            while (true) {
                                int read = inputStream.read(bArr);
                                if (read <= 0) {
                                    break;
                                }
                                fileOutputStream.write(bArr, 0, read);
                            }
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        } catch (IOException e2) {
                            e2.printStackTrace();
                        }
                        if (m11337(file3.getAbsolutePath()) != null) {
                            C3348.m12347("apk label:" + m11337(file3.getAbsolutePath()));
                            return file3;
                        }
                        continue;
                    } else {
                        if (m11337(file3.getAbsolutePath()) == null) {
                            return null;
                        }
                        C3348.m12347("apk label:" + m11337(file3.getAbsolutePath()));
                        return file3;
                    }
                }
                C3348.m12347("base.apk not found!");
                return null;
            }
            for (FileHeader fileHeader2 : zipFile.getFileHeaders()) {
                if (!fileHeader2.getFileName().contains("split") && fileHeader2.getFileName().toLowerCase().endsWith("apk")) {
                    byte[] bArr2 = new byte[4096];
                    ZipInputStream inputStream2 = zipFile.getInputStream(fileHeader2);
                    try {
                        FileOutputStream fileOutputStream2 = new FileOutputStream(file3);
                        while (true) {
                            int read2 = inputStream2.read(bArr2);
                            if (read2 <= 0) {
                                break;
                            }
                            fileOutputStream2.write(bArr2, 0, read2);
                        }
                        if (m11337(file3.getAbsolutePath()) != null) {
                            return file3;
                        }
                    } catch (FileNotFoundException e3) {
                        e3.printStackTrace();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                }
            }
            C3348.m12347("base.apk not found!");
            return null;
        } catch (ZipException e5) {
            e5.printStackTrace();
            C3348.m12347("base.apk not found!");
            return null;
        }
        e5.printStackTrace();
        C3348.m12347("base.apk not found!");
        return null;
    }

    public static File m11345(ArrayList<File> arrayList) {
        if (arrayList != null && arrayList.size() > 0) {
            Iterator<File> it = arrayList.iterator();
            while (it.hasNext()) {
                File next = it.next();
                if (next.getName().toLowerCase().equals("base.apk")) {
                    return next;
                }
            }
            Iterator<File> it2 = arrayList.iterator();
            while (it2.hasNext()) {
                File next2 = it2.next();
                if (m11337(next2.getAbsolutePath()) != null) {
                    return next2;
                }
            }
            return null;
        }
        return null;
    }

    public static String m11346(File file) {
        String str;
        String str2 = "";
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
            String[] strArr = new String[2000];
            str = "";
            boolean z = false;
            int i = 0;
            while (true) {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        strArr[0] = readLine;
                        if (z && (readLine.contains("[") || strArr[0].contains("]") || strArr[0].contains("{"))) {
                            C3348.m12347("" + str + "\n");
                            i++;
                            z = false;
                        }
                        if (z) {
                            str = str + "\n" + strArr[0];
                        }
                        if (strArr[0].toUpperCase().contains("[BEGIN]")) {
                            z = true;
                            if (i > 0) {
                                str = str + "\n-------- " + m11423(R.string.next_custom_patch) + " --------\n";
                            }
                        }
                    } else {
                        fileInputStream.close();
                        return str;
                    }
                } catch (FileNotFoundException unused) {
                    str2 = str;
                    C3348.m12347("Custom Patch not Found in\n/sdcard/LuckyPatcher/\n");
                    return str2;
                } catch (IOException e) {
                    e = e;
                    C3348.m12347("" + e);
                    return str;
                }
            }
        } catch (FileNotFoundException unused2) {
        } catch (IOException e2) {
            e = e2;
            str = "";
        }
    }

    public static String[] m11347() {
        String[] m11410 = m11410();
        for (String str : m11410) {
            File file = new File(str + "/lp_utils");
            if (file.exists() && file.canRead()) {
                try {
                    String[] split = m11486(file).split("%chelpus%");
                    if (split != null && split.length > 0) {
                        for (int i = 0; i < split.length; i++) {
                            if (i == 4) {
                                return m11602(split[i]);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                C3348.m12347("Lucky Patcher not found utils.");
            }
        }
        return null;
    }

    public static List<X509Certificate> m11348(byte[] bArr) {
        m11590();
        try {
            ContentInfo contentInfo = (ContentInfo) Asn1BerParser.parse(ByteBuffer.wrap(bArr), ContentInfo.class);
            if (Pkcs7Constants.OID_SIGNED_DATA.equals(contentInfo.contentType)) {
                SignedData signedData = (SignedData) Asn1BerParser.parse(contentInfo.content.getEncoded(), SignedData.class);
                if (signedData.signerInfos.isEmpty()) {
                    return null;
                }
                List<X509Certificate> list = null;
                for (SignerInfo signerInfo : signedData.signerInfos) {
                    if (list == null) {
                        try {
                            list = Certificate.parseCertificates(signedData.certificates);
                        } catch (CertificateException e) {
                            e.printStackTrace();
                            return null;
                        }
                    }
                }
                return list;
            }
            throw new Asn1DecodingException("Unsupported ContentInfo.contentType: " + contentInfo.contentType);
        } catch (Asn1DecodingException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static SpannableString m11349(String str, int i, String str2) {
        SpannableString spannableString = new SpannableString(str);
        try {
            ?? r1 = str2.toLowerCase().contains("bold");
            if (str2.toLowerCase().contains("bold_italic")) {
                r1 = 3;
            }
            int i2 = r1;
            if (str2.toLowerCase().contains("italic")) {
                i2 = 2;
            }
            spannableString.setSpan(new ForegroundColorSpan(i), 0, str.length(), 0);
            spannableString.setSpan(new StyleSpan(i2), 0, str.length(), 0);
            return spannableString;
        } catch (Exception e) {
            e.printStackTrace();
            if (str.length() == 0) {
                str = " ";
            }
            return new SpannableString(str);
        }
    }

    public static SpannableString m11350(String str, String str2, String str3) {
        if (str == null) {
            str = "";
        }
        SpannableString spannableString = new SpannableString(str);
        try {
            ?? r2 = str3.toLowerCase().contains("bold");
            if (str3.toLowerCase().contains("bold_italic")) {
                r2 = 3;
            }
            int i = r2;
            if (str3.toLowerCase().contains("italic")) {
                i = 2;
            }
            if (!str2.equals("")) {
                spannableString.setSpan(new ForegroundColorSpan(Color.parseColor(str2)), 0, str.length(), 0);
            }
            spannableString.setSpan(new StyleSpan(i), 0, str.length(), 0);
            return spannableString;
        } catch (Exception e) {
            e.printStackTrace();
            if (str.length() == 0) {
                str = " ";
            }
            return new SpannableString(str);
        }
    }

    public static String m11351() {
        try {
            if (C3348.f9871.contains("ART")) {
                return "ART";
            }
            if (!C3348.f9871.contains("DALVIK")) {
                return "ART";
            }
            return "Dalvik";
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Class<?> cls = Class.forName("android.os.SystemProperties");
                try {
                    Method method = cls.getMethod("get", String.class, String.class);
                    if (method == null) {
                        return "WTF?!";
                    }
                    try {
                        String str = (String) method.invoke(cls, "persist.sys.dalvik.vm.lib", "Dalvik");
                        C3348.m12347(str);
                        if ("libdvm.so".equals(str)) {
                            return "Dalvik";
                        }
                        if ("libart.so".equals(str)) {
                            return "ART";
                        }
                        if ("libartd.so".equals(str)) {
                            return "ART debug build";
                        }
                        return str;
                    } catch (IllegalAccessException unused) {
                        return "IllegalAccessException";
                    } catch (IllegalArgumentException unused2) {
                        return "IllegalArgumentException";
                    } catch (InvocationTargetException unused3) {
                        return "InvocationTargetException";
                    }
                } catch (NoSuchMethodException unused4) {
                    return "SystemProperties.get(String key, String def) method is not found";
                }
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
                return "Dalvik";
            } catch (Exception e3) {
                e3.printStackTrace();
                return "Dalvik";
            }
        }
    }

    public static ArrayList<C2988> m11352(String str) {
        m11590();
        ArrayList<C2988> arrayList = new ArrayList<>();
        try {
            File[] fileArr = C3348.f9881;
            int i = 0;
            if (fileArr == null || fileArr.length == 0 || C3348.f9882) {
                C3348.m12343(C3348.m12334());
                try {
                    C3348.f9876 = C3348.m12333().getString("basepath", C3348.f9876);
                    File file = new File(C3348.f9876 + "/CustomPatches");
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    C3348.f9881 = new File[file.listFiles().length];
                    C3348.f9881 = file.listFiles();
                    ArrayList arrayList2 = new ArrayList();
                    arrayList2.clear();
                    int i2 = 0;
                    while (true) {
                        File[] fileArr2 = C3348.f9881;
                        if (i2 >= fileArr2.length) {
                            break;
                        }
                        if (fileArr2[i2].isFile() && C3348.f9881[i2].getName().endsWith(".txt")) {
                            arrayList2.add(C3348.f9881[i2]);
                        }
                        i2++;
                    }
                    if (arrayList2.size() > 0) {
                        File[] fileArr3 = new File[arrayList2.size()];
                        C3348.f9881 = fileArr3;
                        C3348.f9881 = (File[]) arrayList2.toArray(fileArr3);
                    }
                } catch (Exception unused) {
                    C3348.m12347("Not found dir by Lucky Patcher. Custom patch not found.");
                }
                C3348.f9882 = false;
            }
            File[] fileArr4 = C3348.f9881;
            if (fileArr4 != null && fileArr4.length > 0) {
                while (true) {
                    File[] fileArr5 = C3348.f9881;
                    if (i >= fileArr5.length) {
                        break;
                    }
                    String name = fileArr5[i].getName();
                    if (name.contains("_%ALL%.txt")) {
                        if (str.contains(name.replace("_%ALL%.txt", ""))) {
                            arrayList.add(new C2988(C3348.f9881[i]));
                        } else if (name.contains("_%ALL%.txt") && name.contains("%ALL%_") && str.contains(name.split("%ALL%_")[1].replace("_%ALL%.txt", ""))) {
                            arrayList.add(new C2988(C3348.f9881[i]));
                        }
                    }
                    if (name.replace(".txt", "").endsWith(str)) {
                        arrayList.add(new C2988(C3348.f9881[i]));
                    }
                    i++;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return arrayList;
    }

    public static void m11353(File file, ArrayList<C3005> arrayList, ArrayList<Integer> arrayList2) {
        boolean z;
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C3348.m12347("run patchWithRestoreMethodsDex");
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                try {
                    for (DexBackedClassDef dexBackedClassDef : DexBackedDexFile.fromInputStream(null, bufferedInputStream2).getClasses()) {
                        if (dexBackedClassDef != null) {
                            Iterator<Integer> it = arrayList2.iterator();
                            while (it.hasNext()) {
                                C3005 c3005 = arrayList.get(it.next().intValue());
                                if (c3005.f8219.equals("") || dexBackedClassDef.getType().equals(c3005.f8219)) {
                                    for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                        if (dexBackedMethod != null && ((dexBackedMethod.getName().toLowerCase().contains(c3005.f8202.toLowerCase()) && !c3005.f8222) || (dexBackedMethod.getName().toLowerCase().equals(c3005.f8202.toLowerCase()) && c3005.f8222))) {
                                            if (dexBackedMethod.getReturnType().equals(c3005.f8206) || c3005.f8206.equals("")) {
                                                DexBackedMethodImplementation implementation = dexBackedMethod.getImplementation();
                                                if (implementation != null) {
                                                    if (!c3005.f8204.equals("")) {
                                                        String[] split = c3005.f8204.replaceAll("\\s+", "").split(",");
                                                        List<String> parameterTypes = dexBackedMethod.getParameterTypes();
                                                        if (split != null && parameterTypes != null && split.length == parameterTypes.size()) {
                                                            for (int i = 0; i < split.length; i++) {
                                                                C3348.m12347("LP compare paramemeters:" + split[i] + " " + parameterTypes.get(i));
                                                                if (split[i].equals(parameterTypes.get(i))) {
                                                                }
                                                            }
                                                        }
                                                        z = false;
                                                        if (!z) {
                                                            int i2 = implementation.codeOffset + 16;
                                                            System.out.println(dexBackedMethod.getName() + " " + i2);
                                                            System.out.println(dexBackedMethod.getDefiningClass());
                                                            System.out.println(dexBackedMethod.getReturnType());
                                                            int instructionsSize = implementation.getInstructionsSize() * 2;
                                                            if (instructionsSize >= c3005.f8195.length) {
                                                                c3005.f8200.add(Integer.valueOf(i2));
                                                                c3005.f8198.add(Integer.valueOf(instructionsSize));
                                                                c3005.f8194 = true;
                                                            } else {
                                                                c3005.f8220 = true;
                                                                C3348.m12347(dexBackedMethod.getName() + " exclude - not found space for bytes");
                                                            }
                                                        }
                                                    }
                                                    z = true;
                                                    if (!z) {
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    bufferedInputStream2.close();
                } catch (Throwable th) {
                    th = th;
                    bufferedInputStream = bufferedInputStream2;
                    try {
                        th.printStackTrace();
                        if (bufferedInputStream != null) {
                            bufferedInputStream.close();
                        }
                    } finally {
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static void m11354(File file, C2986 c2986) {
        String str;
        boolean z;
        String str2;
        String str3 = "";
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C3348.m12347("run patchWithRestoreMethodsDex");
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                try {
                    for (DexBackedClassDef dexBackedClassDef : DexBackedDexFile.fromInputStream(null, bufferedInputStream2).getClasses()) {
                        if (dexBackedClassDef != null) {
                            Iterator<C3004> it = c2986.f8050.iterator();
                            while (it.hasNext()) {
                                C3004 next = it.next();
                                for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                    if (dexBackedMethod != null && dexBackedMethod.getName().equals(next.f8181) && ((next.f8180.equals(str3) || dexBackedMethod.getDefiningClass().equals(next.f8180)) && (next.f8179.equals(str3) || dexBackedMethod.getReturnType().equals(next.f8179)))) {
                                        C3348.m12347("find " + dexBackedMethod.getName());
                                        DexBackedMethodImplementation implementation = dexBackedMethod.getImplementation();
                                        if (implementation != null) {
                                            if (!next.f8182.equals(str3)) {
                                                List<String> parameterTypes = dexBackedMethod.getParameterTypes();
                                                if (parameterTypes != null) {
                                                    Iterator<String> it2 = parameterTypes.iterator();
                                                    str2 = str3;
                                                    while (it2.hasNext()) {
                                                        str2 = str2 + it2.next();
                                                    }
                                                } else {
                                                    str2 = str3;
                                                }
                                                if (!next.f8182.equals(str2)) {
                                                    z = false;
                                                    if (z) {
                                                        int i = implementation.codeOffset;
                                                        int i2 = i + 16;
                                                        int i3 = i + 12;
                                                        PrintStream printStream = System.out;
                                                        StringBuilder sb = new StringBuilder();
                                                        str = str3;
                                                        sb.append(dexBackedMethod.getName());
                                                        sb.append(" ");
                                                        sb.append(i2);
                                                        printStream.println(sb.toString());
                                                        System.out.println(dexBackedMethod.getDefiningClass());
                                                        System.out.println(dexBackedMethod.getReturnType());
                                                        int instructionsSize = implementation.getInstructionsSize() * 2;
                                                        C3348.m12347("instr size:" + instructionsSize);
                                                        C3348.m12347("patch.repByte.length:" + next.f8168.length);
                                                        C3348.m12347("all size:" + implementation.getSizeToByte());
                                                        C3348.m12347("tries count:" + implementation.getTryBlocks().size());
                                                        if (implementation.getTryBlocks().size() > 0 && next.f8166 == null) {
                                                            instructionsSize = (implementation.getSizeToByte() / 2) * 2;
                                                            if (instructionsSize == implementation.getSizeToByte()) {
                                                                C3348.m12347("put new size up:" + (instructionsSize / 2));
                                                            } else {
                                                                C3348.m12347("put new size up:" + ((implementation.getSizeToByte() + 1) / 2));
                                                                instructionsSize = implementation.getSizeToByte() + 1;
                                                            }
                                                            next.f8186.add(Integer.valueOf(implementation.codeOffset + 6));
                                                            next.f8187.add(Integer.valueOf(i3));
                                                        } else {
                                                            next.f8186.add(0);
                                                            next.f8187.add(0);
                                                        }
                                                        if (instructionsSize >= next.f8168.length) {
                                                            next.f8184.add(Integer.valueOf(i2));
                                                            C3348.m12347("startMethodsAddress:" + next.f8184);
                                                            next.f8185.add(Integer.valueOf(instructionsSize));
                                                            next.f8189 = true;
                                                        } else {
                                                            next.f8190 = true;
                                                            c2986.m11680(C2979.m11674("Method patch") + ":\n" + next.f8183 + "\n" + C2972.f7912 + " " + m11423(R.string.custom_patch_log_method_patch_size_error) + "\n", file);
                                                            StringBuilder sb2 = new StringBuilder();
                                                            sb2.append(dexBackedMethod.getName());
                                                            sb2.append(" exclude - not found space for bytes");
                                                            C3348.m12347(sb2.toString());
                                                        }
                                                        str3 = str;
                                                    }
                                                }
                                            }
                                            z = true;
                                            if (z) {
                                            }
                                        }
                                    }
                                    str = str3;
                                    str3 = str;
                                }
                            }
                        }
                        str3 = str3;
                    }
                    bufferedInputStream2.close();
                } catch (Throwable th) {
                    th = th;
                    bufferedInputStream = bufferedInputStream2;
                    try {
                        th.printStackTrace();
                        if (bufferedInputStream != null) {
                            bufferedInputStream.close();
                        }
                    } finally {
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static String m11355() {
        new File("/data/local/tmp/").mkdirs();
        return "/data/local/tmp/";
    }

    public static void m11356(String str) {
        String string = C3348.m12333().getString("uninstall_after_reboot", "");
        if (string.equals("")) {
            C3348.m12333().edit().putString("uninstall_after_reboot", str).commit();
            return;
        }
        for (String str2 : string.split(",")) {
            if (str2.equals(str)) {
                return;
            }
        }
        C3348.m12333().edit().putString("uninstall_after_reboot", string + "," + str).commit();
    }

    public static File m11357(File file) {
        String[] split = file.toString().split(File.separator);
        String str = "";
        for (int i = 0; i < split.length; i++) {
            if (i != split.length - 1) {
                str = str + split[i] + File.separator;
            }
        }
        return new File(str);
    }

    public static Drawable m11358(C2800 c2800, C2799 c2799) {
        Bitmap bitmap;
        if (c2799 != null) {
            try {
                int i = (int) ((C3348.m12338().getDisplayMetrics().density * 35.0f) + 0.5f);
                try {
                    bitmap = BitmapFactory.decodeStream(c2800.m11032(c2799));
                } catch (Exception e) {
                    e.printStackTrace();
                    bitmap = null;
                }
                int width = bitmap.getWidth();
                int height = bitmap.getHeight();
                float f = i;
                Matrix matrix = new Matrix();
                matrix.postScale(f / width, f / height);
                return new BitmapDrawable(Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true));
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
        return null;
    }

    public static ArrayList<String> m11359(File file) throws ApkFormatException, IOException {
        m11590();
        ArrayList<String> arrayList = new ArrayList<>();
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(randomAccessFile)));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 2 && "uses-feature".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if (MediationMetaData.KEY_NAME.equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            int attributeValueType = androidBinXmlParser.getAttributeValueType(i);
                            if (attributeValueType != 1) {
                                if (attributeValueType == 3) {
                                    C4204 c4204 = new C4204(m11402(DataSources.asDataSource(randomAccessFile)));
                                    c4204.m12862();
                                    C4298 m12861 = c4204.m12861();
                                    arrayList.add(m12861.m13088(androidBinXmlParser.getAttributeIntValue(i)).get(0).m13090().mo13072(m12861, null));
                                }
                            } else {
                                arrayList.add(androidBinXmlParser.getAttributeStringValue(i));
                            }
                        }
                    }
                }
            }
            randomAccessFile.close();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static boolean m11360(File file) {
        try {
            try {
                FileInputStream fileInputStream = new FileInputStream(file);
                java.util.zip.ZipInputStream zipInputStream = new java.util.zip.ZipInputStream(fileInputStream);
                for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
                    if (nextEntry.getName().toLowerCase().equals("classes.dex")) {
                        zipInputStream.closeEntry();
                        zipInputStream.close();
                        fileInputStream.close();
                        return true;
                    }
                }
                zipInputStream.close();
                fileInputStream.close();
                return false;
            } catch (IOException e) {
                e.printStackTrace();
                return false;
            }
        } catch (Exception unused) {
            Iterator<C4199> it = C4201.m12846(file.getAbsolutePath()).m12848().values().iterator();
            while (it.hasNext()) {
                if (it.next().m12835().toLowerCase().equals("classes.dex")) {
                    return true;
                }
            }
            return false;
        }
    }

    public static byte[] m11361(File file) throws IOException {
        m11590();
        FileChannel channel = new RandomAccessFile(file, InternalZipConstants.READ_MODE).getChannel();
        MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
        map.position(0);
        int limit = map.limit() - map.position();
        if (limit <= 0) {
            return null;
        }
        byte[] bArr = new byte[limit];
        map.get(bArr);
        channel.close();
        return bArr;
    }

    public static byte[] m11362(File file, int i) {
        m11590();
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] bArr = new byte[i];
            fileInputStream.read(bArr);
            return bArr;
        } catch (IOException unused) {
            return null;
        }
    }

    public static File m11363(String str) {
        String str2;
        String str3;
        if (C3348.f9924 >= 23 && !str.startsWith("/system/")) {
            File file = new File(str);
            String str4 = "/arm";
            if (!new File("/data/dalvik-cache/arm").exists() || !new File("/data/dalvik-cache/arm").isDirectory()) {
                str3 = "";
            } else {
                str3 = "/arm";
            }
            if (new File("/data/dalvik-cache/arm64").exists() && new File("/data/dalvik-cache/arm64").isDirectory()) {
                str3 = "/arm64";
            }
            if (new File("/data/dalvik-cache/x86").exists() && new File("/data/dalvik-cache/x86").isDirectory()) {
                str3 = "/x86";
            }
            if (new File("/data/dalvik-cache/x86_64").exists() && new File("/data/dalvik-cache/x86_64").isDirectory()) {
                str3 = "/x86_64";
            }
            String m11587 = m11587(file.getName(), "odex");
            if (!m11462(str)) {
                if (str3.equals("/arm64")) {
                    File file2 = new File(m11357(file) + "/oat/arm/" + m11587);
                    if (file2.exists()) {
                    }
                }
                str4 = str3;
                File file3 = new File(m11357(file) + "/oat" + str4 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587);
                if (file3.exists()) {
                    return file3;
                }
            }
        }
        String replaceAll = str.replaceAll(InternalZipConstants.ZIP_FILE_SEPARATOR, "@");
        while (replaceAll.startsWith("@")) {
            replaceAll = replaceAll.replaceFirst("@", "");
        }
        String str5 = replaceAll + "@classes.dex";
        if (C3348.f9948.booleanValue()) {
            try {
                str2 = new C2880("").m11607(new File("/data/dalvik-cache"), str5);
                try {
                    if (str2.startsWith("/data/dalvik-cache/arm/")) {
                        if (new File("/data/dalvik-cache/arm64/" + str5).exists()) {
                            str2 = "/data/dalvik-cache/arm64/" + str5;
                        }
                    }
                } catch (IOException e) {
                    e = e;
                    e.printStackTrace();
                    if (!str2.equals("")) {
                    }
                } catch (Exception e2) {
                    e = e2;
                    e.printStackTrace();
                    if (!str2.equals("")) {
                    }
                }
            } catch (IOException e3) {
                e = e3;
                str2 = "";
            } catch (Exception e4) {
                e = e4;
                str2 = "";
            }
            if (!str2.equals("")) {
                C3348.m12347("" + str2);
                if (new File(str2).exists()) {
                    return new File(str2);
                }
                return null;
            }
            return null;
        }
        if (new File("/data/dalvik-cache/x86/" + str5).exists()) {
            return new File("/data/dalvik-cache/x86/" + str5);
        }
        if (new File("/data/dalvik-cache/x86_64/" + str5).exists()) {
            return new File("/data/dalvik-cache/x86_64/" + str5);
        }
        if (new File("/data/dalvik-cache/arm64/" + str5).exists()) {
            return new File("/data/dalvik-cache/arm64/" + str5);
        }
        if (new File("/data/dalvik-cache/arm/" + str5).exists()) {
            return new File("/data/dalvik-cache/arm/" + str5);
        }
        if (new File("/data/dalvik-cache/" + str5).exists()) {
            return new File("/data/dalvik-cache/" + str5);
        }
        return null;
    }

    public static File m11364(String str) {
        String str2 = "";
        if (new File("/data/art-cache/").exists()) {
            String replaceAll = str.replaceAll(InternalZipConstants.ZIP_FILE_SEPARATOR, "@");
            while (replaceAll.startsWith("@")) {
                replaceAll = replaceAll.replaceFirst("@", "");
            }
            String str3 = replaceAll + ".oat";
            if (new File("/data/art-cache/" + str3).exists()) {
                C3348.m12347("\nLuckyPatcher: found dalvik-cache! /data/art-cache/" + str3);
                return new File("/data/art-cache/" + str3);
            }
        }
        int i = 0;
        String[] strArr = {"/data/dalvik-cache/", "/data/dalvik-cache/arm64/", "/data/dalvik-cache/arm/", "/data/dalvik-cache/x86/", "/data/dalvik-cache/x86_64/", "/sd-ext/data/dalvik-cache/", "/cache/dalvik-cache/", "/sd-ext/data/cache/dalvik-cache/", "/data/cache/dalvik-cache/"};
        String replaceAll2 = str.replaceAll(InternalZipConstants.ZIP_FILE_SEPARATOR, "@");
        while (replaceAll2.startsWith("@")) {
            replaceAll2 = replaceAll2.replaceFirst("@", "");
        }
        String str4 = replaceAll2 + "@classes.dex";
        C3348.m12347("dalvikfile: " + str4);
        File file = null;
        for (int i2 = 9; i < i2; i2 = 9) {
            String str5 = strArr[i];
            if (new File(str5 + str4).exists()) {
                C3348.m12347("\nLuckyPatcher: found dalvik-cache! " + str5 + str4);
                StringBuilder sb = new StringBuilder();
                sb.append(str5);
                sb.append(str4);
                file = new File(sb.toString());
            }
            i++;
        }
        if (file == null) {
            if (!m11315("/data/dalvik-cache/arm") && !m11315("/data/dalvik-cache/arm64") && !m11315("/data/dalvik-cache/x86") && !m11315("/data/dalvik-cache/x86_64")) {
                file = new File("/data/dalvik-cache/" + str4);
            } else {
                if (m11315("/data/dalvik-cache/arm")) {
                    file = new File("/data/dalvik-cache/arm/" + str4);
                }
                if (m11315("/data/dalvik-cache/arm64")) {
                    file = new File("/data/dalvik-cache/arm64/" + str4);
                }
                if (m11315("/data/dalvik-cache/x86")) {
                    file = new File("/data/dalvik-cache/x86/" + str4);
                }
                if (m11315("/data/dalvik-cache/x86_64")) {
                    file = new File("/data/dalvik-cache/x86_64/" + str4);
                }
            }
        }
        if (C3348.f9924 >= 23 && !str.startsWith("/system/")) {
            File file2 = new File(str);
            String str6 = "/x86_64";
            String str7 = "/x86";
            String str8 = "/arm";
            if (C3348.f9948.booleanValue()) {
                if (new File("/data/dalvik-cache/arm").exists() && new File("/data/dalvik-cache/arm").isDirectory()) {
                    str2 = "/arm";
                }
                if (new File("/data/dalvik-cache/arm64").exists() && new File("/data/dalvik-cache/arm64").isDirectory()) {
                    str2 = "/arm64";
                }
                if (!new File("/data/dalvik-cache/x86").exists() || !new File("/data/dalvik-cache/x86").isDirectory()) {
                    str7 = str2;
                }
                if (new File("/data/dalvik-cache/x86_64").exists()) {
                }
                str6 = str7;
                String m11587 = m11587(file2.getName(), "odex");
                if (!m11462(str)) {
                    if (str6.equals("/arm64")) {
                        File file3 = new File(m11357(file2) + "/oat/arm/" + m11587);
                        if (file3.exists()) {
                        }
                    }
                    str8 = str6;
                    File file4 = new File(m11357(file2) + "/oat" + str8 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587);
                    if (file4.exists()) {
                        return file4;
                    }
                }
            } else {
                if (m11315("/data/dalvik-cache/arm")) {
                    str2 = "/arm";
                }
                if (m11315("/data/dalvik-cache/arm64")) {
                    str2 = "/arm64";
                }
                if (!m11315("/data/dalvik-cache/x86")) {
                    str7 = str2;
                }
            }
        }
        return file;
    }

    public static String m11365(String str) {
        int lastIndexOf = str.lastIndexOf(".");
        if (lastIndexOf != -1) {
            return str.substring(lastIndexOf + 1);
        }
        return "";
    }

    public static String m11366(String str) {
        String[] split = str.toString().split(File.separator);
        if (split != null) {
            return split[split.length - 1];
        }
        return "";
    }

    public static String m11367(String str) {
        String[] split = str.split("\\.");
        String str2 = "";
        for (int i = 0; i < split.length; i++) {
            if (i <= split.length - 3) {
                str2 = str2 + split[i] + ".";
            }
            if (i == split.length - 2) {
                str2 = str2 + split[i];
            }
        }
        return str2;
    }

    @SuppressLint({"NewApi"})
    public static String m11368(Context context, Uri uri, String str) {
        boolean isDocumentUri;
        String documentId;
        String documentId2;
        String documentId3;
        String str2 = ".apkm";
        if (!uri.toString().toLowerCase().endsWith(".apkm")) {
            str2 = "";
        }
        if (uri.toString().toLowerCase().endsWith(".xapk")) {
            str2 = ".xapk";
        }
        if (uri.toString().toLowerCase().endsWith(".apks")) {
            str2 = ".apks";
        }
        if (uri.toString().toLowerCase().endsWith(".lpzip")) {
            str2 = ".lpzip";
        }
        if (uri.toString().toLowerCase().endsWith(".apk")) {
            str2 = ".apk";
        }
        if (str2.equals("") && str.toLowerCase().equals("application/vnd.android.package-archive")) {
            str2 = "apk";
        }
        if (Build.VERSION.SDK_INT >= 19) {
            isDocumentUri = DocumentsContract.isDocumentUri(context, uri);
            if (isDocumentUri) {
                if (m11452(uri)) {
                    documentId3 = DocumentsContract.getDocumentId(uri);
                    return Environment.getExternalStorageDirectory() + InternalZipConstants.ZIP_FILE_SEPARATOR + documentId3.split(":")[1];
                }
                if (m11449(uri)) {
                    documentId2 = DocumentsContract.getDocumentId(uri);
                    uri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId2).longValue());
                } else if (m11455(uri)) {
                    documentId = DocumentsContract.getDocumentId(uri);
                    String[] split = documentId.split(":");
                    String str3 = split[0];
                    if ("image".equals(str3)) {
                        uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                    } else if ("video".equals(str3)) {
                        uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                    } else if ("audio".equals(str3)) {
                        uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                    }
                    String str4 = split[1];
                }
            }
        }
        C3348.m12347(uri.getScheme());
        if ("content".equalsIgnoreCase(uri.getScheme())) {
            C3348.m12347("LP: content scheme analize.");
            C3348.m12347("Lucky Patcher: alternative get path from uri");
            try {
                File file = new File(C3348.f9876 + "/tmp2/forAdd." + str2);
                StringBuilder sb = new StringBuilder();
                sb.append(C3348.f9876);
                sb.append("/tmp2/");
                new File(sb.toString()).mkdirs();
                InputStream openInputStream = C3348.m12334().getContentResolver().openInputStream(uri);
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                byte[] bArr = new byte[4096];
                while (true) {
                    int read = openInputStream.read(bArr);
                    if (read != -1) {
                        fileOutputStream.write(bArr, 0, read);
                    } else {
                        openInputStream.close();
                        fileOutputStream.close();
                        C3348.m12347(file.getAbsolutePath() + " " + file.length());
                        return file.getAbsolutePath();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        } else {
            if ("file".equalsIgnoreCase(uri.getScheme())) {
                return uri.getPath();
            }
            return null;
        }
    }

    public static ArrayList<File> m11369(String[] strArr, String str) {
        ArrayList<File> arrayList = new ArrayList<>();
        int length = strArr.length;
        for (int i = 0; i < length; i++) {
            String str2 = strArr[i];
            if (!str.equals("")) {
                str2 = m11587(str2, str);
            }
            if (new File(str2).exists()) {
                arrayList.add(new File(str2));
            }
        }
        return arrayList;
    }

    public static void m11370(String str, File file, ArrayList<File> arrayList) {
        File[] listFiles = file.listFiles();
        if (listFiles != null && listFiles.length != 0) {
            for (File file2 : listFiles) {
                if (file2.getAbsolutePath().endsWith(".apk")) {
                    try {
                        if (str.equals(new C3312(C3348.m12334(), file2, false).f9776) && m11444(file2)) {
                            arrayList.add(file2);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            for (File file3 : listFiles) {
                if (file3.isDirectory()) {
                    try {
                        File[] listFiles2 = file3.listFiles();
                        if (listFiles2 != null && listFiles2.length != 0) {
                            for (File file4 : listFiles2) {
                                if (file4.getAbsolutePath().endsWith(".apk")) {
                                    try {
                                        if (str.equals(new C3312(C3348.m12334(), file4, false).f9776) && m11444(file4)) {
                                            arrayList.add(file4);
                                        }
                                    } catch (Exception e2) {
                                        e2.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                }
            }
            return;
        }
        C3348.m12347("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
    }

    public static ArrayList<File> m11371(C3001 c3001) {
        ArrayList<File> arrayList;
        ArrayList<File> arrayList2 = new ArrayList<>();
        ArrayList arrayList3 = new ArrayList();
        String[] strArr = {"/system/framework/x86/boot.oat", "/system/framework/x86_64/boot.oat", "/system/framework/arm64/boot.oat", "/system/framework/arm/boot.oat", "/system/framework/oat/x86/boot.oat", "/system/framework/oat/x86_64/boot.oat", "/system/framework/oat/arm64/boot.oat", "/system/framework/oat/arm/boot.oat", "/system/framework/x86/apex.oat", "/system/framework/x86_64/apex.oat", "/system/framework/arm64/apex.oat", "/system/framework/arm/apex.oat", "/system/framework/oat/x86/apex.oat", "/system/framework/oat/x86_64/apex.oat", "/system/framework/oat/arm64/apex.oat", "/system/framework/oat/arm/apex.oat", "/system/apex/com.android.art/javalib/arm64/boot.oat", "/system/apex/com.android.art/javalib/arm/boot.oat", "/system/apex/com.android.art/javalib/x86/boot.oat", "/system/apex/com.android.art/javalib/x86_64/boot.oat", "/system/apex/com.android.art.release/javalib/arm64/boot.oat", "/system/apex/com.android.art.release/javalib/arm/boot.oat", "/system/apex/com.android.art.release/javalib/x86/boot.oat", "/system/apex/com.android.art.release/javalib/x86_64/boot.oat", "/system/apex/com.android.art.debug/javalib/arm64/boot.oat", "/system/apex/com.android.art.debug/javalib/arm/boot.oat", "/system/apex/com.android.art.debug/javalib/x86/boot.oat", "/system/apex/com.android.art.debug/javalib/x86_64/boot.oat", "/system/apex/com.android.runtime.release/javalib/arm64/boot.oat", "/system/apex/com.android.runtime.release/javalib/arm/boot.oat", "/system/apex/com.android.runtime.release/javalib/x86/boot.oat", "/system/apex/com.android.runtime.release/javalib/x86_64/boot.oat", "/system/apex/com.android.runtime.debug/javalib/arm64/boot.oat", "/system/apex/com.android.runtime.debug/javalib/arm/boot.oat", "/system/apex/com.android.runtime.debug/javalib/x86/boot.oat", "/system/apex/com.android.runtime.debug/javalib/x86_64/boot.oat"};
        ArrayList<File> m11369 = m11369(strArr, "");
        ArrayList<File> m113692 = m11369(strArr, "vdex");
        ArrayList<File> m113693 = m11369(strArr, "art");
        String[] strArr2 = {"/data/dalvik-cache/x86/system@framework@boot.oat", "/data/dalvik-cache/x86_64/system@framework@boot.oat", "/data/dalvik-cache/arm64/system@framework@boot.oat", "/data/dalvik-cache/arm/system@framework@boot.oat", "/data/dalvik-cache/oat/x86/system@framework@boot.oat", "/data/dalvik-cache/oat/x86_64/system@framework@boot.oat", "/data/dalvik-cache/oat/arm64/system@framework@boot.oat", "/data/dalvik-cache/oat/arm/system@framework@boot.oat", "/data/dalvik-cache/x86/system@framework@apex.oat", "/data/dalvik-cache/x86_64/system@framework@apex.oat", "/data/dalvik-cache/arm64/system@framework@apex.oat", "/data/dalvik-cache/arm/system@framework@apex.oat", "/data/dalvik-cache/oat/x86/system@framework@apex.oat", "/data/dalvik-cache/oat/x86_64/system@framework@apex.oat", "/data/dalvik-cache/oat/arm64/system@framework@apex.oat", "/data/dalvik-cache/oat/arm/system@framework@apex.oat", "/data/dalvik-cache/x86/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/x86_64/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/arm64/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/arm/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/oat/x86/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/oat/x86_64/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/oat/arm64/apex@com.android.art@javalib@boot.oat", "/data/dalvik-cache/oat/arm/apex@com.android.art@javalib@boot.oat"};
        ArrayList<File> m113694 = m11369(strArr2, "");
        ArrayList<File> m113695 = m11369(strArr2, "vdex");
        ArrayList<File> m113696 = m11369(strArr2, "art");
        ArrayList<File> m113697 = m11369(new String[]{"/data/dalvik-cache/x86/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/x86_64/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/arm64/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/arm/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/oat/x86/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/oat/x86_64/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/oat/arm64/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/oat/arm/system@framework@boot-conscrypt.oat", "/data/dalvik-cache/x86/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/x86_64/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/arm64/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/arm/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/oat/x86/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/oat/x86_64/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/oat/arm64/apex@com.android.conscrypt@javalib@boot-conscrypt.oat", "/data/dalvik-cache/oat/arm/apex@com.android.conscrypt@javalib@boot-conscrypt.oat"}, "");
        ArrayList<File> m113698 = m11369(new String[]{"/system/framework/x86/boot-conscrypt.oat", "/system/framework/x86_64/boot-conscrypt.oat", "/system/framework/arm64/boot-conscrypt.oat", "/system/framework/arm/boot-conscrypt.oat", "/system/framework/oat/x86/boot-conscrypt.oat", "/system/framework/oat/x86_64/boot-conscrypt.oat", "/system/framework/oat/arm64/boot-conscrypt.oat", "/system/framework/oat/arm/boot-conscrypt.oat", "/system/apex/com.android.conscrypt/javalib/arm64/boot-conscrypt.oat", "/system/apex/com.android.conscrypt/javalib/arm/boot-conscrypt.oat", "/system/apex/com.android.conscrypt/javalib/x86/boot-conscrypt.oat", "/system/apex/com.android.conscrypt/javalib/x86_64/boot-conscrypt.oat"}, "");
        ArrayList<File> m113699 = m11369(new String[]{"/system/framework/conscrypt.jar", "/system/apex/com.android.conscrypt/javalib/conscrypt.jar"}, "");
        ArrayList<File> m1136910 = m11369(new String[]{"/system/framework/x86/boot-core-oj.oat", "/system/framework/x86_64/boot-core-oj.oat", "/system/framework/arm64/boot-core-oj.oat", "/system/framework/arm/boot-core-oj.oat", "/system/framework/oat/x86/boot-core-oj.oat", "/system/framework/oat/x86_64/boot-core-oj.oat", "/system/framework/oat/arm64/boot-core-oj.oat", "/system/framework/oat/arm/boot-core-oj.oat", "/system/apex/com.android.art/javalib/arm64/boot-core-oj.oat", "/system/apex/com.android.art/javalib/arm/boot-core-oj.oat", "/system/apex/com.android.art/javalib/x86/boot-core-oj.oat", "/system/apex/com.android.art/javalib/x86_64/boot-core-oj.oat", "/system/apex/com.android.art.release/javalib/arm64/boot-core-oj.oat", "/system/apex/com.android.art.release/javalib/arm/boot-core-oj.oat", "/system/apex/com.android.art.release/javalib/x86/boot-core-oj.oat", "/system/apex/com.android.art.release/javalib/x86_64/boot-core-oj.oat", "/system/apex/com.android.art.debug/javalib/arm64/boot-core-oj.oat", "/system/apex/com.android.art.debug/javalib/arm/boot-core-oj.oat", "/system/apex/com.android.art.debug/javalib/x86/boot-core-oj.oat", "/system/apex/com.android.art.debug/javalib/x86_64/boot-core-oj.oat", "/system/apex/com.android.runtime.release/javalib/arm64/boot-core-oj.oat", "/system/apex/com.android.runtime.release/javalib/arm/boot-core-oj.oat", "/system/apex/com.android.runtime.release/javalib/x86/boot-core-oj.oat", "/system/apex/com.android.runtime.release/javalib/x86_64/boot-core-oj.oat", "/system/apex/com.android.runtime.debug/javalib/arm64/boot-core-oj.oat", "/system/apex/com.android.runtime.debug/javalib/arm/boot-core-oj.oat", "/system/apex/com.android.runtime.debug/javalib/x86/boot-core-oj.oat", "/system/apex/com.android.runtime.debug/javalib/x86_64/boot-core-oj.oat"}, "");
        ArrayList<File> m1136911 = m11369(new String[]{"/system/framework/core-oj.jar", "/system/apex/com.android.art/javalib/core-oj.jar", "/system/apex/com.android.art.release/javalib/core-oj.jar", "/system/apex/com.android.art.debug/javalib/core-oj.jar", "/system/apex/com.android.runtime.release/javalib/core-oj.jar", "/system/apex/com.android.runtime.debug/javalib/core-oj.jar"}, "");
        ArrayList<File> m1136912 = m11369(new String[]{"/data/dalvik-cache/x86/system@framework@boot-core-oj.oat", "/data/dalvik-cache/x86_64/system@framework@boot-core-oj.oat", "/data/dalvik-cache/arm64/system@framework@boot-core-oj.oat", "/data/dalvik-cache/arm/system@framework@boot-core-oj.oat", "/data/dalvik-cache/oat/x86/system@framework@boot-core-oj.oat", "/data/dalvik-cache/oat/x86_64/system@framework@boot-core-oj.oat", "/data/dalvik-cache/oat/arm64/system@framework@boot-core-oj.oat", "/data/dalvik-cache/oat/arm/system@framework@boot-core-oj.oat"}, "");
        ArrayList<File> arrayList4 = arrayList2;
        ArrayList<File> m1136913 = m11369(new String[]{"/system/framework/arm/services.odex", "/system/framework/arm64/services.odex", "/system/framework/x86/services.odex", "/system/framework/x86_64/services.odex", "/system/framework/oat/arm/services.odex", "/system/framework/oat/arm64/services.odex", "/system/framework/oat/x86/services.odex", "/system/framework/oat/x86_64/services.odex"}, "");
        String[] strArr3 = {"/data/dalvik-cache/arm/system@framework@services.jar@classes.dex", "/data/dalvik-cache/arm64/system@framework@services.jar@classes.dex", "/data/dalvik-cache/x86/system@framework@services.jar@classes.dex", "/data/dalvik-cache/x86_64/system@framework@services.jar@classes.dex", "/data/dalvik-cache/oat/arm/system@framework@services.jar@classes.dex", "/data/dalvik-cache/oat/arm64/system@framework@services.jar@classes.dex", "/data/dalvik-cache/oat/x86/system@framework@services.jar@classes.dex", "/data/dalvik-cache/oat/x86_64/system@framework@services.jar@classes.dex"};
        ArrayList<File> m1136914 = m11369(strArr3, "");
        ArrayList<File> m1136915 = m11369(strArr3, "art");
        ArrayList<File> m1136916 = m11369(strArr3, "vdex");
        ArrayList<File> m1136917 = m11369(new String[]{"/system/framework/services.jar"}, "");
        ArrayList<File> m1136918 = m11369(new String[]{"/system/framework/arm/services.vdex", "/system/framework/arm64/services.vdex", "/system/framework/x86/services.vdex", "/system/framework/x86_64/services.vdex", "/system/framework/oat/arm/services.vdex", "/system/framework/oat/arm64/services.vdex", "/system/framework/oat/x86/services.vdex", "/system/framework/oat/x86_64/services.vdex"}, "");
        ArrayList<File> m1136919 = m11369(new String[]{"/system/framework/arm/boot-framework.oat", "/system/framework/arm64/boot-framework.oat", "/system/framework/x86/boot-framework.oat", "/system/framework/x86_64/boot-framework.oat", "/system/framework/oat/arm/boot-framework.oat", "/system/framework/oat/arm64/boot-framework.oat", "/system/framework/oat/x86/boot-framework.oat", "/system/framework/oat/x86_64/boot-framework.oat", "/system/framework/arm/apex-framework.oat", "/system/framework/arm64/apex-framework.oat", "/system/framework/x86/apex-framework.oat", "/system/framework/x86_64/apex-framework.oat", "/system/framework/oat/arm/apex-framework.oat", "/system/framework/oat/arm64/apex-framework.oat", "/system/framework/oat/x86/apex-framework.oat", "/system/framework/oat/x86_64/apex-framework.oat", "/system/framework/arm/framework.odex", "/system/framework/arm64/framework.odex", "/system/framework/x86/framework.odex", "/system/framework/x86_64/framework.odex", "/system/framework/oat/arm/framework.odex", "/system/framework/oat/arm64/framework.odex", "/system/framework/oat/x86/framework.odex", "/system/framework/oat/x86_64/framework.odex"}, "");
        ArrayList<File> m1136920 = m11369(new String[]{"/data/dalvik-cache/arm/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/arm64/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/x86/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/x86_64/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/oat/arm/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/oat/arm64/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/oat/x86/system@framework@framework.jar@classes.dex", "/data/dalvik-cache/oat/x86_64/system@framework@framework.jar@classes.dex"}, "");
        ArrayList<File> m1136921 = m11369(new String[]{"/system/framework/framework.jar"}, "");
        ArrayList<File> m1136922 = m11369(new String[]{"/system/framework/boot-framework.vdex"}, "");
        if (c3001.f8135) {
            Iterator<File> it = m113696.iterator();
            while (it.hasNext()) {
                arrayList3.add(it.next());
            }
        }
        if (c3001.f8133) {
            Iterator<File> it2 = m113693.iterator();
            while (it2.hasNext()) {
                arrayList3.add(it2.next());
            }
        }
        if (c3001.f8136) {
            Iterator<File> it3 = m113695.iterator();
            while (it3.hasNext()) {
                arrayList3.add(it3.next());
            }
        }
        if (c3001.f8134) {
            Iterator<File> it4 = m113692.iterator();
            while (it4.hasNext()) {
                arrayList3.add(it4.next());
            }
        }
        if (c3001.f8138) {
            Iterator<File> it5 = m113694.iterator();
            while (it5.hasNext()) {
                arrayList3.add(it5.next());
            }
        }
        if (c3001.f8137) {
            Iterator<File> it6 = m11369.iterator();
            while (it6.hasNext()) {
                arrayList3.add(it6.next());
            }
        }
        if (c3001.f8140) {
            Iterator<File> it7 = m113697.iterator();
            while (it7.hasNext()) {
                arrayList3.add(it7.next());
            }
        }
        if (c3001.f8139) {
            Iterator<File> it8 = m113698.iterator();
            while (it8.hasNext()) {
                arrayList3.add(it8.next());
            }
        }
        if (c3001.f8141) {
            Iterator<File> it9 = m113699.iterator();
            while (it9.hasNext()) {
                arrayList3.add(it9.next());
            }
        }
        if (c3001.f8143) {
            Iterator<File> it10 = m1136912.iterator();
            while (it10.hasNext()) {
                arrayList3.add(it10.next());
            }
        }
        if (c3001.f8142) {
            Iterator<File> it11 = m1136910.iterator();
            while (it11.hasNext()) {
                arrayList3.add(it11.next());
            }
        }
        if (c3001.f8144) {
            if (m1136911.size() > 0) {
                Iterator<File> it12 = m1136911.iterator();
                while (it12.hasNext()) {
                    arrayList3.add(it12.next());
                }
            } else {
                File file = new File("/system/framework/core.jar");
                File file2 = new File("/system/framework/core-libart.jar");
                if (file2.exists()) {
                    arrayList3.add(file2);
                } else if (file.exists()) {
                    arrayList3.add(file);
                }
            }
        }
        if (c3001.f8146) {
            Iterator<File> it13 = m1136914.iterator();
            while (it13.hasNext()) {
                arrayList3.add(it13.next());
            }
        }
        if (c3001.f8147) {
            Iterator<File> it14 = m1136915.iterator();
            while (it14.hasNext()) {
                arrayList3.add(it14.next());
            }
        }
        if (c3001.f8148) {
            Iterator<File> it15 = m1136916.iterator();
            while (it15.hasNext()) {
                arrayList3.add(it15.next());
            }
        }
        if (c3001.f8145) {
            Iterator<File> it16 = m1136913.iterator();
            while (it16.hasNext()) {
                arrayList3.add(it16.next());
            }
        }
        if (c3001.f8149) {
            Iterator<File> it17 = m1136917.iterator();
            while (it17.hasNext()) {
                arrayList3.add(it17.next());
            }
        }
        if (c3001.f8150) {
            Iterator<File> it18 = m1136918.iterator();
            while (it18.hasNext()) {
                arrayList3.add(it18.next());
            }
        }
        if (c3001.f8152) {
            Iterator<File> it19 = m1136920.iterator();
            while (it19.hasNext()) {
                arrayList3.add(it19.next());
            }
        }
        if (c3001.f8151) {
            Iterator<File> it20 = m1136919.iterator();
            while (it20.hasNext()) {
                arrayList3.add(it20.next());
            }
        }
        if (c3001.f8155) {
            Iterator<File> it21 = m1136921.iterator();
            while (it21.hasNext()) {
                arrayList3.add(it21.next());
            }
        }
        if (c3001.f8156) {
            Iterator<File> it22 = m1136922.iterator();
            while (it22.hasNext()) {
                arrayList3.add(it22.next());
            }
        }
        Iterator it23 = arrayList3.iterator();
        while (it23.hasNext()) {
            File file3 = (File) it23.next();
            if (c3001.f8157) {
                File m11297 = m11297(file3.getAbsolutePath());
                if (c3001.f8156 && m11297.exists() && m11297.getAbsolutePath().endsWith(".vdex")) {
                    arrayList = arrayList4;
                    arrayList.add(m11297);
                } else {
                    arrayList = arrayList4;
                }
                if (m11297.exists() && (m11297.getAbsolutePath().endsWith(".oat") || m11297.getAbsolutePath().endsWith(".odex") || m11297.getAbsolutePath().endsWith(".jar"))) {
                    arrayList.add(m11297);
                }
            } else {
                arrayList = arrayList4;
                arrayList.add(file3);
            }
            arrayList4 = arrayList;
        }
        return arrayList4;
    }

    public static Drawable m11372(File file) {
        Bitmap bitmap;
        m11590();
        try {
            C2800 c2800 = new C2800(file);
            C2799 m11031 = c2800.m11031("icon.png");
            if (m11031 != null) {
                int i = (int) ((C3348.m12338().getDisplayMetrics().density * 35.0f) + 0.5f);
                try {
                    bitmap = BitmapFactory.decodeStream(c2800.m11032(m11031));
                } catch (Exception e) {
                    e.printStackTrace();
                    bitmap = null;
                }
                Bitmap bitmap2 = bitmap;
                int width = bitmap2.getWidth();
                int height = bitmap2.getHeight();
                float f = i;
                Matrix matrix = new Matrix();
                matrix.postScale(f / width, f / height);
                return new BitmapDrawable(Bitmap.createBitmap(bitmap2, 0, 0, width, height, matrix, true));
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return m11335(m11344(file).getAbsolutePath());
    }

    public static Drawable m11373(File file) {
        Bitmap bitmap;
        m11590();
        if (file != null) {
            try {
                if (file.exists()) {
                    int i = (int) ((C3348.m12338().getDisplayMetrics().density * 35.0f) + 0.5f);
                    try {
                        bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
                    } catch (Exception e) {
                        e.printStackTrace();
                        bitmap = null;
                    }
                    int width = bitmap.getWidth();
                    int height = bitmap.getHeight();
                    float f = i;
                    Matrix matrix = new Matrix();
                    matrix.postScale(f / width, f / height);
                    return new BitmapDrawable(Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true));
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
        return null;
    }

    public static long m11374() {
        String[] split;
        String m11385 = m11385();
        long j = 0;
        if (new File(m11385 + "/module.prop").exists()) {
            try {
                String m11486 = m11486(new File(m11385 + "/module.prop"));
                if (m11486 != null && (split = m11486.split("\n")) != null) {
                    for (String str : split) {
                        if (str.startsWith("version=")) {
                            try {
                                j = Long.decode(str.substring(str.indexOf("=") + 1)).longValue();
                            } catch (Throwable unused) {
                            }
                            C3348.m12347("firmware crc:" + j);
                            return j;
                        }
                    }
                }
            } catch (Throwable unused2) {
            }
        }
        return j;
    }

    public static String m11375() {
        String[] split;
        String m11385 = m11385();
        String str = "";
        if (new File(m11385 + "/module.prop").exists()) {
            try {
                String m11486 = m11486(new File(m11385 + "/module.prop"));
                if (m11486 != null && (split = m11486.split("\n")) != null) {
                    for (String str2 : split) {
                        if (str2.startsWith("version=")) {
                            try {
                                str = str2.substring(str2.indexOf("=") + 1);
                            } catch (Throwable unused) {
                            }
                            C3348.m12347("firmware crc:" + str);
                            return str;
                        }
                    }
                }
            } catch (Throwable unused2) {
            }
        }
        return str;
    }

    public static boolean m11376(String str, ArrayList<C2993> arrayList, boolean z, boolean z2) {
        Iterator it;
        char c;
        m11590();
        C3348.m12347("scan: " + str);
        ArrayList arrayList2 = new ArrayList();
        char c2 = 2;
        char c3 = 3;
        boolean z3 = false;
        if (C3348.f9948.booleanValue()) {
            m11508("chmod", "777", str);
        } else if (C3348.f9908) {
            m11506("chmod 777 " + str);
        }
        new ArrayList();
        if (!z && str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        if (new File(str).exists()) {
                            try {
                                FileChannel channel = new RandomAccessFile(str, InternalZipConstants.READ_MODE).getChannel();
                                MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
                                map.position(0);
                                if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                    map.position(64);
                                    int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                    int m115922 = m11592(map.get(), map.get(), map.get(), map.get());
                                    C3348.m12347("LuckyPatcher offset_to_data=" + Integer.toHexString(m115922));
                                    map.position(m115922);
                                    int i = 0;
                                    int i2 = 0;
                                    while (true) {
                                        c = 4;
                                        if (i >= m11592) {
                                            break;
                                        }
                                        byte[] bArr = {map.get(), map.get(), map.get(), map.get()};
                                        Iterator<C2993> it2 = arrayList.iterator();
                                        while (it2.hasNext()) {
                                            C2993 next = it2.next();
                                            byte b = bArr[0];
                                            byte[] bArr2 = next.f8087;
                                            if (b == bArr2[0] && bArr[1] == bArr2[1] && bArr[2] == bArr2[2] && bArr[3] == bArr2[3]) {
                                                byte[] bArr3 = next.f8089;
                                                bArr3[0] = (byte) i2;
                                                bArr3[1] = (byte) (i2 >> 8);
                                                next.f8093 = true;
                                            }
                                        }
                                        i2++;
                                        i++;
                                    }
                                    Iterator<C2993> it3 = arrayList.iterator();
                                    boolean z4 = false;
                                    while (it3.hasNext()) {
                                        if (it3.next().f8093) {
                                            z4 = true;
                                        }
                                    }
                                    if (z4) {
                                        map.position(88);
                                        int m115923 = m11592(map.get(), map.get(), map.get(), map.get());
                                        map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                        byte[] bArr4 = new byte[m115923];
                                        int i3 = 0;
                                        boolean z5 = false;
                                        int i4 = 0;
                                        while (i3 < m115923) {
                                            try {
                                                byte[] bArr5 = new byte[8];
                                                bArr5[0] = map.get();
                                                bArr5[1] = map.get();
                                                bArr5[c2] = map.get();
                                                bArr5[c3] = map.get();
                                                bArr5[c] = map.get();
                                                bArr5[5] = map.get();
                                                bArr5[6] = map.get();
                                                bArr5[7] = map.get();
                                                Iterator<C2993> it4 = arrayList.iterator();
                                                while (it4.hasNext()) {
                                                    C2993 next2 = it4.next();
                                                    byte b2 = bArr5[0];
                                                    byte[] bArr6 = next2.f8089;
                                                    if (b2 == bArr6[0] && bArr5[1] == bArr6[1] && m11569(map, next2, m11291(bArr5[c2], bArr5[3]))) {
                                                        byte b3 = bArr5[4];
                                                        byte[] bArr7 = next2.f8088;
                                                        if (b3 == bArr7[0] && bArr5[5] == bArr7[1] && bArr5[6] == bArr7[c2] && bArr5[7] == bArr7[3]) {
                                                            if (!z2 || !next2.f8092) {
                                                                if (next2.f8092) {
                                                                    C2993 c2993 = new C2993(next2);
                                                                    byte[] bArr8 = c2993.f8090;
                                                                    bArr8[0] = (byte) i4;
                                                                    bArr8[1] = (byte) (i4 >> 8);
                                                                    c2993.f8092 = true;
                                                                    c2993.f8096 = true;
                                                                    arrayList2.add(c2993);
                                                                } else {
                                                                    StringBuilder sb = new StringBuilder();
                                                                    sb.append("");
                                                                    byte b4 = (byte) i4;
                                                                    sb.append(Integer.toHexString(b4));
                                                                    sb.append(" ");
                                                                    byte b5 = (byte) (i4 >> 8);
                                                                    sb.append(Integer.toHexString(b5));
                                                                    C3348.m12347(sb.toString());
                                                                    byte[] bArr9 = next2.f8090;
                                                                    bArr9[0] = b4;
                                                                    bArr9[1] = b5;
                                                                    next2.f8092 = true;
                                                                    next2.f8096 = true;
                                                                }
                                                                z5 = true;
                                                            }
                                                        }
                                                    }
                                                    c2 = 2;
                                                }
                                                i4++;
                                                i3++;
                                                c2 = 2;
                                                c3 = 3;
                                                c = 4;
                                            } catch (Exception e) {
                                                e = e;
                                                z3 = z5;
                                                e.printStackTrace();
                                                it = arrayList2.iterator();
                                                while (it.hasNext()) {
                                                }
                                                return z3;
                                            }
                                        }
                                        z3 = z5;
                                    }
                                }
                                channel.close();
                            } catch (Exception e2) {
                                e = e2;
                            }
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                }
            } catch (Exception e4) {
                C3348.m12347(e4);
            }
        }
        it = arrayList2.iterator();
        while (it.hasNext()) {
            arrayList.add((C2993) it.next());
        }
        return z3;
    }

    public static ArrayList<C3346> m11377() {
        String m11438;
        boolean z;
        boolean z2;
        m11590();
        if (!C3348.f9948.booleanValue()) {
            m11438 = new C2880("").m11618(C3348.f9875 + "/busybox mount");
            if (m11438.startsWith("~")) {
                m11317();
                try {
                    C3348.m12342();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                m11438 = new C2880("").m11618("mount");
                if (m11438.startsWith("~")) {
                    m11438 = new C2880("").m11618("busybox mount");
                }
                if (m11438.startsWith("~")) {
                    m11438 = new C2880("").m11618("toolbox mount");
                }
            }
        } else {
            m11438 = m11438(C3348.f9875 + "/busybox", "mount");
            if (m11438.startsWith("~")) {
                m11438 = m11438("mount");
                if (m11438.startsWith("~")) {
                    m11438 = m11438("busybox", "mount");
                }
                if (m11438.startsWith("~")) {
                    m11438 = m11438("toolbox", "mount");
                }
            }
        }
        String[] split = m11438.split("\n");
        ArrayList<C3346> arrayList = new ArrayList<>();
        try {
            z = false;
            z2 = false;
            for (String str : split) {
                try {
                    String[] split2 = str.replace(" on ", " ").replace(" type ", " ").split("\\s+");
                    if (split2[1].startsWith("/system")) {
                        z = true;
                    }
                    if (split2[1].contains("magisk")) {
                        try {
                            f7701 = true;
                            z2 = true;
                        } catch (Exception e2) {
                            e = e2;
                            z2 = true;
                            e.printStackTrace();
                            return z ? arrayList : arrayList;
                        }
                    }
                    arrayList.add(new C3346(new File(split2[0]), new File(split2[1]), split2[2], split2[3]));
                } catch (Exception e3) {
                    e = e3;
                }
            }
        } catch (Exception e4) {
            e = e4;
            z = false;
            z2 = false;
        }
        if (z && !z2) {
            C3348.m12347("LuckyPatcher: get mounts from /proc/mounts");
            if (!C3348.f9948.booleanValue()) {
                m11294("/proc/mounts", "/data/local/RootToolsMounts", false, true);
                m11506("chmod 777 /data/local/RootToolsMounts");
            } else {
                m11294("/proc/mounts", "/data/local/RootToolsMounts", false, true);
                m11508("chmod", "777", "/data/local/RootToolsMounts");
            }
            arrayList.clear();
            try {
                LineNumberReader lineNumberReader = new LineNumberReader(new FileReader("/data/local/RootToolsMounts"));
                ArrayList<C3346> arrayList2 = new ArrayList<>();
                while (true) {
                    try {
                        String readLine = lineNumberReader.readLine();
                        if (readLine != null) {
                            String[] split3 = readLine.split(" ");
                            arrayList2.add(new C3346(new File(split3[0]), new File(split3[1]), split3[2], split3[3]));
                        } else {
                            lineNumberReader.close();
                            return arrayList2;
                        }
                    } catch (Exception e5) {
                        e = e5;
                        arrayList = arrayList2;
                        e.printStackTrace();
                        return arrayList;
                    }
                }
            } catch (Exception e6) {
                e = e6;
            }
        }
    }

    public static String m11378(File file, String str) {
        FileChannel fileChannel = null;
        try {
            try {
                fileChannel = new RandomAccessFile(file, InternalZipConstants.READ_MODE).getChannel();
                MappedByteBuffer map = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) fileChannel.size());
                byte[] bytes = str.getBytes("UTF-8");
                int i = 4096;
                while (map.hasRemaining() && map.position() < 10000) {
                    map.position(i);
                    for (int i2 = 0; i2 < bytes.length && map.get() == bytes[i2]; i2++) {
                        if (i2 == bytes.length - 1 && map.get() == 61) {
                            int position = map.position();
                            while (map.hasRemaining() && map.position() < 10000) {
                                if (map.get() == 32) {
                                    byte[] bArr = new byte[(map.position() - 1) - position];
                                    map.position(position);
                                    map.get(bArr);
                                    fileChannel.close();
                                    String str2 = new String(bArr, "UTF-8");
                                    try {
                                        fileChannel.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    return str2;
                                }
                            }
                        }
                    }
                    i++;
                }
                fileChannel.close();
                return "";
            } catch (IOException e2) {
                e2.printStackTrace();
                return "";
            }
        } catch (Throwable th) {
            try {
                th.printStackTrace();
                if (fileChannel != null) {
                    fileChannel.close();
                    return "";
                }
                return "";
            } catch (Throwable th2) {
                if (fileChannel != null) {
                    try {
                        fileChannel.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                }
                throw th2;
            }
        }
    }

    public static String m11379(File file, String str) {
        FileChannel fileChannel = null;
        try {
            try {
                fileChannel = new RandomAccessFile(file, InternalZipConstants.READ_MODE).getChannel();
                MappedByteBuffer map = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) fileChannel.size());
                byte[] bytes = str.getBytes("UTF-8");
                C3348.m12347(1);
                int i = 4096;
                while (map.hasRemaining() && map.position() < 7000) {
                    map.position(i);
                    for (int i2 = 0; i2 < bytes.length && map.get() == bytes[i2]; i2++) {
                        if (i2 == bytes.length - 1 && map.get() == 0) {
                            int position = map.position();
                            while (map.hasRemaining() && map.position() < 7000) {
                                if (map.get() == 0) {
                                    byte[] bArr = new byte[(map.position() - 1) - position];
                                    map.position(position);
                                    map.get(bArr);
                                    fileChannel.close();
                                    String str2 = new String(bArr, "UTF-8");
                                    try {
                                        fileChannel.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    return str2;
                                }
                            }
                        }
                    }
                    i++;
                }
                fileChannel.close();
                return "";
            } catch (Throwable th) {
                try {
                    th.printStackTrace();
                    if (fileChannel != null) {
                        fileChannel.close();
                        return "";
                    }
                    return "";
                } catch (Throwable th2) {
                    if (fileChannel != null) {
                        try {
                            fileChannel.close();
                        } catch (IOException e2) {
                            e2.printStackTrace();
                        }
                    }
                    throw th2;
                }
            }
        } catch (IOException e3) {
            e3.printStackTrace();
            return "";
        }
    }

    public static void m11380(File file, ArrayList<File> arrayList) {
        if (arrayList != null && arrayList.size() > 0) {
            Iterator<File> it = arrayList.iterator();
            boolean z = false;
            while (it.hasNext()) {
                if (it.next().length() == file.length()) {
                    z = true;
                }
            }
            if (!z) {
                arrayList.add(file);
                return;
            }
            return;
        }
        if (arrayList != null) {
            arrayList.add(file);
        }
    }

    public static String m11381(String str, String str2) {
        String str3;
        String str4;
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        String str10;
        String str11;
        String str12;
        String str13;
        String str14;
        String str15;
        Boolean bool = C3348.f9948;
        if (bool != null && bool.booleanValue()) {
            C3348.m12347("Start under Root");
        } else {
            if (C3348.f9948 == null) {
                C3348.m12347("uderRoot not defined");
            }
            if (!C3348.f9948.booleanValue()) {
                C3348.m12347("uderRoot false");
            }
        }
        File file = new File(str);
        boolean z = false;
        if (C3348.f9924 >= 23) {
            String m11587 = m11587(file.getName(), "odex");
            if (C3348.f9948.booleanValue()) {
                if (new File("/data/dalvik-cache/arm").exists() && new File("/data/dalvik-cache/arm").isDirectory()) {
                    str14 = "/arm";
                } else {
                    str14 = "";
                }
                if (new File("/data/dalvik-cache/arm64").exists() && new File("/data/dalvik-cache/arm64").isDirectory()) {
                    str14 = "/arm64";
                }
                if (new File("/data/dalvik-cache/x86").exists() && new File("/data/dalvik-cache/x86").isDirectory()) {
                    str15 = "/x86";
                } else {
                    str15 = str14;
                }
                if (new File("/data/dalvik-cache/x86_64").exists() && new File("/data/dalvik-cache/x86_64").isDirectory()) {
                    str12 = "/x86_64";
                } else {
                    str12 = str15;
                }
                if (!str12.equals("")) {
                    if (new File("/data/dalvik-cache" + str12).exists()) {
                        if (new File("/data/dalvik-cache" + str12).isDirectory()) {
                            C3348.m12347(str12 + " to dalvik cache found");
                            C3348.m12347("check " + m11357(file) + "/oat" + str12);
                            if (new File(m11357(file) + "/oat" + str12).exists()) {
                            }
                            new File(m11357(file) + "/oat" + str12).mkdirs();
                            C3348.m12347("try make dirs");
                            if (new File(m11357(file) + "/oat" + str12).exists()) {
                                C3348.m12347("dirs created");
                                if (!str2.equals("0")) {
                                    m11508("chmod", "755", m11357(file) + "/oat");
                                    m11508("chown", "1000." + str2, m11357(file) + "/oat");
                                    m11508("chown", "1000:" + str2, m11357(file) + "/oat");
                                    StringBuilder sb = new StringBuilder();
                                    sb.append(m11357(file));
                                    sb.append("/oat");
                                    sb.append(str12);
                                    m11508("chmod", "755", sb.toString());
                                    m11508("chown", "1000." + str2, m11357(file) + "/oat" + str12);
                                    m11508("chown", "1000:" + str2, m11357(file) + "/oat" + str12);
                                } else {
                                    m11508("chmod", "755", m11357(file) + "/oat");
                                    m11508("chown", "0." + str2, m11357(file) + "/oat");
                                    m11508("chown", "0:" + str2, m11357(file) + "/oat");
                                    StringBuilder sb2 = new StringBuilder();
                                    sb2.append(m11357(file));
                                    sb2.append("/oat");
                                    sb2.append(str12);
                                    m11508("chmod", "755", sb2.toString());
                                    m11508("chown", "0." + str2, m11357(file) + "/oat" + str12);
                                    m11508("chown", "0:" + str2, m11357(file) + "/oat" + str12);
                                }
                            }
                        }
                    }
                }
            } else {
                if (m11315("/data/dalvik-cache/arm")) {
                    str10 = "/arm";
                } else {
                    str10 = "";
                }
                if (m11315("/data/dalvik-cache/arm64")) {
                    str10 = "/arm64";
                }
                if (m11315("/data/dalvik-cache/x86")) {
                    str11 = "/x86";
                } else {
                    str11 = str10;
                }
                if (m11315("/data/dalvik-cache/x86_64")) {
                    str12 = "/x86_64";
                } else {
                    str12 = str11;
                }
                if (!str12.equals("")) {
                    if (m11315("/data/dalvik-cache" + str12)) {
                        if (!m11315(m11357(file) + "/oat" + str12)) {
                            m11506("mkdir -p '" + m11357(file) + "/oat" + str12 + "'");
                            if (m11315(m11357(file) + "/oat" + str12)) {
                                if (!str2.equals("0")) {
                                    m11506("chmod 755 " + m11357(file) + "/oat");
                                    m11506("chown 1000." + str2 + " " + m11357(file) + "/oat");
                                    m11506("chown 1000:" + str2 + " " + m11357(file) + "/oat");
                                    StringBuilder sb3 = new StringBuilder();
                                    sb3.append("chmod 755 ");
                                    sb3.append(m11357(file));
                                    sb3.append("/oat");
                                    sb3.append(str12);
                                    m11506(sb3.toString());
                                    m11506("chown 1000." + str2 + " " + m11357(file) + "/oat" + str12);
                                    m11506("chown 1000:" + str2 + " " + m11357(file) + "/oat" + str12);
                                } else {
                                    m11506("chmod 755 " + m11357(file) + "/oat");
                                    m11506("chown 0." + str2 + " " + m11357(file) + "/oat");
                                    m11506("chown 0:" + str2 + " " + m11357(file) + "/oat");
                                    StringBuilder sb4 = new StringBuilder();
                                    sb4.append("chmod 755 ");
                                    sb4.append(m11357(file));
                                    sb4.append("/oat");
                                    sb4.append(str12);
                                    m11506(sb4.toString());
                                    m11506("chown 0." + str2 + " " + m11357(file) + "/oat" + str12);
                                    m11506("chown 0:" + str2 + " " + m11357(file) + "/oat" + str12);
                                }
                            }
                        }
                    }
                }
            }
            if (str12.equals("/arm64")) {
                File file2 = new File(m11357(file) + "/oat/arm/" + m11587);
                if (file2.exists() && file2.length() != 0) {
                    str13 = "/arm";
                    return m11357(file) + "/oat" + str13 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587;
                }
            }
            str13 = str12;
            return m11357(file) + "/oat" + str13 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587;
        }
        if (C3348.f9948.booleanValue()) {
            if (new File("/data/dalvik-cache/arm").exists() && new File("/data/dalvik-cache/arm").isDirectory()) {
                str7 = "/arm";
            } else {
                str7 = "";
            }
            if (new File("/data/dalvik-cache/arm64").exists() && new File("/data/dalvik-cache/arm64").isDirectory()) {
                str8 = "/arm64";
            } else {
                str8 = str7;
            }
            if (new File("/data/dalvik-cache/x86").exists() && new File("/data/dalvik-cache/x86").isDirectory()) {
                str9 = "/x86";
            } else {
                str9 = str8;
            }
            if (new File("/data/dalvik-cache/x86_64").exists() && new File("/data/dalvik-cache/x86_64").isDirectory()) {
                str6 = "/x86_64";
            } else {
                str6 = str9;
            }
            if (!str6.equals("")) {
                if (new File("/data/dalvik-cache" + str6).exists()) {
                    if (new File("/data/dalvik-cache" + str6).isDirectory()) {
                        C3348.m12347(str6 + " to dalvik cache found");
                        C3348.m12347("check " + m11357(file) + str6);
                        if (new File(m11357(file) + str6).exists()) {
                        }
                        new File(m11357(file) + str6).mkdirs();
                        C3348.m12347("try make dirs");
                        if (new File(m11357(file) + str6).exists()) {
                            C3348.m12347("dirs created");
                            if (!str2.equals("0")) {
                                m11508("chmod", "755", m11357(file) + str6);
                                m11508("chown", "1000." + str2, m11357(file) + str6);
                                m11508("chown", "1000:" + str2, m11357(file) + str6);
                            } else {
                                m11508("chmod", "755", m11357(file) + str6);
                                m11508("chown", "0." + str2, m11357(file) + str6);
                                m11508("chown", "0:" + str2, m11357(file) + str6);
                            }
                        }
                        z = true;
                    }
                }
            }
            if (!z) {
                return m11357(file) + str6 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587(file.getName(), "odex");
            }
            return m11587(str, "odex");
        }
        if (m11315("/data/dalvik-cache/arm")) {
            str3 = "/arm";
        } else {
            str3 = "";
        }
        if (m11315("/data/dalvik-cache/arm64")) {
            str4 = "/arm64";
        } else {
            str4 = str3;
        }
        if (m11315("/data/dalvik-cache/x86")) {
            str5 = "/x86";
        } else {
            str5 = str4;
        }
        if (m11315("/data/dalvik-cache/x86_64")) {
            str6 = "/x86_64";
        } else {
            str6 = str5;
        }
        if (!str6.equals("")) {
            if (m11315("/data/dalvik-cache" + str6)) {
                if (!m11315(m11357(file) + str6)) {
                    m11506("mkdir -p '" + m11357(file) + str6 + "'");
                    if (m11315(m11357(file) + str6)) {
                        if (!str2.equals("0")) {
                            m11506("chmod 755 " + m11357(file) + str6);
                            m11506("chown 1000." + str2 + " " + m11357(file) + str6);
                            m11506("chown 1000:" + str2 + " " + m11357(file) + str6);
                        } else {
                            m11506("chmod 755 " + m11357(file) + str6);
                            m11506("chown 0." + str2 + " " + m11357(file) + str6);
                            m11506("chown 0:" + str2 + " " + m11357(file) + str6);
                        }
                    }
                }
                z = true;
            }
        }
        if (!z) {
        }
    }

    public static PackageInfo m11382(File file) throws ApkFormatException, IOException {
        m11590();
        try {
            PackageInfo packageInfo = new PackageInfo();
            packageInfo.applicationInfo = new C2957(file);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(new RandomAccessFile(file, InternalZipConstants.READ_MODE))));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3) {
                    if (androidBinXmlParser.getDepth() == 1 && "manifest".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                        for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                            if ("package".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                packageInfo.packageName = androidBinXmlParser.getAttributeStringValue(i);
                            }
                            if ("versionCode".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                packageInfo.versionCode = Integer.parseInt(androidBinXmlParser.getAttributeStringValue(i));
                            }
                            if ("versionName".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                packageInfo.versionName = androidBinXmlParser.getAttributeStringValue(i);
                            }
                        }
                    }
                }
            }
            return packageInfo;
        } catch (AndroidBinXmlParser.XmlParserException e) {
            e.printStackTrace();
            C3348.m12347("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml");
            return null;
        }
    }

    public static String m11383(File file) throws ApkFormatException, IOException {
        RandomAccessFile randomAccessFile;
        m11590();
        RandomAccessFile randomAccessFile2 = null;
        try {
            try {
                randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            } catch (Throwable th) {
                th = th;
            }
        } catch (AndroidBinXmlParser.XmlParserException e) {
            e = e;
        }
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(randomAccessFile)));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 1 && "manifest".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("package".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            String attributeStringValue = androidBinXmlParser.getAttributeStringValue(i);
                            randomAccessFile.close();
                            return attributeStringValue;
                        }
                    }
                    randomAccessFile.close();
                    return null;
                }
            }
            randomAccessFile.close();
            return null;
        } catch (AndroidBinXmlParser.XmlParserException e2) {
            e = e2;
            throw new ApkFormatException("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml", e);
        } catch (Throwable th2) {
            th = th2;
            randomAccessFile2 = randomAccessFile;
            if (randomAccessFile2 != null) {
                randomAccessFile2.close();
            }
            throw th;
        }
    }

    public static int m11384(File file, int i) throws Exception {
        Class<?> cls = Class.forName("android.os.FileUtils");
        Class<?> cls2 = Integer.TYPE;
        return ((Integer) cls.getMethod("setPermissions", String.class, cls2, cls2, cls2).invoke(null, file.getAbsolutePath(), Integer.valueOf(i), -1, -1)).intValue();
    }

    public static String m11385() {
        if (new File("/sbin/.magisk/modules/").exists()) {
            return "/sbin/.magisk/modules/luckypatcher";
        }
        if (new File("/data/adb/modules/").exists() || m11315("/data/adb/modules/")) {
            return "/data/adb/modules/luckypatcher";
        }
        if (m11315("/sbin/.magisk/modules/")) {
            return "/sbin/.magisk/modules/luckypatcher";
        }
        return "";
    }

    public static String m11386() {
        if (new File("/sbin/.magisk/modules/").exists()) {
            return "/sbin/.magisk/modules/luckypatcher_apps";
        }
        if (new File("/data/adb/modules/").exists() || m11315("/data/adb/modules/")) {
            return "/data/adb/modules/luckypatcher_apps";
        }
        if (m11315("/sbin/.magisk/modules/")) {
            return "/sbin/.magisk/modules/luckypatcher_apps";
        }
        return "";
    }

    public static String m11387(String str) {
        if (!C3348.f9948.booleanValue()) {
            String trim = m11438(C3348.f9875 + "/busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
            C3348.m12347(trim);
            if (!trim.matches("(\\d+)")) {
                C3348.m12347("try get permission again");
                trim = m11438("busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
            }
            if (!trim.matches("(\\d+)")) {
                return "";
            }
            return trim;
        }
        String trim2 = m11438(C3348.f9875 + "/busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
        C3348.m12347("'" + trim2 + "'");
        if (!trim2.matches("(\\d+)")) {
            C3348.m12347("try get permission again");
            trim2 = m11438("busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
        }
        if (!trim2.matches("(\\d+)")) {
            return "";
        }
        return trim2;
    }

    public static ArrayList<String> m11388(File file) throws ApkFormatException, IOException {
        m11590();
        ArrayList<String> arrayList = new ArrayList<>();
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(randomAccessFile)));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 2 && "uses-permission".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if (MediationMetaData.KEY_NAME.equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            int attributeValueType = androidBinXmlParser.getAttributeValueType(i);
                            if (attributeValueType != 1) {
                                if (attributeValueType == 3) {
                                    C4204 c4204 = new C4204(m11402(DataSources.asDataSource(randomAccessFile)));
                                    c4204.m12862();
                                    C4298 m12861 = c4204.m12861();
                                    arrayList.add(m12861.m13088(androidBinXmlParser.getAttributeIntValue(i)).get(0).m13090().mo13072(m12861, null));
                                }
                            } else {
                                arrayList.add(androidBinXmlParser.getAttributeStringValue(i));
                            }
                        }
                    }
                }
            }
            randomAccessFile.close();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static ArrayList<File> m11389(String str, boolean z) {
        String str2;
        ArrayList<File> arrayList = new ArrayList<>();
        if (!z) {
            str2 = "";
        } else {
            str2 = m11386();
        }
        ArrayList arrayList2 = new ArrayList();
        arrayList2.add(new File("/system/app"));
        arrayList2.add(new File("/system/priv-app"));
        arrayList2.add(new File("/system/system_ext/priv-app"));
        arrayList2.add(new File("/system_ext/priv-app"));
        arrayList2.add(new File("/system_ext/app"));
        arrayList2.add(new File("/system/product/app"));
        arrayList2.add(new File("/system/product/priv-app"));
        arrayList2.add(new File("/product/app"));
        arrayList2.add(new File("/product/priv-app"));
        arrayList2.add(new File("/system/vendor/app"));
        arrayList2.add(new File("/system/vendor/priv-app"));
        arrayList2.add(new File("/vendor/app"));
        arrayList2.add(new File("/vendor/priv-app"));
        Iterator it = arrayList2.iterator();
        while (it.hasNext()) {
            File file = (File) it.next();
            File[] listFiles = file.listFiles();
            if (listFiles != null && listFiles.length != 0) {
                boolean z2 = false;
                for (File file2 : listFiles) {
                    if (file2.getAbsolutePath().endsWith(".apk")) {
                        try {
                            if (str.equals(new C3312(C3348.m12334(), file2, false).f9776)) {
                                if (!new File(str2 + file2.getAbsolutePath()).exists() || str2.equals("")) {
                                    arrayList.add(file2);
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                int length = listFiles.length;
                int i = 0;
                while (i < length) {
                    File file3 = listFiles[i];
                    if (file3.isDirectory()) {
                        try {
                            File[] listFiles2 = file3.listFiles();
                            if (listFiles2 != null && listFiles2.length != 0) {
                                int length2 = listFiles2.length;
                                int i2 = 0;
                                while (i2 < length2) {
                                    File file4 = listFiles2[i2];
                                    if (file4.getAbsolutePath().endsWith(".apk")) {
                                        try {
                                            if (str.equals(new C3312(C3348.m12334(), file4, z2).f9776)) {
                                                if (!new File(str2 + file4.getAbsolutePath()).exists() || str2.equals("")) {
                                                    arrayList.add(file4);
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e2.printStackTrace();
                                        }
                                    }
                                    i2++;
                                    z2 = false;
                                }
                            }
                        } catch (Exception e3) {
                            e3.printStackTrace();
                        }
                    }
                    i++;
                    z2 = false;
                }
            } else {
                C3348.m12347("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
            }
        }
        return arrayList;
    }

    public static PackageInfo m11390(String str, int i) {
        try {
            return C3348.m12337().getPackageInfo(str, i);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalArgumentException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static String m11391(String str) {
        try {
            return "" + C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String m11392(String str, boolean z) {
        boolean z2;
        File file = new File(str);
        String str2 = "/x86_64";
        String str3 = "/x86";
        String str4 = "/arm64";
        String str5 = "/arm";
        if (C3348.f9924 >= 23) {
            String m11587 = m11587(file.getName(), "odex");
            if (z) {
                if (!new File("/data/dalvik-cache/arm").exists() || !new File("/data/dalvik-cache/arm").isDirectory()) {
                    str5 = "";
                }
                if (!new File("/data/dalvik-cache/arm64").exists() || !new File("/data/dalvik-cache/arm64").isDirectory()) {
                    str4 = str5;
                }
                if (!new File("/data/dalvik-cache/x86").exists() || !new File("/data/dalvik-cache/x86").isDirectory()) {
                    str3 = str4;
                }
                if (!new File("/data/dalvik-cache/x86_64").exists() || !new File("/data/dalvik-cache/x86_64").isDirectory()) {
                    str2 = str3;
                }
                if (!str2.equals("")) {
                    if (new File("/data/dalvik-cache" + str2).exists()) {
                        new File("/data/dalvik-cache" + str2).isDirectory();
                    }
                }
            } else {
                if (!m11315("/data/dalvik-cache/arm")) {
                    str5 = "";
                }
                if (!m11315("/data/dalvik-cache/arm64")) {
                    str4 = str5;
                }
                if (!m11315("/data/dalvik-cache/x86")) {
                    str3 = str4;
                }
                if (!m11315("/data/dalvik-cache/x86_64")) {
                    str2 = str3;
                }
                if (!str2.equals("")) {
                    m11315("/data/dalvik-cache" + str2);
                }
            }
            return m11357(file) + "/oat" + str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587;
        }
        if (z) {
            if (!new File("/data/dalvik-cache/arm").exists() || !new File("/data/dalvik-cache/arm").isDirectory()) {
                str5 = "";
            }
            if (!new File("/data/dalvik-cache/arm64").exists() || !new File("/data/dalvik-cache/arm64").isDirectory()) {
                str4 = str5;
            }
            if (!new File("/data/dalvik-cache/x86").exists() || !new File("/data/dalvik-cache/x86").isDirectory()) {
                str3 = str4;
            }
            if (!new File("/data/dalvik-cache/x86_64").exists() || !new File("/data/dalvik-cache/x86_64").isDirectory()) {
                str2 = str3;
            }
            if (!str2.equals("")) {
                if (new File("/data/dalvik-cache" + str2).exists()) {
                }
            }
            z2 = false;
        } else {
            if (!m11315("/data/dalvik-cache/arm")) {
                str5 = "";
            }
            if (!m11315("/data/dalvik-cache/arm64")) {
                str4 = str5;
            }
            if (!m11315("/data/dalvik-cache/x86")) {
                str3 = str4;
            }
            if (!m11315("/data/dalvik-cache/x86_64")) {
                str2 = str3;
            }
            if (!str2.equals("")) {
            }
            z2 = false;
        }
        if (z2) {
            return m11357(file) + str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m11587(file.getName(), "odex");
        }
        return m11587(str, "odex");
    }

    public static PrivateKey m11393(String str) {
        try {
            return KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(C3015.m11700(str.getBytes())));
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static long m11394(long j, long j2) {
        long nextLong;
        long j3;
        long j4;
        Random random = new Random();
        do {
            nextLong = (random.nextLong() << 1) >>> 1;
            j3 = j2 - j;
            j4 = nextLong % (1 + j3);
        } while ((nextLong - j4) + j3 < 0);
        return j4 + j;
    }

    public static String m11395(int i) {
        StringBuilder sb = new StringBuilder(i);
        for (int i2 = 0; i2 < i; i2++) {
            sb.append("abcdefghijklmnopqrstuvwxyz".charAt(f7708.nextInt(26)));
        }
        return sb.toString();
    }

    public static String m11396(int i) {
        StringBuilder sb = new StringBuilder(i);
        for (int i2 = 0; i2 < i; i2++) {
            sb.append("ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(f7708.nextInt(26)));
        }
        return sb.toString();
    }

    public static String m11397(int i) {
        StringBuilder sb = new StringBuilder(i);
        for (int i2 = 0; i2 < i; i2++) {
            sb.append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(f7708.nextInt(52)));
        }
        return sb.toString();
    }

    public static byte[] m11398(int i, int i2) {
        m11590();
        try {
            byte[] bArr = new byte[i2];
            C3348.m12338().openRawResource(i).read(bArr);
            return bArr;
        } catch (IOException unused) {
            return null;
        }
    }

    public static long m11399(int i) {
        m11590();
        try {
            InputStream openRawResource = C3348.m12338().openRawResource(i);
            byte[] bArr = new byte[ItemType.CLASS_DATA_ITEM];
            long j = 0;
            while (true) {
                int read = openRawResource.read(bArr);
                if (read != -1) {
                    j += read;
                } else {
                    C3348.m12347("LuckyPatcher (RAW): length = " + j);
                    return j;
                }
            }
        } catch (IOException unused) {
            return 0L;
        }
    }

    public static boolean m11400(int i, File file) {
        m11590();
        if (file.exists()) {
            file.delete();
        } else {
            m11357(file).mkdirs();
        }
        C3348.m12347("try get file from raw");
        try {
            byte[] bArr = new byte[ItemType.CLASS_DATA_ITEM];
            InputStream openRawResource = C3348.m12338().openRawResource(i);
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            for (int read = openRawResource.read(bArr); read > 0; read = openRawResource.read(bArr)) {
                fileOutputStream.write(bArr, 0, read);
            }
            fileOutputStream.flush();
            fileOutputStream.close();
            openRawResource.close();
            C3348.m12347("get file from raw");
            return true;
        } catch (IOException unused) {
            return false;
        }
    }

    public static C2851 m11401(String... strArr) {
        String str;
        String str2;
        String str3 = strArr[0];
        if (strArr.length <= 1) {
            str = "";
        } else {
            str = strArr[1];
        }
        String[] strArr2 = {"https://chelpus.com/luckypatcher/" + str3, "http://chelpus.com/luckypatcher/" + str3, "https://198.244.149.102/luckypatcher/" + str3};
        C2851 c2851 = null;
        int i = 0;
        while (i < 6) {
            if (i < 3) {
                str2 = strArr2[i];
            } else {
                double d = i;
                double floor = Math.floor(i / 3);
                double d2 = 3;
                Double.isNaN(d2);
                Double.isNaN(d);
                str2 = strArr2[(int) (d - (floor * d2))];
            }
            i++;
            try {
                c2851 = C2851.m11233(str2);
                c2851.m11240();
                c2851.m11237();
                c2851.m11257("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:65.0) Gecko/20100101 Firefox/65.0");
                c2851.m11257("Accept-Encoding", "gzip,deflate");
                c2851.m11242(false);
                c2851.m11239(false);
                c2851.m11252(true);
                c2851.m11255().setRequestMethod("GET");
                c2851.m11255().setRequestProperty("Cache-Control", "no-cache");
                if (!str.equals("")) {
                    c2851.m11255().setRequestProperty("Range", "bytes=" + str + "-");
                }
                c2851.m11246(1000000);
                c2851.m11255().setDoInput(true);
                c2851.m11255().setDoOutput(true);
                c2851.m11255().setReadTimeout(30000);
                c2851.m11255().setConnectTimeout(30000);
                int m11245 = c2851.m11245();
                C3348.m12347("RequestCode:" + m11245);
                if (m11245 == 200 || m11245 == 206 || m11245 == 301) {
                    if (c2851.m11248() > 0) {
                        C3348.m12347("select host:" + str2);
                        return c2851;
                    }
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
                c2851.m11251();
            } catch (C2851.C2858 e2) {
                e2.printStackTrace();
                C3348.m12347(str2);
                c2851.m11251();
            } catch (Throwable th) {
                th.printStackTrace();
                C3348.m12347(str2);
                c2851.m11251();
            }
        }
        return null;
    }

    public static ByteBuffer m11402(DataSource dataSource) throws IOException, ApkFormatException {
        CentralDirectoryRecord centralDirectoryRecord;
        m11590();
        try {
            ApkUtils.ZipSections m11320 = m11320(dataSource);
            Iterator<CentralDirectoryRecord> it = V1SchemeVerifier.parseZipCentralDirectory(dataSource, m11320).iterator();
            while (true) {
                if (it.hasNext()) {
                    centralDirectoryRecord = it.next();
                    if ("resources.arsc".equals(centralDirectoryRecord.getName())) {
                        break;
                    }
                } else {
                    centralDirectoryRecord = null;
                    break;
                }
            }
            if (centralDirectoryRecord != null) {
                DataSource slice = dataSource.slice(0L, m11320.getZipCentralDirectoryOffset());
                try {
                    return ByteBuffer.wrap(LocalFileRecord.getUncompressedData(slice, centralDirectoryRecord, slice.size()));
                } catch (ZipFormatException e) {
                    throw new ApkFormatException("Failed to read resources.arsc", e);
                }
            }
            throw new ApkFormatException("Missing resources.arsc");
        } catch (ZipFormatException e2) {
            throw new ApkFormatException("Not a valid ZIP archive", e2);
        }
    }

    public static void m11403() {
        if (!C3348.f9948.booleanValue()) {
            try {
                if (C3348.f9930 == null) {
                    C3348.m12347("LuckyPatcher: GET ROOT.");
                    C3348.f9930 = Runtime.getRuntime().exec("su");
                    C3348.f9932 = new DataOutputStream(C3348.f9930.getOutputStream());
                    C3348.f9931 = new DataInputStream(C3348.f9930.getInputStream());
                    C3348.f9933 = new DataInputStream(C3348.f9930.getErrorStream());
                } else {
                    try {
                        C3348.f9932.writeBytes("echo chelpusstart!\n");
                    } catch (Exception unused) {
                        m11317();
                        C3348.f9930 = Runtime.getRuntime().exec("su");
                        C3348.f9932 = new DataOutputStream(C3348.f9930.getOutputStream());
                        C3348.f9931 = new DataInputStream(C3348.f9930.getInputStream());
                        C3348.f9933 = new DataInputStream(C3348.f9930.getErrorStream());
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static boolean m11404() {
        try {
            if (!System.getProperty("user.name").contains("root")) {
                return false;
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static void m11405(String str, String str2, ArrayList<C3286> arrayList) throws IOException {
        JarEntry jarEntry;
        m11357(new File(str2)).mkdirs();
        C4201 m12846 = C4201.m12846(str);
        JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(str2));
        for (C4199 c4199 : m12846.m12848().values()) {
            if (!C3348.f9948.booleanValue()) {
                try {
                    C3923.m12601(m11423(R.string.patch_step7) + "\n" + c4199.m12835());
                } catch (Throwable unused) {
                }
            }
            try {
                if (c4199.m12829() == 0) {
                    jarEntry = new JarEntry(c4199.m12835());
                    jarEntry.setMethod(0);
                    Iterator<C3286> it = arrayList.iterator();
                    boolean z = false;
                    while (it.hasNext()) {
                        C3286 next = it.next();
                        if (c4199.m12835().equals(next.f9701.replace(next.f9702, ""))) {
                            try {
                                File file = new File(next.f9701);
                                byte[] bArr = new byte[(int) file.length()];
                                FileInputStream fileInputStream = new FileInputStream(next.f9701);
                                fileInputStream.read(bArr);
                                fileInputStream.close();
                                jarEntry.setCompressedSize(file.length());
                                jarEntry.setSize(file.length());
                                CRC32 crc32 = new CRC32();
                                crc32.update(bArr);
                                jarEntry.setCrc(crc32.getValue());
                                jarEntry.setTime(c4199.m12837());
                                z = true;
                            } catch (Exception e) {
                                C3348.m12347(e);
                            }
                        }
                    }
                    if (!z) {
                        jarEntry.setCompressedSize(c4199.m12836());
                        jarEntry.setSize(c4199.m12836());
                        CRC32 crc322 = new CRC32();
                        crc322.update(c4199.m12831());
                        jarEntry.setCrc(crc322.getValue());
                        jarEntry.setTime(c4199.m12837());
                    }
                } else {
                    jarEntry = new JarEntry(c4199.m12835());
                    jarEntry.setTime(c4199.m12837());
                    jarEntry.setMethod(c4199.m12829());
                }
                Iterator<C3286> it2 = arrayList.iterator();
                boolean z2 = false;
                while (it2.hasNext()) {
                    C3286 next2 = it2.next();
                    if (c4199.m12835().equals(next2.f9701.replace(next2.f9702, ""))) {
                        try {
                            File file2 = new File(next2.f9701);
                            byte[] bArr2 = new byte[ItemType.CLASS_DATA_ITEM];
                            FileInputStream fileInputStream2 = new FileInputStream(next2.f9701);
                            jarOutputStream.putNextEntry(jarEntry);
                            while (true) {
                                int read = fileInputStream2.read(bArr2);
                                if (read <= 0) {
                                    break;
                                } else {
                                    jarOutputStream.write(bArr2, 0, read);
                                }
                            }
                            jarOutputStream.flush();
                            fileInputStream2.close();
                            try {
                                file2.delete();
                                C3348.m12347("LuckyPatcher (signer): Additional files added! " + next2);
                                z2 = true;
                            } catch (Exception e2) {
                                e = e2;
                                z2 = true;
                                C3348.m12347(e);
                            }
                        } catch (Exception e3) {
                            e = e3;
                        }
                    }
                }
                if (!z2) {
                    jarOutputStream.putNextEntry(jarEntry);
                    InputStream m12833 = c4199.m12833();
                    byte[] bArr3 = new byte[ItemType.CLASS_DATA_ITEM];
                    while (true) {
                        int read2 = m12833.read(bArr3);
                        if (read2 <= 0) {
                            break;
                        } else {
                            jarOutputStream.write(bArr3, 0, read2);
                        }
                    }
                    jarOutputStream.flush();
                    m12833.close();
                }
            } catch (Exception e4) {
                C3348.m12347(e4);
                e4.printStackTrace();
            }
        }
        m12846.m12847();
        jarOutputStream.close();
    }

    public static String m11406() {
        String str;
        String str2 = "/system/bin/dalvikvm32";
        String str3 = "/system/bin/dalvikvm";
        try {
            if ((C3348.f9924 >= 23 && C3348.m12333().getBoolean("use_app_process", false)) || C3348.m12333().getBoolean("force_use_app_process", false)) {
                C3348.m12347("Use app_process");
                str = "app_process -Djava.class.path=" + App.getInstance().getPackageCodePath() + " /system/bin ";
            } else {
                C3348.m12347("Use dalvikvm");
                if (!new File("/system/bin/dalvikvm").exists()) {
                    str3 = "";
                }
                if (!new File("/system/bin/dalvikvm32").exists()) {
                    str2 = str3;
                }
                str = str2 + " -Xbootclasspath:" + System.getenv("BOOTCLASSPATH") + " -Xverify:none -Xdexopt:none -cp " + App.getInstance().getPackageCodePath() + " ";
            }
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String m11407() {
        String str;
        String str2 = "/system/bin/dalvikvm32";
        String str3 = "/system/bin/dalvikvm";
        try {
            if ((C3348.f9924 >= 23 && C3348.m12333().getBoolean("use_app_process", false)) || C3348.m12333().getBoolean("force_use_app_process", false)) {
                str = "app_process -Djava.class.path=" + App.getInstance().getPackageCodePath() + " /system/bin ";
            } else {
                if (!new File("/system/bin/dalvikvm").exists()) {
                    str3 = "";
                }
                if (!new File("/system/bin/dalvikvm32").exists()) {
                    str2 = str3;
                }
                str = str2 + " -Xbootclasspath:" + System.getenv("BOOTCLASSPATH") + " -Xverify:none -Xdexopt:none -cp " + App.getInstance().getPackageCodePath() + " com.android.internal.util.WithFramework ";
            }
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String m11408() {
        String[] m11410 = m11410();
        for (String str : m11410) {
            new File(str);
            File file = new File(str + "/lp_utils");
            if (file.exists() && file.canRead()) {
                try {
                    String[] split = m11486(file).split("%chelpus%");
                    if (split != null && split.length > 0) {
                        for (int i = 0; i < split.length; i++) {
                            if (i == 3) {
                                return split[i];
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                C3348.m12347("Lucky Patcher not found utils.");
            }
        }
        return "";
    }

    public static C3008 m11409(File file) throws ApkFormatException, IOException {
        m11590();
        try {
            C3008 c3008 = new C3008();
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(new RandomAccessFile(file, InternalZipConstants.READ_MODE))));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3) {
                    if (androidBinXmlParser.getDepth() <= 2 && (("manifest".equals(androidBinXmlParser.getName()) || "uses-sdk".equals(androidBinXmlParser.getName())) && androidBinXmlParser.getNamespace().isEmpty())) {
                        for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                            if (("compileSdkVersion".equals(androidBinXmlParser.getAttributeName(i)) || (androidBinXmlParser.getAttributeValueType(i) == 2 && androidBinXmlParser.getAttributeNameResourceId(i) == 16844146)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                c3008.f8260 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                            if (("minSdkVersion".equals(androidBinXmlParser.getAttributeName(i)) || (androidBinXmlParser.getAttributeValueType(i) == 2 && androidBinXmlParser.getAttributeNameResourceId(i) == 16843276)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                c3008.f8261 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                            if (("targetSdkVersion".equals(androidBinXmlParser.getAttributeName(i)) || (androidBinXmlParser.getAttributeValueType(i) == 2 && androidBinXmlParser.getAttributeNameResourceId(i) == 16843376)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                c3008.f8259 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                        }
                    }
                }
            }
            return c3008;
        } catch (AndroidBinXmlParser.XmlParserException e) {
            e.printStackTrace();
            C3348.m12347("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml");
            return null;
        }
    }

    public static String[] m11410() {
        String pkgName = PkgName.getPkgName();
        if (C3348.f9972 == null) {
            if (new File("/data/user/0/io.va.exposed/virtual/").exists() && System.getProperty("vxp") != null) {
                System.out.println("Virtual Xposed detected!");
                C3348.f9972 = Boolean.TRUE;
                C3348.f9973 = "/data/user/0/io.va.exposed/virtual";
            } else {
                C3348.f9972 = Boolean.FALSE;
            }
        }
        Boolean bool = C3348.f9972;
        if (bool != null && bool.booleanValue()) {
            return new String[]{C3348.f9973 + "/data/user/0/" + pkgName + "/lp"};
        }
        return new String[]{"/data/" + pkgName, "/data/data/" + pkgName + "/lp", "/data/local/tmp", "/data/misc/" + pkgName};
    }

    public static void m11411() {
        File[] listFiles;
        m11590();
        m11492("/system", "ro");
        if (C3348.f9948.booleanValue()) {
            if (C3348.f9924 >= 23) {
                try {
                    if (new File("/data/app").exists()) {
                        for (File file : new File("/data/app").listFiles()) {
                            if (file.isDirectory() && (listFiles = file.listFiles()) != null && listFiles.length > 0) {
                                for (File file2 : listFiles) {
                                    if (file2.isDirectory() && file2.getName().equals("oat")) {
                                        C3348.m12347("delete folder:" + file2.getAbsolutePath());
                                        new C2880("").m11605(file2);
                                    }
                                }
                            }
                        }
                    }
                } catch (Exception unused) {
                }
            }
            m11508("rm", "/data/dalvik-cache/*.dex");
            m11508("rm", "/data/dalvik-cache/*.oat");
            m11508("rm", "/data/dalvik-cache/*.art");
            m11508("rm", "/data/dalvik-cache/arm/*.dex");
            m11508("rm", "/data/dalvik-cache/arm/*.art");
            m11508("rm", "/data/dalvik-cache/arm/*.oat");
            m11508("rm", "/data/dalvik-cache/arm64/*.dex");
            m11508("rm", "/data/dalvik-cache/arm64/*.art");
            m11508("rm", "/data/dalvik-cache/arm64/*.oat");
            m11508("rm", "/data/dalvik-cache/x86/*.dex");
            m11508("rm", "/data/dalvik-cache/x86/*.art");
            m11508("rm", "/data/dalvik-cache/x86/*.oat");
            m11508("rm", "/data/dalvik-cache/x86_64/*.dex");
            m11508("rm", "/data/dalvik-cache/x86_64/*.art");
            m11508("rm", "/data/dalvik-cache/x86_64/*.oat");
            return;
        }
        m11506("rm /data/dalvik-cache/*.dex");
        m11506("rm /data/dalvik-cache/*.oat");
        m11506("rm /data/dalvik-cache/*.art");
        m11506("rm /data/dalvik-cache/arm/*.dex");
        m11506("rm /data/dalvik-cache/arm/*.art");
        m11506("rm /data/dalvik-cache/arm/*.oat");
        m11506("rm /data/dalvik-cache/arm64/*.dex");
        m11506("rm /data/dalvik-cache/arm64/*.art");
        m11506("rm /data/dalvik-cache/arm64/*.oat");
        m11506("rm /data/dalvik-cache/x86/*.dex");
        m11506("rm /data/dalvik-cache/x86/*.art");
        m11506("rm /data/dalvik-cache/x86/*.oat");
        m11506("rm /data/dalvik-cache/x86_64/*.dex");
        m11506("rm /data/dalvik-cache/x86_64/*.art");
        m11506("rm /data/dalvik-cache/x86_64/*.oat");
    }

    private static void m11412() {
        try {
            m11343("testkey.pk8", C3348.f9876 + "/Modified/Keys");
            m11343("testkey.sbt", C3348.f9876 + "/Modified/Keys");
            m11343("testkey.x509.pem", C3348.f9876 + "/Modified/Keys");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static List<X509Certificate> m11413(File file) throws ApkFormatException, IOException, NoSuchAlgorithmException {
        ApkVerifier.Result verify = new ApkVerifier.Builder(file).build().verify();
        verify.isVerified();
        return verify.getSignerCertificates();
    }

    public static String m11414(String str) {
        String group;
        if (C3348.f9948.booleanValue()) {
            Matcher matcher = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(m11438("ls", "-l", str));
            if (matcher.find()) {
                group = matcher.group(1);
                C3348.m12347("Symlink found: " + group);
            } else {
                String m11438 = m11438(C3348.f9875 + "/busybox", "ls", "-l", str);
                C3348.m12347(m11438);
                Matcher matcher2 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(m11438);
                if (matcher2.find()) {
                    group = matcher2.group(1);
                    C3348.m12347("Symlink found: " + group);
                } else {
                    C3348.m12347("No symlink found!");
                    return "";
                }
            }
            return group;
        }
        Matcher matcher3 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(new C2880("").m11618("ls -l " + str));
        if (matcher3.find()) {
            String group2 = matcher3.group(1);
            C3348.m12347("Symlink found: " + group2);
            return group2;
        }
        Matcher matcher4 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(new C2880("").m11618(C3348.f9875 + "/busybox ls -l " + str));
        if (matcher4.find()) {
            String group3 = matcher4.group(1);
            C3348.m12347("Symlink found: " + group3);
            return group3;
        }
        C3348.m12347("No symlink found!");
        return "";
    }

    public static ArrayList<File> m11415(File file) {
        ArrayList<File> arrayList = new ArrayList<>();
        try {
            ZipFile zipFile = new ZipFile(file);
            File file2 = new File(m11421() + "tmp");
            file2.mkdirs();
            for (FileHeader fileHeader : zipFile.getFileHeaders()) {
                if (!fileHeader.getFileName().toLowerCase().equals("base.apk") && fileHeader.getFileName().toLowerCase().endsWith(".apk")) {
                    zipFile.extractFile(fileHeader, file2.getAbsolutePath());
                    File file3 = new File(file2.getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR + fileHeader.getFileName());
                    if (file3.exists() && file3.length() > 0 && m11337(file3.getAbsolutePath()) == null) {
                        arrayList.add(file3);
                    } else {
                        file3.delete();
                    }
                }
            }
            return arrayList;
        } catch (Throwable th) {
            th.printStackTrace();
            return arrayList;
        }
    }

    public static ArrayList<File> m11416(String str) {
        String[] strArr;
        ArrayList<File> arrayList = new ArrayList<>();
        try {
            if (C3348.f9924 >= 21) {
                strArr = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.splitSourceDirs;
                if (strArr != null && strArr.length != 0) {
                    C3348.m12347("Apk is splitted:");
                    for (String str2 : strArr) {
                        C3348.m12347(str2);
                        arrayList.add(new File(str2));
                    }
                }
                return arrayList;
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static void m11417() {
        try {
            C3348.m12347("Android 11 permission request");
            Intent intent = new Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION");
            intent.setData(Uri.parse("package:" + PkgName.getPkgName()));
            C3348 c3348 = C3348.f9870;
            if (c3348 != null) {
                c3348.m2466().startActivity(intent);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static ArrayList<File> m11418() {
        ArrayList<File> arrayList = new ArrayList<>();
        arrayList.clear();
        try {
            for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
                try {
                    if (entry.getKey().toString().toLowerCase().contains("storage") && !entry.getKey().toString().toLowerCase().equals("android_storage")) {
                        File file = new File(entry.getValue().toString());
                        if (file.exists() && file.canRead()) {
                            arrayList.add(file);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        return arrayList;
    }

    public static ArrayList<File> m11419() {
        ArrayList<File> arrayList = new ArrayList<>();
        arrayList.clear();
        try {
            for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
                try {
                    if (entry.getKey().toString().toLowerCase().contains("storage") && !entry.getKey().toString().toLowerCase().equals("android_storage")) {
                        File file = new File(entry.getValue().toString());
                        if (file.exists() && file.canWrite()) {
                            arrayList.add(file);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        return arrayList;
    }

    public static ArrayList<C2999> m11420(String str, ArrayList<String> arrayList, boolean z) {
        boolean z2;
        boolean z3;
        m11590();
        C3348.m12347("scan: " + str);
        int i = 1;
        if (C3348.f9948.booleanValue()) {
            m11508("chmod", "777", str);
        } else if (C3348.f9908) {
            m11506("chmod 777 " + str);
        }
        ArrayList<C2999> arrayList2 = new ArrayList<>();
        int i2 = 4;
        try {
        } catch (Exception e) {
            C3348.m12347(e);
        }
        if (!z) {
            if (str != null && new File(str).exists() && new File(str).length() != 0) {
                try {
                    if (new File(str).exists()) {
                        try {
                            FileChannel channel = new RandomAccessFile(str, InternalZipConstants.READ_MODE).getChannel();
                            MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
                            map.position(0);
                            if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                map.position(56);
                                int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                int[] iArr = new int[m11592];
                                for (int i3 = 0; i3 < m11592; i3++) {
                                    iArr[i3] = m11592(map.get(), map.get(), map.get(), map.get());
                                }
                                int size = arrayList.size();
                                int[] iArr2 = new int[size];
                                String[] strArr = new String[arrayList.size()];
                                for (int i4 = 0; i4 < size; i4++) {
                                    iArr2[i4] = arrayList.get(i4).length();
                                    strArr[i4] = arrayList.get(i4);
                                }
                                int i5 = 0;
                                int i6 = 0;
                                while (i5 < m11592) {
                                    int i7 = 0;
                                    while (i7 < size) {
                                        int m11582 = m11582(map.get(iArr[i5]));
                                        if (m11582 == iArr2[i7]) {
                                            byte[] bArr = new byte[m11582];
                                            map.position(iArr[i5] + 1);
                                            for (int i8 = 0; i8 < m11582; i8++) {
                                                bArr[i8] = map.get();
                                            }
                                            if (strArr[i7].equals(new String(bArr))) {
                                                byte[] bArr2 = new byte[i2];
                                                bArr2[0] = (byte) i6;
                                                bArr2[1] = (byte) (i6 >> 8);
                                                byte b = (byte) (i6 >> 16);
                                                bArr2[2] = b;
                                                byte b2 = (byte) (i6 >> 24);
                                                bArr2[3] = b2;
                                                if (i5 <= 65535 && b == 0 && b2 == 0) {
                                                    z3 = false;
                                                    arrayList2.add(new C2999(strArr[i7], bArr2, z3));
                                                }
                                                z3 = true;
                                                arrayList2.add(new C2999(strArr[i7], bArr2, z3));
                                            }
                                        }
                                        i7++;
                                        i2 = 4;
                                    }
                                    i6++;
                                    i5++;
                                    i2 = 4;
                                }
                            }
                            channel.close();
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }
                    }
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
            }
            return arrayList2;
        }
        if (new File(str).exists()) {
            try {
                FileChannel channel2 = new RandomAccessFile(str, InternalZipConstants.READ_MODE).getChannel();
                MappedByteBuffer map2 = channel2.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel2.size());
                map2.position(8);
                int m115922 = m11592(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m115922 + 56);
                int m115923 = m11592(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m11592(map2.get(), map2.get(), map2.get(), map2.get()) + m115922);
                int[] iArr3 = new int[m115923];
                for (int i9 = 0; i9 < m115923; i9++) {
                    iArr3[i9] = m11592(map2.get(), map2.get(), map2.get(), map2.get()) + m115922;
                }
                int size2 = arrayList.size();
                int[] iArr4 = new int[size2];
                String[] strArr2 = new String[arrayList.size()];
                for (int i10 = 0; i10 < size2; i10++) {
                    iArr4[i10] = arrayList.get(i10).length();
                    strArr2[i10] = arrayList.get(i10);
                }
                int i11 = 0;
                int i12 = 0;
                while (i11 < m115923) {
                    int i13 = 0;
                    while (i13 < size2) {
                        int m115822 = m11582(map2.get(iArr3[i11]));
                        if (m115822 == iArr4[i13]) {
                            byte[] bArr3 = new byte[m115822];
                            map2.position(iArr3[i11] + i);
                            for (int i14 = 0; i14 < m115822; i14++) {
                                bArr3[i14] = map2.get();
                            }
                            if (strArr2[i13].equals(new String(bArr3))) {
                                byte[] bArr4 = new byte[4];
                                bArr4[0] = (byte) i12;
                                bArr4[i] = (byte) (i12 >> 8);
                                byte b3 = (byte) (i12 >> 16);
                                bArr4[2] = b3;
                                byte b4 = (byte) (i12 >> 24);
                                bArr4[3] = b4;
                                if (i11 <= 65535 && b3 == 0 && b4 == 0) {
                                    z2 = false;
                                    arrayList2.add(new C2999(strArr2[i13], bArr4, z2));
                                    i13++;
                                    i = 1;
                                }
                                z2 = true;
                                arrayList2.add(new C2999(strArr2[i13], bArr4, z2));
                                i13++;
                                i = 1;
                            }
                        }
                        i13++;
                        i = 1;
                    }
                    i12++;
                    i11++;
                    i = 1;
                }
                channel2.close();
            } catch (Exception e4) {
                e4.printStackTrace();
            }
        }
        return arrayList2;
    }

    public static String m11421() {
        String str = C3348.m12334().getDir("tmp", 0).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        new File(str).mkdirs();
        return str;
    }

    public static String m11422() {
        return C3348.f9876 + "/tmp/";
    }

    public static String m11423(int i) {
        return C3348.m12338().getString(i);
    }

    public static String m11424(int i, int[] iArr) {
        ArrayList arrayList = new ArrayList();
        for (int i2 : iArr) {
            arrayList.add(C3348.m12338().getString(i2));
        }
        String string = C3348.m12338().getString(i);
        try {
            return String.format(string, arrayList.toArray(new String[iArr.length]));
        } catch (Throwable unused) {
            return string;
        }
    }

    public static String m11425(int i, String... strArr) {
        String string = C3348.m12338().getString(i);
        try {
            return String.format(string, strArr);
        } catch (Throwable unused) {
            return string;
        }
    }

    public static String m11426(String str, int[] iArr, boolean z) {
        ArrayList arrayList = new ArrayList();
        for (int i : iArr) {
            if (z) {
                arrayList.add(C3348.m12338().getString(i).replaceAll("\n", " "));
            } else {
                arrayList.add(C3348.m12338().getString(i));
            }
        }
        try {
            return String.format(str, arrayList.toArray(new String[iArr.length]));
        } catch (Throwable unused) {
            return str;
        }
    }

    public static boolean m11427(String str, ArrayList<C3871> arrayList, boolean z) {
        m11590();
        C3348.m12347("scan: " + str);
        boolean z2 = false;
        if (C3348.f9948.booleanValue()) {
            m11508("chmod", "777", str);
        } else if (C3348.f9908) {
            m11506("chmod 777 " + str);
        }
        new ArrayList();
        if (!z && str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        if (new File(str).exists()) {
                            try {
                                FileChannel channel = new RandomAccessFile(str, InternalZipConstants.READ_MODE).getChannel();
                                MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
                                map.position(0);
                                if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                    map.position(64);
                                    int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                    int m115922 = m11592(map.get(), map.get(), map.get(), map.get());
                                    C3348.m12347("LuckyPatcher offset_to_data=" + Integer.toHexString(m115922));
                                    map.position(m115922);
                                    int i = 0;
                                    for (int i2 = 0; i2 < m11592; i2++) {
                                        byte[] bArr = {map.get(), map.get(), map.get(), map.get()};
                                        Iterator<C3871> it = arrayList.iterator();
                                        while (it.hasNext()) {
                                            C3871 next = it.next();
                                            byte b = bArr[0];
                                            byte[] bArr2 = next.f10749;
                                            if (b == bArr2[0] && bArr[1] == bArr2[1] && bArr[2] == bArr2[2] && bArr[3] == bArr2[3]) {
                                                byte[] bArr3 = next.f10750;
                                                bArr3[0] = (byte) i;
                                                bArr3[1] = (byte) (i >> 8);
                                                next.f10753 = true;
                                                next.f10752 = true;
                                            }
                                        }
                                        i++;
                                    }
                                    Iterator<C3871> it2 = arrayList.iterator();
                                    while (it2.hasNext()) {
                                        if (it2.next().f10752) {
                                            z2 = true;
                                        }
                                    }
                                }
                                channel.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            } catch (Exception e3) {
                C3348.m12347(e3);
            }
        }
        return z2;
    }

    public static int m11428(File file) throws ApkFormatException, IOException {
        m11590();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(new RandomAccessFile(file, InternalZipConstants.READ_MODE))));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 1 && "manifest".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("versionCode".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            return Integer.parseInt(androidBinXmlParser.getAttributeStringValue(i));
                        }
                    }
                    return 0;
                }
            }
            return 0;
        } catch (AndroidBinXmlParser.XmlParserException e) {
            throw new ApkFormatException("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml", e);
        }
    }

    public static String m11429(File file) throws ApkFormatException, IOException {
        m11590();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(new RandomAccessFile(file, InternalZipConstants.READ_MODE))));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 1 && "manifest".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("versionName".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            return androidBinXmlParser.getAttributeStringValue(i);
                        }
                    }
                    return null;
                }
            }
            return null;
        } catch (AndroidBinXmlParser.XmlParserException e) {
            e.printStackTrace();
            throw new ApkFormatException("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml", e);
        }
    }

    public static ArrayList<String> m11430() {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.clear();
        try {
            if (m11438(C3348.f9875 + "/busybox").contains("error execute command " + C3348.f9875 + "/busybox")) {
                C3348.m12347("binaries tool " + C3348.f9875 + "/busybox not found and skipped");
            } else {
                C3348.m12347("binaries tool " + C3348.f9875 + "/busybox found and worked");
                StringBuilder sb = new StringBuilder();
                sb.append(C3348.f9875);
                sb.append("/busybox");
                arrayList.add(sb.toString());
            }
            for (String str : C3348.f9921) {
                if (m11438(str).contains("error execute command " + str)) {
                    C3348.m12347("binaries tool " + str + " not found and skipped");
                } else {
                    C3348.m12347("binaries tool " + str + " found and worked");
                    arrayList.add(str);
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static void m11431(String str, String str2, ArrayList<C3286> arrayList, ArrayList<C3003> arrayList2) throws IOException {
        m11357(new File(str2)).mkdirs();
        C2806 c2806 = null;
        try {
            C2800 c2800 = new C2800(str);
            try {
                C2806 c28062 = new C2806(new File(str2));
                try {
                    Enumeration<C2799> m11030 = c2800.m11030();
                    while (m11030.hasMoreElements()) {
                        C2799 nextElement = m11030.nextElement();
                        String name = nextElement.getName();
                        Iterator<C3286> it = arrayList.iterator();
                        boolean z = false;
                        while (it.hasNext()) {
                            C3286 next = it.next();
                            if (name.equals(next.f9701.replace(next.f9702, ""))) {
                                File file = new File(next.f9701);
                                C2799 c2799 = new C2799(name);
                                c2799.setTime(nextElement.getTime());
                                c2799.setCrc(nextElement.getCrc());
                                if (nextElement.getMethod() == 8) {
                                    c2799.setMethod(8);
                                } else {
                                    c2799.setMethod(0);
                                }
                                c28062.m11056(c2799);
                                C3348.m12347("entry:" + name);
                                C3348.m12347("hex crc orig:" + Long.toHexString(nextElement.getCrc()));
                                c28062.m11063(new FileInputStream(file));
                                c28062.m11051();
                                z = true;
                            }
                        }
                        if (!z) {
                            C3348.m12347("dont change:" + name);
                            c28062.m11052(nextElement, c2800);
                        }
                    }
                    try {
                        c2800.close();
                        c28062.close();
                    } catch (Throwable th) {
                        th = th;
                        c2806 = c28062;
                        try {
                            th.printStackTrace();
                            throw th;
                        } catch (Throwable th2) {
                            if (c2806 != null) {
                                c2806.close();
                            }
                            throw th2;
                        }
                    }
                } catch (Throwable th3) {
                    th = th3;
                    c2806 = c28062;
                    try {
                        c2800.close();
                    } catch (Throwable th4) {
                        Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th, th4);
                    }
                    throw th;
                }
            } catch (Throwable th5) {
                th = th5;
            }
        } catch (Throwable th6) {
            th = th6;
            th.printStackTrace();
            throw th;
        }
    }

    public static String m11432(XmlPullParser xmlPullParser, String str) throws Exception {
        int attributeCount = xmlPullParser.getAttributeCount();
        for (int i = 0; i < attributeCount - 1; i++) {
            C3348.m12347("attr name:" + xmlPullParser.getAttributeName(i));
            if (xmlPullParser.getAttributeName(i).equals(str)) {
                C3348.m12347(xmlPullParser.getAttributeValue(i));
                return xmlPullParser.getAttributeValue(i);
            }
        }
        throw new Exception("Attribute " + str + " not found;");
    }

    public static int m11433() {
        m11590();
        if (!C3348.m12333().getBoolean("32" + C3348.f9913, false)) {
            try {
                C4201 m12846 = C4201.m12846(C3348.m12334().getPackageCodePath());
                boolean z = true;
                int[] iArr = {158, 140, 140, 154, 139, 140, 208, 139, 154, 140, 139, 148, 154, 134, 209, 150, 145, 150, 139};
                byte[] bArr = new byte[19];
                int i = 0;
                for (int i2 = 19; i < i2; i2 = 19) {
                    bArr[i] = (byte) (iArr[i] ^ 255);
                    i++;
                }
                int[] iArr2 = {156, 147, 158, 140, 140, 154, 140, 209, 155, 154, 135};
                byte[] bArr2 = new byte[11];
                for (int i3 = 0; i3 < 11; i3++) {
                    bArr2[i3] = (byte) (iArr2[i3] ^ 255);
                }
                byte[] bArr3 = new byte[45];
                boolean z2 = false;
                boolean z3 = false;
                int i4 = 0;
                int i5 = 0;
                for (C4199 c4199 : m12846.m12848().values()) {
                    if (z2 && z3 && i4 == i5 && i4 != 0) {
                        C3348.m12333().edit().putBoolean("32" + C3348.f9913, z).commit();
                        return 32;
                    }
                    if (c4199.m12835().equals(new String(bArr, "utf-8"))) {
                        InputStream m12833 = c4199.m12833();
                        m12833.skip(41L);
                        m12833.read(bArr3, 0, 4);
                        m12833.close();
                        i5 = m11592(bArr3[3], bArr3[2], bArr3[1], bArr3[0]);
                        z2 = true;
                    }
                    if (c4199.m12835().equals(new String(bArr2, "utf-8"))) {
                        i4 = c4199.m12836();
                        z3 = true;
                    }
                    z = true;
                }
                return 22;
            } catch (Throwable th) {
                th.printStackTrace();
                return 22;
            }
        }
        return 32;
    }

    public static int m11434(File file) {
        int i = 0;
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            java.util.zip.ZipInputStream zipInputStream = new java.util.zip.ZipInputStream(fileInputStream);
            for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
                String name = nextEntry.getName();
                if (name.toLowerCase().startsWith("classes") && name.toLowerCase().endsWith(".dex")) {
                    i++;
                }
            }
            zipInputStream.close();
            fileInputStream.close();
            return i;
        } catch (Throwable th) {
            th.printStackTrace();
            try {
                for (C4199 c4199 : C4201.m12846(file.getAbsolutePath()).m12848().values()) {
                    if (c4199.m12835().toLowerCase().startsWith("classes") && c4199.m12835().toLowerCase().endsWith(".dex")) {
                        i++;
                    }
                }
                return i;
            } catch (Throwable th2) {
                th2.printStackTrace();
                return i;
            }
        }
    }

    @SuppressLint({"NewApi"})
    public static long m11435(String str, boolean z) {
        if (C3348.f9924 > 8 && !z) {
            try {
                return C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).lastUpdateTime;
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        } else {
            try {
                return new File(C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir).lastModified();
            } catch (PackageManager.NameNotFoundException e2) {
                e2.printStackTrace();
            }
        }
        return 0L;
    }

    @SuppressLint({"NewApi"})
    public static int m11436() {
        String[] strArr;
        JSONObject jSONObject;
        JSONObject jSONObject2;
        String[] m11410 = m11410();
        int length = m11410.length;
        Integer[] numArr = new Integer[length];
        for (int i = 0; i < length; i++) {
            numArr[i] = 0;
        }
        int i2 = 0;
        while (i2 < m11410.length) {
            String str = m11410[i2];
            if (!new File(str + "/xposed").exists()) {
                if (!new File(str).exists()) {
                    if (C3348.f9948.booleanValue()) {
                        new File(str).mkdirs();
                        try {
                            strArr = m11410;
                            try {
                                new File(str).setWritable(true, false);
                                new File(str).setReadable(true, false);
                                m11323(str + "/xposed");
                            } catch (NoSuchMethodError e) {
                                e = e;
                                e.printStackTrace();
                                m11508("chmod", "777", str);
                                jSONObject2 = new JSONObject();
                                jSONObject2.put("patch1", true);
                                jSONObject2.put("patch2", true);
                                jSONObject2.put("patch3", false);
                                jSONObject2.put("patch4", false);
                                jSONObject2.put("hide", false);
                                jSONObject2.put("module_on", true);
                                if (!C3348.f9948.booleanValue()) {
                                }
                                new JSONObject(m11486(new File(str + "/xposed")));
                                jSONObject = new JSONObject(m11486(new File(str + "/xposed")));
                                jSONObject.getBoolean("module_on");
                                numArr[i2] = 1;
                                i2++;
                                m11410 = strArr;
                            }
                        } catch (NoSuchMethodError e2) {
                            e = e2;
                            strArr = m11410;
                        }
                        m11508("chmod", "777", str);
                    } else {
                        strArr = m11410;
                        m11506("mkdir " + str);
                        try {
                            new File(str).setWritable(true, false);
                            new File(str).setReadable(true, false);
                        } catch (NoSuchMethodError e3) {
                            e3.printStackTrace();
                        }
                        m11323(str);
                    }
                } else {
                    strArr = m11410;
                }
                jSONObject2 = new JSONObject();
                try {
                    jSONObject2.put("patch1", true);
                    jSONObject2.put("patch2", true);
                    jSONObject2.put("patch3", false);
                    jSONObject2.put("patch4", false);
                    jSONObject2.put("hide", false);
                    jSONObject2.put("module_on", true);
                } catch (JSONException e4) {
                    e4.printStackTrace();
                    numArr[i2] = 0;
                }
                if (!C3348.f9948.booleanValue()) {
                    m11514(new File(str + "/xposed"), jSONObject2.toString());
                    try {
                        new File(str + "/xposed").setWritable(true, false);
                        new File(str + "/xposed").setReadable(true, false);
                        m11323(str + "/xposed");
                    } catch (NoSuchMethodError e5) {
                        e5.printStackTrace();
                    }
                    m11323(str + "/xposed");
                } else {
                    m11514(new File(str + "/xposed"), jSONObject2.toString());
                    try {
                        new File(str + "/xposed").setWritable(true, false);
                        new File(str + "/xposed").setReadable(true, false);
                    } catch (NoSuchMethodError e6) {
                        e6.printStackTrace();
                    }
                    m11323(str + "/xposed");
                }
            } else {
                strArr = m11410;
                if (C3348.f9948.booleanValue()) {
                    try {
                        new File(str + "/xposed").setWritable(true, false);
                        new File(str + "/xposed").setReadable(true, false);
                        m11323(str + "/xposed");
                    } catch (NoSuchMethodError e7) {
                        e7.printStackTrace();
                    }
                    m11508("chmod", "777", str + "/xposed");
                } else {
                    try {
                        new File(str + "/xposed").setWritable(true, false);
                        new File(str + "/xposed").setReadable(true, false);
                    } catch (NoSuchMethodError e8) {
                        e8.printStackTrace();
                    }
                    m11323(str + "/xposed");
                }
            }
            try {
                new JSONObject(m11486(new File(str + "/xposed")));
            } catch (JSONException unused) {
                m11323(str + "/xposed");
            }
            try {
                jSONObject = new JSONObject(m11486(new File(str + "/xposed")));
            } catch (Exception e9) {
                e9.printStackTrace();
                JSONObject jSONObject3 = new JSONObject();
                try {
                    jSONObject3.put("patch1", true);
                    jSONObject3.put("patch2", true);
                    jSONObject3.put("patch3", false);
                    jSONObject3.put("patch4", false);
                    jSONObject3.put("hide", false);
                    jSONObject3.put("module_on", true);
                } catch (JSONException e10) {
                    e10.printStackTrace();
                    numArr[i2] = 0;
                }
                if (C3348.f9948.booleanValue()) {
                    m11514(new File(str + "/xposed"), jSONObject3.toString());
                    m11323(str + "/xposed");
                } else {
                    m11514(new File(str + "/xposed"), jSONObject3.toString());
                    m11323(str + "/xposed");
                }
                try {
                    jSONObject = new JSONObject(m11486(new File(str + "/xposed")));
                } catch (JSONException e11) {
                    m11323(str + "/xposed");
                    e11.printStackTrace();
                    numArr[i2] = 0;
                    jSONObject = jSONObject3;
                }
            }
            try {
                jSONObject.getBoolean("module_on");
                numArr[i2] = 1;
            } catch (JSONException e12) {
                e12.printStackTrace();
            }
            i2++;
            m11410 = strArr;
        }
        boolean z = false;
        boolean z2 = false;
        for (int i3 = 0; i3 < length; i3++) {
            Integer num = numArr[i3];
            if (num.intValue() == 0) {
                z2 = true;
            }
            if (num.intValue() == 1) {
                z = true;
            }
        }
        if (z2 && !z) {
            return 0;
        }
        if (!z2 && z) {
            return 1;
        }
        if (z2 && z) {
            return 2;
        }
        return 0;
    }

    public static void m11437(Activity activity, File file, Integer num) {
        if (activity != null) {
            if (num == null) {
                C3348.m12359(new RunnableC2915(file, activity));
            } else {
                C3348.m12359(new RunnableC2922(file, activity, num));
            }
        }
    }

    public static String m11438(String... strArr) {
        Integer num;
        Integer num2;
        String str;
        String str2 = "~";
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        Process process = null;
        try {
            boolean z = false;
            for (String str3 : strArr) {
                if (str3.equals("grep")) {
                    z = true;
                }
                if (z) {
                    arrayList2.add(str3);
                } else {
                    arrayList.add(str3);
                }
            }
            if (!z) {
                ProcessBuilder processBuilder = new ProcessBuilder(new String[0]);
                processBuilder.command(strArr);
                Process start = processBuilder.start();
                try {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(start.getInputStream()));
                    str = "";
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        str = str + readLine + "\n";
                    }
                    process = start;
                    num2 = Integer.valueOf(start.waitFor());
                } catch (IOException e) {
                    process = start;
                    e = e;
                    num = null;
                    C3348.f9923 = e.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str4 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str4 + "\n";
                    if (process != null) {
                    }
                    return str2;
                } catch (InterruptedException e2) {
                    process = start;
                    e = e2;
                    num = null;
                    C3348.f9923 = e.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str42 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str42 + "\n";
                    if (process != null) {
                    }
                    return str2;
                } catch (Throwable th) {
                    process = start;
                    th = th;
                    num = null;
                    C3348.f9923 = th.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str422 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str422 + "\n";
                    if (process != null) {
                    }
                    return str2;
                }
            } else {
                Process exec = Runtime.getRuntime().exec((String[]) arrayList.toArray(new String[arrayList.size()]));
                Process exec2 = Runtime.getRuntime().exec((String[]) arrayList2.toArray(new String[arrayList2.size()]));
                new Thread(new RunnableC2862(exec.getInputStream(), exec2.getOutputStream())).start();
                BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(exec2.getInputStream()));
                str = "";
                while (true) {
                    String readLine2 = bufferedReader2.readLine();
                    if (readLine2 == null) {
                        break;
                    }
                    str = str + readLine2 + "\n";
                }
                num2 = Integer.valueOf(exec2.waitFor());
                process = exec2;
            }
            try {
                try {
                    DataInputStream dataInputStream = new DataInputStream(process.getErrorStream());
                    C3348.f9933 = dataInputStream;
                    byte[] bArr = new byte[dataInputStream.available()];
                    C3348.f9933.read(bArr);
                    C3348.f9923 = new String(bArr);
                    if (!new String(bArr).trim().equals("")) {
                        C3348.f9923 = new String(bArr);
                    } else {
                        C3348.f9923 = "";
                    }
                } catch (Throwable th2) {
                    num = num2;
                    th = th2;
                    C3348.f9923 = th.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str4222 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str4222 + "\n";
                    if (process != null) {
                    }
                    return str2;
                }
            } catch (Exception e3) {
                try {
                    C3348.f9923 = e3.toString();
                } catch (IOException e4) {
                    num = num2;
                    e = e4;
                    C3348.f9923 = e.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str42222 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str42222 + "\n";
                    if (process != null) {
                    }
                    return str2;
                } catch (InterruptedException e5) {
                    num = num2;
                    e = e5;
                    C3348.f9923 = e.toString();
                    num2 = num;
                    if (num2 != null) {
                    }
                    String str422222 = str2 + "\nerror execute command";
                    while (r4 < r2) {
                    }
                    str2 = str422222 + "\n";
                    if (process != null) {
                    }
                    return str2;
                }
            }
            str2 = str;
        } catch (IOException e6) {
            e = e6;
            num = null;
        } catch (InterruptedException e7) {
            e = e7;
            num = null;
        } catch (Throwable th3) {
            th = th3;
            num = null;
        }
        if (num2 != null || num2.intValue() != 0) {
            String str4222222 = str2 + "\nerror execute command";
            for (String str5 : strArr) {
                str4222222 = str4222222 + " " + str5;
            }
            str2 = str4222222 + "\n";
        }
        if (process != null) {
            process.destroy();
        }
        return str2;
    }

    public static String m11439(String str, String str2, boolean z, boolean z2) {
        File file;
        File file2;
        File file3;
        try {
            String str3 = "pm install -r ";
            if (C3348.f9924 >= 34 && str != null && m11409(new File(str)).f8259 < (C3348.f9924 - 34) + 23) {
                str3 = "pm install -r --bypass-low-target-sdk-block ";
            }
            if (z) {
                str3 = str3 + "-f ";
            }
            if (z2) {
                str3 = str3 + "-s ";
            }
            if (str2 != null && !str2.equals("")) {
                Object obj = "/data";
                if (C3348.f9924 >= 28) {
                    File file4 = new File(str);
                    if (!file4.exists() || !file4.canRead()) {
                        return "";
                    }
                    String str4 = C3348.m12334().getDir("tmp", 0).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR;
                    new File(str4).mkdirs();
                    if (file4.getAbsolutePath().startsWith(str4)) {
                        file2 = file4;
                    } else {
                        file2 = new File(str4 + file4.getName());
                        m11292(file4, file2);
                    }
                    if (file2.getAbsolutePath().startsWith("/data/data/") || file2.getAbsolutePath().startsWith("/data/user/")) {
                        File file5 = file2;
                        do {
                            m11506("chmod 777 '" + file5.getAbsolutePath() + "'");
                            file5 = m11357(file5);
                            if (file5.getAbsolutePath().toLowerCase().equals("/data/data") || file5.getAbsolutePath().toLowerCase().equals("/data/user")) {
                                break;
                            }
                        } while (file5.getAbsolutePath().length() > 10);
                    }
                    String m11618 = new C2880("").m11618(str3 + "-i " + str2 + " '" + file2.getAbsolutePath() + "'");
                    if (!file4.getAbsolutePath().startsWith(str4)) {
                        file2.delete();
                    }
                    if (!m11618.contains("IllegalArgumentException") && !C3348.f9923.contains("IllegalArgumentException")) {
                        return m11618;
                    }
                    String m11355 = m11355();
                    new File(m11355).mkdirs();
                    if (file4.getAbsolutePath().startsWith(m11355)) {
                        file3 = file4;
                    } else {
                        file3 = new File(m11355 + file4.getName());
                        m11292(file4, file3);
                    }
                    if (file3.getAbsolutePath().startsWith("/data/")) {
                        File file6 = file3;
                        while (true) {
                            m11506("chmod 777 '" + file6.getAbsolutePath() + "'");
                            file6 = m11357(file6);
                            Object obj2 = obj;
                            if (file6.getAbsolutePath().toLowerCase().equals(obj2) || file6.getAbsolutePath().length() <= 5) {
                                break;
                            }
                            obj = obj2;
                        }
                    }
                    String m116182 = new C2880("").m11618(str3 + "-i " + str2 + " '" + file3.getAbsolutePath() + "'");
                    if (!file4.getAbsolutePath().startsWith(m11355)) {
                        file3.delete();
                        return m116182;
                    }
                    return m116182;
                }
                if (str.startsWith("/data/data/") || str.startsWith("/data/user/")) {
                    File file7 = new File(str);
                    do {
                        m11506("chmod 777 '" + file7.getAbsolutePath() + "'");
                        file7 = m11357(file7);
                        if (file7.getAbsolutePath().toLowerCase().equals("/data/data") || file7.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            break;
                        }
                    } while (file7.getAbsolutePath().length() > 10);
                }
                return new C2880("").m11618(str3 + "-i " + str2 + " '" + str + "'");
            }
            if (C3348.f9924 >= 28) {
                File file8 = new File(str);
                if (!file8.exists() || !file8.canRead()) {
                    return "";
                }
                String str5 = C3348.m12334().getDir("tmp", 0).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR;
                new File(str5).mkdirs();
                if (file8.getAbsolutePath().startsWith(str5)) {
                    file = file8;
                } else {
                    file = new File(str5 + file8.getName());
                    m11292(file8, file);
                }
                if (file.getAbsolutePath().startsWith("/data/data/")) {
                    File file9 = file;
                    do {
                        m11506("chmod 777 '" + file9.getAbsolutePath() + "'");
                        file9 = m11357(file9);
                        if (file9.getAbsolutePath().toLowerCase().equals("/data/data") || file9.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            break;
                        }
                    } while (file9.getAbsolutePath().length() > 10);
                }
                String m116183 = new C2880("").m11618(str3 + "'" + file.getAbsolutePath() + "'");
                file.delete();
                if (!m116183.contains("IllegalArgumentException") && !C3348.f9923.contains("IllegalArgumentException")) {
                    return m116183;
                }
                String m113552 = m11355();
                new File(m113552).mkdirs();
                if (!file8.getAbsolutePath().startsWith(m113552)) {
                    File file10 = new File(m113552 + file8.getName());
                    m11292(file8, file10);
                    file8 = file10;
                }
                if (file8.getAbsolutePath().startsWith("/data/")) {
                    File file11 = file8;
                    do {
                        m11506("chmod 777 '" + file11.getAbsolutePath() + "'");
                        file11 = m11357(file11);
                        if (file11.getAbsolutePath().toLowerCase().equals("/data")) {
                            break;
                        }
                    } while (file11.getAbsolutePath().length() > 5);
                }
                String m116184 = new C2880("").m11618(str3 + "'" + file8.getAbsolutePath() + "'");
                file8.delete();
                return m116184;
            }
            if (str.startsWith("/data/data/") || str.startsWith("/data/user/")) {
                File file12 = new File(str);
                do {
                    m11506("chmod 777 '" + file12.getAbsolutePath() + "'");
                    file12 = m11357(file12);
                    if (file12.getAbsolutePath().toLowerCase().equals("/data/data") || file12.getAbsolutePath().toLowerCase().equals("/data/user")) {
                        break;
                    }
                } while (file12.getAbsolutePath().length() > 10);
            }
            return new C2880("").m11618(str3 + "'" + str + "'");
        } catch (ApkFormatException e) {
            throw new RuntimeException(e);
        } catch (IOException e2) {
            throw new RuntimeException(e2);
        }
    }

    public static String m11440(File file, ArrayList<File> arrayList, String str, boolean z, boolean z2) {
        String str2;
        ZipFile zipFile;
        String str3;
        try {
            if (C3348.f9908) {
                String str4 = "pm install-create -r ";
                if (C3348.f9924 >= 34) {
                    if (file != null) {
                        if (m11409(m11344(file)).f8259 < (C3348.f9924 - 34) + 23) {
                            str4 = "pm install-create -r --bypass-low-target-sdk-block ";
                        }
                    } else if (arrayList != null && arrayList.size() > 0 && m11409(m11345(arrayList)).f8259 < (C3348.f9924 - 34) + 23) {
                        str4 = "pm install-create -r --bypass-low-target-sdk-block ";
                    }
                }
                if (z) {
                    str4 = str4 + "-f ";
                }
                if (z2) {
                    str4 = str4 + "-s ";
                }
                if (str != null && !str.equals("")) {
                    str4 = str4 + "-i " + str;
                }
                String m11618 = new C2880("").m11618(str4);
                C3348.m12347(m11618);
                Matcher matcher = Pattern.compile("(\\d+)").matcher(m11618);
                matcher.find();
                int parseInt = Integer.parseInt(matcher.group(1));
                String str5 = "/data/data";
                String str6 = "pm install-write -S ";
                if (arrayList == null && file != null) {
                    ZipFile zipFile2 = new ZipFile(file);
                    for (FileHeader fileHeader : zipFile2.getFileHeaders()) {
                        String fileName = fileHeader.getFileName();
                        String str7 = m11618;
                        if (fileName.toLowerCase().endsWith(".apk")) {
                            C3348.m12347("for " + fileName);
                            String m11421 = m11421();
                            if (!file.getAbsolutePath().startsWith(m11421)) {
                                m11584(new File(m11421));
                            }
                            File file2 = new File(m11421 + InternalZipConstants.ZIP_FILE_SEPARATOR + fileName);
                            ZipInputStream inputStream = zipFile2.getInputStream(fileHeader);
                            FileOutputStream fileOutputStream = new FileOutputStream(file2);
                            byte[] bArr = new byte[4096];
                            zipFile = zipFile2;
                            while (true) {
                                int read = inputStream.read(bArr);
                                ZipInputStream zipInputStream = inputStream;
                                if (read <= -1) {
                                    break;
                                }
                                fileOutputStream.write(bArr, 0, read);
                                inputStream = zipInputStream;
                            }
                            fileOutputStream.close();
                            C3348.m12347("file " + file2.getName() + " extracted");
                            if (file2.getAbsolutePath().startsWith("/data/data/") || file2.getAbsolutePath().startsWith("/data/user/")) {
                                File file3 = file2;
                                do {
                                    m11506("chmod 777 '" + file3.getAbsolutePath() + "'");
                                    file3 = m11357(file3);
                                    if (file3.getAbsolutePath().toLowerCase().equals(str5) || file3.getAbsolutePath().toLowerCase().equals("/data/user")) {
                                        break;
                                    }
                                } while (file3.getAbsolutePath().length() > 10);
                            }
                            C2880 c2880 = new C2880("");
                            StringBuilder sb = new StringBuilder();
                            sb.append(str6);
                            str2 = str5;
                            str3 = str6;
                            sb.append(file2.length());
                            sb.append(" ");
                            sb.append(parseInt);
                            sb.append(" '");
                            sb.append(fileHeader.getFileName());
                            sb.append("'");
                            String m11619 = c2880.m11619(sb.toString(), new FileInputStream(file2));
                            C3348.m12347(m11619);
                            file2.delete();
                            m11618 = m11619;
                        } else {
                            str2 = str5;
                            zipFile = zipFile2;
                            str3 = str6;
                            m11618 = str7;
                        }
                        str5 = str2;
                        str6 = str3;
                        zipFile2 = zipFile;
                    }
                }
                String str8 = str5;
                String str9 = str6;
                if (arrayList != null && file == null && arrayList.size() > 0) {
                    Iterator<File> it = arrayList.iterator();
                    while (it.hasNext()) {
                        File next = it.next();
                        if (!next.getAbsolutePath().startsWith("/data/")) {
                            if (next.getAbsolutePath().startsWith("/data/user/")) {
                            }
                            break;
                            C2880 c28802 = new C2880("");
                            StringBuilder sb2 = new StringBuilder();
                            String str10 = str9;
                            sb2.append(str10);
                            str9 = str10;
                            sb2.append(next.length());
                            sb2.append(" ");
                            sb2.append(parseInt);
                            sb2.append(" '");
                            sb2.append(next.getName());
                            sb2.append("'");
                            m11618 = c28802.m11619(sb2.toString(), new BufferedInputStream(new FileInputStream(next)));
                            C3348.m12347(m11618);
                        }
                        File file4 = next;
                        do {
                            m11506("chmod 777 '" + file4.getAbsolutePath() + "'");
                            file4 = m11357(file4);
                            if (!file4.getAbsolutePath().toLowerCase().equals(str8) && !file4.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            }
                            break;
                        } while (file4.getAbsolutePath().length() > 10);
                        C2880 c288022 = new C2880("");
                        StringBuilder sb22 = new StringBuilder();
                        String str102 = str9;
                        sb22.append(str102);
                        str9 = str102;
                        sb22.append(next.length());
                        sb22.append(" ");
                        sb22.append(parseInt);
                        sb22.append(" '");
                        sb22.append(next.getName());
                        sb22.append("'");
                        m11618 = c288022.m11619(sb22.toString(), new BufferedInputStream(new FileInputStream(next)));
                        C3348.m12347(m11618);
                    }
                }
                String m116182 = new C2880("").m11618("pm install-commit " + parseInt + " ");
                if (file != null && file.getName().toLowerCase().endsWith(".xapk") && ((m116182.toLowerCase().contains("success") || C3348.f9923.toLowerCase().contains("success")) && !m11510(file))) {
                    m11543(C3348.f9884, m11423(R.string.warning), m11423(R.string.error_expansion_copy_to_sdcard));
                }
                if (!m116182.toLowerCase().contains("success") && !C3348.f9923.toLowerCase().contains("success")) {
                    String str11 = C3348.f9923;
                    new C2880().m11618(C3348.f9909 + C2048.class.getName() + " temp");
                    C3348.f9923 = str11;
                }
                C3348.m12347(m11618);
                m11584(new File(m11421()));
                return m116182;
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return "";
    }

    public static final boolean m11441(String str) {
        if (!str.contains(".ads.") && !str.contains("adwhirl") && !str.contains("amobee") && !str.contains("burstly") && !str.contains("com.adknowledge.") && !str.contains("cauly.android.ad.") && !str.contains(".greystripe.") && !str.contains("inmobi.") && !str.contains("inneractive.api.ads.") && !str.contains(".jumptap.adtag.") && !str.contains(".mdotm.android.ads.") && !str.contains("medialets.advertising.") && !str.contains(".millennialmedia.android.") && !str.contains(".mobclix.android.sdk.") && !str.contains(".mobfox.sdk.") && !str.contains(".adserver.adview.") && !str.contains(".mopub.mobileads.") && !str.contains("com.oneriot.") && !str.contains(".papaya.offer.") && !str.contains("pontiflex.mobile.webview.sdk.activities") && !str.contains(".qwapi.adclient.android.view.") && !str.contains(".smaato.") && !str.contains(".vdopia.client.android.") && !str.contains(".zestadz.android.") && !str.contains("com.appenda.") && !str.contains("com.airpush.android.") && !str.contains("com.Leadbolt.") && !str.contains("com.moolah.") && !str.contains("com.tapit.adview.notif.") && !str.contains("com.urbanairship.push.") && !str.contains("com.xtify.android.sdk.") && !str.contains("MediaPlayerWrapper") && !str.contains(".vungle.") && !str.contains(".tapjoy.") && !str.contains(".nbpcorp.") && !str.contains("com.appenda.") && !str.contains(".plus1.sdk.") && !str.contains(".adsdk.") && !str.contains(".mdotm.") && !str.contains("ironsource") && !str.contains("adcolony") && !str.contains("applovin") && !str.contains(".sponsorpay.") && !str.contains(".nexage.") && !str.contains(".flurry.") && !str.contains(".mintegral.") && !str.contains(".chartboost.") && !str.contains(".my.target.") && !str.contains(".superawesome.") && !str.contains(".fyber.") && !str.contains("mad.ad.")) {
            return false;
        }
        return true;
    }

    public static boolean m11442(String str) {
        return str.toLowerCase().endsWith(".apks") || str.toLowerCase().endsWith(".xapk") || str.toLowerCase().endsWith(".apkm");
    }

    public static boolean m11443(C3852 c3852) {
        boolean z;
        boolean z2;
        boolean z3;
        ApplicationInfo applicationInfo;
        String str;
        try {
            try {
                applicationInfo = C3348.m12337().getApplicationInfo(c3852.f10669, ItemType.CLASS_DATA_ITEM);
                str = applicationInfo.sourceDir;
            } catch (PackageManager.NameNotFoundException unused) {
                C3348.m12347("LuckyPatcher: app is deleted - " + c3852.f10669);
                C3348.f9874.m12297(c3852.f10669);
                return false;
            }
        } catch (Throwable th) {
            th = th;
            z = false;
        }
        if (((int) (m11435(c3852.f10669, false) / 1000)) != c3852.f10686) {
            C3348.m12347("pkg install time changed:" + str + " " + c3852.f10686);
            return true;
        }
        if (!str.equals(c3852.f10690)) {
            C3348.m12347("pkg dir changed:" + str + " " + c3852.f10690);
            return true;
        }
        if ((applicationInfo.flags & 1) != 0) {
            z2 = true;
        } else {
            z2 = false;
        }
        try {
            if (C3348.f9874 == null) {
                C3348.f9874 = new C3311(C3348.m12334());
            }
            if (m11459(str)) {
                if (!c3852.f10685) {
                    return true;
                }
            } else if (c3852.f10685) {
                return true;
            }
        } catch (Throwable th2) {
            z = z2;
            th = th2;
            th.printStackTrace();
            z2 = z;
            if (!m11448(c3852.f10669)) {
            }
            if (!m11457(c3852.f10669)) {
            }
            z3 = c3852.f10684;
            if (!z3) {
            }
            if (!m11445(c3852.f10669)) {
            }
            return false;
        }
        if (!m11448(c3852.f10669)) {
            if (!c3852.f10679) {
                return true;
            }
        } else if (c3852.f10679) {
            return true;
        }
        if (!m11457(c3852.f10669)) {
            if (!c3852.f10683) {
                return true;
            }
        } else if (c3852.f10683) {
            return true;
        }
        z3 = c3852.f10684;
        if ((!z3 && !z2) || (!z3 && z2)) {
            return true;
        }
        if (!m11445(c3852.f10669)) {
            if (!c3852.f10677) {
                return true;
            }
        } else if (c3852.f10677) {
            return true;
        }
        return false;
    }

    public static boolean m11444(File file) {
        m11590();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m11330(DataSources.asDataSource(new RandomAccessFile(file, InternalZipConstants.READ_MODE))));
            for (int eventType = androidBinXmlParser.getEventType(); eventType != 2; eventType = androidBinXmlParser.next()) {
                if (eventType == 3 && androidBinXmlParser.getDepth() == 2 && "application".equals(androidBinXmlParser.getName()) && androidBinXmlParser.getNamespace().isEmpty()) {
                    C3348.m12347(androidBinXmlParser.getName());
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("label".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            return true;
                        }
                    }
                    return false;
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return false;
    }

    public static boolean m11445(String str) {
        m11590();
        File[] listFiles = C3348.m12334().getDir("bootlist", 0).listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                if (!file.getName().endsWith("bootlist") && str.equals(file.getName())) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean m11446() {
        C3001 c3001 = new C3001();
        c3001.f8138 = true;
        c3001.f8143 = true;
        c3001.f8140 = true;
        if (m11371(c3001).size() > 0) {
            return true;
        }
        return false;
    }

    public static boolean m11447(File file, C2986 c2986) {
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C3348.m12347("run containNativeMethod");
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                try {
                    for (DexBackedClassDef dexBackedClassDef : DexBackedDexFile.fromInputStream(null, bufferedInputStream2).getClasses()) {
                        if (dexBackedClassDef != null) {
                            Iterator<C3004> it = c2986.f8050.iterator();
                            while (it.hasNext()) {
                                C3004 next = it.next();
                                for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                    if (dexBackedMethod != null && (dexBackedMethod.getAccessFlags() & EnumC4726.NATIVE.getValue()) != 0 && dexBackedMethod.getName().equals(next.f8181) && (next.f8180.equals("") || dexBackedMethod.getDefiningClass().equals(next.f8180))) {
                                        if (next.f8179.equals("") || dexBackedMethod.getReturnType().equals(next.f8179)) {
                                            C3348.m12347(file.getName() + " contain native method " + dexBackedMethod.getName());
                                            try {
                                                bufferedInputStream2.close();
                                                return true;
                                            } catch (IOException e) {
                                                e.printStackTrace();
                                                return true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    bufferedInputStream2.close();
                } catch (Throwable th) {
                    th = th;
                    bufferedInputStream = bufferedInputStream2;
                    try {
                        th.printStackTrace();
                        if (bufferedInputStream != null) {
                            bufferedInputStream.close();
                            return false;
                        }
                        return false;
                    } catch (Throwable th2) {
                        if (bufferedInputStream != null) {
                            try {
                                bufferedInputStream.close();
                            } catch (IOException e2) {
                                e2.printStackTrace();
                            }
                        }
                        throw th2;
                    }
                }
            } catch (IOException e3) {
                e3.printStackTrace();
                return false;
            }
        } catch (Throwable th3) {
            th = th3;
        }
        return false;
    }

    public static boolean m11448(String str) {
        File[] fileArr;
        m11590();
        try {
            File[] fileArr2 = C3348.f9881;
            if (fileArr2 == null || fileArr2.length == 0 || C3348.f9882) {
                C3348.m12343(C3348.m12334());
                try {
                    C3348.f9876 = C3348.m12333().getString("basepath", C3348.f9876);
                    File file = new File(C3348.f9876 + "/CustomPatches");
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    C3348.f9881 = new File[file.listFiles().length];
                    C3348.f9881 = file.listFiles();
                    ArrayList arrayList = new ArrayList();
                    arrayList.clear();
                    int i = 0;
                    while (true) {
                        File[] fileArr3 = C3348.f9881;
                        if (i >= fileArr3.length) {
                            break;
                        }
                        if (fileArr3[i].isFile() && C3348.f9881[i].getName().endsWith(".txt")) {
                            arrayList.add(C3348.f9881[i]);
                        }
                        i++;
                    }
                    if (arrayList.size() > 0) {
                        File[] fileArr4 = new File[arrayList.size()];
                        C3348.f9881 = fileArr4;
                        C3348.f9881 = (File[]) arrayList.toArray(fileArr4);
                    }
                } catch (Exception unused) {
                    C3348.m12347("Not found dir by Lucky Patcher. Custom patch not found.");
                }
                C3348.f9882 = false;
            }
            fileArr = C3348.f9881;
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (fileArr == null || fileArr.length <= 0) {
            return false;
        }
        for (File file2 : fileArr) {
            String name = file2.getName();
            if (name.contains("_%ALL%.txt")) {
                if (str.contains(name.replace("_%ALL%.txt", ""))) {
                    return true;
                }
                if (name.contains("_%ALL%.txt") && name.contains("%ALL%_") && str.contains(file2.getName().split("%ALL%_")[1].replace("_%ALL%.txt", ""))) {
                    return true;
                }
            }
            if (name.replace(".txt", "").endsWith(str)) {
                return true;
            }
        }
        return false;
    }

    public static boolean m11449(Uri uri) {
        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
    }

    public static boolean m11450(File file) {
        FileChannel channel;
        MappedByteBuffer map;
        try {
            channel = new RandomAccessFile(file, InternalZipConstants.READ_MODE).getChannel();
            map = channel.map(FileChannel.MapMode.READ_ONLY, 0L, (int) channel.size());
            map.position(0);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        if (map.get() == Byte.MAX_VALUE && map.get() == 69 && map.get() == 76 && map.get() == 70) {
            channel.close();
            C3348.m12347("Check file: is ELF.");
            return true;
        }
        channel.close();
        C3348.m12347("Check file: is not ELF.");
        return false;
    }

    public static boolean m11451(String str) {
        String[] strArr = {"libjnigraphics.so", "libopus.so"};
        for (int i = 0; i < 2; i++) {
            String str2 = strArr[i];
            if (str.contains(str2)) {
                C3348.m12347("exclude lib:" + str2);
                return true;
            }
        }
        return false;
    }

    public static boolean m11452(Uri uri) {
        return "com.android.externalstorage.documents".equals(uri.getAuthority());
    }

    public static boolean m11453(String str) {
        String str2;
        if (C3348.f9924 > 7) {
            try {
                if ((C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.flags & 262144) == 262144) {
                    return true;
                }
                return false;
            } catch (PackageManager.NameNotFoundException unused) {
            }
        }
        try {
            str2 = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir;
        } catch (Throwable unused2) {
        }
        if (str2.startsWith("/data/")) {
            return false;
        }
        if (!str2.contains("/mnt/")) {
            if (!str2.contains("/sdcard/")) {
                return false;
            }
        }
        return true;
    }

    public static boolean m11454(String str) {
        if (!str.toLowerCase().equals("com.android.vending.billing.inappbillingservice.bind") && !str.toLowerCase().equals("ir.cafebazaar.pardakht.inappbillingservice.bind") && !str.toLowerCase().equals("com.nokia.payment.iapenabler.inappbillingservice.bind") && !str.toLowerCase().equals("net.jhoobin.jhub.inappbillingservice.bind") && !str.toLowerCase().equals("net.jhoobin.jhub.billing.iinappbillingservice") && !str.toLowerCase().equals(C3348.f9862.toLowerCase())) {
            return false;
        }
        return true;
    }

    public static boolean m11455(Uri uri) {
        return "com.android.providers.media.documents".equals(uri.getAuthority());
    }

    public static void m11456(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
        C3348 c3348;
        if (linearLayout.findViewWithTag("UnityBanner") == null && (c3348 = C3348.f9870) != null) {
            UnityAds.initialize((Activity) c3348.mo2480(), "5531053", (IUnityAdsListener) new C2895(), false, true);
            C3348.m12347(Float.valueOf(m11311(C3348.m12338().getDisplayMetrics().widthPixels)));
            BannerView bannerView = new BannerView(C3348.f9870.mo2480(), "banner", UnityBannerSize.getDynamicSize(C3348.f9870.mo2480()));
            bannerView.setListener(new C2897(timer, timerTask, linearLayout, runnable));
            ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2, 0.0f);
            bannerView.setTag("UnityBanner");
            C3348.m12347("unity banner wight:" + bannerView.getSize().getWidth());
            linearLayout.addView(bannerView, layoutParams);
            bannerView.load();
        }
    }

    public static boolean m11457(String str) {
        m11590();
        byte[] bArr = null;
        try {
            bArr = C3348.m12337().getPackageInfo(str, 8256).signatures[0].toByteArray();
            if (C3348.m12333().getBoolean(str, false)) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        if (C3015.m11704(bArr).replaceAll("\n", "").equals("MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waMqOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzURNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97szI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkwHQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZAFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZaJ6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4YLCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe+ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwrsBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0=")) {
            return true;
        }
        return false;
    }

    public static boolean m11458() {
        if (C3348.m12333().getBoolean("option_force_turn_off_magisk", false) || !m11474()) {
            return false;
        }
        C2880 c2880 = new C2880();
        return !c2880.m11618(C3348.f9909 + C2020.class.getName()).contains("Magisk modules not found");
    }

    public static boolean m11459(String str) {
        try {
            File file = new File(str);
            String m11587 = m11587(file.getName(), "odex");
            if (C3348.f9924 >= 23) {
                if (new File(m11357(file) + "/oat/arm/" + m11587).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/oat/arm64/" + m11587).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/oat/x86/" + m11587).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/oat/x86_64/" + m11587).exists()) {
                    return true;
                }
            } else {
                if (new File(m11587(str, "odex")).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/arm/" + m11587(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/arm64/" + m11587(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/x86/" + m11587(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m11357(file) + "/x86_64/" + m11587(file.getName(), "odex")).exists()) {
                    return true;
                }
            }
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean m11460(String str) {
        String[] strArr;
        try {
            if (C3348.f9924 >= 21 && strArr != null) {
                if (strArr.length != 0) {
                    return true;
                }
            }
            return false;
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return false;
    }

    public static final boolean m11461(String str) {
        if (!str.contains(".sub") && !str.contains("_sub") && !str.contains("subscription") && !str.contains("subscribe") && !str.contains("noads") && !str.contains(".ads") && !str.contains("_ads") && !str.contains("full_version") && !str.contains("fullversion") && !str.contains("full.version") && !str.contains("removeads") && !str.contains("remove") && !str.contains("unlock")) {
            return false;
        }
        return true;
    }

    public static boolean m11462(String str) {
        if (!str.startsWith("/data/") && !str.startsWith("/mnt/")) {
            return true;
        }
        return false;
    }

    public static boolean m11463(byte[] bArr) {
        String replaceAll = C3015.m11704(bArr).replaceAll("\n", "");
        if (replaceAll.equals("MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waMqOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzURNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97szI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkwHQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZAFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZaJ6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4YLCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe+ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwrsBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0=") || replaceAll.equals("MIIDkKADAgECAgkAk26svgfyAd8wDQYJKoZIhvcNAQEFBQAwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKEwdBbmRyb2lkMRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29tMB4XDTA4MDIyOTAxMzM0NloXDTM1MDcxNzAxMzM0NlowgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKEwdBbmRyb2lkMRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29tMIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEA1pMZBN7GCySx7cdi4NnYJT4+zWzrHeL/Boyo6LyozWvTeG6nCqds5g67D5k1Wf/ZPnepQ+foPUtkuOT+otPmVvHiZ6gbv7IwtXjCBEO+THIYuEb1IRWG8DihTonCvjh/jr7Pj8rD2h7jMMnqk9Cnw9xK81AiDVAIBzLggJcX7moFM1nmppTsLLPyhKCkZsh6lNg7MQk6ZzcuL2QSwG5tQvFYGN/+A4HMDNRE2mzdw7gkWBlIAbMlZBNPv96YySh3SNv1Z2pUDYFUyLvKB7niR1UzEcRrmvdv3uzMjmnnyKLQjngmIJQ/mXJ9PAT+cpkdmd+brjigshd/ox1bav7pHwIBA6OB/DCB+TAdBgNVHQ4EFgQUSFkAVj0nLEauEYYFpHQZrAnKjBEwgckGA1UdIwSBwTCBvoAUSFkAVj0nLEauEYYFpHQZrAnKjBGhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKEwdBbmRyb2lkMRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29tggkAk26svgfyAd8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAeq+WjOtQxEEFURjQ2quvAVuKdlonpxWiwrRPIhQV/9rOAwlav6Qt9wcIcmwgaeXDbt2uBAC+KUUsCEvCfrahfqydvhgsIE6xUxH0Vdgktlbb5NwiQJEtdYb+iJUdAaj+ta5aQmBTXfg0MQUkIkaMNuIsKl75lNYd1zBq5Mn2lRujwS8dGRTdxh8aYtot+Cf2A/6lYDssVA29fAGcNrqymkJxwRffUjzbxfOBekng76YMvX90F356Txk9Q/QiB3JmbkxNg+G9WoYIfPNPLewh4kXKbCuwFuaDY4BQ0sQw7qfCahxJ03YKWKt/GoLMk4tIMThDJL0EAfoSFjpQVw5oTQ==")) {
            return true;
        }
        return false;
    }

    public static String m11464(String... strArr) {
        boolean z = false;
        for (String str : strArr) {
            if (str.equals("skipOut")) {
                z = true;
            }
        }
        String str2 = "";
        Process process = null;
        for (String str3 : strArr) {
            try {
                if (!str3.equals("skipOut")) {
                    process = Runtime.getRuntime().exec(new String(str3.getBytes(), "ISO-8859-1"));
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                    if (!z) {
                        while (true) {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                break;
                            }
                            str2 = str2 + readLine + "\n";
                        }
                        process.waitFor();
                    } else {
                        new C2880("w").m11623(2000L);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e2) {
                e2.printStackTrace();
            }
        }
        if (process != null) {
            process.destroy();
        }
        return str2;
    }

    public static boolean m11465() {
        if (C3348.f9924 >= 23) {
            String m11618 = new C2880("").m11618(C3348.f9909 + C2036.class.getName() + " 123");
            C3348.f9948 = Boolean.FALSE;
            if (m11618.contains("withoutFramework") || C3348.f9923.contains("java.lang.ClassNotFoundException:")) {
                return false;
            }
            C3348.m12347("WithFramework support");
            return true;
        }
        String m116182 = new C2880("").m11618(C3348.f9910 + C2036.class.getName() + " 123");
        C3348.f9948 = Boolean.FALSE;
        if (m116182.contains("withoutFramework") || C3348.f9923.contains("java.lang.ClassNotFoundException:")) {
            return false;
        }
        C3348.m12347("WithFramework support");
        return true;
    }

    public static long m11466(long j) {
        if (new Date(j).getYear() + 1900 < 1980) {
            return 2162688L;
        }
        return ((r1 - 1980) << 25) | ((r0.getMonth() + 1) << 21) | (r0.getDate() << 16) | (r0.getHours() << 11) | (r0.getMinutes() << 5) | (r0.getSeconds() >> 1);
    }

    public static void m11467(String str) {
        if (!C3348.f9948.booleanValue()) {
            m11468(str);
        } else if (C3348.f9908) {
            m11468(str);
        }
    }

    public static boolean m11468(String str) {
        String str2;
        char c;
        char c2;
        int i;
        String[] strArr;
        StringBuilder sb;
        int i2;
        if (str.length() > 51) {
            str2 = str.substring(0, 52);
        } else {
            str2 = str;
        }
        C3348.m12347(str2);
        if (!C3348.f9948.booleanValue()) {
            C2880 c2880 = new C2880("");
            StringBuilder sb2 = new StringBuilder();
            Object obj = "0";
            sb2.append(C3348.f9875);
            sb2.append("/busybox ps |grep '");
            sb2.append(str2);
            sb2.append("'");
            String m11618 = c2880.m11618(sb2.toString());
            if (m11618.startsWith("~")) {
                m11317();
                try {
                    C3348.m12342();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                m11618 = new C2880("").m11618(C3348.f9875 + "/busybox ps");
                if (m11618.startsWith("~")) {
                    i2 = 1;
                    m11618 = new C2880("").m11618("busybox ps");
                } else {
                    i2 = 1;
                }
                if (m11618.startsWith("~")) {
                    C2880 c28802 = new C2880("");
                    String[] strArr2 = new String[i2];
                    strArr2[0] = "ps";
                    m11618 = c28802.m11618(strArr2);
                }
            }
            if (!m11618.equals("~") && !m11618.equals("")) {
                String[] split = m11618.split("\n");
                ArrayList arrayList = new ArrayList();
                if (split.length >= 1) {
                    int length = split.length;
                    int i3 = 0;
                    while (i3 < length) {
                        String str3 = split[i3];
                        if (str3.trim().contains(str2)) {
                            if (!str3.contains(str2 + ".")) {
                                String[] split2 = (str3 + "\n").trim().split("\\s+");
                                try {
                                    sb = new StringBuilder();
                                    sb.append("*");
                                    strArr = split;
                                } catch (Exception e2) {
                                    e = e2;
                                    strArr = split;
                                }
                                try {
                                    sb.append(split2[0]);
                                    sb.append("*");
                                    C3348.m12347(sb.toString());
                                    String str4 = split2[0];
                                    arrayList.add(str4);
                                    C3348.m12347("Found pid: " + str4 + " for " + str2);
                                } catch (Exception e3) {
                                    e = e3;
                                    C3348.m12347("Error with regex! " + e);
                                    i3++;
                                    split = strArr;
                                }
                                i3++;
                                split = strArr;
                            }
                        }
                        strArr = split;
                        i3++;
                        split = strArr;
                    }
                    if (arrayList.size() > 0) {
                        Iterator it = arrayList.iterator();
                        while (it.hasNext()) {
                            String str5 = (String) it.next();
                            C3348.m12347("Kill: " + str5 + " for " + str2);
                            Object obj2 = obj;
                            if (!str5.equals(obj2)) {
                                new C2880("").m11618("kill -9 " + str5);
                                new C2880("").m11618("am force-stop " + str);
                                new C2880("").m11618("am kill --user all " + str);
                            }
                            obj = obj2;
                        }
                        return true;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
        if (C3348.f9908) {
            String m11438 = m11438(C3348.f9875 + "/busybox", "ps", "grep", str2);
            if (m11438.startsWith("~")) {
                if (m11438.startsWith("~")) {
                    c2 = 0;
                    c = 1;
                    m11438 = m11438(C3348.f9875 + "/busybox", "ps");
                } else {
                    c = 1;
                    c2 = 0;
                }
                if (m11438.startsWith("~")) {
                    i = 2;
                    String[] strArr3 = new String[2];
                    strArr3[c2] = "busybox";
                    strArr3[c] = "ps";
                    m11438 = m11438(strArr3);
                } else {
                    i = 2;
                }
                if (m11438.startsWith("~")) {
                    String[] strArr4 = new String[i];
                    strArr4[c2] = "toolbox";
                    strArr4[c] = "ps";
                    m11438 = m11438(strArr4);
                }
            }
            if (!m11438.equals("~") && !m11438.equals("")) {
                String[] split3 = m11438.split("\n");
                ArrayList arrayList2 = new ArrayList();
                if (split3.length >= 1) {
                    for (String str6 : split3) {
                        if (str6.trim().contains(str2)) {
                            if (!str6.contains(str2 + ".")) {
                                try {
                                    String str7 = (str6 + "\n").trim().split("\\s+")[0];
                                    arrayList2.add(str7);
                                    C3348.m12347("Found pid: " + str7 + " for " + str2);
                                } catch (Exception e4) {
                                    C3348.m12347("Error with regex! " + e4);
                                }
                            }
                        }
                    }
                    if (arrayList2.size() > 0) {
                        Iterator it2 = arrayList2.iterator();
                        while (it2.hasNext()) {
                            String str8 = (String) it2.next();
                            C3348.m12347("Kill: " + str8 + " for " + str2);
                            if (!str8.equals("0")) {
                                m11438("kill", "-9", str8);
                                m11438("am", "force-stop", str);
                                m11438("am", "kill", "--user", "all", str);
                            }
                        }
                        return true;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
        return false;
    }

    public static String m11469(File file) throws JSONException {
        try {
            if (!file.exists() || !file.canRead()) {
                return null;
            }
            return new JSONObject(m11486(file)).getString("label");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void m11470(boolean z) {
        if (C3348.f9908) {
            new Thread(new RunnableC2933(z)).start();
        }
    }

    public static void m11471(boolean z) {
        PackageInfo packageInfo;
        ServiceInfo[] serviceInfoArr;
        if (C3348.f9908) {
            new ArrayList();
            try {
                packageInfo = C3348.m12337().getPackageInfo("com.android.vending", 8708);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
                packageInfo = null;
            }
            if (packageInfo != null && (serviceInfoArr = packageInfo.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = packageInfo.services;
                    if (i < serviceInfoArr2.length) {
                        if (!z) {
                            try {
                                if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || packageInfo.services[i].name.endsWith("MarketBillingService")) && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", packageInfo.services[i].name)) != 2) {
                                    new C2880("").m11618("pm disable 'com.android.vending/" + packageInfo.services[i].name + "'", "skipOut");
                                }
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        } else if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || packageInfo.services[i].name.endsWith("MarketBillingService")) && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", packageInfo.services[i].name)) != 1) {
                            new C2880("").m11618("pm enable 'com.android.vending/" + packageInfo.services[i].name + "'", "skipOut");
                        }
                        i++;
                    } else {
                        return;
                    }
                }
            }
        }
    }

    public static void m11472(boolean z) {
        if (C3348.f9908) {
            new Thread(new RunnableC2936(z)).start();
        }
    }

    public static void m11473(boolean z) {
        ServiceInfo[] serviceInfoArr;
        if (C3348.f9908) {
            new ArrayList();
            PackageInfo m11390 = m11390("com.android.vending", 516);
            if (m11390 != null && (serviceInfoArr = m11390.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = m11390.services;
                    if (i < serviceInfoArr2.length) {
                        if (!z) {
                            try {
                                if (serviceInfoArr2[i].name.endsWith("LicensingService") && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 2) {
                                    new C2880("").m11618("pm disable 'com.android.vending/" + m11390.services[i].name + "'", "skipOut");
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else if (serviceInfoArr2[i].name.endsWith("LicensingService") && C3348.m12337().getComponentEnabledSetting(new ComponentName("com.android.vending", m11390.services[i].name)) != 1) {
                            new C2880("").m11618("pm enable 'com.android.vending/" + m11390.services[i].name + "'", "skipOut");
                        }
                        i++;
                    } else {
                        return;
                    }
                }
            }
        }
    }

    public static boolean m11474() {
        return !m11385().equals("") && C3348.f9924 >= 23;
    }

    public static boolean m11475() {
        try {
            if (Looper.myLooper() != null) {
                return Looper.myLooper() == Looper.getMainLooper();
            }
            return false;
        } catch (Throwable unused) {
            return false;
        }
    }

    public static boolean m11476(Activity activity) {
        return true;
    }

    public static void m11477(int i) {
        try {
            Thread.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void m11478(boolean z, boolean z2, boolean z3) {
        File file = new File(C3348.f9875 + "/pinapp.apk");
        long m11399 = m11399(R.raw.pinapp);
        if (!file.exists() || file.length() != m11399) {
            if (file.length() != m11399) {
                File file2 = new File(C3348.f9875 + "/pinapp.apk");
                if (file2.exists()) {
                    file2.delete();
                }
                C3348.m12347("LuckyPatcher: p.info version updated. " + m11399 + " " + file.length());
                if (file.exists()) {
                    file.delete();
                }
            }
            try {
                m11400(R.raw.pinapp, new File(C3348.f9875 + "/pinapp.apk"));
            } catch (Exception unused) {
            }
            try {
                m11384(new File(file.getAbsolutePath()), 3583);
            } catch (Exception e) {
                C3348.m12347(e);
                e.printStackTrace();
            }
            if (C3348.f9908) {
                m11506("chmod 06777 " + file.getAbsolutePath());
                m11506("chown 0.0 " + file.getAbsolutePath());
                m11506("chown 0:0 " + file.getAbsolutePath());
            }
        }
        boolean z4 = false;
        if (((new File(C3348.f9875 + "/pinapp.apk").canRead() && !C3348.m12333().getBoolean("dont_show_pinapp", false)) || z) && !z2) {
            boolean z5 = true;
            PackageInfo m11338 = m11338(C3348.f9875 + "/pinapp.apk", 1);
            String str = m11338.packageName;
            try {
            } catch (PackageManager.NameNotFoundException unused2) {
                if (!z3) {
                    z5 = false;
                    z4 = true;
                    if (!z4) {
                        C3348.m12359(new RunnableC2906(z5, str, file));
                        return;
                    }
                    return;
                }
                z5 = false;
                if (!z4) {
                }
            }
        } else {
            if (!new File(C3348.f9875 + "/pinapp.apk").canRead()) {
                m11543(C3348.f9884, m11423(R.string.warning), m11423(R.string.warning_internal_data_folder_corrupt));
            }
        }
    }

    public static void m11479() {
        File file = new File(C3348.f9875 + "/p.apk");
        long m11399 = m11399(R.raw.p);
        if (!file.exists() || file.length() != m11399) {
            if (file.length() != m11399) {
                File file2 = new File(C3348.f9875 + "/p_gp.apk");
                if (file2.exists()) {
                    file2.delete();
                }
                C3348.m12347("LuckyPatcher: p.info version updated. " + m11399 + " " + file.length());
                if (file.exists()) {
                    file.delete();
                }
            }
            try {
                m11400(R.raw.p, new File(C3348.f9875 + "/p.apk"));
            } catch (Exception unused) {
            }
            try {
                m11384(new File(file.getAbsolutePath()), 3583);
            } catch (Exception e) {
                C3348.m12347(e);
                e.printStackTrace();
            }
            m11506("chmod 06777 " + file.getAbsolutePath());
            m11506("chown 0.0 " + file.getAbsolutePath());
            m11506("chown 0:0 " + file.getAbsolutePath());
        }
        File file3 = new File(C3348.f9875 + "/empty_class");
        long m113992 = m11399(R.raw.pcl);
        if (!file3.exists() || file3.length() != m113992) {
            if (file3.length() != m113992) {
                C3348.m12347("LuckyPatcher: pcl.info version updated. " + m113992 + " " + file3.length());
                if (file3.exists()) {
                    file3.delete();
                }
            }
            try {
                m11400(R.raw.pcl, new File(C3348.f9875 + "/empty_class"));
            } catch (Exception unused2) {
            }
            try {
                m11384(new File(file3.getAbsolutePath()), 3583);
            } catch (Exception e2) {
                C3348.m12347(e2);
                e2.printStackTrace();
            }
            m11506("chmod 06777 " + file3.getAbsolutePath());
            m11506("chown 0.0 " + file3.getAbsolutePath());
            m11506("chown 0:0 " + file3.getAbsolutePath());
        }
    }

    public static void m11480(PackageInfo packageInfo) {
        ZipOutputStream zipOutputStream;
        FileOutputStream fileOutputStream;
        try {
            int m11434 = m11434(new File(packageInfo.applicationInfo.sourceDir));
            File file = new File(C3348.f9875 + "/p_gp.apk");
            if (file.exists() && m11434(file) == m11434) {
                return;
            }
            C3348.m12347("" + m11434);
            C3348.m12347("22222222222222222222222222222222222222222222222222222222222");
            byte[] bArr = new byte[4096];
            FileOutputStream fileOutputStream2 = null;
            try {
                if (file.exists()) {
                    file.delete();
                }
                FileInputStream fileInputStream = new FileInputStream(C3348.f9875 + "/p.apk");
                java.util.zip.ZipInputStream zipInputStream = new java.util.zip.ZipInputStream(fileInputStream);
                fileOutputStream = new FileOutputStream(file, false);
                try {
                    zipOutputStream = new ZipOutputStream(new BufferedOutputStream(fileOutputStream));
                    try {
                        for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
                            zipOutputStream.putNextEntry(new ZipEntry(nextEntry.getName()));
                            while (true) {
                                int read = zipInputStream.read(bArr);
                                if (read != -1) {
                                    zipOutputStream.write(bArr, 0, read);
                                }
                            }
                            zipInputStream.closeEntry();
                        }
                        zipInputStream.close();
                        fileInputStream.close();
                        for (int i = 2; i <= m11434; i++) {
                            FileInputStream fileInputStream2 = new FileInputStream(C3348.f9875 + "/empty_class");
                            BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream2, 4096);
                            zipOutputStream.putNextEntry(new ZipEntry("classes" + i + ".dex"));
                            while (true) {
                                int read2 = bufferedInputStream.read(bArr, 0, 4096);
                                if (read2 != -1) {
                                    zipOutputStream.write(bArr, 0, read2);
                                }
                            }
                            bufferedInputStream.close();
                            zipOutputStream.closeEntry();
                            fileInputStream2.close();
                        }
                        m11506("chmod 06777 " + C3348.f9875 + "/p_gp.apk");
                        m11506("chown 0.0 " + C3348.f9875 + "/p_gp.apk");
                        m11506("chown 0:0 " + C3348.f9875 + "/p_gp.apk");
                    } catch (Throwable th) {
                        th = th;
                        fileOutputStream2 = fileOutputStream;
                        th.printStackTrace();
                        fileOutputStream = fileOutputStream2;
                        if (zipOutputStream != null) {
                        }
                        if (fileOutputStream == null) {
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    zipOutputStream = null;
                }
            } catch (Throwable th3) {
                th = th3;
                zipOutputStream = null;
            }
            if (zipOutputStream != null) {
                try {
                    zipOutputStream.flush();
                    zipOutputStream.finish();
                    zipOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream == null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e2) {
                    e2.printStackTrace();
                }
            }
        } catch (Throwable th4) {
            th4.printStackTrace();
        }
    }

    public static float m11481(float f) {
        return f * C3348.m12334().getResources().getDisplayMetrics().density;
    }

    public static void m11482(String str, String str2, String str3, String str4, String str5) {
        C3348.m12347("uid:" + str4);
        if (str.contains("copyDC") || str.contains("deleteDC")) {
            File m11363 = m11363(str2);
            if (m11363 != null) {
                m11363.delete();
                if (str.contains("copyDC")) {
                    m11292(new File(str3), m11363);
                    if (m11363.exists() && m11363.length() == new File(str3).length()) {
                        new File(str3).delete();
                        m11508("chmod", "644", m11363.getAbsolutePath());
                        m11508("chown", "1000:" + str4, m11363.getAbsolutePath());
                        m11508("chown", "1000." + str4, m11363.getAbsolutePath());
                        return;
                    }
                    return;
                }
                return;
            }
            if (str.contains("copyDC")) {
                File m11364 = m11364(str2);
                m11292(new File(str3), m11364);
                if (m11364.exists() && m11364.length() == new File(str3).length()) {
                    new File(str3).delete();
                    m11508("chmod", "644", m11364.getAbsolutePath());
                    m11508("chown", "1000:" + str4, m11364.getAbsolutePath());
                    m11508("chown", "1000." + str4, m11364.getAbsolutePath());
                }
            }
        }
    }

    public static String m11483(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        while (true) {
            int read = inputStream.read();
            if (read < 0) {
                return null;
            }
            if (read == 10) {
                return new String(byteArrayOutputStream.toByteArray(), "UTF-8");
            }
            byteArrayOutputStream.write(read);
        }
    }

    public static int m11484(MappedByteBuffer mappedByteBuffer) {
        int i;
        int i2 = 0;
        int i3 = 0;
        do {
            int i4 = mappedByteBuffer.get() & 255;
            i2 |= (i4 & 127) << (i3 * 7);
            i3++;
            i = i4 & 128;
            if (i != 128) {
                break;
            }
        } while (i3 < 5);
        if (i == 128) {
            C3348.m12347("LuckyPatcher:invalid LEB128 sequence");
        }
        return i2;
    }

    public static JSONObject m11485() throws JSONException {
        JSONObject jSONObject = null;
        for (String str : m11410()) {
            try {
                if (new File(str + "/xposed").exists()) {
                    if (new File(str + "/xposed").canRead()) {
                        jSONObject = new JSONObject(m11486(new File(str + "/xposed")));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return jSONObject;
    }

    public static String m11486(File file) {
        m11590();
        byte[] bArr = new byte[(int) file.length()];
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            randomAccessFile.seek(0L);
            randomAccessFile.read(bArr);
            randomAccessFile.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new String(bArr);
    }

    public static void m11487() {
        if (!C3348.f9948.booleanValue()) {
            try {
                new C2880("").m11618("reboot");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/bin/reboot");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/xbin/reboot");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2880("").m11618("busybox reboot");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m11464("reboot");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m11506("reboot");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C3348.f9884.runOnUiThread(new RunnableC2883());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2880("w").m11623(5000L);
            try {
                m11506(C3348.m12334().getFilesDir() + "/reboot");
                return;
            } catch (Exception e8) {
                e8.printStackTrace();
                return;
            }
        }
        try {
            m11438("reboot");
        } catch (Exception e9) {
            e9.printStackTrace();
        }
        try {
            m11438("/system/bin/reboot");
        } catch (Exception e10) {
            e10.printStackTrace();
        }
        try {
            m11438("/system/xbin/reboot");
        } catch (Exception e11) {
            e11.printStackTrace();
        }
        try {
            m11438("busybox reboot");
        } catch (Exception e12) {
            e12.printStackTrace();
        }
        try {
            m11464("reboot");
        } catch (Exception e13) {
            e13.printStackTrace();
        }
        try {
            m11508("reboot");
        } catch (Exception e14) {
            e14.printStackTrace();
        }
        try {
            m11508(C3348.f9875 + "/reboot");
        } catch (Exception e15) {
            e15.printStackTrace();
        }
    }

    public static void m11488() {
        if (!C3348.f9948.booleanValue()) {
            try {
                new C2880("").m11618("reboot bootloader");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/bin/reboot bootloader");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/xbin/reboot bootloader");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2880("").m11618("busybox reboot bootloader");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m11464("reboot bootloader");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m11506("reboot bootloader");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C3348.f9884.runOnUiThread(new RunnableC2900());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2880("w").m11623(5000L);
            try {
                m11506(C3348.m12334().getFilesDir() + "/reboot");
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
    }

    public static void m11489() {
        if (!C3348.f9948.booleanValue()) {
            try {
                new C2880("").m11618("reboot recovery");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/bin/reboot recovery");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2880("").m11618("/system/xbin/reboot recovery");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2880("").m11618("busybox reboot recovery");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m11464("reboot recovery");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m11506("reboot recovery");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C3348.f9884.runOnUiThread(new RunnableC2894());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2880("w").m11623(5000L);
            try {
                m11506(C3348.m12334().getFilesDir() + "/reboot");
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
    }

    public static void m11490(String str, String str2, ArrayList<C3003> arrayList, File file) throws IOException {
        m11357(new File(str2)).mkdirs();
        try {
            C2800 c2800 = new C2800(str);
            try {
                C2806 c2806 = new C2806(new File(str2));
                Enumeration<C2799> m11030 = c2800.m11030();
                while (m11030.hasMoreElements()) {
                    C2799 nextElement = m11030.nextElement();
                    String name = nextElement.getName();
                    if (!name.toLowerCase().endsWith(".dex") && !name.toLowerCase().endsWith(".so") && !name.toLowerCase().endsWith(".xml") && !name.toLowerCase().endsWith(".arsc")) {
                        c2806.m11052(nextElement, c2800);
                    }
                    Iterator<C3003> it = arrayList.iterator();
                    boolean z = false;
                    while (it.hasNext()) {
                        C3003 next = it.next();
                        if (name.equals(next.f8162)) {
                            c2806.m11053(nextElement, c2800, next.f8163, next.f8164);
                            if (nextElement.getCrc() != next.f8163) {
                                C3348.m12347("correct entry " + next.f8162);
                            }
                            z = true;
                        }
                    }
                    if (!z) {
                        m11543(C3348.f9884, m11423(R.string.warning), m11425(R.string.error_file_not_found_in_original_apk, name, file.getName()));
                        c2806.m11052(nextElement, c2800);
                    }
                }
                c2806.close();
                c2800.close();
            } finally {
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void m11491(String str, String str2, ArrayList<C2990> arrayList, ArrayList<String> arrayList2, ArrayList<C2984> arrayList3, ArrayList<String> arrayList4) throws IOException {
        m11357(new File(str2)).mkdirs();
        try {
            C2800 c2800 = new C2800(str);
            try {
                C2806 c2806 = new C2806(new File(str2));
                ArrayList arrayList5 = new ArrayList();
                if (arrayList3 != null) {
                    Iterator<C2984> it = arrayList3.iterator();
                    while (it.hasNext()) {
                        C2984 next = it.next();
                        if (c2800.m11031(next.f8038) != null) {
                            C3348.m12347("Found file to zip:" + next.f8037);
                            arrayList5.add(next.f8038);
                            C3348.m12347("Remove file from zip:" + next.f8038);
                        }
                        try {
                            File file = new File(next.f8037);
                            C2799 c2799 = new C2799(next.f8038);
                            c2799.setTime(file.lastModified());
                            if (next.f8041) {
                                c2799.setMethod(8);
                            } else {
                                c2799.setMethod(0);
                            }
                            c2806.m11057(c2799);
                            c2806.m11063(new FileInputStream(file));
                            c2806.m11051();
                            C3348.m12347("LuckyPatcher (signer): Add file to entries: " + next.f8037);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                Enumeration<C2799> m11030 = c2800.m11030();
                while (m11030.hasMoreElements()) {
                    C2799 nextElement = m11030.nextElement();
                    String name = nextElement.getName();
                    Iterator it2 = arrayList5.iterator();
                    boolean z = false;
                    while (it2.hasNext()) {
                        if (name.equals((String) it2.next())) {
                            z = true;
                        }
                    }
                    if (arrayList != null) {
                        Iterator<C2990> it3 = arrayList.iterator();
                        while (it3.hasNext()) {
                            C2990 next2 = it3.next();
                            if (name.equals(next2.f8077)) {
                                C3348.m12347("Found file to zip:" + next2.f8077);
                                nextElement.m11020(next2.f8078);
                            }
                        }
                    }
                    if (arrayList2 != null) {
                        Iterator<String> it4 = arrayList2.iterator();
                        while (it4.hasNext()) {
                            String next3 = it4.next();
                            if (name.equals(next3)) {
                                C3348.m12347("Found file to zip:" + next3);
                                C3348.m12347("Remove file from zip:" + next3);
                                z = true;
                            }
                        }
                    }
                    if (arrayList4 != null) {
                        Iterator<String> it5 = arrayList4.iterator();
                        while (it5.hasNext()) {
                            String next4 = it5.next();
                            if (!next4.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                                next4 = next4 + InternalZipConstants.ZIP_FILE_SEPARATOR;
                            }
                            if (name.startsWith(next4)) {
                                C3348.m12347("Found folder to zip:" + next4);
                                C3348.m12347("Remove file in folder from zip:" + name);
                                z = true;
                            }
                        }
                    }
                    if (!z) {
                        c2806.m11052(nextElement, c2800);
                    }
                }
                c2806.close();
                c2800.close();
            } finally {
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static boolean m11492(String str, String str2) {
        int i;
        C3346 m11319;
        String str3;
        String str4 = str;
        m11590();
        if (!C3348.f9948.booleanValue()) {
            if (str.toLowerCase().startsWith("/system")) {
                str3 = "LuckyPatcher:not remount ";
                new C2880("").m11618("stop ric");
                if (m11315("/sbin/ric") || m11315("/system/bin/ric")) {
                    new C2880("").m11618("stop ric");
                    m11506("pkill -f /sbin/ric");
                    m11506("pkill -f /system/bin/ric");
                }
            } else {
                str3 = "LuckyPatcher:not remount ";
            }
            if (str4.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR) && !str4.equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                str4 = str4.substring(0, str4.lastIndexOf(InternalZipConstants.ZIP_FILE_SEPARATOR));
            }
            C3346 m113192 = m11319(str4);
            if (m113192 != null) {
                Set<String> m12312 = m113192.m12312();
                Locale locale = Locale.US;
                boolean contains = m12312.contains(str2.toLowerCase(locale));
                if (m113192.m12313().getAbsolutePath().equals("/data")) {
                    C3348.m12347("skip remount for " + m113192.m12313().getAbsolutePath());
                    contains = true;
                }
                if (!contains) {
                    try {
                        C3348.m12347("Run command remount:mount -o remount," + str2.toLowerCase(locale) + " " + m113192.m12311().getAbsolutePath() + " " + m113192.m12313().getAbsolutePath());
                        StringBuilder sb = new StringBuilder();
                        sb.append("blockdev --setrw ");
                        sb.append(m113192.m12311().getAbsolutePath());
                        m11506(sb.toString());
                        m11506("mount -o remount," + str2.toLowerCase(locale) + " " + m113192.m12311().getAbsolutePath() + " " + m113192.m12313().getAbsolutePath());
                        C3346 m113193 = m11319(str4);
                        if (!m113193.m12312().contains(str2.toLowerCase(locale))) {
                            m11506("mount -o remount " + str2.toLowerCase(locale) + " " + m113193.m12311().getAbsolutePath() + " " + m113193.m12313().getAbsolutePath());
                        }
                    } catch (Exception unused) {
                    }
                    m113192 = m11319(str4);
                }
                if (m113192 != null) {
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append(m113192.m12312());
                    sb2.append(" AND ");
                    Locale locale2 = Locale.US;
                    sb2.append(str2.toLowerCase(locale2));
                    C3348.m12347(sb2.toString());
                    if (m113192.m12312().toString().contains(str2.toLowerCase(locale2))) {
                        C3348.m12347("Lucky Patcher: remount " + str4 + " to " + str2);
                        return true;
                    }
                }
            }
            C3348.m12347(str3 + str4 + " to " + str2);
            return false;
        }
        if (str.toLowerCase().startsWith("/system")) {
            m11438("stop", "ric");
            if (new File("/sbin/ric").exists() || new File("/system/bin/ric").exists()) {
                i = 0;
                m11438("stop", "ric");
                m11508("pkill", "-f", "/sbin/ric");
                m11508("pkill", "-f", "/system/bin/ric");
                if (str4.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR) && !str4.equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                    str4 = str4.substring(i, str4.lastIndexOf(InternalZipConstants.ZIP_FILE_SEPARATOR));
                }
                m11319 = m11319(str4);
                if (m11319 != null) {
                    Set<String> m123122 = m11319.m12312();
                    Locale locale3 = Locale.US;
                    boolean contains2 = m123122.contains(str2.toLowerCase(locale3));
                    if (m11319.m12313().getAbsolutePath().equals("/data")) {
                        C3348.m12347("skip remount for " + m11319.m12313().getAbsolutePath());
                        contains2 = true;
                    }
                    if (!contains2) {
                        try {
                            C3348.m12347("Run command remount:mount -o remount," + str2.toLowerCase(locale3) + " " + m11319.m12311().getAbsolutePath() + " " + m11319.m12313().getAbsolutePath());
                            m11508("blockdev", "--setrw", m11319.m12311().getAbsolutePath());
                            StringBuilder sb3 = new StringBuilder();
                            sb3.append("remount,");
                            sb3.append(str2.toLowerCase(locale3));
                            m11508("mount", "-o", sb3.toString(), m11319.m12311().getAbsolutePath(), m11319.m12313().getAbsolutePath());
                            C3346 m113194 = m11319(str4);
                            if (!m113194.m12312().contains(str2.toLowerCase(locale3))) {
                                m11508("mount", "-o", "remount", str2.toLowerCase(locale3), m113194.m12311().getAbsolutePath(), m113194.m12313().getAbsolutePath());
                            }
                        } catch (Exception unused2) {
                        }
                        m11319 = m11319(str4);
                    }
                    if (m11319 != null) {
                        StringBuilder sb4 = new StringBuilder();
                        sb4.append(m11319.m12312());
                        sb4.append(" AND ");
                        Locale locale4 = Locale.US;
                        sb4.append(str2.toLowerCase(locale4));
                        C3348.m12347(sb4.toString());
                        if (m11319.m12312().toString().contains(str2.toLowerCase(locale4))) {
                            C3348.m12347("Lucky Patcher: remount " + str4 + " to " + str2);
                            return true;
                        }
                    }
                }
                C3348.m12347("LuckyPatcher:not remount " + str4 + " to " + str2);
                return false;
            }
        }
        i = 0;
        if (str4.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            str4 = str4.substring(i, str4.lastIndexOf(InternalZipConstants.ZIP_FILE_SEPARATOR));
        }
        m11319 = m11319(str4);
        if (m11319 != null) {
        }
        C3348.m12347("LuckyPatcher:not remount " + str4 + " to " + str2);
        return false;
    }

    public static String m11493(String str) {
        String str2 = "";
        if (str == null) {
            return "";
        }
        String[] split = str.split("\\.");
        for (int i = 0; i < split.length; i++) {
            if (i < split.length - 2) {
                str2 = str2 + split[i] + ".";
            } else {
                return str2 + split[i];
            }
        }
        return str2;
    }

    public static void m11494(String str) {
        String str2;
        Iterator it;
        m11492("/system", InternalZipConstants.WRITE_MODE);
        try {
            str2 = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir;
        } catch (Exception e) {
            e = e;
            str2 = "";
        }
        try {
            String str3 = C3348.m12337().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.dataDir;
            m11492(str2, "RW");
            m11506("chmod 777 " + str2);
            m11506("chattr -ai " + str2);
        } catch (Exception e2) {
            e = e2;
            e.printStackTrace();
            if (!str2.equals("")) {
                m11495(new File(str2));
            }
            ArrayList arrayList = new ArrayList();
            arrayList.add(new File("/system/app"));
            arrayList.add(new File("/system/priv-app"));
            it = arrayList.iterator();
            while (it.hasNext()) {
            }
        }
        if (!str2.equals("") && new File(str2).exists() && str2.startsWith("/system/")) {
            m11495(new File(str2));
        }
        ArrayList arrayList2 = new ArrayList();
        arrayList2.add(new File("/system/app"));
        arrayList2.add(new File("/system/priv-app"));
        it = arrayList2.iterator();
        while (it.hasNext()) {
            File file = (File) it.next();
            File[] listFiles = file.listFiles();
            if (listFiles != null && listFiles.length != 0) {
                for (File file2 : listFiles) {
                    if (file2.getAbsolutePath().endsWith(".apk")) {
                        try {
                            if (str.equals(new C3312(C3348.m12334(), file2, false).f9776)) {
                                m11495(file2);
                            }
                        } catch (Exception e3) {
                            e3.printStackTrace();
                        }
                    }
                }
                for (File file3 : listFiles) {
                    if (file3.isDirectory()) {
                        try {
                            File[] listFiles2 = file3.listFiles();
                            if (listFiles2 != null && listFiles2.length != 0) {
                                for (File file4 : listFiles2) {
                                    if (file4.getAbsolutePath().endsWith(".apk")) {
                                        try {
                                            if (str.equals(new C3312(C3348.m12334(), file4, false).f9776)) {
                                                m11495(file4);
                                                m11506("rm -rf '" + file3.getAbsolutePath() + "'");
                                            }
                                        } catch (Exception e4) {
                                            e4.printStackTrace();
                                        }
                                    }
                                }
                            }
                        } catch (Exception e5) {
                            e5.printStackTrace();
                        }
                    }
                }
            } else {
                C3348.m12347("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
            }
        }
    }

    public static void m11495(File file) {
        String m11414 = m11414(file.getAbsolutePath());
        if (!m11414.equals("")) {
            m11506("chmod 777 '" + m11414 + "'");
            m11506("rm '" + m11414 + "'");
        }
        File m11364 = m11364(file.getAbsolutePath());
        if (m11364 != null && m11364.exists()) {
            m11506("rm '" + m11364.getAbsolutePath() + "'");
            m11506("rm '" + m11587(m11364.getAbsolutePath(), "art") + "'");
            m11506("rm '" + m11587(m11364.getAbsolutePath(), "vdex") + "'");
        }
        m11506("chmod 777 '" + file.getAbsolutePath() + "'");
        m11506("rm '" + file.getAbsolutePath() + "'");
        m11506("rm '" + m11392(file.getAbsolutePath(), false) + "'");
        File m11357 = m11357(file);
        String name = m11357.getName();
        if (m11357.getAbsolutePath().startsWith("/system/") && !name.toLowerCase().equals("app") && !name.toLowerCase().equals("priv-app")) {
            m11506("rm -rf '" + m11357.getAbsolutePath() + "'");
        }
    }

    public static String m11496(String str, String str2, String str3) {
        return str.replaceFirst("(?s)(.*)" + str2, "$1" + str3);
    }

    public static int m11497(String str, String[] strArr, boolean z, String[] strArr2) {
        m11590();
        C3348.m12347("scan: " + str);
        int i = 0;
        m11508("chmod", "777", str);
        new ArrayList();
        try {
        } catch (Exception e) {
            C3348.m12347(e);
        }
        if (!z) {
            if (str != null) {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        if (new File(str).exists()) {
                            try {
                                FileChannel channel = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                                MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                map.position(0);
                                if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                    map.position(56);
                                    int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                    byte[] bArr = new byte[m11592 / 4];
                                    map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                    int[] iArr = new int[m11592];
                                    for (int i2 = 0; i2 < m11592; i2++) {
                                        iArr[i2] = m11592(map.get(), map.get(), map.get(), map.get());
                                    }
                                    int i3 = 0;
                                    for (int i4 = 0; i4 < m11592; i4++) {
                                        try {
                                            int i5 = iArr[i4];
                                            map.position(i5);
                                            int m11484 = m11484(map);
                                            int position = map.position();
                                            byte[] m11566 = m11566(map, m11484);
                                            for (int i6 = 0; i6 < strArr.length; i6++) {
                                                if (new String(m11566, "UTF-16LE").equals(strArr[i6])) {
                                                    strArr2[i6].getBytes();
                                                    if (strArr2[i6].length() <= m11484) {
                                                        map.position(i5);
                                                        m11574(map, strArr2[i6].length());
                                                        map.position(position);
                                                        m11573(map, strArr2[i6]);
                                                        map.force();
                                                        C3348.m12347("Replace string:" + strArr[i6]);
                                                        i3++;
                                                    }
                                                }
                                            }
                                        } catch (Exception e2) {
                                            e = e2;
                                            i = i3;
                                            e.printStackTrace();
                                            return i;
                                        }
                                    }
                                    i = i3;
                                }
                                channel.close();
                            } catch (Exception e3) {
                                e = e3;
                            }
                        }
                    } catch (Exception e4) {
                        e4.printStackTrace();
                    }
                }
            }
            return i;
        }
        if (new File(str).exists()) {
            try {
                FileChannel channel2 = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                MappedByteBuffer map2 = channel2.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel2.size());
                map2.position(8);
                int m115922 = m11592(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m115922 + 56);
                int m115923 = m11592(map2.get(), map2.get(), map2.get(), map2.get());
                int m115924 = m11592(map2.get(), map2.get(), map2.get(), map2.get()) + m115922;
                C3348.m12347("LuckyPatcher offset_to_data=" + Integer.toHexString(m115924));
                map2.position(m115924);
                int[] iArr2 = new int[m115923];
                for (int i7 = 0; i7 < m115923; i7++) {
                    iArr2[i7] = m11592(map2.get(), map2.get(), map2.get(), map2.get()) + m115922;
                }
                int i8 = 0;
                for (int i9 = 0; i9 < m115923; i9++) {
                    try {
                        int i10 = iArr2[i9];
                        map2.position(i10);
                        int m114842 = m11484(map2);
                        int position2 = map2.position();
                        byte[] m115662 = m11566(map2, m114842);
                        for (int i11 = 0; i11 < strArr.length; i11++) {
                            if (new String(m115662).equals(strArr[i11])) {
                                strArr2[i11].getBytes();
                                if (strArr2[i11].length() <= m114842) {
                                    map2.position(i10);
                                    m11574(map2, strArr2[i11].length());
                                    map2.position(position2);
                                    m11573(map2, strArr2[i11]);
                                    map2.force();
                                    C3348.m12347("Replace string:" + strArr[i11]);
                                    i8++;
                                }
                            }
                        }
                    } catch (Exception e5) {
                        e = e5;
                        i = i8;
                        e.printStackTrace();
                        return i;
                    }
                }
                channel2.close();
                i = i8;
            } catch (Exception e6) {
                e = e6;
            }
        }
        return i;
    }

    public static int m11498(String str, String[] strArr) {
        int i;
        m11590();
        byte[][] bArr = new byte[strArr.length];
        byte[][] bArr2 = new byte[strArr.length];
        int length = strArr.length;
        byte[][] bArr3 = new byte[length];
        byte[][] bArr4 = new byte[strArr.length];
        char c = 0;
        int i2 = 1;
        if (strArr.length > 0) {
            int i3 = 0;
            while (i3 < strArr.length) {
                bArr3[i3] = new byte[strArr[i3].length()];
                bArr3[i3] = strArr[i3].getBytes();
                bArr[i3] = new byte[strArr[i3].length()];
                bArr[i3] = m11556(strArr[i3]).getBytes();
                bArr4[i3] = new byte[(bArr3[i3].length * 2) - i2];
                bArr2[i3] = new byte[(bArr3[i3].length * 2) - i2];
                int i4 = 0;
                for (byte b : bArr3[i3]) {
                    byte[] bArr5 = bArr4[i3];
                    bArr5[i4] = b;
                    if (i4 < bArr5.length - 2) {
                        bArr5[i4 + 1] = 0;
                    }
                    i4 += 2;
                }
                int i5 = 0;
                for (byte b2 : bArr[i3]) {
                    byte[] bArr6 = bArr2[i3];
                    bArr6[i5] = b2;
                    if (i5 < bArr6.length - 2) {
                        bArr6[i5 + 1] = 0;
                    }
                    i5 += 2;
                }
                i3++;
                i2 = 1;
            }
        }
        m11508("chmod", "777", str);
        if (str != null) {
            try {
                if (new File(str).exists()) {
                    if (new File(str).length() != 0) {
                        try {
                            if (new File(str).exists()) {
                                try {
                                    FileChannel channel = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                                    MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                    map.position(0);
                                    int i6 = -1;
                                    int i7 = 0;
                                    while (map.hasRemaining()) {
                                        try {
                                            i6++;
                                            map.position(i6);
                                            byte b3 = map.get();
                                            int i8 = 0;
                                            while (i8 < length) {
                                                byte[] bArr7 = bArr3[i8];
                                                if (bArr7 != null && b3 == bArr7[c]) {
                                                    int i9 = i6 + 1;
                                                    map.position(i9);
                                                    byte b4 = map.get();
                                                    int i10 = 1;
                                                    while (map.hasRemaining()) {
                                                        byte[] bArr8 = bArr3[i8];
                                                        if (i10 >= bArr8.length || b4 != bArr8[i10]) {
                                                            break;
                                                        }
                                                        i10++;
                                                        if (i10 == bArr8.length) {
                                                            map.position(i6);
                                                            map.put(bArr[i8]);
                                                            map.force();
                                                            i7++;
                                                        }
                                                        if (map.hasRemaining()) {
                                                            b4 = map.get();
                                                        }
                                                    }
                                                    map.position(i9);
                                                }
                                                byte[] bArr9 = bArr4[i8];
                                                if (bArr9 != null && b3 == bArr9[0]) {
                                                    map.position(i6 + 1);
                                                    byte b5 = map.get();
                                                    int i11 = 1;
                                                    while (map.hasRemaining()) {
                                                        byte[] bArr10 = bArr4[i8];
                                                        if (i11 >= bArr10.length || b5 != bArr10[i11]) {
                                                            break;
                                                        }
                                                        i11++;
                                                        if (i11 == bArr10.length) {
                                                            map.position(i6);
                                                            map.put(bArr2[i8]);
                                                            map.force();
                                                            i7++;
                                                        }
                                                        if (map.hasRemaining()) {
                                                            b5 = map.get();
                                                        }
                                                    }
                                                }
                                                i8++;
                                                c = 0;
                                            }
                                        } catch (Exception e) {
                                            e = e;
                                            i = i7;
                                            try {
                                                e.printStackTrace();
                                                return i;
                                            } catch (Exception e2) {
                                                e = e2;
                                                try {
                                                    e.printStackTrace();
                                                    return i;
                                                } catch (Exception e3) {
                                                    e = e3;
                                                    C3348.m12347(e);
                                                    return i;
                                                }
                                            }
                                        }
                                    }
                                    channel.close();
                                    return i7;
                                } catch (Exception e4) {
                                    e = e4;
                                    i = 0;
                                }
                            }
                        } catch (Exception e5) {
                            e = e5;
                            i = 0;
                        }
                    }
                }
            } catch (Exception e6) {
                e = e6;
                i = 0;
            }
        }
        return 0;
    }

    public static int m11499(String str, String[] strArr, String[] strArr2) {
        int i;
        char[] cArr;
        m11590();
        byte[][] bArr = new byte[strArr.length];
        byte[][] bArr2 = new byte[strArr.length];
        int length = strArr.length;
        byte[][] bArr3 = new byte[length];
        byte[][] bArr4 = new byte[strArr.length];
        if (strArr.length > 0) {
            for (int i2 = 0; i2 < strArr.length; i2++) {
                bArr3[i2] = new byte[strArr[i2].length()];
                try {
                    bArr3[i2] = strArr[i2].getBytes("UTF8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                bArr[i2] = new byte[strArr[i2].length()];
                ArrayList arrayList = new ArrayList();
                try {
                    bArr[i2] = strArr2[i2].getBytes("UTF8");
                    char[] charArray = strArr2[i2].toCharArray();
                    int length2 = charArray.length;
                    int i3 = 0;
                    while (i3 < length2) {
                        char c = charArray[i3];
                        C3348.m12347("ch:" + c);
                        if (c == 1089) {
                            byte[] bArr5 = {65, 4};
                            int i4 = 0;
                            for (int i5 = 2; i4 < i5; i5 = 2) {
                                arrayList.add(Byte.valueOf(bArr5[i4]));
                                i4++;
                            }
                        } else if (c == 1082) {
                            byte[] bArr6 = {58, 4};
                            int i6 = 0;
                            for (int i7 = 2; i6 < i7; i7 = 2) {
                                arrayList.add(Byte.valueOf(bArr6[i6]));
                                i6++;
                            }
                        } else if (c == 1056) {
                            byte[] bArr7 = {32, 4};
                            int i8 = 0;
                            for (int i9 = 2; i8 < i9; i9 = 2) {
                                arrayList.add(Byte.valueOf(bArr7[i8]));
                                i8++;
                            }
                        } else if (c == 1077) {
                            byte[] bArr8 = {53, 4};
                            int i10 = 0;
                            for (int i11 = 2; i10 < i11; i11 = 2) {
                                arrayList.add(Byte.valueOf(bArr8[i10]));
                                i10++;
                            }
                        } else if (c == 1072) {
                            byte[] bArr9 = {48, 4};
                            int i12 = 0;
                            for (int i13 = 2; i12 < i13; i13 = 2) {
                                arrayList.add(Byte.valueOf(bArr9[i12]));
                                i12++;
                            }
                        } else if (c == 1091) {
                            byte[] bArr10 = {67, 4};
                            int i14 = 0;
                            for (int i15 = 2; i14 < i15; i15 = 2) {
                                arrayList.add(Byte.valueOf(bArr10[i14]));
                                i14++;
                            }
                        } else {
                            cArr = charArray;
                            byte[] bytes = new String(new char[]{c}).getBytes("UTF8");
                            for (byte b : bytes) {
                                arrayList.add(Byte.valueOf(b));
                            }
                            arrayList.add((byte) 0);
                            i3++;
                            charArray = cArr;
                        }
                        cArr = charArray;
                        i3++;
                        charArray = cArr;
                    }
                } catch (UnsupportedEncodingException e2) {
                    e2.printStackTrace();
                }
                if (((Byte) arrayList.get(arrayList.size() - 1)).byteValue() == 0) {
                    arrayList.remove(arrayList.size() - 1);
                }
                bArr4[i2] = new byte[(bArr3[i2].length * 2) - 1];
                bArr2[i2] = new byte[arrayList.size()];
                int i16 = 0;
                for (byte b2 : bArr3[i2]) {
                    byte[] bArr11 = bArr4[i2];
                    bArr11[i16] = b2;
                    if (i16 < bArr11.length - 2) {
                        bArr11[i16 + 1] = 0;
                    }
                    i16 += 2;
                }
                Iterator it = arrayList.iterator();
                int i17 = 0;
                while (it.hasNext()) {
                    bArr2[i2][i17] = ((Byte) it.next()).byteValue();
                    i17++;
                }
            }
        }
        if (str != null) {
            try {
                if (new File(str).exists()) {
                    if (new File(str).length() != 0) {
                        try {
                            if (new File(str).exists()) {
                                try {
                                    FileChannel channel = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                                    MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                    map.position(0);
                                    int i18 = 0;
                                    while (map.hasRemaining()) {
                                        try {
                                            int position = map.position();
                                            byte b3 = map.get();
                                            for (int i19 = 0; i19 < length; i19++) {
                                                byte[] bArr12 = bArr3[i19];
                                                if (bArr12 != null && b3 == bArr12[0]) {
                                                    int i20 = position + 1;
                                                    map.position(i20);
                                                    byte b4 = map.get();
                                                    int i21 = 1;
                                                    while (map.hasRemaining()) {
                                                        byte[] bArr13 = bArr3[i19];
                                                        if (i21 >= bArr13.length || b4 != bArr13[i21]) {
                                                            break;
                                                        }
                                                        i21++;
                                                        if (i21 == bArr13.length) {
                                                            map.position(position);
                                                            map.put(bArr[i19]);
                                                            map.force();
                                                            i18++;
                                                        }
                                                        if (map.hasRemaining()) {
                                                            b4 = map.get();
                                                        }
                                                    }
                                                    map.position(i20);
                                                }
                                                byte[] bArr14 = bArr4[i19];
                                                if (bArr14 != null && b3 == bArr14[0]) {
                                                    int i22 = position + 1;
                                                    map.position(i22);
                                                    byte b5 = map.get();
                                                    int i23 = 1;
                                                    while (map.hasRemaining()) {
                                                        byte[] bArr15 = bArr4[i19];
                                                        if (i23 >= bArr15.length || b5 != bArr15[i23]) {
                                                            break;
                                                        }
                                                        i23++;
                                                        if (i23 == bArr15.length) {
                                                            map.position(position);
                                                            map.put(bArr2[i19]);
                                                            map.force();
                                                            i18++;
                                                        }
                                                        if (map.hasRemaining()) {
                                                            b5 = map.get();
                                                        }
                                                    }
                                                    map.position(i22);
                                                }
                                            }
                                            map.position(position + 1);
                                        } catch (Exception e3) {
                                            e = e3;
                                            i = i18;
                                            try {
                                                e.printStackTrace();
                                                return i;
                                            } catch (Exception e4) {
                                                e = e4;
                                                try {
                                                    e.printStackTrace();
                                                    return i;
                                                } catch (Exception e5) {
                                                    e = e5;
                                                    C3348.m12347(e);
                                                    return i;
                                                }
                                            }
                                        }
                                    }
                                    channel.close();
                                    return i18;
                                } catch (Exception e6) {
                                    e = e6;
                                    i = 0;
                                }
                            }
                        } catch (Exception e7) {
                            e = e7;
                            i = 0;
                        }
                    }
                }
            } catch (Exception e8) {
                e = e8;
                i = 0;
            }
        }
        return 0;
    }

    public static void m11500(ArrayList<C3004> arrayList) {
        if (arrayList != null) {
            Iterator<C3004> it = arrayList.iterator();
            while (it.hasNext()) {
                C3004 next = it.next();
                if (!next.f8181.equals("")) {
                    next.f8189 = false;
                    next.f8185.clear();
                    next.f8184.clear();
                    next.f8190 = false;
                }
            }
        }
    }

    public static boolean m11501(String str, String str2, ArrayList<C3286> arrayList, boolean z, boolean z2) throws MinSdkVersionException {
        m11590();
        m11412();
        ArrayList<SignerParams> arrayList2 = new ArrayList(1);
        SignerParams signerParams = new SignerParams();
        signerParams.setKeyFile(C3348.f9876 + "/Modified/Keys/testkey.pk8");
        signerParams.setCertFile(C3348.f9876 + "/Modified/Keys/testkey.x509.pem");
        arrayList2.add(signerParams);
        ArrayList arrayList3 = new ArrayList(arrayList2.size());
        PasswordRetriever passwordRetriever = new PasswordRetriever();
        try {
            int i = 0;
            for (SignerParams signerParams2 : arrayList2) {
                i++;
                signerParams2.setName("signer #" + i);
                ApkSigner.SignerConfig signerConfig = ApkSignerTool.getSignerConfig(signerParams2, passwordRetriever);
                if (signerConfig == null) {
                    passwordRetriever.close();
                    return false;
                }
                arrayList3.add(signerConfig);
            }
            passwordRetriever.close();
            boolean z3 = !m11314(z);
            ApkSigner.Builder signingCertificateLineage = new ApkSigner.Builder(arrayList3).setInputApk(new File(str)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(true).setV2SigningEnabled(z3).setV3SigningEnabled(false).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
            signingCertificateLineage.setMinSdkVersion(14);
            ApkSigner build = signingCertificateLineage.build();
            ApkSigner.use_original_signature = z;
            ApkSigner.files_for_add_to_zip = arrayList;
            try {
                build.sign();
                z3 = build.mV2SigningEnabled;
            } catch (MinSdkVersionException e) {
                e.getMessage().endsWith(".");
                throw new MinSdkVersionException("Failed to determine APK's minimum supported platform version. Use --min-sdk-version to override", e);
            } catch (Throwable th) {
                th.printStackTrace();
            }
            if (new File(str2 + ".tmp").exists()) {
                new File(str2 + ".tmp").delete();
            }
            return z3;
        } catch (Throwable th2) {
            try {
                passwordRetriever.close();
            } catch (Throwable th3) {
                Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th2, th3);
            }
            throw th2;
        }
    }

    public static boolean m11502(String str, String str2, ArrayList<C3286> arrayList, boolean z, boolean z2, ArrayList<C3003> arrayList2, File file, C2972 c2972) throws MinSdkVersionException {
        String str3;
        String str4;
        C3348.m12347("source apk:" + str);
        C3348.m12347("dest apk:" + str2);
        m11590();
        if (file != null) {
            file.getName();
        }
        ArrayList arrayList3 = new ArrayList();
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        if (c2972 != null) {
            Iterator<C2995> it = c2972.f7920.iterator();
            while (it.hasNext()) {
                C2995 next = it.next();
                if (next.f8099 == 24) {
                    Iterator<C2984> it2 = next.f8109.iterator();
                    while (it2.hasNext()) {
                        C2984 next2 = it2.next();
                        if (next2.f8040) {
                            arrayList3.add(next2);
                            C3348.m12347("file added " + next2.f8037 + " for add zip " + str2);
                        }
                    }
                }
                if (next.f8099 == 25) {
                    Iterator<C2990> it3 = next.f8110.iterator();
                    while (it3.hasNext()) {
                        arrayList4.add(it3.next());
                    }
                }
                if (next.f8099 == 26) {
                    Iterator<String> it4 = next.f8107.iterator();
                    while (it4.hasNext()) {
                        arrayList5.add(it4.next());
                    }
                }
                if (next.f8099 == 28) {
                    Iterator<String> it5 = next.f8108.iterator();
                    while (it5.hasNext()) {
                        arrayList6.add(it5.next());
                    }
                }
            }
        }
        m11412();
        ArrayList<SignerParams> arrayList7 = new ArrayList(1);
        SignerParams signerParams = new SignerParams();
        signerParams.setKeyFile(C3348.f9876 + "/Modified/Keys/testkey.pk8");
        signerParams.setCertFile(C3348.f9876 + "/Modified/Keys/testkey.x509.pem");
        arrayList7.add(signerParams);
        ArrayList arrayList8 = new ArrayList(arrayList7.size());
        PasswordRetriever passwordRetriever = new PasswordRetriever();
        try {
            int i = 0;
            for (SignerParams signerParams2 : arrayList7) {
                i++;
                signerParams2.setName("signer #" + i);
                ApkSigner.SignerConfig signerConfig = ApkSignerTool.getSignerConfig(signerParams2, passwordRetriever);
                if (signerConfig == null) {
                    passwordRetriever.close();
                    return false;
                }
                arrayList8.add(signerConfig);
            }
            passwordRetriever.close();
            if (arrayList3.size() > 0 || arrayList4.size() > 0 || arrayList5.size() > 0 || arrayList6.size() > 0) {
                try {
                    m11491(str, str2 + ".tmp", arrayList4, arrayList5, arrayList3, arrayList6);
                    str3 = str2 + ".tmp";
                } catch (Throwable th) {
                    th.printStackTrace();
                }
                if (!z2 && file != null) {
                    str4 = str3 + ".tmp";
                    if (!str3.equals(str2 + ".tmp")) {
                        str4 = str2 + ".tmp";
                    }
                    try {
                        m11490(str3, str4, arrayList2, file);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                } else {
                    str4 = str3;
                }
                boolean z3 = !m11314(z);
                ApkSigner.Builder signingCertificateLineage = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(true).setV2SigningEnabled(z3).setV3SigningEnabled(false).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
                signingCertificateLineage.setMinSdkVersion(14);
                ApkSigner build = signingCertificateLineage.build();
                ApkSigner.use_original_signature = z;
                ApkSigner.use_zip_crc_image = z2;
                ApkSigner.files_for_add_to_zip = arrayList;
                build.sign();
                z3 = build.mV2SigningEnabled;
                C3923.m12601(m11425(R.string.patch_step8, new File(str2).getName()));
                if (new File(str2 + ".tmp").exists()) {
                    new File(str2 + ".tmp").delete();
                }
                if (new File(str4 + ".tmp").exists()) {
                    new File(str4 + ".tmp").delete();
                }
                return z3;
            }
            str3 = str;
            if (!z2) {
            }
            str4 = str3;
            boolean z32 = !m11314(z);
            ApkSigner.Builder signingCertificateLineage2 = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(true).setV2SigningEnabled(z32).setV3SigningEnabled(false).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
            signingCertificateLineage2.setMinSdkVersion(14);
            ApkSigner build2 = signingCertificateLineage2.build();
            ApkSigner.use_original_signature = z;
            ApkSigner.use_zip_crc_image = z2;
            ApkSigner.files_for_add_to_zip = arrayList;
            build2.sign();
            z32 = build2.mV2SigningEnabled;
            C3923.m12601(m11425(R.string.patch_step8, new File(str2).getName()));
            if (new File(str2 + ".tmp").exists()) {
            }
            if (new File(str4 + ".tmp").exists()) {
            }
            return z32;
        } finally {
        }
    }

    public static void m11503(String str) {
        ArrayList<File> m11419 = m11419();
        if (m11419 != null) {
            try {
                if (m11419.size() > 0) {
                    Iterator<File> it = m11419.iterator();
                    while (it.hasNext()) {
                        File next = it.next();
                        File file = new File(next.getAbsolutePath() + "/Android/obb/" + str);
                        File file2 = new File(next.getAbsolutePath() + "/Android/data/" + str);
                        File file3 = new File(next.getAbsolutePath() + "/Android/obb/!lp_backup_" + str);
                        File file4 = new File(next.getAbsolutePath() + "/Android/data/!lp_backup_" + str);
                        if (file3.exists()) {
                            if (!file.exists()) {
                                file3.renameTo(file);
                            } else {
                                file.delete();
                                file3.renameTo(file);
                            }
                        }
                        if (file4.exists()) {
                            if (!file2.exists()) {
                                file4.renameTo(file2);
                            } else {
                                file2.delete();
                                file4.renameTo(file2);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void m11504(String str) {
        int i;
        File m11357 = m11357(new File(str));
        if (C3348.f9948.booleanValue()) {
            String[] strArr = {"ls", "-dZ", m11357.getAbsolutePath()};
            if (new File("/system/bin/toybox").exists()) {
                C3348.m12347("use toybox");
                i = 3;
                strArr = new String[]{"toybox", "ls", "-dZ", m11357.getAbsolutePath()};
            } else {
                i = 3;
            }
            String m11438 = m11438(strArr);
            String[] strArr2 = new String[i];
            strArr2[0] = "chmod";
            strArr2[1] = "777";
            strArr2[2] = str;
            m11508(strArr2);
            if (m11438 != null && !m11438.equals("")) {
                String[] split = m11438.split("\\s+");
                if (split.length > 4 && !split[0].contains(":") && !split[3].contains(":")) {
                    C3348.m12347("0:" + split[0]);
                    C3348.m12347("1:" + split[1]);
                    C3348.m12347("2:" + split[2]);
                    C3348.m12347("3:" + split[3]);
                    C3348.m12347(m11438);
                }
                if (split.length > 1) {
                    if (split[0].contains(":")) {
                        C3348.m12347(split[0]);
                        m11508("chcon", split[0].trim(), str);
                        return;
                    } else {
                        if (split.length > 4 && split[3].contains(":")) {
                            C3348.m12347(split[3]);
                            m11508("chcon", split[3].trim(), str);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            C3348.m12347("manual:u:object_r:media_rw_data_file:s0");
            m11508("chcon", "u:object_r:media_rw_data_file:s0", str);
            return;
        }
        if (C3348.f9908) {
            String[] strArr3 = {"ls -dZ " + m11357.getAbsolutePath()};
            if (new File("/system/bin/toybox").exists()) {
                C3348.m12347("use toybox");
                strArr3 = new String[]{"toybox ls -dZ " + m11357.getAbsolutePath()};
            }
            String m11618 = new C2880("").m11618(strArr3);
            m11506("chmod 777 " + str);
            if (m11618 != null && !m11618.equals("")) {
                String[] split2 = m11618.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":") && !split2[3].contains(":")) {
                    C3348.m12347("0:" + split2[0]);
                    C3348.m12347("1:" + split2[1]);
                    C3348.m12347("2:" + split2[2]);
                    C3348.m12347("3:" + split2[3]);
                    C3348.m12347(m11618);
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        C3348.m12347(split2[0]);
                        m11506("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        C3348.m12347(split2[3]);
                        m11506("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            C3348.m12347("manual:u:object_r:media_rw_data_file:s0");
            m11506("chcon u:object_r:media_rw_data_file:s0 " + str);
        }
    }

    public static String m11505(Class cls, String... strArr) {
        String str = " " + cls.getName();
        for (String str2 : strArr) {
            str = str + " '" + str2 + "'";
        }
        return new C2880("").m11618(C3348.f9909 + str);
    }

    public static void m11506(String str) {
        try {
            m11570();
            if (C3348.f9908) {
                if (C3348.f9920 == null) {
                    C3348.f9920 = new String[0];
                }
                String[] strArr = C3348.f9920;
                int i = 1;
                String[] strArr2 = new String[strArr.length + 1];
                strArr2[0] = str;
                for (String str2 : strArr) {
                    strArr2[i] = str2 + " " + str;
                    i++;
                }
                new C2880("").m11618(strArr2);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String m11507(String str, String str2) {
        return str.replaceAll("%PACKAGE_NAME%", str2);
    }

    public static void m11508(String... strArr) {
        try {
            m11570();
            m11438(strArr);
            String[] strArr2 = C3348.f9920;
            if (strArr2 != null && strArr2.length > 0) {
                int i = 1;
                String[] strArr3 = new String[strArr.length + 1];
                for (String str : strArr) {
                    strArr3[i] = str;
                    i++;
                }
                for (String str2 : C3348.f9920) {
                    strArr3[0] = str2;
                    m11438(strArr3);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static boolean m11509(File file, String str) {
        JSONObject jSONObject;
        if (file.exists()) {
            try {
                jSONObject = new JSONObject(m11486(file));
            } catch (JSONException e) {
                e.printStackTrace();
                jSONObject = null;
            }
        } else {
            jSONObject = new JSONObject();
        }
        try {
            jSONObject.put("label", str);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        C3348.m12347(jSONObject.toString());
        m11514(file, jSONObject.toString());
        if (file.exists() && file.length() > 0) {
            return true;
        }
        return false;
    }

    public static boolean m11510(File file) {
        JSONArray jSONArray;
        C3348.m12347("save expansion from xapk");
        try {
            C2800 c2800 = new C2800(file);
            try {
                jSONArray = new JSONObject(new String(C2793.m10957(c2800.m11032(c2800.m11031("manifest.json"))), "utf-8")).getJSONArray("expansions");
            } catch (Throwable unused) {
                C3348.m12347("expansion files not found in хapk");
                jSONArray = null;
            }
            if (jSONArray == null) {
                return true;
            }
            for (int i = 0; i < jSONArray.length(); i++) {
                String string = ((JSONObject) jSONArray.get(i)).getString("file");
                File file2 = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR + ((JSONObject) jSONArray.get(i)).getString("install_path"));
                if (C3348.f9924 >= 30 && C3348.f9908) {
                    if (!new C2880().m11618(C3348.f9909 + C2022.class.getName() + " '" + file.getAbsolutePath() + "' '" + string + "' '" + file2.getAbsolutePath() + "'").contains("File copied!")) {
                        return false;
                    }
                } else if (!m11293(c2800.m11032(c2800.m11031(string)), file2)) {
                    return false;
                }
            }
            return true;
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    public static boolean m11511(Drawable drawable, File file) {
        if (drawable != null) {
            try {
                Bitmap m11313 = m11313(drawable);
                if (m11313 != null) {
                    if (file.exists()) {
                        file.delete();
                    }
                    m11313.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(file));
                    if (file.exists()) {
                        if (file.length() > 0) {
                            return true;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            } catch (FileNotFoundException unused) {
                return false;
            }
        }
        return false;
    }

    public static boolean m11512(File file, String str) {
        m11590();
        try {
            if (!file.exists()) {
                m11357(file).mkdirs();
                file.createNewFile();
            }
            C3348.m12347("...rrunning my app...");
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE);
            long length = file.length();
            randomAccessFile.seek(file.length());
            randomAccessFile.write(str.getBytes());
            C3348.m12347("...file length..." + randomAccessFile.length());
            randomAccessFile.close();
            if (file.length() != length + str.length()) {
                return false;
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean m11513(File file, File file2) {
        m11590();
        try {
            C3348.m12347("...rrunning my app...");
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE);
            RandomAccessFile randomAccessFile2 = new RandomAccessFile(file2, InternalZipConstants.READ_MODE);
            file.length();
            randomAccessFile.seek(file.length());
            try {
                randomAccessFile.write("#Lucky Patcher block Ads start#\n".getBytes());
                byte[] bArr = new byte[4096];
                while (true) {
                    int read = randomAccessFile2.read(bArr);
                    if (read > 0) {
                        randomAccessFile.write(bArr, 0, read);
                    } else {
                        randomAccessFile.write("#Lucky Patcher block Ads finish#\n\n\n".getBytes());
                        randomAccessFile2.close();
                        randomAccessFile.close();
                        return true;
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
                return false;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    @SuppressLint({"NewApi"})
    public static boolean m11514(File file, String str) {
        m11590();
        try {
            if (!file.exists()) {
                m11357(file).mkdirs();
                file.createNewFile();
                try {
                    file.setReadable(true, false);
                    file.setWritable(true, false);
                } catch (NoSuchMethodError e) {
                    e.printStackTrace();
                }
            }
            C3348.m12347("...rrunning my app...");
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE);
            randomAccessFile.setLength(0L);
            randomAccessFile.seek(0L);
            randomAccessFile.write(str.getBytes());
            randomAccessFile.close();
            if (file.length() != str.length()) {
                return false;
            }
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public static boolean m11515(File file, String str) {
        m11590();
        try {
            if (!file.exists()) {
                return false;
            }
            C3348.m12347("...search text to file...");
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            randomAccessFile.seek(0L);
            while (randomAccessFile.getFilePointer() < randomAccessFile.length()) {
                String readLine = randomAccessFile.readLine();
                if (readLine != null && readLine.contains(str.replaceAll("\n", ""))) {
                    return true;
                }
            }
            C3348.m12347("...file length..." + randomAccessFile.length());
            randomAccessFile.close();
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean m11516(String str) {
        C3348.m12347(str);
        return false;
    }

    public static boolean m11517(String str) {
        C3348.m12347(str);
        return false;
    }

    public static void m11518(String str) {
        int i;
        int i2;
        if (C3348.f9948.booleanValue()) {
            String[] strArr = {"ls", "-dZ", "/data/media"};
            if (new File("/system/bin/toybox").exists()) {
                i = 3;
                strArr = new String[]{"toybox", "ls", "-dZ", "/data/media"};
            } else {
                i = 3;
            }
            String m11438 = m11438(strArr);
            String[] strArr2 = new String[i];
            strArr2[0] = "restorecon";
            strArr2[1] = "-v";
            strArr2[2] = str;
            m11438(strArr2);
            String[] strArr3 = new String[i];
            strArr3[0] = "chmod";
            strArr3[1] = "777";
            strArr3[2] = str;
            m11508(strArr3);
            if (m11438 != null && !m11438.equals("")) {
                String[] split = m11438.split("\\s+");
                if (split.length > 4 && !split[0].contains(":")) {
                    i2 = 3;
                    split[3].contains(":");
                } else {
                    i2 = 3;
                }
                if (split.length > 1) {
                    if (split[0].contains(":")) {
                        String[] strArr4 = new String[i2];
                        strArr4[0] = "chcon";
                        strArr4[1] = split[0].trim();
                        strArr4[2] = str;
                        m11508(strArr4);
                        return;
                    }
                    if (split.length > 4 && split[i2].contains(":")) {
                        String[] strArr5 = new String[i2];
                        strArr5[0] = "chcon";
                        strArr5[1] = split[i2].trim();
                        strArr5[2] = str;
                        m11508(strArr5);
                        return;
                    }
                    return;
                }
                return;
            }
            m11508("chcon", "u:object_r:media_rw_data_file:s0", str);
            return;
        }
        if (C3348.f9908) {
            String[] strArr6 = {"ls", "-dZ", "/data/media"};
            if (new File("/system/bin/toybox").exists()) {
                strArr6 = new String[]{"toybox", "ls", "-dZ", "/data/media"};
            }
            String m114382 = m11438(strArr6);
            new C2880("").m11618("restorecon -v " + str);
            m11506("chmod 777 " + str);
            if (m114382 != null && !m114382.equals("")) {
                String[] split2 = m114382.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":")) {
                    split2[3].contains(":");
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        m11506("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        m11506("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            m11506("chcon u:object_r:media_rw_data_file:s0 " + str);
        }
    }

    public static void m11519(C3312 c3312, File file) {
        String[] split;
        try {
            String comment = new ZipFile(file.getAbsolutePath() + "/data.lpbkp").getComment();
            if (comment != null && !comment.equals("") && (split = comment.split("\n")) != null && split.length > 0) {
                for (String str : split) {
                    if (str.contains("version=")) {
                        c3312.f9779 = str.substring(str.lastIndexOf("=") + 1, str.length());
                    }
                    if (str.contains("versionCode=")) {
                        try {
                            c3312.f9780 = Integer.valueOf(str.substring(str.lastIndexOf("=") + 1, str.length())).intValue();
                        } catch (Throwable th) {
                            th.printStackTrace();
                            c3312.f9780 = 0;
                        }
                    }
                }
            }
        } catch (ZipException e) {
            e.printStackTrace();
        } catch (Throwable th2) {
            th2.printStackTrace();
        }
    }

    @SuppressLint({"NewApi"})
    public static final void m11520(int i) {
        String[] strArr = {"MainActivity1", "MainActivity2", "MainActivity3", "MainActivity4", "MainActivity5", "MainActivity6", "MainActivity7", "MainActivity10"};
        try {
            switch (i) {
                case 0:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.drawable.ic_launcher);
                    }
                    return;
                case 1:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher2);
                    }
                    return;
                case 2:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher3);
                    }
                    return;
                case 3:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher4);
                    }
                    return;
                case 4:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher5);
                    }
                    return;
                case 5:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher6);
                    }
                    return;
                case 6:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 1, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 2, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher7);
                    }
                    return;
                case 7:
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[0]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[7]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[1]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[2]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[3]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[4]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[5]), 2, 1);
                    C3348.m12337().setComponentEnabledSetting(new ComponentName(C3348.m12334(), C3348.m12334().getPackageName() + "." + strArr[6]), 1, 1);
                    if (C3348.f9870 != null && C3348.f9924 > 10) {
                        C3348.f9870.m2466().getActionBar().setIcon(R.mipmap.ic_launcher8);
                    }
                    return;
                default:
                    return;
            }
        } catch (Exception | NoSuchMethodError unused) {
        }
    }

    public static Context m11521(Context context) {
        Locale locale;
        Context createConfigurationContext;
        Context createConfigurationContext2;
        try {
            String string = C3348.m12333().getString("force_language", "default");
            if (string.equals("default")) {
                Locale locale2 = Resources.getSystem().getConfiguration().locale;
                Locale.setDefault(Locale.getDefault());
                Configuration configuration = new Configuration();
                int i = Build.VERSION.SDK_INT;
                if (i >= 17) {
                    configuration.setLocale(locale2);
                    configuration.locale = locale2;
                } else {
                    configuration.locale = locale2;
                }
                if (i >= 17) {
                    configuration.setLayoutDirection(locale2);
                }
                if (i > 24) {
                    context.getResources().updateConfiguration(configuration, context.getResources().getDisplayMetrics());
                    createConfigurationContext2 = context.createConfigurationContext(configuration);
                    return createConfigurationContext2;
                }
                context.getResources().updateConfiguration(configuration, context.getResources().getDisplayMetrics());
            } else {
                String[] split = string.split("_");
                if (split.length == 1) {
                    locale = new Locale(split[0]);
                } else {
                    locale = null;
                }
                if (split.length == 2) {
                    locale = new Locale(split[0], split[1], "");
                    if (split[1].equals("rBR")) {
                        locale = new Locale(split[0], "BR");
                    }
                }
                if (split.length == 3) {
                    locale = new Locale(split[0], split[1], split[2]);
                }
                Locale.setDefault(locale);
                Configuration configuration2 = new Configuration();
                configuration2.setToDefaults();
                int i2 = Build.VERSION.SDK_INT;
                if (i2 >= 17) {
                    configuration2.setLocale(locale);
                    configuration2.locale = locale;
                } else {
                    configuration2.locale = locale;
                }
                if (i2 >= 17) {
                    configuration2.setLayoutDirection(locale);
                }
                if (i2 > 24) {
                    context.getResources().updateConfiguration(configuration2, context.getResources().getDisplayMetrics());
                    createConfigurationContext = context.createConfigurationContext(configuration2);
                    return createConfigurationContext;
                }
                context.getResources().updateConfiguration(configuration2, context.getResources().getDisplayMetrics());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        C3348.f9968 = null;
        return null;
    }

    public static void m11522(String str, String str2, String str3, boolean z) {
        if (new File(str2).exists()) {
            String[] split = str2.split(File.separator);
            String str4 = InternalZipConstants.ZIP_FILE_SEPARATOR;
            for (int i = 0; i < split.length; i++) {
                if (!split[i].equals("")) {
                    str4 = str4 + split[i];
                }
                if (!str4.startsWith(str)) {
                }
                if (z) {
                    m11438("chown", str3, str4);
                    m11438("chown", str3.replace(":", "."), str4);
                }
                z = true;
                if (!split[i].equals("")) {
                    str4 = str4 + InternalZipConstants.ZIP_FILE_SEPARATOR;
                }
            }
        }
    }

    public static void m11523(String str, String str2, String str3, boolean z) {
        if (new File(str2).exists()) {
            String[] split = str2.split(File.separator);
            String str4 = InternalZipConstants.ZIP_FILE_SEPARATOR;
            for (int i = 0; i < split.length; i++) {
                if (!split[i].equals("")) {
                    str4 = str4 + split[i];
                }
                if (!str4.startsWith(str)) {
                }
                if (z) {
                    m11438("chmod", str3, str4);
                }
                z = true;
                if (!split[i].equals("")) {
                    str4 = str4 + InternalZipConstants.ZIP_FILE_SEPARATOR;
                }
            }
        }
    }

    public static void m11524(String str) {
        m11506("chmod 0644 " + str);
        m11506("chown 0.0 " + str);
        m11506("chown 0:0 " + str);
    }

    public static int m11525(String str, byte[][] bArr, byte b, String str2) {
        byte[] bArr2;
        int i;
        int i2;
        int i3;
        byte[][] bArr3 = bArr;
        m11590();
        C3348.m12347("scan: " + str);
        int i4 = 0;
        int i5 = 2;
        m11508("chmod", "777", str);
        new ArrayList();
        byte[] bArr4 = null;
        try {
            bArr2 = "schemas".getBytes("UTF-8");
            try {
                if (!str2.equals("")) {
                    bArr4 = str2.getBytes("UTF-8");
                }
            } catch (UnsupportedEncodingException e) {
                e = e;
                e.printStackTrace();
                if (str != null) {
                }
                return 0;
            }
        } catch (UnsupportedEncodingException e2) {
            e = e2;
            bArr2 = null;
        }
        if (str != null) {
            try {
                if (new File(str).exists()) {
                    if (new File(str).length() != 0) {
                        try {
                            if (new File(str).exists()) {
                                try {
                                    FileChannel channel = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                                    MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                    map.position(0);
                                    if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                        map.position(56);
                                        int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                        byte[] bArr5 = new byte[m11592 / 4];
                                        map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                        int[] iArr = new int[m11592];
                                        for (int i6 = 0; i6 < m11592; i6++) {
                                            try {
                                                iArr[i6] = m11592(map.get(), map.get(), map.get(), map.get());
                                            } catch (Exception e3) {
                                                e = e3;
                                                try {
                                                    e.printStackTrace();
                                                    return i4;
                                                } catch (Exception e4) {
                                                    e = e4;
                                                    try {
                                                        e.printStackTrace();
                                                        return i4;
                                                    } catch (Exception e5) {
                                                        e = e5;
                                                        C3348.m12347(e);
                                                        return i4;
                                                    }
                                                }
                                            }
                                        }
                                        int i7 = 0;
                                        int i8 = 0;
                                        while (i7 < m11592) {
                                            try {
                                                map.position(iArr[i7]);
                                                int m11484 = m11484(map);
                                                byte[] bArr6 = new byte[m11484];
                                                int position = map.position();
                                                for (int i9 = 0; i9 < m11484; i9++) {
                                                    bArr6[i9] = map.get();
                                                }
                                                int i10 = 0;
                                                while (i10 < bArr3.length) {
                                                    byte[] bArr7 = (byte[]) Array.get(bArr3, i10);
                                                    if (bArr7.length <= m11484 && bArr7.length > i5 && (bArr4 == null || m11484 > bArr4.length)) {
                                                        int i11 = 0;
                                                        boolean z = false;
                                                        while (i11 < m11484) {
                                                            if (bArr4 != null) {
                                                                i = m11592;
                                                                if (bArr6[0] == bArr4[0] && m11484 > bArr4.length) {
                                                                    int i12 = 0;
                                                                    while (i12 < bArr4.length) {
                                                                        boolean z2 = z;
                                                                        if (bArr6[i12] != bArr4[i12]) {
                                                                            z = true;
                                                                            break;
                                                                        }
                                                                        i12++;
                                                                        z = z2;
                                                                    }
                                                                }
                                                                i10++;
                                                                m11592 = i;
                                                                bArr3 = bArr;
                                                                bArr4 = bArr4;
                                                                i5 = 2;
                                                            } else {
                                                                i = m11592;
                                                            }
                                                            z = z;
                                                            byte[] bArr8 = bArr4;
                                                            if (bArr6[i11] == bArr7[0] && !z) {
                                                                int i13 = 1;
                                                                while (i13 < bArr7.length && (i3 = i11 + i13) < m11484 && bArr6[i3] == bArr7[i13] && !z) {
                                                                    i13++;
                                                                    if (i13 == bArr7.length) {
                                                                        if (bArr7.length > 2) {
                                                                            map.position(position + i11 + (bArr7.length - 1));
                                                                            map.put((byte) (bArr6[(bArr7.length - 1) + i11] - 1));
                                                                        }
                                                                        map.force();
                                                                        i8++;
                                                                    }
                                                                }
                                                            }
                                                            if (bArr6[i11] == bArr2[0] && !z) {
                                                                int i14 = 1;
                                                                while (i14 < bArr2.length && (i2 = i11 + i14) < m11484 && bArr6[i2] == bArr2[i14]) {
                                                                    i14++;
                                                                    if (i14 == bArr2.length) {
                                                                        z = true;
                                                                    }
                                                                }
                                                            }
                                                            i11++;
                                                            m11592 = i;
                                                            bArr4 = bArr8;
                                                        }
                                                    }
                                                    i = m11592;
                                                    i10++;
                                                    m11592 = i;
                                                    bArr3 = bArr;
                                                    bArr4 = bArr4;
                                                    i5 = 2;
                                                }
                                                i7++;
                                                bArr3 = bArr;
                                                i5 = 2;
                                            } catch (Exception e6) {
                                                e = e6;
                                                i4 = i8;
                                                e.printStackTrace();
                                                return i4;
                                            }
                                        }
                                        i4 = i8;
                                    } else {
                                        i4 = 0;
                                    }
                                    channel.close();
                                    return i4;
                                } catch (Exception e7) {
                                    e = e7;
                                    i4 = 0;
                                }
                            }
                        } catch (Exception e8) {
                            e = e8;
                            i4 = 0;
                        }
                    }
                }
            } catch (Exception e9) {
                e = e9;
                i4 = 0;
            }
        }
        return 0;
    }

    public static String m11526(String str) {
        try {
            Signature signature = Signature.getInstance("SHA1withRSA");
            signature.initSign(m11393(f7710));
            signature.update(str.getBytes());
            return C3015.m11704(signature.sign());
        } catch (InvalidKeyException e) {
            e.printStackTrace();
            return "";
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
            return "";
        } catch (SignatureException e3) {
            e3.printStackTrace();
            return "";
        }
    }

    public static String m11527(String str) {
        try {
            Signature signature = Signature.getInstance("SHA256withRSA");
            signature.initSign(m11393(f7710));
            signature.update(str.getBytes());
            return Base64.encodeToString(signature.sign(), 8);
        } catch (InvalidKeyException e) {
            e.printStackTrace();
            return "";
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
            return "";
        } catch (SignatureException e3) {
            e3.printStackTrace();
            return "";
        }
    }

    public static void m11528(String str) {
        if (C3348.f9870 != null) {
            C3348.m12359(new RunnableC2927(str));
        }
    }

    public static void m11529(Dialog dialog) {
        try {
            C3348.m12359(new RunnableC2917(dialog));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11530(String str) {
        ArrayList<File> m11419 = m11419();
        if (m11419 != null) {
            try {
                if (m11419.size() > 0) {
                    Iterator<File> it = m11419.iterator();
                    while (it.hasNext()) {
                        File next = it.next();
                        File file = new File(next.getAbsolutePath() + "/Android/obb/" + str);
                        File file2 = new File(next.getAbsolutePath() + "/Android/data/" + str);
                        File file3 = new File(next.getAbsolutePath() + "/Android/obb/!lp_backup_" + str);
                        File file4 = new File(next.getAbsolutePath() + "/Android/data/!lp_backup_" + str);
                        if (file.exists()) {
                            if (!file3.exists()) {
                                if (C3348.f9908) {
                                    new C2880("").m11612(file, "777");
                                }
                                file.renameTo(file3);
                            } else {
                                if (C3348.f9908) {
                                    new C2880("").m11612(file3, "777");
                                }
                                file3.delete();
                                if (C3348.f9908) {
                                    new C2880("").m11612(file, "777");
                                }
                                file.renameTo(file3);
                            }
                        }
                        if (file2.exists()) {
                            if (!file4.exists()) {
                                if (C3348.f9908) {
                                    new C2880("").m11612(file2, "777");
                                }
                                file2.renameTo(file4);
                            } else {
                                if (C3348.f9908) {
                                    new C2880("").m11612(file4, "777");
                                }
                                file4.delete();
                                if (C3348.f9908) {
                                    new C2880("").m11612(file2, "777");
                                }
                                file2.renameTo(file4);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void m11531(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z, Runnable runnable, long j) {
        f7699 = false;
        try {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C3287 c3287 = new C3287(C3348.f9870.mo2480(), true);
                LinearLayout linearLayout = (LinearLayout) View.inflate(C3348.f9884, R.layout.ads, null);
                TextView textView = (TextView) linearLayout.findViewById(R.id.dialog_message);
                ((ScrollView) linearLayout.findViewById(R.id.dialog_message_container)).setVisibility(0);
                textView.setMovementMethod(new ScrollingMovementMethod());
                textView.setText(str2);
                if (z) {
                    try {
                        Linkify.addLinks(textView, 3);
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                }
                linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0f));
                c3287.m12264(linearLayout);
                f7700 = c3287.m12290().m12266(str).m12279(R.drawable.ic_vopros).m12281(str3, onClickListener).m12285(m11423(R.string.no), onClickListener2).m12288(onCancelListener).m12261();
                if (!C3348.m12333().getBoolean("remove_ads", false)) {
                    C3348.m12347("Try show ads dialog");
                    try {
                        Timer timer = new Timer("ads timer");
                        C2881 c2881 = new C2881(runnable);
                        C3348.m12347("Start timer");
                        timer.schedule(c2881, j);
                        m11331(linearLayout, new RunnableC2890(timer, c2881), timer, c2881);
                        return;
                    } catch (Throwable th2) {
                        m11533(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z);
                        C3348.m12356(11);
                        th2.printStackTrace();
                        return;
                    }
                }
                m11533(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z);
                C3348.m12356(11);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11532(Dialog dialog) {
        try {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                if (C3348.f9979.size() == 0 || C3348.f9979.size() == 1) {
                    dialog.show();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11533(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z) {
        C3348.m12359(new RunnableC2885(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z));
    }

    public static void m11534(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, String str4, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C3348.m12359(new RunnableC2901(str4, str, str2, str3, onClickListener, onClickListener2, onCancelListener));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11535(String str, SpannableStringBuilder spannableStringBuilder, String str2, DialogInterface.OnClickListener onClickListener, String str3, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C3287 c3287 = new C3287(C3348.f9884);
                if (str3 != null && !str3.equals("")) {
                    Dialog m12261 = c3287.m12266(str).m12280(spannableStringBuilder).m12279(R.drawable.ic_vopros).m12281(str2, onClickListener).m12285(str3, onClickListener2).m12289(true).m12288(onCancelListener).m12261();
                    m11532(m12261);
                    m12261.findViewById(android.R.id.message);
                } else {
                    Dialog m122612 = c3287.m12266(str).m12280(spannableStringBuilder).m12279(R.drawable.ic_vopros).m12281(str2, onClickListener).m12289(true).m12288(onCancelListener).m12261();
                    m11532(m122612);
                    m122612.findViewById(android.R.id.message);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11536(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, String str4, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C3348.f9884;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C3287 c3287 = new C3287(C3348.f9884);
                if (str4 != null && !str4.equals("")) {
                    Dialog m12261 = c3287.m12266(str).m12282(str2).m12279(R.drawable.ic_vopros).m12281(str3, onClickListener).m12285(str4, onClickListener2).m12289(true).m12288(onCancelListener).m12261();
                    m11532(m12261);
                    m12261.findViewById(android.R.id.message);
                } else {
                    Dialog m122612 = c3287.m12266(str).m12282(str2).m12279(R.drawable.ic_vopros).m12281(str3, onClickListener).m12289(true).m12288(onCancelListener).m12261();
                    m11532(m122612);
                    m122612.findViewById(android.R.id.message);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11537(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        if (C3348.f9870 != null) {
            C3348.m12359(new RunnableC2953(str, str2, onClickListener, onClickListener2, onCancelListener));
        }
    }

    public static void m11538(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, String str4, CompoundButton.OnCheckedChangeListener onCheckedChangeListener2, boolean z2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z3) {
        C3348.m12359(new RunnableC2961(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, str4, onCheckedChangeListener2, z2, z3));
    }

    public static void m11539(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z2) {
        C3348.m12359(new RunnableC2931(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, z2));
    }

    public static void m11540(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z2) {
        C3348.m12359(new RunnableC2884(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, z2));
    }

    public static String m11541(ArrayList<File> arrayList) {
        String str = "{";
        for (int i = 0; i < arrayList.size(); i++) {
            if (i <= arrayList.size() - 2) {
                str = str + arrayList.get(i).getAbsolutePath() + "--lp--";
            }
            if (i == arrayList.size() - 1) {
                str = str + arrayList.get(i).getAbsolutePath();
            }
        }
        return str + "}";
    }

    public static void m11542(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        if (C3348.f9870 != null) {
            C3348.m12359(new RunnableC2891(str, str2, onClickListener, onClickListener2, onCancelListener));
        }
    }

    public static void m11543(Activity activity, String str, String str2) {
        if (activity != null) {
            activity.runOnUiThread(new RunnableC2905(activity, str, str2));
        }
    }

    public static void m11544(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, boolean z2) {
        C3348.m12359(new RunnableC2925(str, str2, onClickListener, str3, onCheckedChangeListener, z, z2));
    }

    public static void m11545(Activity activity, String str, SpannableStringBuilder spannableStringBuilder) {
        if (activity != null) {
            activity.runOnUiThread(new RunnableC2910(activity, str, spannableStringBuilder));
        }
    }

    public static void m11546(Activity activity, String str, String str2) {
        if (activity != null) {
            activity.runOnUiThread(new RunnableC2919(activity, str, str2));
        }
    }

    public static void m11547(Activity activity, String str, String str2, String str3, DialogInterface.OnClickListener onClickListener) {
        if (activity != null) {
            activity.runOnUiThread(new RunnableC2914(activity, str, str2, str3, onClickListener));
        }
    }

    public static void m11548(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) {
        try {
            C3348.m12359(new RunnableC2959(str, str2, onClickListener, onCancelListener));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m11549(int i, String str, String str2, String str3) {
        NotificationChannel notificationChannel;
        if (!C3348.m12333().getBoolean("hide_notify", false)) {
            System.currentTimeMillis();
            C3348.m12334();
            NotificationManager notificationManager = (NotificationManager) C3348.m12334().getSystemService("notification");
            if (Build.VERSION.SDK_INT >= 26) {
                notificationChannel = notificationManager.getNotificationChannel("default_channel_id");
                if (notificationChannel == null) {
                    NotificationChannel notificationChannel2 = new NotificationChannel("default_channel_id", str, 3);
                    notificationChannel2.enableVibration(false);
                    notificationManager.createNotificationChannel(notificationChannel2);
                }
            }
            notificationManager.notify(i, new C0560.C0563(C3348.m12334(), "default_channel_id").m1966(PendingIntent.getActivity(C3348.m12334(), 0, new Intent(C3348.m12334(), (Class<?>) MainActivity.class), 0)).m1968(str).m1967(str3).m1971(R.drawable.ic_notify).m1963());
        }
    }

    public static void m11550(String str, String str2, View.OnClickListener onClickListener, View.OnClickListener onClickListener2) {
        WindowManager windowManager = (WindowManager) C3348.m12334().getSystemService("window");
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        layoutParams.gravity = 17;
        layoutParams.type = 2003;
        layoutParams.width = -2;
        layoutParams.height = -2;
        layoutParams.alpha = 1.0f;
        layoutParams.packageName = C3348.m12334().getPackageName();
        layoutParams.buttonBrightness = 1.0f;
        layoutParams.windowAnimations = android.R.style.Animation.Dialog;
        View inflate = View.inflate(C3348.m12334(), R.layout.sys_dialog, null);
        Button button = (Button) inflate.findViewById(R.id.button_yes);
        Button button2 = (Button) inflate.findViewById(R.id.button_no);
        TextView textView = (TextView) inflate.findViewById(R.id.message);
        ((TextView) inflate.findViewById(R.id.TitleText)).setText(str);
        textView.setText(str2);
        button.setOnClickListener(onClickListener);
        button2.setOnClickListener(onClickListener2);
        button.setOnKeyListener(new ViewOnKeyListenerC2958(windowManager));
        windowManager.addView(inflate, layoutParams);
    }

    public static boolean m11551(String str, String str2) {
        try {
            WindowManager windowManager = (WindowManager) C3348.m12334().getSystemService("window");
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
            layoutParams.gravity = 17;
            layoutParams.type = 2003;
            layoutParams.width = -2;
            layoutParams.height = -2;
            layoutParams.alpha = 1.0f;
            layoutParams.packageName = C3348.m12334().getPackageName();
            layoutParams.buttonBrightness = 1.0f;
            layoutParams.windowAnimations = R.style.full_screen_dialog;
            View inflate = View.inflate(C3348.m12334(), R.layout.sys_dialog_ok, null);
            Button button = (Button) inflate.findViewById(R.id.button_ok);
            TextView textView = (TextView) inflate.findViewById(R.id.message);
            ((TextView) inflate.findViewById(R.id.TitleText)).setText(str);
            textView.setText(str2);
            button.setOnClickListener(new ViewOnClickListenerC2960(windowManager));
            button.setOnKeyListener(new ViewOnKeyListenerC2962(windowManager));
            windowManager.addView(inflate, layoutParams);
            return true;
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    public static void m11552(String str) {
        Intent launchIntentForPackage = C3348.m12337().getLaunchIntentForPackage(str);
        if (str == null) {
            C3348.m12347("Error LP: pkgname is null");
        }
        if (launchIntentForPackage == null) {
            C3348.m12347("Error LP: launch intent is null");
        }
        if (launchIntentForPackage == null) {
            Intent intent = new Intent("android.intent.action.MAIN", (Uri) null);
            intent.addCategory("android.intent.category.LAUNCHER");
            List<ResolveInfo> queryIntentActivities = C3348.m12337().queryIntentActivities(intent, 0);
            if (queryIntentActivities != null) {
                Iterator<ResolveInfo> it = queryIntentActivities.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    ResolveInfo next = it.next();
                    if (next.activityInfo.packageName.equals(str)) {
                        ActivityInfo activityInfo = next.activityInfo;
                        ComponentName componentName = new ComponentName(activityInfo.applicationInfo.packageName, activityInfo.name);
                        launchIntentForPackage = new Intent("android.intent.action.MAIN");
                        launchIntentForPackage.addCategory("android.intent.category.LAUNCHER");
                        launchIntentForPackage.setComponent(componentName);
                        break;
                    }
                }
            }
        }
        if (C3348.f9908) {
            if (launchIntentForPackage != null) {
                new C2880("").m11618("am start -n " + str + InternalZipConstants.ZIP_FILE_SEPARATOR + launchIntentForPackage.getComponent().getClassName());
                return;
            }
            return;
        }
        MainActivity mainActivity = C3348.f9884;
        if (mainActivity != null && launchIntentForPackage != null) {
            mainActivity.startActivity(launchIntentForPackage);
        }
    }

    public static void m11553() {
        String[] split;
        System.out.println("SU Java-Code Running!");
        C3348.f9948 = Boolean.TRUE;
        C3348.f9875 = "";
        Thread.setDefaultUncaughtExceptionHandler(new C2929());
        for (String str : m11410()) {
            new File(str);
            File file = new File(str + "/lp_utils");
            if (file.exists() && file.canRead() && (split = m11486(file).split("%chelpus%")) != null && split.length > 0) {
                for (int i = 0; i < split.length; i++) {
                    if (i != 0) {
                        if (i != 1) {
                            if (i != 2) {
                                if (i != 3) {
                                    if (i != 4) {
                                    }
                                    C3348.f9922 = true;
                                    C3348.f9920 = m11602(split[i]);
                                }
                                C3348.f9872 = split[i];
                                C3348.f9922 = true;
                                C3348.f9920 = m11602(split[i]);
                            }
                        } else {
                            C3348.f9924 = Integer.parseInt(split[i]);
                        }
                        C3348.f9871 = split[i];
                        C3348.f9872 = split[i];
                        C3348.f9922 = true;
                        C3348.f9920 = m11602(split[i]);
                    } else {
                        C3348.f9875 = split[i];
                    }
                }
            }
        }
    }

    public static void m11554(Object obj) {
        if (obj != null) {
            System.out.println("SU Java-Code Running! " + obj.getClass().getName());
        }
        C3348.f9948 = Boolean.TRUE;
        C3348.f9875 = "";
        Thread.setDefaultUncaughtExceptionHandler(new C2896());
        for (String str : m11410()) {
            new File(str);
            File file = new File(str + "/lp_utils");
            if (file.exists() && file.canRead()) {
                String[] split = m11486(file).split("%chelpus%");
                if (split != null && split.length > 0) {
                    for (int i = 0; i < split.length; i++) {
                        if (i != 0) {
                            if (i != 1) {
                                if (i != 2) {
                                    if (i != 3) {
                                        if (i != 4) {
                                        }
                                        C3348.f9922 = true;
                                        C3348.f9920 = m11602(split[i]);
                                    }
                                    C3348.f9872 = split[i];
                                    C3348.f9922 = true;
                                    C3348.f9920 = m11602(split[i]);
                                }
                            } else {
                                C3348.f9924 = Integer.parseInt(split[i]);
                            }
                            C3348.f9871 = split[i];
                            C3348.f9872 = split[i];
                            C3348.f9922 = true;
                            C3348.f9920 = m11602(split[i]);
                        } else {
                            C3348.f9875 = split[i];
                        }
                    }
                }
                if (obj != null) {
                    System.out.println("tools read:" + C3348.f9875 + "/busybox");
                }
                if (new File(C3348.f9875 + "/busybox").exists()) {
                    if (obj != null) {
                        System.out.println("Lucky Patcher found utils.");
                    } else if (obj != null) {
                        System.out.println("Lucky Patcher not found busybox util.");
                    }
                }
            } else if (obj != null) {
                System.out.println("Lucky Patcher not found utils.");
            }
        }
    }

    public static void m11555(Bundle bundle) {
        try {
            C3348.m12347("Bundle{");
            if (bundle != null) {
                for (String str : bundle.keySet()) {
                    C3348.m12347(str + " = \"" + bundle.get(str) + "\"");
                }
            }
            C3348.m12347("}Bundle;");
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static String m11556(String str) {
        byte[] bytes = str.getBytes();
        for (int i = 0; i < bytes.length; i++) {
            if (i == bytes.length - 1) {
                byte b = bytes[i];
                if (b == 122) {
                    bytes[i] = 65;
                } else {
                    bytes[i] = (byte) (b + 1);
                }
            }
        }
        return new String(bytes);
    }

    public static void m11557(Context context, String str, String str2) {
        C3348.m12359(new RunnableC2939(str2, str));
    }

    private static byte[] m11558(int i, int i2) {
        throw new IllegalArgumentException("bad utf-8 byte " + C2612.m10570(i) + " at offset " + C2612.m10571(i2));
    }

    public static String m11559(byte[] bArr) {
        String str = "";
        for (byte b : bArr) {
            int i = b & 255;
            if (i <= 15) {
                str = str + "0";
            }
            str = str + Integer.toHexString(i);
        }
        return str;
    }

    public static boolean m11560(String[] strArr, String str) {
        m11590();
        long j = 0;
        long j2 = 0;
        int i = 255;
        for (int i2 = 0; i2 < strArr.length; i2++) {
            if (new File(strArr[i2] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).canRead()) {
                long lastModified = new File(strArr[i2] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).lastModified();
                if (i2 > 0 && j2 != lastModified) {
                    if (j2 > lastModified) {
                        i = i2 - 1;
                    }
                    if (j2 < lastModified) {
                        i = i2;
                    }
                }
                j2 = lastModified;
            }
        }
        if (i != 255) {
            for (int i3 = 0; i3 < strArr.length; i3++) {
                if (i3 != i) {
                    if (new File(strArr[i3] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).canWrite()) {
                        m11292(new File(strArr[i] + InternalZipConstants.ZIP_FILE_SEPARATOR + str), new File(strArr[i3] + InternalZipConstants.ZIP_FILE_SEPARATOR + str));
                        m11323(strArr[i] + InternalZipConstants.ZIP_FILE_SEPARATOR + str);
                        m11323(strArr[i3] + InternalZipConstants.ZIP_FILE_SEPARATOR + str);
                        new File(strArr[i3] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).setLastModified(new File(strArr[i] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).lastModified());
                    }
                }
            }
            C3348.m12347("Synchronize files... from " + strArr[i]);
        }
        int i4 = 255;
        for (int i5 = 0; i5 < strArr.length; i5++) {
            if (new File(strArr[i5] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).canRead()) {
                long lastModified2 = new File(strArr[i5] + InternalZipConstants.ZIP_FILE_SEPARATOR + str).lastModified();
                if (i5 > 0 && j != lastModified2) {
                    if (j > lastModified2) {
                        i4 = i5 - 1;
                    }
                    if (j < lastModified2) {
                        i4 = i5;
                    }
                }
                j = lastModified2;
            }
        }
        if (i4 != 255) {
            return false;
        }
        return true;
    }

    public static final void m11561(String str) {
        String string = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch1")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string.replaceAll("patch1", "")).commit();
        }
        String string2 = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch2")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string2.replaceAll("patch2", "")).commit();
        }
        String string3 = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch3")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string3.replaceAll("patch3", "")).commit();
        }
    }

    public static final void m11562() {
        C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", "").commit();
    }

    public static final void m11563(String str) {
        String string = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch1")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string.replaceAll("patch1", "") + "patch1").commit();
        }
        String string2 = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch2")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string2.replaceAll("patch2", "") + "patch2").commit();
        }
        String string3 = C3348.m12333().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch3")) {
            C3348.m12333().edit().putString("patch_dalvik_on_boot_patterns", string3.replaceAll("patch3", "") + "patch3").commit();
        }
    }

    public static void m11564(Activity activity, String str, Integer num) {
        if (activity != null) {
            if (num == null) {
                C3348.m12359(new RunnableC2920(str, activity));
            } else {
                C3348.m12359(new RunnableC2952(str, activity, num));
            }
        }
    }

    public static boolean m11565(File file, String str, File file2) {
        Iterator<C4199> it;
        byte[] bArr = new byte[4096];
        boolean z = false;
        try {
            C4201 m12846 = C4201.m12846(file.getAbsolutePath());
            Iterator<C4199> it2 = m12846.m12848().values().iterator();
            boolean z2 = false;
            while (it2.hasNext()) {
                try {
                    C4199 next = it2.next();
                    String m12835 = next.m12835();
                    if (m12835.equals(str)) {
                        InputStream m12833 = next.m12833();
                        if (file2.exists()) {
                            file2.delete();
                        }
                        FileOutputStream fileOutputStream = new FileOutputStream(file2);
                        while (true) {
                            int read = m12833.read(bArr);
                            it = it2;
                            if (read == -1) {
                                break;
                            }
                            fileOutputStream.write(bArr, 0, read);
                            it2 = it;
                        }
                        fileOutputStream.close();
                        if (C3348.f9948.booleanValue()) {
                            if (C3348.f9908) {
                                m11438("chmod", "777", file2.getAbsolutePath());
                            }
                        } else if (C3348.f9908) {
                            m11506("chmod 777 " + file2.getAbsolutePath());
                        }
                        C3348.m12347("unpack " + m12835);
                        if (file2.exists()) {
                            z2 = true;
                        }
                    } else {
                        it = it2;
                    }
                    it2 = it;
                } catch (Throwable th) {
                    th = th;
                    z = z2;
                    th.printStackTrace();
                    return z;
                }
            }
            if (m12846.m12848().values().size() == 0) {
                C3348.m12347("start alternative unpacker");
                try {
                    ZipFile zipFile = new ZipFile(file);
                    for (FileHeader fileHeader : zipFile.getFileHeaders()) {
                        String fileName = fileHeader.getFileName();
                        if (fileName.equals(str)) {
                            if (file2.exists()) {
                                file2.delete();
                            }
                            zipFile.extractFile(fileHeader, m11357(file2).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR);
                            new File(m11357(file2).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR + fileName).renameTo(file2);
                            if (file2.exists()) {
                                z2 = true;
                            }
                            if (C3348.f9948.booleanValue()) {
                                if (C3348.f9908) {
                                    m11438("chmod", "777", file2.getAbsolutePath());
                                }
                            } else if (C3348.f9908) {
                                m11506("chmod 777 " + file2.getAbsolutePath());
                            }
                            C3348.m12347("unpack " + fileName);
                        }
                    }
                    return z2;
                } catch (Throwable th2) {
                    z = z2;
                    th2.printStackTrace();
                    return z;
                }
            }
            return z2;
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static byte[] m11566(MappedByteBuffer mappedByteBuffer, int i) throws UnsupportedEncodingException {
        ThreadLocal<char[]> threadLocal = f7702;
        char[] cArr = threadLocal.get();
        if (cArr == null || cArr.length < i) {
            cArr = new char[i];
            threadLocal.set(cArr);
        }
        int i2 = 0;
        while (i > 0) {
            int i3 = mappedByteBuffer.get() & 255;
            switch (i3 >> 4) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                    if (i3 != 0) {
                        break;
                    } else {
                        return m11558(i3, mappedByteBuffer.position());
                    }
                case 8:
                case 9:
                case 10:
                case 11:
                default:
                    return m11558(i3, mappedByteBuffer.position());
                case 12:
                case 13:
                    int i4 = mappedByteBuffer.get() & 255;
                    if ((i4 & 192) != 128) {
                        return m11558(i4, mappedByteBuffer.position());
                    }
                    i3 = ((i3 & 31) << 6) | (i4 & 63);
                    if (i3 != 0 && i3 < 128) {
                        return m11558(i4, mappedByteBuffer.position());
                    }
                    break;
                case 14:
                    int i5 = mappedByteBuffer.get() & 255;
                    if ((i5 & 192) != 128) {
                        return m11558(i5, mappedByteBuffer.position());
                    }
                    int i6 = mappedByteBuffer.get() & 255;
                    if ((i6 & 192) != 128) {
                        return m11558(i6, mappedByteBuffer.position());
                    }
                    i3 = ((i3 & 15) << 12) | ((i5 & 63) << 6) | (i6 & 63);
                    if (i3 >= 2048) {
                        break;
                    } else {
                        return m11558(i6, mappedByteBuffer.position());
                    }
            }
            cArr[i2] = (char) i3;
            i2++;
            i--;
        }
        return new String(cArr, 0, i2).getBytes("UTF-16LE");
    }

    public static long m11567(String str) throws Exception {
        FileInputStream fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(new File(str));
            try {
                byte[] bArr = new byte[16384];
                CRC32 crc32 = new CRC32();
                while (true) {
                    int read = fileInputStream2.read(bArr);
                    if (read != -1) {
                        crc32.update(bArr, 0, read);
                    } else {
                        long value = crc32.getValue();
                        try {
                            fileInputStream2.close();
                            return value;
                        } catch (IOException unused) {
                            throw new Exception("error while closing the file after calculating crc");
                        }
                    }
                }
            } catch (Throwable th) {
                th = th;
                fileInputStream = fileInputStream2;
                if (fileInputStream != null) {
                    try {
                        fileInputStream.close();
                    } catch (IOException unused2) {
                        throw new Exception("error while closing the file after calculating crc");
                    }
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static boolean m11568(boolean z, boolean z2) {
        if (z) {
            return C3348.f9924 < 23 || z2;
        }
        return false;
    }

    public static boolean m11569(MappedByteBuffer mappedByteBuffer, C2993 c2993, int i) {
        m11590();
        int position = mappedByteBuffer.position();
        if (!c2993.f8094) {
            return true;
        }
        mappedByteBuffer.position(72);
        m11592(mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get());
        mappedByteBuffer.position(m11592(mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get()) + (i * 12));
        if (c2993.f8095[0] == mappedByteBuffer.get() && c2993.f8095[1] == mappedByteBuffer.get() && c2993.f8095[2] == mappedByteBuffer.get() && c2993.f8095[3] == mappedByteBuffer.get()) {
            mappedByteBuffer.position(position);
            return true;
        }
        mappedByteBuffer.position(position);
        return false;
    }

    public static void m11570() {
        m11590();
        if (C3348.f9908 && !C3348.f9922) {
            if (!C3348.f9948.booleanValue()) {
                String m11618 = new C2880().m11618(C3348.f9909 + C2032.class.getName() + " ");
                C3348.m12347(m11618);
                String[] split = m11618.split("\n");
                int length = split.length;
                int i = 0;
                while (true) {
                    if (i >= length) {
                        break;
                    }
                    String str = split[i];
                    if (str.contains("{") && str.contains("}")) {
                        C3348.m12347(str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1));
                        ArrayList<String> m11586 = m11586(str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1));
                        C3348.f9920 = (String[]) m11586.toArray(new String[m11586.size()]);
                        break;
                    }
                    i++;
                }
                C3348.f9922 = true;
            } else {
                ArrayList<String> m11430 = m11430();
                C3348.f9920 = (String[]) m11430.toArray(new String[m11430.size()]);
                C3348.f9922 = true;
            }
        }
        if (C3348.f9920 == null) {
            C3348.f9920 = new String[0];
        }
    }

    public static void m11571(String str, String str2) {
        C3348.f9923 = "";
        new C2880("").m11618(str + " " + str2);
        if (!C3348.f9923.equals("")) {
            new C2880("").m11618("busybox " + str + " " + str2);
        }
        if (!C3348.f9923.equals("")) {
            new C2880("").m11618(C3348.f9875 + "/busybox " + str + " " + str2);
        }
    }

    public static void m11572(String str, String str2, String str3, String str4) {
        String str5;
        String str6;
        if (str4.trim().startsWith("~chelpus_disabled~")) {
            return;
        }
        String trim = str3.trim();
        String trim2 = str4.trim();
        if (!trim.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            str5 = trim.trim() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        } else {
            str5 = trim;
        }
        if (!trim2.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            str6 = trim2.trim() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        } else {
            str6 = trim2;
        }
        new File(trim2).mkdirs();
        new File(trim).mkdirs();
        if (!new File(trim2).exists()) {
            m11571("mkdir", "-p '" + trim2 + "'");
        }
        if (!new File(trim).exists()) {
            m11571("mkdir", "-p '" + trim + "'");
        }
        try {
            new File(str5 + "test.txt").createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        m11506("echo '' >'" + str5 + "test.txt'");
        if (!m11315(str6 + "test.txt")) {
            m11506("umount '" + trim2 + "'");
            C3348.m12347("data: " + str5 + "test.txt");
            C3348.m12347("target: " + str6 + "test.txt");
            try {
                new File(str5 + "test.txt").createNewFile();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            m11506("echo '' >'" + str5 + "test.txt'");
            if (!m11315(str6 + "test.txt")) {
                new C2880("").m11618("busybox " + str + " " + str2);
                try {
                    new File(str5 + "test.txt").createNewFile();
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
                m11506("echo '' >'" + str5 + "test.txt'");
                if (!m11315(str6 + "test.txt")) {
                    new C2880("").m11618(C3348.f9875 + "/busybox " + str + " " + str2);
                    new C2880("").m11618("busybox " + str + " " + str2);
                    try {
                        new File(str5 + "test.txt").createNewFile();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                    m11506("echo '' >'" + str5 + "test.txt'");
                    if (!m11315(str6 + "test.txt")) {
                        C3348.m12347("LuckyPatcher(Binder error): bind not created!");
                    }
                }
            }
        } else {
            C3348.m12347("LuckyPatcher(Binder): " + trim2 + " exists!");
        }
        if (m11315(str5 + "test.txt")) {
            if (m11315(str6 + "test.txt")) {
                C3348.m12347("LuckyPatcher(Binder): " + trim2 + " binded!");
            } else {
                C3348.m12347("LuckyPatcher(Binder error): " + trim2 + " not binded!");
            }
            new File(str5 + "test.txt").delete();
            if (m11315(str5 + "test.txt")) {
                m11506("rm '" + str5 + "test.txt'");
            }
        }
    }

    public static void m11573(MappedByteBuffer mappedByteBuffer, String str) throws IOException {
        int length = str.length();
        if (f7703.length <= str.length() * 3) {
            f7703 = new byte[str.length() * 3];
        }
        byte[] bArr = f7703;
        int i = 0;
        for (int i2 = 0; i2 < length; i2++) {
            char charAt = str.charAt(i2);
            if (charAt != 0 && charAt < 128) {
                bArr[i] = (byte) charAt;
                i++;
            } else if (charAt < 2048) {
                int i3 = i + 1;
                bArr[i] = (byte) (((charAt >> 6) & 31) | 192);
                i = i3 + 1;
                bArr[i3] = (byte) ((charAt & '?') | 128);
            } else {
                int i4 = i + 1;
                bArr[i] = (byte) (((charAt >> '\f') & 15) | 224);
                int i5 = i4 + 1;
                bArr[i4] = (byte) (((charAt >> 6) & 63) | 128);
                bArr[i5] = (byte) ((charAt & '?') | 128);
                i = i5 + 1;
            }
        }
        mappedByteBuffer.put(bArr, 0, i);
    }

    public static void m11574(MappedByteBuffer mappedByteBuffer, int i) throws IOException {
        while (i > 127) {
            mappedByteBuffer.put((byte) ((i & 127) | 128));
            i >>>= 7;
        }
        mappedByteBuffer.put((byte) i);
    }

    public static void m11575(String str, String str2, ArrayList<File> arrayList, String str3) {
        try {
            ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(str3, false)));
            byte[] bArr = new byte[4096];
            Iterator<File> it = arrayList.iterator();
            while (it.hasNext()) {
                File next = it.next();
                FileInputStream fileInputStream = new FileInputStream(str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + next.getName());
                BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream, 4096);
                zipOutputStream.putNextEntry(new ZipEntry(next.getName()));
                while (true) {
                    int read = bufferedInputStream.read(bArr, 0, 4096);
                    if (read != -1) {
                        zipOutputStream.write(bArr, 0, read);
                    }
                }
                bufferedInputStream.close();
                zipOutputStream.closeEntry();
                fileInputStream.close();
            }
            FileInputStream fileInputStream2 = new FileInputStream(str2 + "/AndroidManifest.xml");
            BufferedInputStream bufferedInputStream2 = new BufferedInputStream(fileInputStream2, 4096);
            zipOutputStream.putNextEntry(new ZipEntry(ApkUtils.ANDROID_MANIFEST_ZIP_ENTRY_NAME));
            while (true) {
                int read2 = bufferedInputStream2.read(bArr, 0, 4096);
                if (read2 == -1) {
                    break;
                } else {
                    zipOutputStream.write(bArr, 0, read2);
                }
            }
            bufferedInputStream2.close();
            zipOutputStream.closeEntry();
            zipOutputStream.close();
            fileInputStream2.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        new File(str2 + "/AndroidManifest.xml").delete();
        Iterator<File> it2 = arrayList.iterator();
        while (it2.hasNext()) {
            new File(str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + it2.next().getName()).delete();
        }
    }

    public static String m11576(String str, String str2, ArrayList<File> arrayList, File file, String str3) {
        String str4;
        String str5;
        ZipOutputStream zipOutputStream;
        FileOutputStream fileOutputStream;
        Iterator<File> it;
        String str6;
        byte[] bArr;
        Iterator<File> it2;
        BufferedInputStream bufferedInputStream;
        int read;
        m11508("chmod", "777", "/data/tmp");
        FileOutputStream fileOutputStream2 = null;
        try {
            C3348.m12347("Try create tmp.");
            new File("/data/tmp").mkdir();
            if (!new File("/data/tmp").exists()) {
                C3348.m12347("tmp dir not found. Try create with root.");
                new File("/data/tmp").mkdirs();
                if (!new File("/data/tmp").exists()) {
                    m11508("mkdir", "/data/tmp");
                }
                if (!new File("/data/tmp").exists()) {
                    C3348.m12347("tmp dir not created.");
                } else {
                    m11508("chmod", "777", "/data/tmp");
                }
            } else {
                m11508("chmod", "777", "/data/tmp");
                try {
                    File[] listFiles = new File("/data/tmp").listFiles();
                    if (listFiles != null) {
                        for (File file2 : listFiles) {
                            C2880 c2880 = new C2880("1");
                            file2.delete();
                            if (file2.exists()) {
                                c2880.m11605(file2);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Throwable th) {
            th = th;
            str4 = "";
            str5 = str4;
        }
        if (str3.length() > ("/data/tmp/" + str).length()) {
            if (str3.length() - ("/data/tmp/" + str).length() > 1) {
                int length = (str3.length() - ("/data/tmp/" + str).length()) - 1;
                char[] cArr = new char[length];
                for (int i = 0; i < length; i++) {
                    cArr[i] = '1';
                }
                str4 = "/data/tmp/" + new String(cArr) + InternalZipConstants.ZIP_FILE_SEPARATOR + str;
                try {
                    str6 = "/data/tmp/" + new String(cArr) + InternalZipConstants.ZIP_FILE_SEPARATOR + str + ".for_sign";
                    str5 = "/data/tmp/" + new String(cArr);
                    try {
                        new File("/data/tmp/" + new String(cArr)).mkdirs();
                        if (new File("/data/tmp/" + new String(cArr)).exists()) {
                            C3348.m12347("Dir delta created.");
                        }
                        C3348.m12347("Path to create zip: " + str4);
                        C3348.m12347("Path to origin zip: " + str3);
                        if (str3.length() == ("/data/tmp/" + str).length()) {
                            str4 = "/data/tmp/" + str;
                            str5 = "";
                        }
                        if (new File(str4).exists()) {
                            new File(str4).delete();
                        }
                        if (new File(str6).exists()) {
                            new File(str6).delete();
                        }
                        fileOutputStream = new FileOutputStream(str4, false);
                        zipOutputStream = new ZipOutputStream(new BufferedOutputStream(fileOutputStream));
                        bArr = new byte[4096];
                        it2 = arrayList.iterator();
                        while (it2.hasNext()) {
                            File next = it2.next();
                            FileInputStream fileInputStream = new FileInputStream(str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + next.getName());
                            BufferedInputStream bufferedInputStream2 = new BufferedInputStream(fileInputStream, 4096);
                            zipOutputStream.putNextEntry(new ZipEntry(next.getName()));
                            while (true) {
                                int read2 = bufferedInputStream2.read(bArr, 0, 4096);
                                if (read2 != -1) {
                                    zipOutputStream.write(bArr, 0, read2);
                                }
                            }
                            bufferedInputStream2.close();
                            zipOutputStream.closeEntry();
                            fileInputStream.close();
                        }
                        FileInputStream fileInputStream2 = new FileInputStream(file);
                        bufferedInputStream = new BufferedInputStream(fileInputStream2, 4096);
                        zipOutputStream.putNextEntry(new ZipEntry(file.getName()));
                        while (true) {
                            read = bufferedInputStream.read(bArr, 0, 4096);
                            if (read != -1) {
                                break;
                            }
                            zipOutputStream.write(bArr, 0, read);
                        }
                        bufferedInputStream.close();
                        zipOutputStream.closeEntry();
                        fileInputStream2.close();
                    } catch (Throwable th2) {
                        th = th2;
                        zipOutputStream = null;
                        th.printStackTrace();
                        if (new File(str4).exists()) {
                        }
                        fileOutputStream = fileOutputStream2;
                        if (zipOutputStream != null) {
                        }
                        if (fileOutputStream != null) {
                        }
                        new File(str2 + "/AndroidManifest.xml").delete();
                        it = arrayList.iterator();
                        while (it.hasNext()) {
                        }
                        if (!new File(str4).exists()) {
                        }
                        if (new File(str4).exists()) {
                        }
                        if (new File(str5).exists()) {
                        }
                        return "";
                    }
                } catch (Throwable th3) {
                    th = th3;
                    str5 = "";
                    zipOutputStream = null;
                    th.printStackTrace();
                    if (new File(str4).exists()) {
                    }
                    fileOutputStream = fileOutputStream2;
                    if (zipOutputStream != null) {
                    }
                    if (fileOutputStream != null) {
                    }
                    new File(str2 + "/AndroidManifest.xml").delete();
                    it = arrayList.iterator();
                    while (it.hasNext()) {
                    }
                    if (!new File(str4).exists()) {
                    }
                    if (new File(str4).exists()) {
                    }
                    if (new File(str5).exists()) {
                    }
                    return "";
                }
                if (zipOutputStream != null) {
                    try {
                        zipOutputStream.close();
                    } catch (IOException e2) {
                        e2.printStackTrace();
                    }
                }
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                    }
                }
                new File(str2 + "/AndroidManifest.xml").delete();
                it = arrayList.iterator();
                while (it.hasNext()) {
                    new File(str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + it.next().getName()).delete();
                }
                if (!new File(str4).exists() && new File(str4).length() != 0) {
                    return str4;
                }
                if (new File(str4).exists()) {
                    new File(str4).delete();
                }
                if (new File(str5).exists() && str5.contains("1")) {
                    new File(str5).delete();
                }
                return "";
            }
        }
        str6 = "";
        str4 = str6;
        str5 = str4;
        if (str3.length() == ("/data/tmp/" + str).length()) {
        }
        if (new File(str4).exists()) {
        }
        if (new File(str6).exists()) {
        }
        fileOutputStream = new FileOutputStream(str4, false);
        zipOutputStream = new ZipOutputStream(new BufferedOutputStream(fileOutputStream));
        bArr = new byte[4096];
        it2 = arrayList.iterator();
        while (it2.hasNext()) {
        }
        FileInputStream fileInputStream22 = new FileInputStream(file);
        bufferedInputStream = new BufferedInputStream(fileInputStream22, 4096);
        zipOutputStream.putNextEntry(new ZipEntry(file.getName()));
        while (true) {
            read = bufferedInputStream.read(bArr, 0, 4096);
            if (read != -1) {
            }
            zipOutputStream.write(bArr, 0, read);
        }
        bufferedInputStream.close();
        zipOutputStream.closeEntry();
        fileInputStream22.close();
        if (zipOutputStream != null) {
        }
        if (fileOutputStream != null) {
        }
        new File(str2 + "/AndroidManifest.xml").delete();
        it = arrayList.iterator();
        while (it.hasNext()) {
        }
        if (!new File(str4).exists()) {
        }
        if (new File(str4).exists()) {
        }
        if (new File(str5).exists()) {
            new File(str5).delete();
        }
        return "";
    }

    public static void m11577(List<File> list, ZipOutputStream zipOutputStream) {
        byte[] bArr = new byte[4096];
        try {
            for (File file : list) {
                System.out.println("Added " + file);
                ZipEntry zipEntry = new ZipEntry(file.getName());
                zipEntry.setTime(file.lastModified());
                zipEntry.setMethod(8);
                zipOutputStream.putNextEntry(zipEntry);
                FileInputStream fileInputStream = new FileInputStream(file);
                while (true) {
                    int read = fileInputStream.read(bArr);
                    if (read > 0) {
                        zipOutputStream.write(bArr, 0, read);
                    }
                }
                fileInputStream.close();
            }
            System.out.println("Done");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static boolean m11578(File file) {
        m11590();
        C3348.m12347("zipalign " + file.getName());
        File file2 = new File(file.getAbsolutePath() + ".tmp");
        file.renameTo(file2);
        try {
            C2829.m11137(file2, file);
            if (file.exists() && file.length() > 0) {
                file2.delete();
                return true;
            }
            file2.renameTo(file);
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            file2.renameTo(file);
            return false;
        }
    }

    public static String m11579(byte[] bArr) {
        char[] cArr = new char[bArr.length * 2];
        for (int i = 0; i < bArr.length; i++) {
            int i2 = bArr[i] & 255;
            int i3 = i * 2;
            char[] cArr2 = f7705;
            cArr[i3] = cArr2[i2 >>> 4];
            cArr[i3 + 1] = cArr2[i2 & 15];
        }
        return new String(cArr);
    }

    public static String m11580(ArrayList<String> arrayList) {
        String str = "{";
        for (int i = 0; i < arrayList.size(); i++) {
            if (i <= arrayList.size() - 2) {
                str = str + arrayList.get(i) + "--lp--";
            }
            if (i == arrayList.size() - 1) {
                str = str + arrayList.get(i);
            }
        }
        return str + "}";
    }

    private static final void m11581(File file) {
        m11590();
        FileChannel fileChannel = null;
        try {
            try {
                try {
                    try {
                        fileChannel = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
                        MappedByteBuffer map = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) fileChannel.size());
                        map.position(0);
                        if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                            Adler32 adler32 = new Adler32();
                            map.position(12);
                            MappedByteBuffer map2 = fileChannel.map(FileChannel.MapMode.READ_ONLY, 12L, ((int) fileChannel.size()) - 12);
                            int position = map2.position();
                            int limit = map2.limit();
                            int i = limit - position;
                            if (i <= 0) {
                                try {
                                    fileChannel.close();
                                    return;
                                } catch (IOException e) {
                                    e.printStackTrace();
                                    return;
                                }
                            }
                            if (map2.hasArray()) {
                                adler32.update(map2.array(), position + map2.arrayOffset(), i);
                            } else {
                                byte[] bArr = new byte[i];
                                map2.get(bArr);
                                adler32.update(bArr, 0, i);
                            }
                            map2.position(limit);
                            int value = (int) adler32.getValue();
                            map.position(8);
                            map.put((byte) value);
                            map.force();
                            map.position(9);
                            map.put((byte) (value >> 8));
                            map.force();
                            map.position(10);
                            map.put((byte) (value >> 16));
                            map.force();
                            map.position(11);
                            map.put((byte) (value >> 24));
                            map.force();
                        }
                        fileChannel.close();
                        fileChannel.close();
                    } catch (IOException e2) {
                        e2.printStackTrace();
                        if (fileChannel != null) {
                            fileChannel.close();
                        }
                    }
                } catch (FileNotFoundException e3) {
                    e3.printStackTrace();
                    if (fileChannel != null) {
                        fileChannel.close();
                    }
                }
            } catch (IOException e4) {
                e4.printStackTrace();
            }
        } catch (Throwable th) {
            if (0 != 0) {
                try {
                    fileChannel.close();
                } catch (IOException e5) {
                    e5.printStackTrace();
                }
            }
            throw th;
        }
    }

    public static int m11582(byte b) {
        return b & 255;
    }

    private static void m11583(int i, int i2, File file) {
        m11590();
        try {
            FileChannel channel = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
            MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
            Adler32 adler32 = new Adler32();
            MappedByteBuffer map2 = channel.map(FileChannel.MapMode.READ_ONLY, 12 + i, i2);
            int position = map2.position();
            int limit = map2.limit();
            int i3 = limit - position;
            if (i3 <= 0) {
                return;
            }
            if (map2.hasArray()) {
                adler32.update(map2.array(), position + map2.arrayOffset(), i3);
            } else {
                byte[] bArr = new byte[i3];
                map2.get(bArr);
                adler32.update(bArr, 0, i3);
            }
            map2.position(limit);
            int value = (int) adler32.getValue();
            map.position(i + 8);
            map.put((byte) value);
            map.force();
            map.position(i + 9);
            map.put((byte) (value >> 8));
            map.force();
            map.position(i + 10);
            map.put((byte) (value >> 16));
            map.force();
            map.position(i + 11);
            map.put((byte) (value >> 24));
            map.force();
            channel.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    public static void m11584(File file) {
        try {
            new C2880("").m11605(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        file.mkdirs();
    }

    private static final void m11585(File file) {
        m11590();
        try {
            FileChannel channel = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE).getChannel();
            MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
            map.position(0);
            if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                try {
                    MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
                    byte[] bArr = new byte[20];
                    map.position(32);
                    messageDigest.update(channel.map(FileChannel.MapMode.READ_ONLY, 32L, ((int) channel.size()) - 32));
                    try {
                        int digest = messageDigest.digest(bArr, 0, 20);
                        if (digest == 20) {
                            map.position(12);
                            map.put(bArr);
                            map.force();
                        } else {
                            throw new RuntimeException("unexpected digest write:" + digest + "bytes");
                        }
                    } catch (DigestException e) {
                        throw new RuntimeException(e);
                    }
                } catch (NoSuchAlgorithmException e2) {
                    throw new RuntimeException(e2);
                }
            }
            channel.close();
        } catch (FileNotFoundException e3) {
            e3.printStackTrace();
        } catch (IOException e4) {
            e4.printStackTrace();
        }
    }

    public static ArrayList<String> m11586(String str) {
        String substring = str.substring(1, str.length() - 1);
        ArrayList<String> arrayList = new ArrayList<>();
        String[] split = substring.split("--lp--");
        if (split != null) {
            for (String str2 : split) {
                if (!str2.equals("")) {
                    arrayList.add(str2);
                }
            }
        }
        return arrayList;
    }

    public static String m11587(String str, String str2) {
        String str3 = "";
        if (str != null) {
            String[] split = str.split("\\.");
            for (int i = 0; i < split.length; i++) {
                if (i < split.length - 1) {
                    str3 = str3 + split[i] + ".";
                } else {
                    str3 = str3 + str2;
                }
            }
        }
        return str3;
    }

    public static void m11588() {
        try {
            if (m11474() && C3348.m12333().getBoolean("warning_magisk", true)) {
                C3348.m12359(new RunnableC2954());
            }
        } catch (Throwable unused) {
            C3348.m12347("LP:Magisk root not found.");
        }
    }

    public static int m11589(String str, String str2, String str3) {
        String str4 = str2;
        m11590();
        String str5 = "L" + str4.replaceAll("\\.", InternalZipConstants.ZIP_FILE_SEPARATOR);
        String str6 = "L" + str3.replaceAll("\\.", InternalZipConstants.ZIP_FILE_SEPARATOR);
        C3348.m12347(str5 + " " + str6);
        StringBuilder sb = new StringBuilder();
        sb.append("scan: ");
        sb.append(str);
        C3348.m12347(sb.toString());
        new ArrayList();
        int i = 0;
        if (str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        if (new File(str).exists()) {
                            try {
                                FileChannel channel = new RandomAccessFile(str, InternalZipConstants.WRITE_MODE).getChannel();
                                MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0L, (int) channel.size());
                                map.position(0);
                                if (map.get() == 100 && map.get() == 101 && map.get() == 120 && map.get() == 10) {
                                    map.position(56);
                                    int m11592 = m11592(map.get(), map.get(), map.get(), map.get());
                                    byte[] bArr = new byte[m11592 / 4];
                                    map.position(m11592(map.get(), map.get(), map.get(), map.get()));
                                    int[] iArr = new int[m11592];
                                    for (int i2 = 0; i2 < m11592; i2++) {
                                        iArr[i2] = m11592(map.get(), map.get(), map.get(), map.get());
                                    }
                                    int i3 = 0;
                                    while (i < m11592) {
                                        try {
                                            int i4 = iArr[i];
                                            map.position(i4);
                                            int m11484 = m11484(map);
                                            int position = map.position();
                                            byte[] m11566 = m11566(map, m11484);
                                            int length = m11566.length;
                                            int i5 = m11592;
                                            if (m11484 >= str3.length() && new String(m11566, "UTF-16LE").contains(str4)) {
                                                String replaceAll = new String(m11566, "UTF-16LE").replaceAll(str4, str3);
                                                if (replaceAll.getBytes("UTF-16LE").length <= length) {
                                                    map.position(i4);
                                                    m11574(map, replaceAll.length());
                                                    map.position(position);
                                                    m11573(map, replaceAll);
                                                    map.force();
                                                    i3++;
                                                }
                                            }
                                            if (m11484 >= str5.length() && new String(m11566, "UTF-16LE").contains(str5)) {
                                                String replaceAll2 = new String(m11566, "UTF-16LE").replaceAll(str5, str6);
                                                if (replaceAll2.getBytes("UTF-16LE").length <= length) {
                                                    map.position(i4);
                                                    m11574(map, replaceAll2.length());
                                                    map.position(position);
                                                    m11573(map, replaceAll2);
                                                    map.force();
                                                    i3++;
                                                }
                                            }
                                            i++;
                                            m11592 = i5;
                                            str4 = str2;
                                        } catch (Exception e) {
                                            e = e;
                                            i = i3;
                                            e.printStackTrace();
                                            return i;
                                        }
                                    }
                                    i = i3;
                                }
                                channel.close();
                            } catch (Exception e2) {
                                e = e2;
                            }
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                }
            } catch (Exception e4) {
                C3348.m12347(e4);
            }
        }
        return i;
    }

    public static void m11590() {
    }

    public static boolean m11591(C3306 c3306) {
        String str;
        String str2;
        if (c3306.f9753.trim().startsWith("~chelpus_disabled~")) {
            return false;
        }
        String trim = c3306.f9752.trim();
        String trim2 = c3306.f9753.trim();
        if (!trim.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            str = trim.trim() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        } else {
            str = trim;
        }
        if (!trim2.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            str2 = trim2.trim() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        } else {
            str2 = trim2;
        }
        new File(trim2).mkdirs();
        new File(trim).mkdirs();
        if (!new File(trim2).exists()) {
            m11571("mkdir", "-p '" + trim2 + "'");
        }
        if (!new File(trim).exists()) {
            m11571("mkdir", "-p '" + trim + "'");
        }
        try {
            new File(str + "test.txt").createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        m11506("echo '' >'" + str + "test.txt'");
        if (!m11315(str2 + "test.txt")) {
            new File(str + "test.txt").delete();
            if (m11315(str + "test.txt")) {
                m11506("rm '" + str + "test.txt'");
            }
            return false;
        }
        new File(str + "test.txt").delete();
        if (m11315(str + "test.txt")) {
            m11506("rm '" + str + "test.txt'");
            return true;
        }
        return true;
    }

    public static int m11592(byte b, byte b2, byte b3, byte b4) {
        return (b & 255) | ((b2 & 255) << 8) | ((b3 & 255) << 16) | (b4 << DerValue.tag_GeneralizedTime);
    }

    public static boolean m11593() {
        try {
            Signature signature = Signature.getInstance("SHA1withRSA");
            signature.initVerify(KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger("12345678", 16), new BigInteger("11", 16))));
            signature.update("367".getBytes());
            if (!signature.verify("123098".getBytes())) {
                return false;
            }
            return true;
        } catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException unused) {
            return false;
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static String m11594(String[] strArr) {
        String str = "{";
        if (strArr != null) {
            for (int i = 0; i < strArr.length; i++) {
                if (i <= strArr.length - 2) {
                    str = str + strArr[i] + "--lp--";
                }
                if (i == strArr.length - 1) {
                    str = str + strArr[i];
                }
            }
        }
        return str + "}";
    }

    public static boolean m11595() {
        try {
            Signature signature = Signature.getInstance("SHA1withRSA");
            signature.initVerify(KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger("12345678", 16), new BigInteger("11", 16))));
            signature.update("367".getBytes());
            if (!signature.verify("123098".getBytes(), 1, 5)) {
                return false;
            }
            return true;
        } catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException unused) {
            return false;
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static byte[] m11596(int i) {
        return new byte[]{(byte) ((i >> 0) & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255)};
    }

    public static boolean m11597() {
        return MessageDigest.isEqual("12".getBytes(), "45".getBytes());
    }

    public static void m11598(File file, C2986 c2986) {
        String str;
        String str2;
        boolean z;
        String str3;
        String str4 = "";
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C3348.m12347("run convertNativeMethods for " + file.getName());
                if (m11447(file, c2986)) {
                    BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                    try {
                        C2236 m10053 = C2236.m10053(C4730.m14317(), bufferedInputStream2);
                        C2568 c2568 = new C2568(C4730.m14317());
                        boolean z2 = false;
                        for (C2226 c2226 : m10053.m10055()) {
                            if (c2226 != null) {
                                ArrayList arrayList = new ArrayList();
                                ArrayList arrayList2 = new ArrayList();
                                for (C2242 c2242 : c2226.getFields()) {
                                    arrayList.add(c2568.m10485(c2242.getDefiningClass(), c2242.getName(), c2242.getType(), c2242.getAccessFlags(), c2242.getInitialValue(), c2242.getAnnotations()));
                                }
                                boolean z3 = z2;
                                for (C2243 c2243 : c2226.getMethods()) {
                                    int accessFlags = c2243.getAccessFlags();
                                    InterfaceC2358 implementation = c2243.getImplementation();
                                    Iterator<C3004> it = c2986.f8050.iterator();
                                    int i = accessFlags;
                                    while (it.hasNext()) {
                                        C3004 next = it.next();
                                        if ((EnumC4726.NATIVE.getValue() & i) != 0 && c2243.getName().equals(next.f8181) && ((next.f8180.equals(str4) || c2243.getDefiningClass().equals(next.f8180)) && (next.f8179.equals(str4) || c2243.getReturnType().equals(next.f8179)))) {
                                            C3348.m12347("find " + c2243.getName());
                                            if (!next.f8182.equals(str4)) {
                                                List<? extends CharSequence> parameterTypes = c2243.getParameterTypes();
                                                if (parameterTypes != null) {
                                                    Iterator<? extends CharSequence> it2 = parameterTypes.iterator();
                                                    str3 = str4;
                                                    while (it2.hasNext()) {
                                                        str3 = str3 + ((String) it2.next());
                                                        str4 = str4;
                                                    }
                                                    str2 = str4;
                                                } else {
                                                    str2 = str4;
                                                    str3 = str2;
                                                }
                                                if (!next.f8182.equals(str3)) {
                                                    z = false;
                                                    if (!z) {
                                                        C3348.m12347("reset native flag for method:" + c2243.getName());
                                                        if (!next.f8188) {
                                                            C3348.m12347("convert native method:" + c2243.getName());
                                                            C2163 c2163 = new C2163(10);
                                                            for (int i2 = 0; i2 < next.f8169.length + 1; i2++) {
                                                                c2163.m9930(new C2188(EnumC4728.f12928));
                                                            }
                                                            implementation = c2163.m9931();
                                                            next.f8188 = true;
                                                        }
                                                        i = c2243.getAccessFlags() & (EnumC4726.NATIVE.getValue() ^ (-1));
                                                        z3 = true;
                                                    }
                                                }
                                            } else {
                                                str2 = str4;
                                            }
                                            z = true;
                                            if (!z) {
                                            }
                                        } else {
                                            str2 = str4;
                                        }
                                        str4 = str2;
                                    }
                                    arrayList2.add(c2568.m10486(c2243.getDefiningClass(), c2243.getName(), c2243.getParameters(), c2243.getReturnType(), i, c2243.getAnnotations(), c2568.m10479(implementation)));
                                    str4 = str4;
                                }
                                str = str4;
                                c2568.m10484(c2226.getType(), c2226.getAccessFlags(), c2226.getSuperclass(), c2226.getInterfaces(), c2226.getSourceFile(), c2226.getAnnotations(), arrayList, arrayList2);
                                z2 = z3;
                            } else {
                                str = str4;
                            }
                            str4 = str;
                        }
                        if (z2) {
                            c2568.m10263(new C2593(file));
                        }
                        bufferedInputStream = bufferedInputStream2;
                    } catch (Throwable th) {
                        th = th;
                        bufferedInputStream = bufferedInputStream2;
                        try {
                            th.printStackTrace();
                            if (bufferedInputStream != null) {
                                bufferedInputStream.close();
                            }
                            return;
                        } finally {
                        }
                    }
                }
            } catch (Throwable th2) {
                th = th2;
            }
            if (bufferedInputStream != null) {
                bufferedInputStream.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static boolean m11599() {
        String str;
        String str2 = "chelpa";
        int i = 8256;
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA");
            messageDigest.update(C3348.m12337().getPackageInfo("android", 8256).signatures[0].toByteArray());
            str = C3015.m11704(messageDigest.digest()).trim().replaceAll("\n", "");
        } catch (Exception unused) {
            str = "chelpa";
        }
        try {
            MessageDigest messageDigest2 = MessageDigest.getInstance("SHA");
            messageDigest2.update(C3348.m12337().getPackageInfo(C3348.m12334().getPackageName(), 8256).signatures[0].toByteArray());
            str2 = C3015.m11704(messageDigest2.digest()).trim().replaceAll("\n", "");
        } catch (Exception unused2) {
        }
        String str3 = str2;
        String[] m12336 = C3348.m12336();
        if (m12336 != null && m12336.length > 0) {
            int length = m12336.length;
            int i2 = 0;
            while (i2 < length) {
                String str4 = m12336[i2];
                if (!str4.equals("android") && !str4.equals(PkgName.getPkgName())) {
                    try {
                        android.content.pm.Signature[] signatureArr = C3348.m12337().getPackageInfo(str4, i).signatures;
                        if (signatureArr != null && signatureArr.length == 1) {
                            for (android.content.pm.Signature signature : signatureArr) {
                                try {
                                    MessageDigest messageDigest3 = MessageDigest.getInstance("SHA");
                                    messageDigest3.update(signature.toByteArray());
                                    String replaceAll = C3015.m11704(messageDigest3.digest()).trim().replaceAll("\n", "");
                                    if (!replaceAll.equals(str) && !replaceAll.equals(str3)) {
                                        if (C3348.m12337().checkSignatures(str4, C3348.m12334().getPackageName()) == 0) {
                                            return true;
                                        }
                                        return false;
                                    }
                                } catch (Throwable th) {
                                    th.printStackTrace();
                                }
                            }
                        }
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                        C3348.m12347("dont get Android signature");
                    }
                }
                i2++;
                i = 8256;
            }
            return false;
        }
        return false;
    }

    public static ArrayList<File> m11600(String str) {
        String replaceAll = str.replaceAll("\n", "");
        String substring = replaceAll.substring(1, replaceAll.length() - 1);
        ArrayList<File> arrayList = new ArrayList<>();
        String[] split = substring.split("--lp--");
        if (split != null) {
            for (String str2 : split) {
                if (!str2.equals("")) {
                    arrayList.add(new File(str2));
                }
            }
        }
        return arrayList;
    }

    public static boolean m11601() {
        f7706 = new ServiceConnectionC2963();
        try {
            Intent intent = new Intent("com.ui.ITestServiceInterface.BIND");
            intent.setPackage("com.android.vending");
            if (!C3348.m12334().bindService(intent, f7706, 1)) {
                return false;
            }
            if (f7706 != null) {
                C3348.m12334().unbindService(f7706);
            }
            return true;
        } catch (SecurityException e) {
            e.printStackTrace();
            return false;
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public static String[] m11602(String str) {
        String substring = str.substring(1, str.length() - 1);
        new ArrayList();
        String[] split = substring.split("--lp--");
        if (split == null) {
            return new String[0];
        }
        return split;
    }

    public static boolean m11603(long j) {
        long m11374 = m11374();
        if (j != m11374 && m11374 != 0 && m11374 != 1) {
            C3348.m12347("firmware updated: need clear magisk module android patches");
            return true;
        }
        return false;
    }

    public static boolean m11604() {
        return System.getenv("BOOTCLASSPATH").contains("knoxsdk");
    }

    public void m11605(File file) throws IOException {
        File[] listFiles;
        m11590();
        if (!file.exists()) {
            return;
        }
        if (file.isDirectory() && (listFiles = file.listFiles()) != null) {
            for (File file2 : listFiles) {
                m11605(file2);
            }
        }
        new File(file.toString()).delete();
    }

    public String m11606(File file, String str) throws IOException {
        m11590();
        if (!file.exists()) {
            return "";
        }
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                String m11606 = m11606(file2, str);
                if (!m11606.equals("")) {
                    return m11606;
                }
            }
        }
        if (!file.getName().equals(str)) {
            return "";
        }
        return file.getAbsolutePath();
    }

    public String m11607(File file, String str) throws IOException {
        m11590();
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                String m11607 = m11607(file2, str);
                if (!m11607.equals("")) {
                    return m11607;
                }
            }
        }
        if (!file.getName().contains(str)) {
            return "";
        }
        return file.getAbsolutePath();
    }

    public String m11608(File file, String str, ArrayList<File> arrayList) throws IOException {
        m11590();
        if (!file.exists()) {
            return "";
        }
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                String m11608 = m11608(file2, str, arrayList);
                if (!m11608.equals("")) {
                    m11380(new File(m11608), arrayList);
                }
            }
        }
        if (!file.getName().endsWith(str)) {
            return "";
        }
        m11380(file, arrayList);
        return file.getAbsolutePath();
    }

    public boolean m11609(File file, String str) {
        try {
            m11590();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        if (!file.exists()) {
            return false;
        }
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                boolean m11609 = m11609(file2, str);
                if (m11609) {
                    return m11609;
                }
            }
        }
        if (!file.getName().endsWith(str)) {
            return false;
        }
        return true;
    }

    public void m11610(ArrayList<File> arrayList, File file, String str) throws IOException {
        String str2;
        String str3;
        m11590();
        String[] split = str.split("\\*");
        ArrayList arrayList2 = new ArrayList();
        int i = 0;
        if (split == null || split.length <= 0) {
            str2 = "";
            str3 = str2;
        } else {
            str2 = "";
            str3 = str2;
            for (int i2 = 0; i2 < split.length; i2++) {
                if (i2 == 0) {
                    str2 = split[i2];
                } else if (i2 == split.length - 1) {
                    str3 = split[i2];
                } else {
                    arrayList2.add(split[i2]);
                }
            }
        }
        if (file != null && file.exists()) {
            if (file.isDirectory()) {
                File[] listFiles = file.listFiles();
                int length = listFiles.length;
                while (i < length) {
                    m11610(arrayList, listFiles[i], str);
                    i++;
                }
                return;
            }
            if (str.equals("")) {
                arrayList.add(file);
                return;
            }
            if (file.getName().startsWith(str2) && file.getName().endsWith(str3)) {
                Iterator it = arrayList2.iterator();
                while (true) {
                    if (it.hasNext()) {
                        if (!file.getName().contains((String) it.next())) {
                            break;
                        }
                    } else {
                        i = 1;
                        break;
                    }
                }
                if (i != 0) {
                    arrayList.add(file);
                }
            }
        }
    }

    public void m11611(File file, String str) throws IOException {
        m11590();
        m11508("chown", str, file.getAbsolutePath());
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                m11508("chown", str, file.getAbsolutePath());
                m11611(file2, str);
            }
        }
    }

    public void m11612(File file, String str) throws IOException {
        m11590();
        m11508("chmod", str, file.getAbsolutePath());
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                m11508("chmod", str, file.getAbsolutePath());
                m11612(file2, str);
            }
        }
    }

    public String m11613(String str) {
        String substring = str.substring(str.indexOf(32) + 1, str.indexOf(40));
        String substring2 = substring.substring(0, substring.lastIndexOf(46));
        C3348.m12347("class:" + substring2);
        return substring2;
    }

    public String m11614(boolean z, C2889 c2889) throws Exception {
        String str;
        C4083 c4083;
        String str2 = "";
        Timer timer = new Timer();
        C2888 c2888 = new C2888(c2889);
        if (!c2889.f7740[0].contains(" " + C1968.class.getName() + " ") && !c2889.f7740[0].contains("oatdump ") && !c2889.f7740[0].contains("pm install")) {
            timer.schedule(c2888, 600000L);
            C3348.m12347("Input a string within 3 minuten: ");
        }
        try {
            c2889.f7743 = C3348.f9931;
            str = "";
            while (true) {
                try {
                    String m11483 = m11483(c2889.f7743);
                    if (m11483 == null) {
                        break;
                    }
                    c2889.f7744 = System.currentTimeMillis();
                    if (z && (c4083 = C3348.f9902) != null && c4083.m12645()) {
                        if (m11483.contains("Get classes.dex.")) {
                            C3348.m12359(new RunnableC2921());
                        }
                        if (m11483.equals("String analysis.")) {
                            C3348.m12359(new RunnableC2924());
                        }
                        if (m11483.equals("Parse data for patch.")) {
                            C3348.m12359(new RunnableC2926());
                        }
                        if (m11483.startsWith("Progress size:")) {
                            C3348.m12359(new RunnableC2928(m11483));
                        }
                        if (m11483.startsWith("Size file:")) {
                            C3348.m12359(new RunnableC2930(m11483));
                        }
                        if (m11483.startsWith("Analise Results:")) {
                            C3348.m12359(new RunnableC2932());
                        }
                        if (m11483.startsWith("Create ODEX:")) {
                            C3348.m12359(new RunnableC2935());
                        }
                        if (m11483.startsWith("Optional Steps After Patch:")) {
                            C3348.m12359(new RunnableC2938());
                        }
                    }
                    if (m11483.contains(C2010.class.getName())) {
                        C3348.m12347(str);
                        str = "";
                    }
                    if (m11483.contains("chelpus done!")) {
                        break;
                    }
                    if (!m11483.contains("chelpusstart!")) {
                        str = str + m11483 + "\n";
                    }
                } catch (Throwable th) {
                    th = th;
                    str2 = str;
                    th.printStackTrace();
                    str = str2;
                    timer.cancel();
                    C3348.m12347("you have entered: " + str);
                    return str;
                }
            }
        } catch (Throwable th2) {
            th = th2;
        }
        timer.cancel();
        C3348.m12347("you have entered: " + str);
        return str;
    }

    public String m11615(String str) {
        String substring = str.substring(str.indexOf(32) + 1, str.indexOf(40));
        String substring2 = substring.substring(substring.lastIndexOf(46) + 1);
        C3348.m12347("method:" + substring2);
        return substring2;
    }

    public C2887 m11616(File file, ArrayList<String> arrayList) {
        long j;
        Process process;
        int i;
        int i2;
        long j2;
        Iterator<String> it;
        int i3;
        int i4;
        int i5;
        new ArrayList();
        new ArrayList();
        C2887 c2887 = new C2887();
        long currentTimeMillis = System.currentTimeMillis();
        Process process2 = null;
        if (C3348.f9924 >= 23) {
            C3348.m12347("run filter mode.");
            Iterator<String> it2 = arrayList.iterator();
            process = null;
            while (it2.hasNext()) {
                String next = it2.next();
                try {
                    String[] strArr = new String[6];
                    strArr[0] = "oatdump";
                    StringBuilder sb = new StringBuilder();
                    sb.append("--oat-file=");
                    it = it2;
                    try {
                        sb.append(file.getAbsolutePath());
                        strArr[1] = sb.toString();
                        strArr[2] = "--class-filter=" + m11613(next);
                        strArr[3] = "--method-filter=" + m11615(next);
                        strArr[4] = "--no-disassemble";
                        strArr[5] = "--no-dump:vmap";
                        process = Runtime.getRuntime().exec(strArr);
                        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                        j2 = currentTimeMillis;
                        String str = null;
                        boolean z = false;
                        boolean z2 = false;
                        while (true) {
                            try {
                                String readLine = bufferedReader.readLine();
                                if (readLine == null) {
                                    break;
                                }
                                if (!z) {
                                    if (z2) {
                                        c2887.f7734 = readLine;
                                        z = true;
                                    }
                                    if (readLine.equals("INSTRUCTION SET:")) {
                                        z2 = true;
                                    }
                                } else if (str == null) {
                                    if (readLine.contains("dex_method_idx") && readLine.contains(next)) {
                                        str = next;
                                    }
                                } else if (readLine.contains("CODE: ")) {
                                    String[] split = readLine.substring(readLine.indexOf(40) + 1, readLine.indexOf(41)).split("\\s+");
                                    if (split.length >= 3) {
                                        String str2 = split[0];
                                        i3 = Integer.decode(str2.substring(str2.indexOf(61) + 1)).intValue();
                                        String str3 = split[2];
                                        i4 = Integer.decode(str3.substring(str3.indexOf(61) + 1)).intValue();
                                    } else {
                                        i3 = 0;
                                        i4 = 0;
                                    }
                                    int i6 = i3;
                                    if (split.length == 2) {
                                        String str4 = split[0];
                                        i5 = Integer.decode(str4.substring(str4.indexOf(61) + 1)).intValue();
                                        String str5 = split[1];
                                        i4 = Integer.decode(str5.substring(str5.indexOf(61) + 1)).intValue();
                                    } else {
                                        i5 = i6;
                                    }
                                    try {
                                        c2887.f7735.add(new C2886(str, i5, i4));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    bufferedReader.close();
                                    process.destroy();
                                }
                            } catch (IOException e2) {
                                e = e2;
                                e.printStackTrace();
                                C3348.f9923 = e.toString();
                                C3348.m12347(e.toString());
                                it2 = it;
                                currentTimeMillis = j2;
                            } catch (Exception e3) {
                                e = e3;
                                e.printStackTrace();
                                it2 = it;
                                currentTimeMillis = j2;
                            }
                        }
                    } catch (IOException e4) {
                        e = e4;
                        j2 = currentTimeMillis;
                    } catch (Exception e5) {
                        e = e5;
                        j2 = currentTimeMillis;
                    }
                } catch (IOException e6) {
                    e = e6;
                    j2 = currentTimeMillis;
                    it = it2;
                } catch (Exception e7) {
                    e = e7;
                    j2 = currentTimeMillis;
                    it = it2;
                }
                it2 = it;
                currentTimeMillis = j2;
            }
            j = currentTimeMillis;
        } else {
            j = currentTimeMillis;
            try {
                process = Runtime.getRuntime().exec(new String[]{"oatdump", "--oat-file=" + file.getAbsolutePath(), "--no-disassemble", "--no-dump:vmap"});
                try {
                    BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(process.getInputStream()));
                    String str6 = null;
                    boolean z3 = false;
                    boolean z4 = false;
                    int i7 = 0;
                    while (true) {
                        String readLine2 = bufferedReader2.readLine();
                        if (readLine2 == null) {
                            break;
                        }
                        if (!z3) {
                            if (z4) {
                                c2887.f7734 = readLine2;
                                z3 = true;
                            }
                            if (readLine2.equals("INSTRUCTION SET:")) {
                                z4 = true;
                            }
                        } else if (str6 == null) {
                            if (readLine2.contains("dex_method_idx")) {
                                Iterator<String> it3 = arrayList.iterator();
                                while (it3.hasNext()) {
                                    String next2 = it3.next();
                                    if (readLine2.contains(next2)) {
                                        str6 = next2;
                                    }
                                }
                            }
                        } else if (readLine2.contains("CODE: ")) {
                            i7++;
                            String[] split2 = readLine2.substring(readLine2.indexOf(40) + 1, readLine2.indexOf(41)).split("\\s+");
                            if (split2.length >= 3) {
                                String str7 = split2[0];
                                i = Integer.decode(str7.substring(str7.indexOf(61) + 1)).intValue();
                                String str8 = split2[2];
                                i2 = Integer.decode(str8.substring(str8.indexOf(61) + 1)).intValue();
                            } else {
                                i = 0;
                                i2 = 0;
                            }
                            if (split2.length == 2) {
                                String str9 = split2[0];
                                i = Integer.decode(str9.substring(str9.indexOf(61) + 1)).intValue();
                                String str10 = split2[1];
                                i2 = Integer.decode(str10.substring(str10.indexOf(61) + 1)).intValue();
                            }
                            try {
                                c2887.f7735.add(new C2886(str6, i, i2));
                            } catch (Exception e8) {
                                e8.printStackTrace();
                            }
                            if (i7 == arrayList.size()) {
                                break;
                            }
                            str6 = null;
                        }
                    }
                } catch (IOException e9) {
                    e = e9;
                    process2 = process;
                    C3348.f9923 = e.toString();
                    C3348.m12347(e.toString());
                    process = process2;
                    C3348.m12347("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
                    if (process != null) {
                    }
                    return c2887;
                } catch (Exception e10) {
                    e = e10;
                    process2 = process;
                    e.printStackTrace();
                    process = process2;
                    C3348.m12347("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
                    if (process != null) {
                    }
                    return c2887;
                }
            } catch (IOException e11) {
                e = e11;
            } catch (Exception e12) {
                e = e12;
            }
        }
        C3348.m12347("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
        if (process != null) {
            process.destroy();
        }
        return c2887;
    }

    public void m11617(File file) {
        boolean canRequestPackageInstalls;
        MainActivity mainActivity;
        C3348.m12347("install rootless.");
        if (C3348.f9924 >= 26) {
            canRequestPackageInstalls = C3348.m12337().canRequestPackageInstalls();
            if (!canRequestPackageInstalls && (mainActivity = C3348.f9884) != null) {
                mainActivity.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C3348.f10019);
            }
        }
        C3923.m12560(m11423(R.string.wait), m11423(R.string.installer_prepare), 3, false, false);
        Thread thread = new Thread(new RunnableC2918(file));
        thread.setPriority(10);
        thread.start();
    }

    public String m11618(String... strArr) {
        try {
            m11590();
        } catch (C3870 e) {
            e.printStackTrace();
        }
        try {
        } catch (C3870 e2) {
            e2.printStackTrace();
        }
        if (C3348.f9948.booleanValue()) {
            throw new C3870("Application attempted to run a shell command from the main thread");
        }
        if (!C3348.f9908 && !strArr[0].equals("checkRoot")) {
            return "lucky patcher root not found!";
        }
        C2889 c2889 = new C2889(this, null);
        c2889.f7740 = strArr;
        c2889.start();
        try {
            boolean z = false;
            for (String str : strArr) {
                if (str.contains("-Xbootclasspath:") || str.contains("app_process") || str.contains("dd ") || str.contains("cp ") || str.contains("cat ") || str.contains("pm ")) {
                    z = true;
                }
            }
            if (z) {
                c2889.join();
            } else {
                c2889.join();
                Integer unused = c2889.f7742;
            }
        } catch (InterruptedException e3) {
            e3.printStackTrace();
            c2889.interrupt();
            Thread.currentThread().interrupt();
            m11317();
        }
        C3348.f9948 = Boolean.FALSE;
        return c2889.f7739;
    }

    public String m11619(String str, InputStream inputStream) {
        m11590();
        try {
        } catch (C3870 e) {
            e.printStackTrace();
        }
        if (C3348.f9948.booleanValue()) {
            throw new C3870("Application attempted to run a shell command from the main thread");
        }
        if (!C3348.f9908 && !str.equals("checkRoot")) {
            return "lucky patcher root not found!";
        }
        C2889 c2889 = new C2889(this, null);
        boolean z = true;
        c2889.f7740 = new String[]{str};
        c2889.f7741 = inputStream;
        c2889.start();
        try {
            if (!str.contains("-Xbootclasspath:") && !str.contains("app_process") && !str.contains("dd ") && !str.contains("cp ") && !str.contains("cat ") && !str.contains("pm ")) {
                z = false;
            }
            c2889.join();
            Integer unused = c2889.f7742;
        } catch (InterruptedException e2) {
            e2.printStackTrace();
            c2889.interrupt();
            Thread.currentThread().interrupt();
            m11317();
        }
        C3348.f9948 = Boolean.FALSE;
        return c2889.f7739;
    }

    @SuppressLint({"NewApi"})
    public void m11620(File file) {
        try {
            file.setReadable(true);
            if (file.isDirectory()) {
                for (File file2 : file.listFiles()) {
                    file.setReadable(true);
                    m11620(file2);
                }
            }
        } catch (Exception | NoSuchMethodError e) {
            e.printStackTrace();
        }
    }

    @SuppressLint({"NewApi"})
    public void m11621(File file) {
        try {
            file.setWritable(true);
            if (file.isDirectory()) {
                for (File file2 : file.listFiles()) {
                    file.setWritable(true);
                    m11621(file2);
                }
            }
        } catch (Exception | NoSuchMethodError e) {
            e.printStackTrace();
        }
    }

    public float m11622(File file, boolean z) throws IOException {
        m11590();
        if (z) {
            this.f7711 = 0.0f;
        }
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                m11622(file2, false);
            }
        }
        float length = this.f7711 + ((float) new File(file.toString()).length());
        this.f7711 = length;
        return length / 1048576.0f;
    }

    public void m11623(long j) {
        long currentTimeMillis = System.currentTimeMillis() + j;
        while (System.currentTimeMillis() < currentTimeMillis) {
            synchronized (this) {
                try {
                    wait(currentTimeMillis - System.currentTimeMillis());
                } catch (Exception unused) {
                }
            }
        }
    }

    public C2880() {
    }
}