Luсky+Рatcher v11.3.3版本的 MD5 值为:fcc08dfa98a57a21951c5463e292fdaf

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


package p037;

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.SharedPreferences;
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.C0476;
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.InterfaceC1470;
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.ObjectInputStream;
import java.io.ObjectOutputStream;
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.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
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.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javaroot.utils.C1545;
import javaroot.utils.C1600;
import javaroot.utils.C1601;
import javaroot.utils.C1617;
import javaroot.utils.C1632;
import javaroot.utils.C1635;
import javaroot.utils.C1642;
import javaroot.utils.C1644;
import javaroot.utils.C1666;
import javaroot.utils.C1668;
import javaroot.utils.C1682;
import javaroot.utils.C1686;
import javaroot.utils.C1696;
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.Opcode;
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 p002.C1783;
import p004.C1808;
import p005.C1846;
import p005.C1856;
import p005.C1862;
import p005.C1863;
import p011.InterfaceC1978;
import p023.C2188;
import p024.C2213;
import p027.C2232;
import p029.C2413;
import p031.C2419;
import p031.C2420;
import p031.C2426;
import p034.C2449;
import p036.InterfaceC2466;
import p037.C2471;
import p038.C2597;
import p039.C2604;
import p040.C2608;
import p040.C2610;
import p040.C2612;
import p040.C2614;
import p040.C2616;
import p040.C2618;
import p040.C2619;
import p040.C2621;
import p040.C2623;
import p040.C2627;
import p040.C2630;
import p040.C2631;
import p040.C2632;
import p040.C2635;
import p041.C2636;
import p042.C2641;
import p085.C2912;
import p085.C2913;
import p085.C2933;
import p085.C2938;
import p085.C2939;
import p085.C2973;
import p085.C2975;
import p085.C3478;
import p085.C3496;
import p085.C3497;
import p086.C3549;
import p086.C3740;
import p086.C3746;
import p105.C3862;
import p105.C3864;
import p107.C3867;
import p110.C3961;
import p149.C4373;
import p149.EnumC4369;
import p149.EnumC4371;
import ru.aaaaabbt.installer.R;
import ru.sxbuIDfx.pFSOyagrF.App;
import ru.sxbuIDfx.pFSOyagrF.MainActivity;
import ru.sxbuIDfx.pFSOyagrF.PkgName;
import sun.security.pkcs.PKCS7;
import sun.security.util.DerValue;

public class C2500 {

    public static boolean f7059 = false;

    public static Dialog f7060 = null;

    public static boolean f7061 = false;

    private static final ThreadLocal<char[]> f7062 = new C2579();

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

    private static String f7064 = "";

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

    static ServiceConnection f7066 = null;

    static InterfaceC1470 f7067 = null;

    static Random f7068 = new Random();

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

    static String f7070 = "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 f7071 = 0.0f;

    public class C2501 extends TimerTask {

        final Runnable f7072;

        class RunnableC2502 implements Runnable {
            RunnableC2502() {
            }

            @Override
            public void run() {
                C2975.m7942("step1");
                if (!C2500.f7059) {
                    C2975.m7942("step2");
                    C2500.f7059 = true;
                    C2500.m7117(C2500.f7060);
                }
                C2975.m7951(11);
            }
        }

        C2501(Runnable runnable) {
            this.f7072 = runnable;
        }

        @Override
        public void run() {
            C2975.m7942("Cancel timer 2");
            if (C2975.f9245 != null) {
                C2975.m7942("run to main show ads dialog");
                C2975.m7954(new RunnableC2502());
            }
            Runnable runnable = this.f7072;
            if (runnable != null) {
                runnable.run();
            }
        }
    }

    public class RunnableC2503 implements Runnable {
        RunnableC2503() {
        }

        @Override
        public void run() {
            Toast.makeText(C2975.m7929(), C2500.m7007(R.string.reboot_message), 1).show();
        }
    }

    public class RunnableC2504 implements Runnable {

        final String f7074;

        final String f7075;

        final DialogInterface.OnClickListener f7076;

        final DialogInterface.OnClickListener f7077;

        final DialogInterface.OnCancelListener f7078;

        final String f7079;

        final CompoundButton.OnCheckedChangeListener f7080;

        final boolean f7081;

        final boolean f7082;

        RunnableC2504(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7074 = str;
            this.f7075 = str2;
            this.f7076 = onClickListener;
            this.f7077 = onClickListener2;
            this.f7078 = onCancelListener;
            this.f7079 = str3;
            this.f7080 = onCheckedChangeListener;
            this.f7081 = z;
            this.f7082 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C2913 c2913 = new C2913(C2975.f9245.mo1874());
                    c2913.m7860(this.f7074).m7876(this.f7075).m7872(R.drawable.ic_vopros).m7875(C2500.m7007(R.string.Yes), this.f7076).m7878(C2500.m7007(R.string.no), this.f7077).m7881(this.f7078).m7866(this.f7079, this.f7080, this.f7081);
                    try {
                        if (this.f7082) {
                            Linkify.addLinks(c2913.f9086, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m7851 = c2913.m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2505 implements Runnable {

        final String f7083;

        final String f7084;

        final DialogInterface.OnClickListener f7085;

        final DialogInterface.OnClickListener f7086;

        final DialogInterface.OnCancelListener f7087;

        final String f7088;

        final CompoundButton.OnCheckedChangeListener f7089;

        final boolean f7090;

        final String f7091;

        final CompoundButton.OnCheckedChangeListener f7092;

        final boolean f7093;

        final boolean f7094;

        RunnableC2505(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.f7083 = str;
            this.f7084 = str2;
            this.f7085 = onClickListener;
            this.f7086 = onClickListener2;
            this.f7087 = onCancelListener;
            this.f7088 = str3;
            this.f7089 = onCheckedChangeListener;
            this.f7090 = z;
            this.f7091 = str4;
            this.f7092 = onCheckedChangeListener2;
            this.f7093 = z2;
            this.f7094 = z3;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C2913 c2913 = new C2913(C2975.f9245.mo1874());
                    c2913.m7860(this.f7083).m7876(this.f7084).m7872(R.drawable.ic_vopros).m7875(C2500.m7007(R.string.Yes), this.f7085).m7878(C2500.m7007(R.string.no), this.f7086).m7881(this.f7087).m7866(this.f7088, this.f7089, this.f7090).m7867(this.f7091, this.f7092, this.f7093);
                    try {
                        if (this.f7094) {
                            Linkify.addLinks(c2913.f9086, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m7851 = c2913.m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2506 implements Runnable {

        final String f7095;

        final String f7096;

        final DialogInterface.OnClickListener f7097;

        final DialogInterface.OnClickListener f7098;

        final DialogInterface.OnCancelListener f7099;

        final String f7100;

        final CompoundButton.OnCheckedChangeListener f7101;

        final boolean f7102;

        final boolean f7103;

        RunnableC2506(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7095 = str;
            this.f7096 = str2;
            this.f7097 = onClickListener;
            this.f7098 = onClickListener2;
            this.f7099 = onCancelListener;
            this.f7100 = str3;
            this.f7101 = onCheckedChangeListener;
            this.f7102 = z;
            this.f7103 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C2913 c2913 = new C2913(C2975.f9245.mo1874());
                    c2913.m7860(this.f7095).m7876(this.f7096).m7872(R.drawable.ic_vopros).m7875(C2500.m7007(R.string.Yes), this.f7097).m7878(C2500.m7007(R.string.no), this.f7098).m7882(true).m7881(this.f7099).m7866(this.f7100, this.f7101, this.f7102);
                    try {
                        if (this.f7103) {
                            Linkify.addLinks(c2913.f9086, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m7851 = c2913.m7851();
                    C2500.m7119(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2507 implements Runnable {

        final String f7104;

        final String f7105;

        final String f7106;

        final DialogInterface.OnClickListener f7107;

        final DialogInterface.OnClickListener f7108;

        final DialogInterface.OnCancelListener f7109;

        final boolean f7110;

        RunnableC2507(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z) {
            this.f7104 = str;
            this.f7105 = str2;
            this.f7106 = str3;
            this.f7107 = onClickListener;
            this.f7108 = onClickListener2;
            this.f7109 = onCancelListener;
            this.f7110 = z;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C2913 c2913 = new C2913(C2975.f9245.mo1874());
                    c2913.m7860(this.f7104).m7876(this.f7105).m7872(R.drawable.ic_vopros).m7875(this.f7106, this.f7107).m7878(C2500.m7007(R.string.no), this.f7108).m7881(this.f7109);
                    try {
                        if (this.f7110) {
                            Linkify.addLinks(c2913.f9086, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m7851 = c2913.m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class C2508 {

        public String f7111;

        public int f7112;

        public int f7113;

        public C2508(String str, int i, int i2) {
            this.f7111 = str;
            this.f7112 = i;
            this.f7113 = i2;
        }
    }

    public class C2509 {

        public String f7115 = null;

        public ArrayList<C2508> f7116 = new ArrayList<>();

        public C2509() {
        }
    }

    public class C2510 extends TimerTask {

        C2511 f7118;

        public C2510(C2511 c2511) {
            this.f7118 = c2511;
        }

        @Override
        public void run() {
            if (System.currentTimeMillis() - this.f7118.f7125 < 300000) {
                C2975.m7942("LuckyPatcher: timeout cancel. Too long process...");
                return;
            }
            String str = "";
            if (C2975.f9302.equals("")) {
                C2975.m7942("LuckyPatcher: timeout for wait root. exit...");
                try {
                    this.f7118.interrupt();
                    this.f7118.f7124.close();
                    try {
                        if (C2975.f9245 != null) {
                            C2975.m7951(23);
                        }
                        C2975.m7951(1);
                        C2975.m7951(11);
                        try {
                            for (String str2 : this.f7118.f7121) {
                                str = "\n" + str2;
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        String str3 = C2975.f9234;
                        C2975.m7962("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.f7118.f7121) {
                            C2975.m7942("Lucky Patcher: freezes root commands:" + str4);
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                    C2500.m6900();
                    C2975.f9309.release();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
        }
    }

    public class C2511 extends Thread {

        private String f7120;

        private String[] f7121;

        private InputStream f7122;

        private Integer f7123;

        public DataInputStream f7124;

        public long f7125;

        C2511(C2500 c2500, RunnableC2536 runnableC2536) {
            this();
        }

        @Override
        public void run() {
            Class<C1617> 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<C1617> cls2;
            String str12;
            String str13 = "env: not found";
            String[] strArr = this.f7121;
            int length2 = strArr.length;
            char c2 = 0;
            int i3 = 0;
            boolean z4 = false;
            boolean z5 = false;
            boolean z6 = false;
            while (true) {
                cls = C1617.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.f7120.contains("SU Java-Code Running!") || z8) {
                    break;
                }
                String str16 = this.f7121[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.f7121[0]);
                    C2975.m7942(sb.toString());
                } else {
                    z = z7;
                    c = 0;
                }
                try {
                    if (this.f7121[c].equals("checkRoot")) {
                        C2975.m7942("LuckyPatcher: test root.");
                        this.f7121[0] = "ps init";
                        z = true;
                    }
                    boolean z9 = z8;
                    int i4 = C2975.f9272 + 1;
                    C2975.f9272 = i4;
                    C2975.m7942("Block root thread" + C2975.f9272);
                    try {
                        str3 = str;
                        str4 = "";
                    } catch (InterruptedException e) {
                        e = e;
                        str3 = str;
                        str4 = "";
                    }
                    try {
                        if (!C2975.f9309.tryAcquire(300L, TimeUnit.SECONDS)) {
                            C2975.m7942("Root command timeout. Bad root.");
                            C2500.m6900();
                            C2975.f9309.release();
                        }
                    } catch (InterruptedException e2) {
                        e = e2;
                        e.printStackTrace();
                        C2975.f9272--;
                        C2500.m6988();
                        C2975.m7942("UNBlock root thread N" + i4);
                        String[] strArr2 = this.f7121;
                        length = strArr2.length;
                        i = 0;
                        while (i < length) {
                        }
                        String str18 = str17;
                        Class<C1617> cls3 = cls;
                        String str19 = str15;
                        inputStream = this.f7122;
                        if (inputStream != null) {
                        }
                        C2975.f9307.writeBytes("\n");
                        C2975.f9307.writeBytes("echo 'chelpus done!'\n");
                        C2975.f9307.flush();
                        if (!z5) {
                        }
                        str2 = str4;
                        z2 = z;
                        if (z2) {
                        }
                        if (!this.f7120.equals(str2)) {
                        }
                        if (this.f7120.equals(str2)) {
                        }
                        if (z4) {
                        }
                    }
                    C2975.f9272--;
                    C2500.m6988();
                    C2975.m7942("UNBlock root thread N" + i4);
                    String[] strArr22 = this.f7121;
                    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 = C2975.f9307;
                            str12 = str15;
                            cls2 = cls;
                            StringBuilder sb2 = new StringBuilder();
                            str11 = str17;
                            sb2.append(C2975.f9250);
                            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")) {
                            C2975.f9307.writeBytes(new String((str20 + "\n").getBytes(), "ISO-8859-1"));
                        }
                        i++;
                        strArr22 = strArr3;
                        length = i2;
                        str15 = str12;
                        cls = cls2;
                        str17 = str11;
                    }
                    String str182 = str17;
                    Class<C1617> cls32 = cls;
                    String str192 = str15;
                    inputStream = this.f7122;
                    if (inputStream != null) {
                        try {
                            C2500.m6879(inputStream, C2975.f9307);
                            C2975.f9307.writeBytes("exit\n");
                            C2975.f9307.flush();
                            C2975.f9305.destroy();
                            C2975.f9305 = Runtime.getRuntime().exec("su");
                            C2975.f9307 = new DataOutputStream(C2975.f9305.getOutputStream());
                            C2975.f9306 = new DataInputStream(C2975.f9305.getInputStream());
                            C2975.f9308 = new DataInputStream(C2975.f9305.getErrorStream());
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                        try {
                            this.f7122.close();
                        } catch (Throwable th2) {
                            try {
                                th2.printStackTrace();
                            } catch (Throwable th3) {
                                this.f7122 = null;
                                throw th3;
                            }
                        }
                        this.f7122 = null;
                    }
                    C2975.f9307.writeBytes("\n");
                    C2975.f9307.writeBytes("echo 'chelpus done!'\n");
                    C2975.f9307.flush();
                    if (!z5) {
                        break;
                    }
                    this.f7120 = C2500.this.m7203(z6, this);
                    if (z6) {
                        z6 = false;
                    }
                    try {
                        dataInputStream = C2975.f9308;
                    } catch (IOException e3) {
                        e = e3;
                        str5 = str4;
                    } catch (Exception e4) {
                        e = e4;
                        str5 = str4;
                    }
                    if (dataInputStream == null) {
                        break;
                    }
                    byte[] bArr = new byte[dataInputStream.available()];
                    C2975.f9308.read(bArr);
                    String str21 = new String(bArr);
                    C2975.f9298 = str21;
                    if (str21.contains(str13)) {
                        C2500.m6900();
                    }
                    str5 = str4;
                    try {
                        if (!new String(bArr).trim().equals(str5)) {
                            C2975.m7942("LuckyApcther root errors: " + C2975.f9298);
                            C2975.f9298 = new String(bArr);
                        } else {
                            C2975.f9298 = str5;
                        }
                    } catch (IOException e5) {
                        e = e5;
                        e.printStackTrace();
                        C2500.m6900();
                        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.f7121;
                            if (i5 < strArr4.length) {
                                if (!strArr4[i5].contains("-Xbootclasspath:") && !this.f7121[i5].contains("app_process")) {
                                    str9 = str13;
                                    z3 = z8;
                                    str7 = str3;
                                    str10 = str192;
                                    str8 = str182;
                                } else {
                                    str8 = str182;
                                    if (!this.f7121[i5].contains(str8)) {
                                        if (!this.f7121[i5].contains(str5 + C1635.class.getName())) {
                                            String str22 = this.f7121[i5];
                                            StringBuilder sb3 = new StringBuilder();
                                            str7 = str3;
                                            sb3.append(str7);
                                            sb3.append(C1632.class.getName());
                                            if (!str22.contains(sb3.toString())) {
                                                if (!this.f7121[i5].contains(str7 + C1644.class.getName() + str7)) {
                                                    if (this.f7121[i5].contains(str7 + C1600.class.getName() + str7)) {
                                                        break;
                                                    }
                                                    if (this.f7121[i5].contains(str7 + cls32.getName() + str7)) {
                                                        break;
                                                    }
                                                    String str23 = System.getenv("LD_LIBRARY_PATH");
                                                    String str24 = this.f7121[i5];
                                                    if (C2975.f9298.contains(str13)) {
                                                        str9 = str13;
                                                        this.f7121[i5] = str8 + str23 + str7 + str24;
                                                        z3 = z8;
                                                    } else {
                                                        str9 = str13;
                                                        z3 = true;
                                                    }
                                                    str10 = str192;
                                                    if (this.f7120.contains(str10)) {
                                                        z3 = true;
                                                    } else {
                                                        this.f7120 = str5;
                                                    }
                                                } else {
                                                    break;
                                                }
                                            } else {
                                                break;
                                            }
                                        } else {
                                            break;
                                        }
                                    } else {
                                        break;
                                    }
                                }
                                i5++;
                                str192 = str10;
                                z8 = z3;
                                str182 = str8;
                                str3 = str7;
                                str13 = str9;
                            } else {
                                str6 = str13;
                                str7 = str3;
                                break;
                            }
                        }
                        str6 = str13;
                        C2975.m7942("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();
                    C2975.m7942("LuckyPatcher (result root): root not found.");
                    C2975.f9309.release();
                    return;
                } catch (Exception e8) {
                    e8.printStackTrace();
                    C2975.f9309.release();
                    return;
                }
                z2 = z;
                if (z2) {
                    C2975.m7942("LuckyPatcher (result root): " + this.f7120);
                }
                if (!this.f7120.equals(str2) && z2) {
                    if (z4) {
                        C2500.m6900();
                    } else {
                        C2975.f9309.release();
                    }
                    this.f7120 = "lucky patcher root not found!";
                    return;
                }
                if (this.f7120.equals(str2)) {
                    this.f7120 = "~";
                }
                if (z4) {
                    C2500.m6900();
                    return;
                } else {
                    C2975.f9309.release();
                    return;
                }
            }
            z = z7;
            str2 = "";
            z2 = z;
            if (z2) {
            }
            if (!this.f7120.equals(str2)) {
            }
            if (this.f7120.equals(str2)) {
            }
            if (z4) {
            }
        }

        private C2511() {
            this.f7120 = "";
            this.f7121 = null;
            this.f7122 = null;
            this.f7123 = null;
            this.f7124 = null;
            this.f7125 = 0L;
        }
    }

    public class RunnableC2512 implements Runnable {

        final Timer f7127;

        final TimerTask f7128;

        RunnableC2512(Timer timer, TimerTask timerTask) {
            this.f7127 = timer;
            this.f7128 = timerTask;
        }

        @Override
        public void run() {
            C2975.m7942("Cancel timer");
            this.f7127.cancel();
            this.f7128.run();
        }
    }

    public class RunnableC2513 implements Runnable {
        RunnableC2513() {
        }

        @Override
        public void run() {
            Toast.makeText(C2975.m7929(), C2500.m7007(R.string.reboot_message), 1).show();
        }
    }

    public class RunnableC2514 implements Runnable {

        final LinearLayout f7129;

        final Runnable f7130;

        final Timer f7131;

        final TimerTask f7132;

        class RunnableC2515 implements Runnable {
            RunnableC2515() {
            }

            @Override
            public void run() {
                RunnableC2514 runnableC2514 = RunnableC2514.this;
                C2500.m7037(runnableC2514.f7129, runnableC2514.f7130, runnableC2514.f7131, runnableC2514.f7132);
            }
        }

        RunnableC2514(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
            this.f7129 = linearLayout;
            this.f7130 = runnable;
            this.f7131 = timer;
            this.f7132 = timerTask;
        }

        @Override
        public void run() {
            C2500.m7037(this.f7129, new RunnableC2515(), this.f7131, this.f7132);
        }
    }

    public class RunnableC2516 implements Runnable {

        final String f7134;

        final String f7135;

        final DialogInterface.OnClickListener f7136;

        final DialogInterface.OnClickListener f7137;

        final DialogInterface.OnCancelListener f7138;

        RunnableC2516(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7134 = str;
            this.f7135 = str2;
            this.f7136 = onClickListener;
            this.f7137 = onClickListener2;
            this.f7138 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    Dialog m7851 = new C2913(C2975.f9245.mo1874()).m7860(this.f7134).m7876(this.f7135).m7872(R.drawable.ic_vopros).m7875(C2500.m7007(R.string.Yes), this.f7136).m7878(C2500.m7007(R.string.no), this.f7137).m7882(true).m7881(this.f7138).m7851();
                    C2500.m7119(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class C2517 implements IUnityAdsListener {
        C2517() {
        }

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

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

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

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

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

        @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 C2519 implements BannerView.IListener {

        final Timer f7139;

        final TimerTask f7140;

        final LinearLayout f7141;

        final Runnable f7142;

        class RunnableC2520 implements Runnable {
            RunnableC2520() {
            }

            @Override
            public void run() {
                if (!C2500.f7059) {
                    C2500.f7059 = true;
                    C2500.m7117(C2500.f7060);
                }
                C2975.m7951(11);
            }
        }

        class RunnableC2521 implements Runnable {
            RunnableC2521() {
            }

            @Override
            public void run() {
                if (!C2500.f7059) {
                    C2500.f7059 = true;
                    C2500.m7117(C2500.f7060);
                }
                C2975.m7951(11);
            }
        }

        C2519(Timer timer, TimerTask timerTask, LinearLayout linearLayout, Runnable runnable) {
            this.f7139 = timer;
            this.f7140 = timerTask;
            this.f7141 = linearLayout;
            this.f7142 = runnable;
        }

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

        @Override
        public void onBannerFailedToLoad(BannerView bannerView, BannerErrorInfo bannerErrorInfo) {
            C2975.m7942("UnityBannerOnAdFailedToLoad");
            if (this.f7141.findViewWithTag("UnityBanner") != null) {
                LinearLayout linearLayout = this.f7141;
                linearLayout.removeView(linearLayout.findViewWithTag("UnityBanner"));
            }
            Runnable runnable = this.f7142;
            if (runnable != null) {
                runnable.run();
            }
            if (!C2500.f7059 && C2975.f9245 != null) {
                C2975.m7954(new RunnableC2521());
            }
        }

        @Override
        public void onBannerLeftApplication(BannerView bannerView) {
        }

        @Override
        public void onBannerLoaded(BannerView bannerView) {
            C2975.m7942("Unity ad loaded");
            Timer timer = this.f7139;
            if (timer != null && this.f7140 != null) {
                timer.cancel();
                this.f7140.run();
            }
            if (!C2500.f7059 && C2975.f9245 != null) {
                C2975.m7954(new RunnableC2520());
            }
        }
    }

    public class RunnableC2522 implements Runnable {
        RunnableC2522() {
        }

        @Override
        public void run() {
            Toast.makeText(C2975.m7929(), C2500.m7007(R.string.reboot_message), 1).show();
        }
    }

    public class RunnableC2523 implements Runnable {

        final String f7145;

        final String f7146;

        final String f7147;

        final String f7148;

        final DialogInterface.OnClickListener f7149;

        final DialogInterface.OnClickListener f7150;

        final DialogInterface.OnCancelListener f7151;

        RunnableC2523(String str, String str2, String str3, String str4, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7145 = str;
            this.f7146 = str2;
            this.f7147 = str3;
            this.f7148 = str4;
            this.f7149 = onClickListener;
            this.f7150 = onClickListener2;
            this.f7151 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                C2913 c2913 = new C2913(C2975.f9259);
                String str = this.f7145;
                if (str != null && !str.equals("")) {
                    Dialog m7851 = c2913.m7860(this.f7146).m7876(this.f7147).m7872(R.drawable.ic_vopros).m7875(this.f7148, this.f7149).m7878(this.f7145, this.f7150).m7881(this.f7151).m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                } else {
                    Dialog m78512 = c2913.m7860(this.f7146).m7876(this.f7147).m7872(R.drawable.ic_vopros).m7875(this.f7148, this.f7149).m7881(this.f7151).m7851();
                    C2500.m7117(m78512);
                    m78512.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    class RunnableC2524 implements Runnable {

        int f7152 = 0;

        boolean f7153 = false;

        boolean f7154 = false;

        boolean f7155 = false;

        boolean f7156 = false;

        final String f7157;

        final Runnable f7158;

        final Runnable f7159;

        class RunnableC2525 implements Runnable {
            RunnableC2525() {
            }

            @Override
            public void run() {
                C2975.m7960(23);
            }
        }

        class RunnableC2526 implements Runnable {
            RunnableC2526() {
            }

            @Override
            public void run() {
                C2975.m7951(23);
            }
        }

        RunnableC2524(String str, Runnable runnable, Runnable runnable2) {
            this.f7157 = str;
            this.f7158 = runnable;
            this.f7159 = runnable2;
        }

        @Override
        public void run() {
            Runnable runnable;
            Runnable runnable2;
            C2975.m7954(new RunnableC2525());
            C2471 c2471 = null;
            try {
                c2471 = C2500.m6985(this.f7157);
                if (c2471 != null) {
                    this.f7154 = false;
                    int m6829 = c2471.m6829();
                    this.f7152 = m6829;
                    if (m6829 == 0) {
                        this.f7154 = true;
                    }
                    C2975.m7942(String.format("%s bytes found, %s Mb", Integer.valueOf(m6829), Float.valueOf(this.f7152 / 1048576.0f)));
                } else {
                    this.f7152 = 0;
                    this.f7154 = true;
                }
            } catch (Exception e) {
                e.printStackTrace();
                if (0 != 0) {
                    c2471.m6832();
                }
            }
            if (c2471 != null) {
                c2471.m6832();
            }
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8247(this.f7152 / 1024);
            }
            this.f7155 = false;
            if (new File(C2975.f9251 + "/Download/" + this.f7157).exists()) {
                if (!this.f7154) {
                    C2975.m7942(Long.valueOf(new File(C2975.f9251 + "/Download/" + this.f7157).length()));
                    C2975.m7942(Integer.valueOf(this.f7152));
                    long length = new File(C2975.f9251 + "/Download/" + this.f7157).length();
                    int i = this.f7152;
                    if (length == i || i == 0) {
                        this.f7155 = true;
                    }
                } else {
                    this.f7155 = true;
                }
            }
            if (!this.f7154 && !this.f7155) {
                try {
                    new C2483(this.f7157).m6851();
                } catch (Throwable th) {
                    th.printStackTrace();
                    if (c2471 != null) {
                        c2471.m6832();
                    }
                }
                if (new File(C2975.f9251 + "/Download/" + this.f7157).exists()) {
                    if (new File(C2975.f9251 + "/Download/" + this.f7157).length() == this.f7152) {
                        this.f7155 = true;
                        this.f7156 = true;
                    } else {
                        this.f7153 = true;
                        this.f7155 = false;
                    }
                }
            } else {
                if (new File(C2975.f9251 + "/Download/" + this.f7157).exists() && !this.f7155) {
                    new File(C2975.f9251 + "/Download/" + this.f7157).delete();
                }
            }
            C2975.m7954(new RunnableC2526());
            if (this.f7153) {
                C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.corrupt_download));
            }
            if (this.f7154 && !this.f7155) {
                C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.internet_not_found));
            }
            if (this.f7155) {
                if (new File(C2975.f9251 + "/Download/" + this.f7157).exists()) {
                    try {
                        if (this.f7155 && !this.f7156 && (runnable2 = this.f7158) != null) {
                            runnable2.run();
                        }
                        if (this.f7156 && (runnable = this.f7159) != null) {
                            runnable.run();
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.corrupt_download));
                    }
                }
            }
        }
    }

    public class RunnableC2527 implements Runnable {

        final Activity f7162;

        final String f7163;

        final String f7164;

        RunnableC2527(Activity activity, String str, String str2) {
            this.f7162 = activity;
            this.f7163 = str;
            this.f7164 = str2;
        }

        @Override
        public void run() {
            C2913 c2913 = new C2913(this.f7162);
            c2913.m7860(this.f7163);
            c2913.m7876(this.f7164);
            c2913.m7873(R.string.ok, null);
            try {
                C2500.m7117(c2913.m7851());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2528 implements Runnable {

        final boolean f7165;

        final String f7166;

        final File f7167;

        class DialogInterfaceOnClickListenerC2529 implements DialogInterface.OnClickListener {

            class RunnableC2530 implements Runnable {
                RunnableC2530() {
                }

                @Override
                public void run() {
                    if (RunnableC2528.this.f7165) {
                        new C2500("").m7211("pm uninstall " + RunnableC2528.this.f7166);
                    }
                    C2500.m7024(C2975.f9250 + "/pinapp.apk", "", true, false);
                    Context m7929 = C2975.m7929();
                    String str = C2975.f9237;
                    C2500.m7145(m7929, str, str);
                }
            }

            DialogInterfaceOnClickListenerC2529() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (C2975.f9283) {
                    new Thread(new RunnableC2530()).start();
                    return;
                }
                File file = new File(C2975.f9251 + "/tmp/pinapp.apk");
                C2500.m6875(RunnableC2528.this.f7167, file);
                if (RunnableC2528.this.f7167.exists() && file.exists() && RunnableC2528.this.f7167.length() == file.length()) {
                    if (RunnableC2528.this.f7165) {
                        C2975.f9389 = new C2939(C2975.m7929(), file, false);
                        C2500.m7153(C2975.f9259, RunnableC2528.this.f7166, Integer.valueOf(C2975.f9393));
                    } else {
                        C2500.m7023(C2975.f9259, file, Integer.valueOf(C2975.f9395));
                    }
                }
            }
        }

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

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

        RunnableC2528(boolean z, String str, File file) {
            this.f7165 = z;
            this.f7166 = str;
            this.f7167 = file;
        }

        @Override
        public void run() {
            C2500.m7125(C2500.m7007(R.string.information), C2500.m7007(R.string.message_installation_inapp_proxy), new DialogInterfaceOnClickListenerC2529(), new DialogInterfaceOnClickListenerC2531(), null);
        }
    }

    public class RunnableC2532 implements Runnable {

        final Activity f7171;

        final String f7172;

        final SpannableStringBuilder f7173;

        RunnableC2532(Activity activity, String str, SpannableStringBuilder spannableStringBuilder) {
            this.f7171 = activity;
            this.f7172 = str;
            this.f7173 = spannableStringBuilder;
        }

        @Override
        public void run() {
            C2913 c2913 = new C2913(this.f7171);
            c2913.m7860(this.f7172);
            c2913.m7874(this.f7173);
            c2913.m7882(true);
            c2913.m7873(R.string.ok, null);
            try {
                C2500.m7119(c2913.m7851());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2533 implements Runnable {

        int f7174 = 0;

        boolean f7175 = false;

        boolean f7176 = false;

        boolean f7177 = false;

        boolean f7178 = false;

        final ArrayList f7179;

        final Runnable f7180;

        final Runnable f7181;

        class RunnableC2534 implements Runnable {
            RunnableC2534() {
            }

            @Override
            public void run() {
                C2975.m7960(23);
            }
        }

        class RunnableC2535 implements Runnable {
            RunnableC2535() {
            }

            @Override
            public void run() {
                C2975.m7951(23);
            }
        }

        RunnableC2533(ArrayList arrayList, Runnable runnable, Runnable runnable2) {
            this.f7179 = arrayList;
            this.f7180 = runnable;
            this.f7181 = runnable2;
        }

        @Override
        public void run() {
            Runnable runnable;
            Runnable runnable2;
            C2975.m7954(new RunnableC2534());
            Iterator it = this.f7179.iterator();
            while (it.hasNext()) {
                C2623 c2623 = (C2623) it.next();
                C2471 c2471 = null;
                try {
                    c2471 = C2500.m6985(c2623.f7515);
                    if (c2471 != null) {
                        this.f7176 = false;
                        int m6829 = c2471.m6829();
                        this.f7174 = m6829;
                        if (m6829 == 0) {
                            this.f7176 = true;
                        }
                        C2975.m7942(String.format("%s bytes found, %s Mb", Integer.valueOf(m6829), Float.valueOf(this.f7174 / 1048576.0f)));
                    } else {
                        this.f7174 = 0;
                        this.f7176 = true;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    if (c2471 != null) {
                        c2471.m6832();
                    }
                }
                if (c2471 != null) {
                    c2471.m6832();
                }
                C3746 c3746 = C2975.f9277;
                if (c3746 != null && c3746.m8243()) {
                    C2975.f9277.m8247(this.f7174 / 1024);
                }
                this.f7177 = false;
                if (new File(C2975.f9251 + "/Download/" + c2623.f7515).exists()) {
                    if (!this.f7176) {
                        C2975.m7942(Long.valueOf(new File(C2975.f9251 + "/Download/" + c2623.f7515).length()));
                        C2975.m7942(Integer.valueOf(this.f7174));
                        long length = new File(C2975.f9251 + "/Download/" + c2623.f7515).length();
                        int i = this.f7174;
                        if (length == i || i == 0) {
                            this.f7177 = true;
                        }
                    } else {
                        this.f7177 = true;
                    }
                }
                if (!this.f7176 && !this.f7177) {
                    try {
                        new C2483(c2623.f7515).m6851();
                    } catch (Throwable th) {
                        th.printStackTrace();
                        if (c2471 != null) {
                            c2471.m6832();
                        }
                    }
                    if (new File(C2975.f9251 + "/Download/" + c2623.f7515).exists()) {
                        if (new File(C2975.f9251 + "/Download/" + c2623.f7515).length() == this.f7174) {
                            this.f7177 = true;
                            this.f7178 = true;
                        } else {
                            this.f7175 = true;
                            this.f7177 = false;
                        }
                    }
                } else {
                    if (new File(C2975.f9251 + "/Download/" + c2623.f7515).exists() && !this.f7177) {
                        new File(C2975.f9251 + "/Download/" + c2623.f7515).delete();
                    }
                }
            }
            C2975.m7954(new RunnableC2535());
            if (this.f7175) {
                C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.corrupt_download));
                Iterator it2 = this.f7179.iterator();
                while (it2.hasNext()) {
                    C2623 c26232 = (C2623) it2.next();
                    if (new File(C2975.f9251 + "/Download/" + c26232.f7515).exists()) {
                        new File(C2975.f9251 + "/Download/" + c26232.f7515).delete();
                    }
                }
            }
            if (this.f7176 && !this.f7177) {
                C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.internet_not_found));
            }
            boolean z = this.f7177;
            if (z && !this.f7175) {
                if (z) {
                    try {
                        if (!this.f7178 && (runnable = this.f7180) != null) {
                            runnable.run();
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        C2975.m7962(C2500.m7007(R.string.warning), C2500.m7007(R.string.corrupt_download));
                        return;
                    }
                }
                if (this.f7178 && (runnable2 = this.f7181) != null) {
                    runnable2.run();
                }
            }
        }
    }

    public class RunnableC2536 implements Runnable {

        final Dialog f7184;

        RunnableC2536(Dialog dialog) {
            this.f7184 = dialog;
        }

        @Override
        public void run() {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                this.f7184.show();
            }
        }
    }

    public class RunnableC2537 implements Runnable {

        final File f7185;

        final Activity f7186;

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

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent();
                intent.setAction("android.settings.APPLICATION_SETTINGS");
                intent.setFlags(131072);
                if (C2975.f9245 != null) {
                    C2975.f9389 = new C2939(C2975.m7929(), RunnableC2537.this.f7185, false);
                    C2975.f9245.m1854(intent, C2975.f9397);
                }
            }
        }

        RunnableC2537(File file, Activity activity) {
            this.f7185 = file;
            this.f7186 = activity;
        }

        @Override
        public void run() {
            boolean canRequestPackageInstalls;
            if (C2975.f9299 < 26 && Settings.Secure.getInt(C2975.f9245.mo1874().getContentResolver(), "install_non_market_apps", 0) == 0) {
                C2500.m7125(C2500.m7007(R.string.warning), C2500.m7007(R.string.message_allow_non_market_app), new DialogInterfaceOnClickListenerC2538(), null, null);
            }
            if (C2975.f9299 >= 24) {
                Uri m1512 = FileProvider.m1512(this.f7186, PkgName.getPkgName() + ".provider", this.f7185);
                Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE");
                intent.setDataAndType(m1512, "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.f7186.startActivityForResult(intent, C2975.f9391);
                    return;
                } catch (Throwable th) {
                    if (C2975.f9299 >= 26) {
                        canRequestPackageInstalls = C2975.m7932().canRequestPackageInstalls();
                        if (!canRequestPackageInstalls) {
                            C2975.f9389 = new C2939(C2975.m7929(), this.f7185, false);
                            this.f7186.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C2975.f9397);
                        }
                    } else {
                        Intent intent2 = new Intent();
                        intent2.setAction("android.settings.APPLICATION_SETTINGS");
                        intent2.setFlags(131072);
                        if (C2975.f9245 != null) {
                            C2975.f9389 = new C2939(C2975.m7929(), this.f7185, false);
                            C2975.f9245.m1854(intent2, C2975.f9397);
                        }
                    }
                    th.printStackTrace();
                    return;
                }
            }
            Uri fromFile = Uri.fromFile(this.f7185);
            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.f7186.startActivity(intent3);
        }
    }

    public class RunnableC2539 implements Runnable {

        final Activity f7188;

        final String f7189;

        final String f7190;

        final String f7191;

        final DialogInterface.OnClickListener f7192;

        RunnableC2539(Activity activity, String str, String str2, String str3, DialogInterface.OnClickListener onClickListener) {
            this.f7188 = activity;
            this.f7189 = str;
            this.f7190 = str2;
            this.f7191 = str3;
            this.f7192 = onClickListener;
        }

        @Override
        public void run() {
            C2913 c2913 = new C2913(this.f7188);
            c2913.m7860(this.f7189);
            c2913.m7876(this.f7190);
            c2913.m7882(true);
            c2913.f9084 = true;
            c2913.m7865(false);
            c2913.m7875(this.f7191, this.f7192);
            try {
                C2500.m7119(c2913.m7851());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2540 implements Runnable {

        final File f7193;

        RunnableC2540(File file) {
            this.f7193 = file;
        }

        @Override
        public void run() {
            PackageInstaller packageInstaller;
            int createSession;
            OutputStream openWrite;
            try {
                packageInstaller = C2975.m7932().getPackageInstaller();
                PackageInstaller.Session session = null;
                try {
                    createSession = packageInstaller.createSession(new PackageInstaller.SessionParams(1));
                    session = packageInstaller.openSession(createSession);
                    C3549.m8199(C2500.m7007(R.string.wait), C2500.m7007(R.string.installer_slit_get_apk_from_apks), "", 1, 3, false);
                    if (!this.f7193.getAbsolutePath().toLowerCase().endsWith(".apk")) {
                        ZipFile zipFile = new ZipFile(this.f7193);
                        for (FileHeader fileHeader : zipFile.getFileHeaders()) {
                            String fileName = fileHeader.getFileName();
                            if (fileName.toLowerCase().endsWith(".apk")) {
                                C2975.m7942("for " + fileName);
                                C2975.m7942("size for entry:" + fileHeader.getUncompressedSize());
                                ZipInputStream inputStream = zipFile.getInputStream(fileHeader);
                                try {
                                    openWrite = session.openWrite(fileName, 0L, fileHeader.getUncompressedSize());
                                    try {
                                        C2500.m6879(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 {
                        C2975.m7942("session apk installer:" + this.f7193.getAbsolutePath());
                        FileInputStream fileInputStream = new FileInputStream(this.f7193);
                        try {
                            openWrite = session.openWrite(this.f7193.getName(), 0L, this.f7193.length());
                            try {
                                C2500.m6879(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(C2975.m7929(), (Class<?>) MyService.class);
                    intent.putExtra("com.ui.extra.file_name_for_install", this.f7193.getAbsolutePath());
                    session.commit(PendingIntent.getService(C2975.m7929(), 0, intent, 0).getIntentSender());
                } catch (Throwable th3) {
                    try {
                        th3.printStackTrace();
                        C2500.m7130(C2975.f9259, C2500.m7007(R.string.error), C2500.m7009(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 RunnableC2541 implements Runnable {

        final Activity f7195;

        final String f7196;

        final String f7197;

        RunnableC2541(Activity activity, String str, String str2) {
            this.f7195 = activity;
            this.f7196 = str;
            this.f7197 = str2;
        }

        @Override
        public void run() {
            C2913 c2913 = new C2913(this.f7195);
            c2913.m7860(this.f7196);
            c2913.m7876(this.f7197);
            c2913.m7882(true);
            c2913.m7873(R.string.ok, null);
            try {
                C2500.m7119(c2913.m7851());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2542 implements Runnable {

        final String f7198;

        final String f7199;

        final DialogInterface.OnClickListener f7200;

        final String f7201;

        final CompoundButton.OnCheckedChangeListener f7202;

        final boolean f7203;

        final boolean f7204;

        RunnableC2542(String str, String str2, DialogInterface.OnClickListener onClickListener, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, boolean z2) {
            this.f7198 = str;
            this.f7199 = str2;
            this.f7200 = onClickListener;
            this.f7201 = str3;
            this.f7202 = onCheckedChangeListener;
            this.f7203 = z;
            this.f7204 = z2;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    C2913 c2913 = new C2913(C2975.f9245.mo1874());
                    c2913.m7860(this.f7198).m7876(this.f7199).m7872(R.drawable.ic_angel).m7875(C2500.m7007(R.string.ok), this.f7200).m7866(this.f7201, this.f7202, this.f7203);
                    try {
                        if (this.f7204) {
                            Linkify.addLinks(c2913.f9086, 3);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                    }
                    Dialog m7851 = c2913.m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2543 implements Runnable {
        RunnableC2543() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_progress_get_classes));
                C2975.f9277.m8246(false, C2975.f9245.mo1874());
            }
        }
    }

    public class RunnableC2544 implements Runnable {

        final File f7206;

        final Activity f7207;

        final Integer f7208;

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

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent();
                intent.setAction("android.settings.APPLICATION_SETTINGS");
                intent.setFlags(131072);
                C2975 c2975 = C2975.f9245;
                if (c2975 != null) {
                    c2975.m1852(intent);
                    C2975.f9389 = new C2939(C2975.m7929(), RunnableC2544.this.f7206, false);
                    C2975.f9245.m1854(intent, C2975.f9397);
                }
            }
        }

        RunnableC2544(File file, Activity activity, Integer num) {
            this.f7206 = file;
            this.f7207 = activity;
            this.f7208 = num;
        }

        @Override
        public void run() {
            boolean canRequestPackageInstalls;
            if (C2975.f9299 < 26 && Settings.Secure.getInt(C2975.f9245.mo1874().getContentResolver(), "install_non_market_apps", 0) == 0) {
                C2500.m7125(C2500.m7007(R.string.warning), C2500.m7007(R.string.message_allow_non_market_app), new DialogInterfaceOnClickListenerC2545(), null, null);
            }
            if (Build.VERSION.SDK_INT >= 24) {
                Uri m1512 = FileProvider.m1512(this.f7207, PkgName.getPkgName() + ".provider", this.f7206);
                C2975.m7942("api 24 install");
                Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE");
                intent.setDataAndType(m1512, "application/vnd.android.package-archive");
                intent.setFlags(1);
                try {
                    this.f7207.startActivityForResult(intent, this.f7208.intValue());
                    return;
                } catch (Throwable th) {
                    if (C2975.f9299 >= 26) {
                        canRequestPackageInstalls = C2975.m7932().canRequestPackageInstalls();
                        if (!canRequestPackageInstalls) {
                            C2975.f9389 = new C2939(C2975.m7929(), this.f7206, false);
                            this.f7207.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C2975.f9397);
                        } else {
                            Intent intent2 = new Intent();
                            intent2.setAction("android.settings.APPLICATION_SETTINGS");
                            intent2.setFlags(131072);
                            if (C2975.f9245 != null) {
                                C2975.f9389 = new C2939(C2975.m7929(), this.f7206, false);
                                C2975.f9245.m1854(intent2, C2975.f9397);
                            }
                        }
                    }
                    th.printStackTrace();
                    return;
                }
            }
            Uri fromFile = Uri.fromFile(this.f7206);
            Intent intent3 = new Intent("android.intent.action.VIEW");
            intent3.setDataAndType(fromFile, "application/vnd.android.package-archive");
            intent3.setFlags(131072);
            this.f7207.startActivityForResult(intent3, this.f7208.intValue());
        }
    }

    public class RunnableC2546 implements Runnable {
        RunnableC2546() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_progress_strings_analisis));
                C2975.f9277.m8246(false, C2975.f9245.mo1874());
            }
        }
    }

    public class RunnableC2547 implements Runnable {

        final String f7211;

        final Activity f7212;

        RunnableC2547(String str, Activity activity) {
            this.f7211 = str;
            this.f7212 = activity;
        }

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

    public class RunnableC2548 implements Runnable {
        RunnableC2548() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_progress_data_parse));
                C2975.f9277.m8246(false, C2975.f9245.mo1874());
            }
        }
    }

    public class RunnableC2549 implements Runnable {

        final String f7214;

        RunnableC2549(String str) {
            this.f7214 = str;
        }

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

    public class RunnableC2550 implements Runnable {

        final String f7215;

        RunnableC2550(String str) {
            this.f7215 = str;
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_step2));
                try {
                    C2975.f9277.m8249(Integer.valueOf(this.f7215.replace("Progress size:", "")).intValue());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
            }
        }
    }

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

        @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 RunnableC2552 implements Runnable {

        final String f7217;

        RunnableC2552(String str) {
            this.f7217 = str;
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_step2));
                try {
                    C2975.f9277.m8247(Integer.valueOf(this.f7217.replace("Size file:", "")).intValue());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                C2975.f9277.m8250("%1d/%2d bytes");
            }
        }
    }

    public class RunnableC2553 implements Runnable {

        final File[] f7219;

        class RunnableC2554 implements Runnable {
            RunnableC2554() {
            }

            @Override
            public void run() {
                boolean z;
                Throwable th;
                IOException iOException;
                ObjectInputStream objectInputStream;
                try {
                    C2420 c2420 = new C2420(RunnableC2553.this.f7219[0].getAbsolutePath());
                    if (c2420.m6612(".lucky_patcher_backup") != null) {
                        Enumeration<C2419> m6611 = c2420.m6611();
                        File parentFile = C2975.m7929().getDatabasePath("a").getParentFile();
                        C2975.m7942(parentFile);
                        z = true;
                        ObjectInputStream objectInputStream2 = null;
                        while (m6611.hasMoreElements()) {
                            C2419 nextElement = m6611.nextElement();
                            String name = nextElement.getName();
                            if (name.toLowerCase().equals("settings.data")) {
                                C2975.m7942("found settings:" + name);
                                try {
                                    try {
                                        objectInputStream = new ObjectInputStream(new GZIPInputStream(c2420.m6613(nextElement)));
                                    } catch (Throwable th2) {
                                        th = th2;
                                    }
                                } catch (FileNotFoundException e) {
                                    e = e;
                                } catch (IOException e2) {
                                    e = e2;
                                } catch (ClassNotFoundException e3) {
                                    e = e3;
                                }
                                try {
                                    SharedPreferences.Editor edit = C2975.m7928().edit();
                                    edit.clear();
                                    for (Map.Entry entry : ((Map) objectInputStream.readObject()).entrySet()) {
                                        Object value = entry.getValue();
                                        String str = (String) entry.getKey();
                                        C2975.m7942(str + " " + value.toString());
                                        if (!str.equals("basepath") && !str.equals("path") && !str.equals("extStorageDirectory")) {
                                            if (value instanceof Boolean) {
                                                edit.putBoolean(str, ((Boolean) value).booleanValue());
                                            } else if (value instanceof Float) {
                                                edit.putFloat(str, ((Float) value).floatValue());
                                            } else if (value instanceof Integer) {
                                                edit.putInt(str, ((Integer) value).intValue());
                                            } else if (value instanceof Long) {
                                                edit.putLong(str, ((Long) value).longValue());
                                            } else if (value instanceof String) {
                                                edit.putString(str, (String) value);
                                            }
                                        } else {
                                            C2975.m7942("skip " + str);
                                        }
                                    }
                                    edit.commit();
                                    try {
                                        objectInputStream.close();
                                    } catch (IOException e4) {
                                        e4.printStackTrace();
                                        z = false;
                                        objectInputStream2 = objectInputStream;
                                    }
                                } catch (FileNotFoundException e5) {
                                    e = e5;
                                    objectInputStream2 = objectInputStream;
                                    e.printStackTrace();
                                    if (objectInputStream2 != null) {
                                        try {
                                            objectInputStream2.close();
                                        } catch (IOException e6) {
                                            iOException = e6;
                                            iOException.printStackTrace();
                                            objectInputStream = objectInputStream2;
                                            z = false;
                                            objectInputStream2 = objectInputStream;
                                        }
                                    }
                                    objectInputStream = objectInputStream2;
                                    z = false;
                                    objectInputStream2 = objectInputStream;
                                } catch (IOException e7) {
                                    e = e7;
                                    objectInputStream2 = objectInputStream;
                                    e.printStackTrace();
                                    if (objectInputStream2 != null) {
                                        try {
                                            objectInputStream2.close();
                                        } catch (IOException e8) {
                                            iOException = e8;
                                            iOException.printStackTrace();
                                            objectInputStream = objectInputStream2;
                                            z = false;
                                            objectInputStream2 = objectInputStream;
                                        }
                                    }
                                    objectInputStream = objectInputStream2;
                                    z = false;
                                    objectInputStream2 = objectInputStream;
                                } catch (ClassNotFoundException e9) {
                                    e = e9;
                                    objectInputStream2 = objectInputStream;
                                    e.printStackTrace();
                                    if (objectInputStream2 != null) {
                                        try {
                                            objectInputStream2.close();
                                        } catch (IOException e10) {
                                            iOException = e10;
                                            iOException.printStackTrace();
                                            objectInputStream = objectInputStream2;
                                            z = false;
                                            objectInputStream2 = objectInputStream;
                                        }
                                    }
                                    objectInputStream = objectInputStream2;
                                    z = false;
                                    objectInputStream2 = objectInputStream;
                                } catch (Throwable th3) {
                                    th = th3;
                                    objectInputStream2 = objectInputStream;
                                    if (objectInputStream2 != null) {
                                        try {
                                            objectInputStream2.close();
                                            throw th;
                                        } catch (IOException e11) {
                                            e11.printStackTrace();
                                            throw th;
                                        }
                                    }
                                    throw th;
                                }
                                objectInputStream2 = objectInputStream;
                            } else if (nextElement.getName().equals(".lucky_patcher_backup")) {
                                C2975.m7942("skip " + nextElement.getName());
                            } else if (nextElement.getName().equals("BillingRestoreTransactions")) {
                                InputStream m6613 = c2420.m6613(nextElement);
                                File file = new File(C2500.m7005() + nextElement.getName());
                                C2500.m6876(m6613, file);
                                if (nextElement.getSize() == file.length()) {
                                    C2975.m7942("copy database:" + nextElement.getName() + " to " + file.getAbsolutePath());
                                    new C2636(C2975.m7929()).m7278(file);
                                } else {
                                    z = false;
                                }
                                file.delete();
                            } else {
                                C2975.m7942("copy database:" + nextElement.getName());
                                InputStream m66132 = c2420.m6613(nextElement);
                                File file2 = new File(parentFile + InternalZipConstants.ZIP_FILE_SEPARATOR + nextElement.getName());
                                C2500.m6876(m66132, file2);
                                if (nextElement.getSize() == file2.length()) {
                                    C2975.m7942("database " + file2 + " copied to " + parentFile);
                                } else {
                                    z = false;
                                }
                            }
                        }
                    } else {
                        z = false;
                    }
                    c2420.close();
                } catch (Throwable th4) {
                    th4.printStackTrace();
                    z = false;
                }
                if (z) {
                    C2500.m7130(C2975.f9259, C2500.m7007(R.string.information), C2500.m7007(R.string.lp_backups_import_succes) + " " + RunnableC2553.this.f7219[0].getName());
                    return;
                }
                C2500.m7130(C2975.f9259, C2500.m7007(R.string.error), C2500.m7007(R.string.lp_backups_import_failed));
            }
        }

        RunnableC2553(File[] fileArr) {
            this.f7219 = fileArr;
        }

        @Override
        public void run() {
            C2975.m7956(new RunnableC2554());
        }
    }

    public class RunnableC2555 implements Runnable {
        RunnableC2555() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_step3));
                C2975.f9277.m8247(6);
                C2975.f9277.m8249(3);
                C2975.f9277.m8250("%1d/%2d");
            }
        }
    }

    public class RunnableC2556 implements Runnable {

        final boolean f7222;

        class RunnableC2557 implements Runnable {
            RunnableC2557() {
            }

            @Override
            public void run() {
                try {
                    if (C2975.f9264 != null) {
                        C2975.m7951(11);
                        C2975.f9264.notifyDataSetChanged();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        RunnableC2556(boolean z) {
            this.f7222 = z;
        }

        @Override
        public void run() {
            ServiceInfo[] serviceInfoArr;
            new ArrayList();
            PackageInfo m6974 = C2500.m6974("com.android.vending", 516);
            if (m6974 != null && (serviceInfoArr = m6974.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = m6974.services;
                    if (i >= serviceInfoArr2.length) {
                        break;
                    }
                    try {
                        if (!this.f7222) {
                            if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || m6974.services[i].name.endsWith("MarketBillingService")) && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", m6974.services[i].name)) != 2) {
                                new C2500("").m7211("pm disable 'com.android.vending/" + m6974.services[i].name + "'");
                            }
                        } else if ((serviceInfoArr2[i].name.endsWith("InAppBillingService") || m6974.services[i].name.endsWith("MarketBillingService")) && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", m6974.services[i].name)) != 1) {
                            new C2500("").m7211("pm enable 'com.android.vending/" + m6974.services[i].name + "'");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    i++;
                }
                if (C2975.f9245 != null) {
                    C2975.m7954(new RunnableC2557());
                }
            }
        }
    }

    public class RunnableC2558 implements Runnable {
        RunnableC2558() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_step4));
                C2975.f9277.m8249(4);
            }
        }
    }

    public class RunnableC2559 implements Runnable {

        final boolean f7225;

        class RunnableC2560 implements Runnable {
            RunnableC2560() {
            }

            @Override
            public void run() {
                try {
                    if (C2975.f9264 != null) {
                        C2975.m7951(11);
                        C2975.f9264.notifyDataSetChanged();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        RunnableC2559(boolean z) {
            this.f7225 = z;
        }

        @Override
        public void run() {
            ServiceInfo[] serviceInfoArr;
            new ArrayList();
            PackageInfo m6974 = C2500.m6974("com.android.vending", 516);
            if (m6974 != null && (serviceInfoArr = m6974.services) != null && serviceInfoArr.length != 0) {
                int i = 0;
                while (true) {
                    ServiceInfo[] serviceInfoArr2 = m6974.services;
                    if (i >= serviceInfoArr2.length) {
                        break;
                    }
                    try {
                        if (!this.f7225) {
                            if (serviceInfoArr2[i].name.endsWith("LicensingService") && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", m6974.services[i].name)) != 2) {
                                new C2500("").m7211("pm disable 'com.android.vending/" + m6974.services[i].name + "'");
                            }
                        } else if (serviceInfoArr2[i].name.endsWith("LicensingService") && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", m6974.services[i].name)) != 1) {
                            new C2500("").m7211("pm enable 'com.android.vending/" + m6974.services[i].name + "'");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    i++;
                }
                if (C2975.f9245 != null) {
                    C2975.m7954(new RunnableC2560());
                }
            }
        }
    }

    public class RunnableC2561 implements Runnable {
        RunnableC2561() {
        }

        @Override
        public void run() {
            C3746 c3746 = C2975.f9277;
            if (c3746 != null && c3746.m8243()) {
                C2975.f9277.m8248(C2500.m7007(R.string.patch_step6));
                C2975.f9277.m8249(6);
            }
        }
    }

    public class RunnableC2562 implements Runnable {

        final String f7228;

        final String f7229;

        class ServiceConnectionC2563 implements ServiceConnection {

            boolean f7230 = false;

            class DialogInterfaceOnClickListenerC2564 implements DialogInterface.OnClickListener {

                class RunnableC2565 implements Runnable {

                    final Intent f7233;

                    RunnableC2565(Intent intent) {
                        this.f7233 = intent;
                    }

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

                DialogInterfaceOnClickListenerC2564() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m6902 = C2500.m6902();
                    if (m6902 != null) {
                        C2975.m7954(new RunnableC2565(m6902));
                    } else {
                        C2500.m7116(RunnableC2562.this.f7229);
                    }
                }
            }

            class DialogInterfaceOnClickListenerC2566 implements DialogInterface.OnClickListener {

                class RunnableC2567 implements Runnable {

                    final Intent f7236;

                    RunnableC2567(Intent intent) {
                        this.f7236 = intent;
                    }

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

                DialogInterfaceOnClickListenerC2566() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m6902 = C2500.m6902();
                    if (m6902 != null) {
                        C2975.m7954(new RunnableC2567(m6902));
                    } else {
                        C2500.m7116(RunnableC2562.this.f7229);
                    }
                }
            }

            class DialogInterfaceOnClickListenerC2568 implements DialogInterface.OnClickListener {

                class RunnableC2569 implements Runnable {

                    final Intent f7239;

                    RunnableC2569(Intent intent) {
                        this.f7239 = intent;
                    }

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

                DialogInterfaceOnClickListenerC2568() {
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent m6902 = C2500.m6902();
                    if (m6902 != null) {
                        C2975.m7954(new RunnableC2569(m6902));
                    } else {
                        C2500.m7116(RunnableC2562.this.f7229);
                    }
                }
            }

            ServiceConnectionC2563() {
            }

            @Override
            public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
                if (RunnableC2562.this.f7229.equals(C2975.f9237)) {
                    try {
                        if (InterfaceC2466.AbstractBinderC2467.m6802(iBinder).mo3532(3, C2975.m7929().getPackageName(), "inapp") == 0) {
                            C2975.m7962(C2500.m7007(R.string.information), C2500.m7007(R.string.test_services_for_work_success));
                            C2975.m7951(1);
                        } else {
                            try {
                                C2500.m7125(C2500.m7007(R.string.warning), C2500.m7009(R.string.test_services_for_work_failed, C2975.m7932().getApplicationInfo(RunnableC2562.this.f7229, ItemType.CLASS_DATA_ITEM).loadLabel(C2975.m7932()).toString()), new DialogInterfaceOnClickListenerC2564(), null, null);
                            } catch (PackageManager.NameNotFoundException e) {
                                e.printStackTrace();
                            }
                            String str = C2975.f9234;
                            C2975.m7951(1);
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                        try {
                            C2500.m7125(C2500.m7007(R.string.warning), C2500.m7009(R.string.test_services_for_work_failed, C2975.m7932().getApplicationInfo(RunnableC2562.this.f7229, ItemType.CLASS_DATA_ITEM).loadLabel(C2975.m7932()).toString()), new DialogInterfaceOnClickListenerC2566(), null, null);
                        } catch (PackageManager.NameNotFoundException e2) {
                            e2.printStackTrace();
                        }
                        String str2 = C2975.f9234;
                        C2975.m7951(1);
                    }
                } else {
                    C2975.m7962(C2500.m7007(R.string.information), C2500.m7007(R.string.test_services_for_work_success));
                    C2975.m7951(1);
                }
                this.f7230 = true;
                C2975.m7929().unbindService(this);
            }

            @Override
            public void onServiceDisconnected(ComponentName componentName) {
                if (!this.f7230) {
                    try {
                        C2500.m7125(C2500.m7007(R.string.warning), C2500.m7009(R.string.test_services_for_work_failed, C2975.m7932().getApplicationInfo(RunnableC2562.this.f7229, ItemType.CLASS_DATA_ITEM).loadLabel(C2975.m7932()).toString()), new DialogInterfaceOnClickListenerC2568(), null, null);
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                    }
                }
                String str = C2975.f9234;
                C2975.m7951(1);
            }
        }

        class DialogInterfaceOnClickListenerC2570 implements DialogInterface.OnClickListener {

            class RunnableC2571 implements Runnable {

                final Intent f7242;

                RunnableC2571(Intent intent) {
                    this.f7242 = intent;
                }

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

            DialogInterfaceOnClickListenerC2570() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent m6902 = C2500.m6902();
                if (m6902 != null) {
                    C2975.m7954(new RunnableC2571(m6902));
                } else {
                    C2500.m7116(RunnableC2562.this.f7229);
                }
            }
        }

        class DialogInterfaceOnClickListenerC2572 implements DialogInterface.OnClickListener {

            class RunnableC2573 implements Runnable {

                final Intent f7245;

                RunnableC2573(Intent intent) {
                    this.f7245 = intent;
                }

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

            DialogInterfaceOnClickListenerC2572() {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent m6902 = C2500.m6902();
                if (m6902 != null) {
                    C2975.m7954(new RunnableC2573(m6902));
                } else {
                    C2500.m7116(RunnableC2562.this.f7229);
                }
            }
        }

        RunnableC2562(String str, String str2) {
            this.f7228 = str;
            this.f7229 = str2;
        }

        @Override
        public void run() {
            if (C2975.f9245 != null) {
                C2975.m7960(1);
                C3740 c3740 = C2975.f9275;
                if (c3740 != null) {
                    c3740.m8231(true);
                    C2975.f9275.m8232(C2500.m7007(R.string.test_services_for_work_progress));
                }
                Intent intent = new Intent(this.f7228);
                intent.setPackage(this.f7229);
                try {
                    if (!C2975.m7929().bindService(intent, new ServiceConnectionC2563(), 1)) {
                        try {
                            C2500.m7125(C2500.m7007(R.string.warning), C2500.m7009(R.string.test_services_for_work_failed, C2975.m7932().getApplicationInfo(this.f7229, ItemType.CLASS_DATA_ITEM).loadLabel(C2975.m7932()).toString()), new DialogInterfaceOnClickListenerC2570(), null, null);
                        } catch (PackageManager.NameNotFoundException e) {
                            e.printStackTrace();
                        }
                        String str = C2975.f9234;
                        C2975.m7951(1);
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                    try {
                        C2500.m7125(C2500.m7007(R.string.warning), C2500.m7009(R.string.test_services_for_work_failed, C2975.m7932().getApplicationInfo(this.f7229, ItemType.CLASS_DATA_ITEM).loadLabel(C2975.m7932()).toString()), new DialogInterfaceOnClickListenerC2572(), null, null);
                    } catch (PackageManager.NameNotFoundException e2) {
                        e2.printStackTrace();
                    }
                    String str2 = C2975.f9234;
                    C2975.m7951(1);
                }
            }
        }
    }

    public class RunnableC2574 implements Runnable {

        final String f7247;

        final String f7248;

        final DialogInterface.OnClickListener f7249;

        final DialogInterface.OnClickListener f7250;

        final DialogInterface.OnCancelListener f7251;

        RunnableC2574(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
            this.f7247 = str;
            this.f7248 = str2;
            this.f7249 = onClickListener;
            this.f7250 = onClickListener2;
            this.f7251 = onCancelListener;
        }

        @Override
        public void run() {
            try {
                MainActivity mainActivity = C2975.f9259;
                if (mainActivity != null && !mainActivity.isFinishing()) {
                    Dialog m7851 = new C2913(C2975.f9245.mo1874()).m7860(this.f7247).m7876(this.f7248).m7872(R.drawable.ic_vopros).m7875(C2500.m7007(R.string.Yes), this.f7249).m7878(C2500.m7007(R.string.no), this.f7250).m7881(this.f7251).m7851();
                    C2500.m7117(m7851);
                    m7851.findViewById(android.R.id.message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public class RunnableC2575 implements Runnable {

        final String f7252;

        final Activity f7253;

        final Integer f7254;

        RunnableC2575(String str, Activity activity, Integer num) {
            this.f7252 = str;
            this.f7253 = activity;
            this.f7254 = num;
        }

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

    public class C2576 implements Comparator<C2618> {
        C2576() {
        }

        @Override
        public int compare(C2618 c2618, C2618 c26182) {
            if (c2618.f7475.equals(c26182.f7475)) {
                return 0;
            }
            if (c2618.f7475.length() < c26182.f7475.length()) {
                return -1;
            }
            if (c2618.f7475.length() > c26182.f7475.length()) {
                return 1;
            }
            if (c2618.f7475.length() != c26182.f7475.length()) {
                return 0;
            }
            return c2618.f7475.compareTo(c26182.f7475);
        }
    }

    public class RunnableC2577 implements Runnable {

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

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

        RunnableC2577() {
        }

        @Override
        public void run() {
            C2500.m7131(C2500.m7007(R.string.warning), C2500.m7007(R.string.magisk_warning2), C2500.m7007(R.string.warning_superSu_mount_name_space_separation_3), new C2578(), false, null, true);
        }
    }

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

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

    public class C2580 extends ApplicationInfo {

        final File f7256;

        C2580(File file) {
            this.f7256 = file;
        }

        @Override
        public CharSequence loadLabel(PackageManager packageManager) {
            try {
                RandomAccessFile randomAccessFile = new RandomAccessFile(this.f7256, InternalZipConstants.READ_MODE);
                AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(C2500.m6916(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()) {
                        C2975.m7942(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) {
                                        C3867 c3867 = new C3867(C2500.m6987(DataSources.asDataSource(randomAccessFile)));
                                        c3867.m8460();
                                        C3961 m8459 = c3867.m8459();
                                        return m8459.m8686(androidBinXmlParser.getAttributeIntValue(i)).get(0).m8688().mo8670(m8459, null);
                                    }
                                } else {
                                    return androidBinXmlParser.getAttributeStringValue(i);
                                }
                            }
                        }
                        return null;
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            return null;
        }
    }

    class ViewOnKeyListenerC2581 implements View.OnKeyListener {

        final WindowManager f7257;

        ViewOnKeyListenerC2581(WindowManager windowManager) {
            this.f7257 = windowManager;
        }

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

    public class RunnableC2582 implements Runnable {

        final File[] f7258;

        class RunnableC2583 implements Runnable {

            class DialogInterfaceOnClickListenerC2584 implements DialogInterface.OnClickListener {

                final File f7260;

                DialogInterfaceOnClickListenerC2584(File file) {
                    this.f7260 = file;
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    String absolutePath = this.f7260.getAbsolutePath();
                    C2975.m7942("path_to_file:" + absolutePath);
                    Intent intent = new Intent("android.intent.action.SEND");
                    Uri parse = Uri.parse("file://" + absolutePath);
                    if (C2975.f9299 >= 24) {
                        parse = FileProvider.m1512(C2975.f9259, PkgName.getPkgName() + ".provider", new File(absolutePath));
                    }
                    intent.setType("*/*");
                    intent.putExtra("android.intent.extra.STREAM", parse);
                    String name = this.f7260.getName();
                    intent.setFlags(131072);
                    intent.addFlags(1);
                    MainActivity mainActivity = C2975.f9259;
                    if (mainActivity != null) {
                        mainActivity.startActivity(Intent.createChooser(intent, C2500.m7007(R.string.share) + " " + name));
                    }
                }
            }

            RunnableC2583() {
            }

            @Override
            public void run() {
                boolean z;
                ObjectOutputStream objectOutputStream;
                ArrayList arrayList = new ArrayList();
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
                StringBuilder sb = new StringBuilder();
                boolean z2 = false;
                sb.append(RunnableC2582.this.f7258[0].getAbsolutePath());
                sb.append("/lp_settings");
                sb.append(simpleDateFormat.format(Long.valueOf(System.currentTimeMillis())));
                sb.append(".zip");
                File file = new File(sb.toString());
                HashMap hashMap = new HashMap(C2975.m7928().getAll());
                File file2 = new File(C2500.m7005() + "settings.data");
                ObjectOutputStream objectOutputStream2 = null;
                try {
                    try {
                        try {
                            objectOutputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(file2)));
                        } catch (IOException e) {
                            e.printStackTrace();
                            z = false;
                            if (file2.exists()) {
                                arrayList.add(file2);
                            }
                            File parentFile = C2975.m7929().getDatabasePath("a").getParentFile();
                            C2975.m7942(parentFile);
                            while (r8 < r4) {
                            }
                            File file3 = new File(C2500.m7005() + ".lucky_patcher_backup");
                            file3.createNewFile();
                            z2 = z;
                            arrayList.add(file3);
                            C2500.m7166(arrayList, file);
                            C2500.m6992(new File(C2500.m7005()));
                            if (!z2) {
                            }
                        }
                    } catch (FileNotFoundException e2) {
                        e = e2;
                    } catch (IOException e3) {
                        e = e3;
                    }
                } catch (Throwable th) {
                    th = th;
                }
                try {
                    objectOutputStream.writeObject(hashMap);
                    objectOutputStream.flush();
                    objectOutputStream.close();
                    z = true;
                } catch (FileNotFoundException e4) {
                    e = e4;
                    objectOutputStream2 = objectOutputStream;
                    e.printStackTrace();
                    if (objectOutputStream2 != null) {
                        objectOutputStream2.flush();
                        objectOutputStream2.close();
                    }
                    z = false;
                    if (file2.exists()) {
                    }
                    File parentFile2 = C2975.m7929().getDatabasePath("a").getParentFile();
                    C2975.m7942(parentFile2);
                    while (r8 < r4) {
                    }
                    File file32 = new File(C2500.m7005() + ".lucky_patcher_backup");
                    file32.createNewFile();
                    z2 = z;
                    arrayList.add(file32);
                    C2500.m7166(arrayList, file);
                    C2500.m6992(new File(C2500.m7005()));
                    if (!z2) {
                    }
                } catch (IOException e5) {
                    e = e5;
                    objectOutputStream2 = objectOutputStream;
                    e.printStackTrace();
                    if (objectOutputStream2 != null) {
                        objectOutputStream2.flush();
                        objectOutputStream2.close();
                    }
                    z = false;
                    if (file2.exists()) {
                    }
                    File parentFile22 = C2975.m7929().getDatabasePath("a").getParentFile();
                    C2975.m7942(parentFile22);
                    while (r8 < r4) {
                    }
                    File file322 = new File(C2500.m7005() + ".lucky_patcher_backup");
                    file322.createNewFile();
                    z2 = z;
                    arrayList.add(file322);
                    C2500.m7166(arrayList, file);
                    C2500.m6992(new File(C2500.m7005()));
                    if (!z2) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    objectOutputStream2 = objectOutputStream;
                    if (objectOutputStream2 != null) {
                        try {
                            objectOutputStream2.flush();
                            objectOutputStream2.close();
                        } catch (IOException e6) {
                            e6.printStackTrace();
                        }
                    }
                    throw th;
                }
                if (file2.exists() && file2.length() != 0) {
                    arrayList.add(file2);
                }
                File parentFile222 = C2975.m7929().getDatabasePath("a").getParentFile();
                C2975.m7942(parentFile222);
                for (File file4 : parentFile222.listFiles()) {
                    C2975.m7942(file4.getAbsolutePath());
                    if (file4.length() != 0) {
                        arrayList.add(file4);
                    }
                }
                File file3222 = new File(C2500.m7005() + ".lucky_patcher_backup");
                file3222.createNewFile();
                z2 = z;
                arrayList.add(file3222);
                C2500.m7166(arrayList, file);
                C2500.m6992(new File(C2500.m7005()));
                if (!z2) {
                    C2500.m7121(C2500.m7007(R.string.information), C2500.m7007(R.string.lp_backups_export_succes) + ": " + file.getAbsolutePath(), C2500.m7007(R.string.ok), null, C2500.m7007(R.string.share), new DialogInterfaceOnClickListenerC2584(file), null);
                    return;
                }
                C2500.m7130(C2975.f9259, C2500.m7007(R.string.warning), C2500.m7007(R.string.lp_backups_export_failed));
            }
        }

        RunnableC2582(File[] fileArr) {
            this.f7258 = fileArr;
        }

        @Override
        public void run() {
            if (C2500.m7144(true, this.f7258[0].getAbsolutePath())) {
                C2975.m7956(new RunnableC2583());
            }
        }
    }

    class ViewOnClickListenerC2585 implements View.OnClickListener {

        final WindowManager f7262;

        ViewOnClickListenerC2585(WindowManager windowManager) {
            this.f7262 = windowManager;
        }

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

    public class RunnableC2586 implements Runnable {

        final String f7263;

        final String f7264;

        final DialogInterface.OnClickListener f7265;

        final DialogInterface.OnCancelListener f7266;

        RunnableC2586(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) {
            this.f7263 = str;
            this.f7264 = str2;
            this.f7265 = onClickListener;
            this.f7266 = onCancelListener;
        }

        @Override
        public void run() {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C2913 c2913 = new C2913(C2975.f9245.mo1874());
                c2913.m7860(this.f7263).m7876(this.f7264).m7872(R.drawable.ic_angel).m7875(C2500.m7007(R.string.ok), this.f7265).m7881(this.f7266);
                Dialog m7851 = c2913.m7851();
                C2500.m7117(m7851);
                m7851.findViewById(android.R.id.message);
            }
        }
    }

    class ViewOnKeyListenerC2587 implements View.OnKeyListener {

        final WindowManager f7267;

        ViewOnKeyListenerC2587(WindowManager windowManager) {
            this.f7267 = windowManager;
        }

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

    public class ServiceConnectionC2588 implements ServiceConnection {
        ServiceConnectionC2588() {
        }

        @Override
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            InterfaceC1470 m5342 = InterfaceC1470.AbstractBinderC1471.m5342(iBinder);
            C2500.f7067 = m5342;
            boolean z = false;
            if (m5342 != null) {
                try {
                    z = m5342.mo5341();
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
            C2975.m7942("TestService:" + z);
            C2975.m7942("TestService:" + z);
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            C2975.m7942("test service disconnected.");
            C2500.f7067 = null;
        }
    }

    public C2500(String str) {
    }

    public static boolean m6868(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()) {
            C2975.m7942("not found dir for ectract xz.");
            return false;
        }
        if (str.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
            file2 = new File(str + m7079(file.getName()));
        } else {
            file2 = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + m7079(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 m6869() {
        long j;
        long j2;
        long length;
        PackageInfo m6974 = m6974("com.android.vending", 0);
        if (m6974 != null) {
            File file = new File(m6976(m6974.applicationInfo.sourceDir, true));
            File m6947 = m6947(m6974.applicationInfo.sourceDir);
            File file2 = null;
            if (m6947 != null) {
                try {
                    j = m6947.length();
                    try {
                        File file3 = new File(m7176(m6947.getAbsolutePath(), "vdex"));
                        try {
                            j2 = file3.length();
                            file2 = file3;
                        } catch (Exception e) {
                            e = e;
                            j2 = 0;
                            file2 = file3;
                            e.printStackTrace();
                            if (file2 != null) {
                            }
                            if (m6947 != null) {
                                j = m6947.length();
                            }
                            length = j2;
                            C2975.m7942("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(m7176(file.getAbsolutePath(), "vdex")).length();
            } catch (Exception e4) {
                e = e4;
                e.printStackTrace();
                if (file2 != null) {
                    try {
                    } catch (Exception e5) {
                        e5.printStackTrace();
                        length = j2;
                        C2975.m7942("vdex=" + length + " odex=" + j);
                        if (j < 225280) {
                        }
                        return false;
                    }
                    if (file2.exists()) {
                        length = file2.length();
                        C2975.m7942("vdex=" + length + " odex=" + j);
                        if (j < 225280) {
                            if (length != 0) {
                            }
                        }
                        return false;
                    }
                }
                if (m6947 != null && m6947.exists()) {
                    j = m6947.length();
                }
                length = j2;
                C2975.m7942("vdex=" + length + " odex=" + j);
                if (j < 225280) {
                }
                return false;
            }
            C2975.m7942("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 ArrayList<String> m6870(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[] m6871(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 void m6872(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();
                C2975.m7942(" " + 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();
                        C2975.m7942(" " + 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) {
            C2975.m7942("" + trim);
            C2975.m7942("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 m6873(String str) {
        if (str != null) {
            return str.replaceAll(":", " ").replaceAll("\\s+", ".").replaceAll(InternalZipConstants.ZIP_FILE_SEPARATOR, ".");
        }
        return "null";
    }

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

    public static void m6875(File file, File file2) {
        Throwable th;
        AbstractInterruptibleChannel abstractInterruptibleChannel;
        FileChannel channel;
        int i;
        boolean z;
        String[] strArr;
        m7179();
        if (!m6942(file2).exists()) {
            m6942(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")) {
                                    C2975.m7942("try copy with root");
                                    if (C2975.f9283) {
                                        if (m6989()) {
                                            String file3 = file.getAbsoluteFile().toString();
                                            String file4 = file2.getAbsoluteFile().toString();
                                            String[] strArr2 = new String[i];
                                            strArr2[0] = "dd if=" + file3 + " of=" + file4;
                                            m7019(strArr2);
                                            String[] strArr3 = C2975.f9295;
                                            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;
                                                    m7019(strArr4);
                                                    i2++;
                                                    i = 1;
                                                }
                                            }
                                            if (file.length() != file2.length()) {
                                                file2.delete();
                                            }
                                        } else {
                                            m6877(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 (C2975.f9283 && !z) {
                            if (C2975.f9323.booleanValue()) {
                                String file5 = file.getAbsoluteFile().toString();
                                String file6 = file2.getAbsoluteFile().toString();
                                m7098("dd", "if=" + file5, "of=" + file6);
                                if ((!new File(file6).exists() || file.length() != file2.length()) && (strArr = C2975.f9295) != null) {
                                    for (String str2 : strArr) {
                                        m7098(str2, "dd", "if=" + file5, "of=" + file6);
                                        if (new File(file6).exists() && file.length() == file2.length()) {
                                            break;
                                        }
                                    }
                                }
                                if (file.length() != file2.length()) {
                                    file2.delete();
                                }
                            } else {
                                m6877(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 m6876(InputStream inputStream, File file) {
        m7179();
        if (!m6942(file).exists()) {
            m6942(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 m6877(String str, String str2, boolean z, boolean z2) {
        String str3 = "777";
        int i = 1;
        if (!C2975.f9323.booleanValue()) {
            try {
                if (m6898(str)) {
                    if (z) {
                        m7078(str2, "RW");
                    }
                    if (!z2) {
                        str3 = "";
                    } else {
                        String m6971 = m6971(str);
                        if (m6971 != null) {
                            try {
                                if (!m6971.equals("")) {
                                    str3 = m6971;
                                }
                            } catch (Exception unused) {
                            }
                        }
                    }
                    m6900();
                    new C2500("").m7211("dd if=" + str + " of=" + str2);
                    File file = new File(str);
                    File file2 = new File(str2);
                    String[] strArr = C2975.f9295;
                    if (strArr != null) {
                        int length = strArr.length;
                        int i2 = 0;
                        while (i2 < length) {
                            String str4 = strArr[i2];
                            if (m6898(str2) && file.length() == file2.length()) {
                                break;
                            }
                            C2500 c2500 = new C2500("");
                            String[] strArr2 = new String[i];
                            strArr2[0] = str4 + " dd if=" + str + " of=" + str2;
                            c2500.m7211(strArr2);
                            i2++;
                            i = 1;
                        }
                        if (!m6898(str2)) {
                            new C2500("").m7211(C2975.f9250 + "/busybox cp -fp " + str + " " + str2);
                        }
                    }
                    m7091(str2);
                    if (z2) {
                        m7093("chmod " + str3 + " " + str2);
                    }
                }
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
        File file3 = new File(str);
        File file4 = new File(str2);
        if (z) {
            m7078(str2, "RW");
        }
        if (!z2) {
            str3 = "";
        } else {
            String m69712 = m6971(str);
            if (m69712 != null) {
                try {
                    if (!m69712.equals("")) {
                        str3 = m69712;
                    }
                } catch (Exception unused2) {
                }
            }
        }
        m7098("dd", "if=" + str, "of=" + str2);
        String[] strArr3 = C2975.f9295;
        if (strArr3 != null) {
            for (String str5 : strArr3) {
                if (new File(str2).exists() && file3.length() == file4.length()) {
                    break;
                }
                m7098(str5, "dd", "if=" + str, "of=" + str2);
            }
            if (!new File(str2).exists() || file3.length() != file4.length()) {
                m7098(C2975.f9250 + "/busybox", "dd", "if=" + str, "of=" + str2);
            }
        }
        if (!new File(str2).exists() || file3.length() != file4.length()) {
            m6875(file3, file4);
        }
        m7091(str2);
        if (file3.length() == file4.length()) {
            if (z2) {
                m7094("chmod", str3, str2);
                return true;
            }
            return true;
        }
        file4.delete();
        C2975.m7942("LuckyPatcher (cmdCopy): error copy... not enougth space to destination.");
        return false;
    }

    public static void m6878(File file, File file2, String[] strArr) throws Exception {
        boolean z;
        boolean z2;
        m7179();
        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();
                    C2975.m7942("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) {
                            m6878(file3, file4, strArr);
                        }
                    }
                    return;
                }
                return;
            }
            return;
        }
        m6875(file, file2);
    }

    public static void m6879(InputStream inputStream, OutputStream outputStream) throws IOException {
        m7179();
        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 m6880(String str) {
        File file = new File(m6969() + str);
        if (!new File(m6969()).exists()) {
            new File(m6969()).mkdirs();
        }
        String[] strArr = {"odex", "oat", "art", "vdex", "jar"};
        for (int i = 0; i < 5; i++) {
            String m7176 = m7176(str, strArr[i]);
            File file2 = new File(m6969() + m7176);
            if (new File(m7176).exists() && ((new File(m7176).length() != 0 && file2.exists() && file2.length() != new File(m7176).length()) || !file2.exists() || file2.length() == 0)) {
                m6877(m7176, file2.getAbsolutePath(), true, true);
                if (file2.length() == 0) {
                    file2.delete();
                } else {
                    m6884();
                    m7094("chmod", "0644", file.getAbsolutePath());
                    m7094("chown", "0:0", file.getAbsolutePath());
                    m7094("chmod", "0.0", file.getAbsolutePath());
                }
            }
        }
        return file;
    }

    public static File m6881(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 m6922 = m6922(next.getAbsolutePath(), 1);
                    String str6 = m6922.packageName;
                    str4 = m6921(next.getAbsolutePath());
                    str2 = "" + m6922.versionName;
                    String str7 = "" + m6922.versionCode;
                    Drawable m6919 = m6919(next.getAbsolutePath());
                    C2975.m7942("iconka:" + m6919);
                    loadIcon = m6919;
                    str = str6;
                    str3 = str7;
                    break;
                }
            }
            str3 = "";
            str4 = str3;
            str2 = str4;
            loadIcon = null;
        } else {
            try {
                PackageInfo packageInfo = C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM);
                str4 = packageInfo.applicationInfo.loadLabel(C2975.m7932()).toString();
                try {
                    str2 = "" + packageInfo.versionName;
                } catch (PackageManager.NameNotFoundException e) {
                    str2 = "";
                    nameNotFoundException = e;
                    str3 = str2;
                }
                try {
                    str5 = "" + packageInfo.versionCode;
                    str3 = str5;
                    loadIcon = C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.loadIcon(C2975.m7932());
                } 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 = m7005() + "tmp/";
                        new File(str9).mkdirs();
                        file2 = new File(str9 + "icon.png");
                        if (loadIcon != null) {
                        }
                        m7167(arrayList, zipOutputStream);
                        C2975.m7942(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(C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir));
                strArr = C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.splitSourceDirs;
                for (String str10 : strArr) {
                    arrayList22.add(new File(str10));
                }
                arrayList = arrayList22;
            }
            String str92 = m7005() + "tmp/";
            new File(str92).mkdirs();
            file2 = new File(str92 + "icon.png");
            if (loadIcon != null) {
                Bitmap m6897 = m6897(loadIcon);
                C2975.m7942("image:" + m6897);
                if (m6897 != null) {
                    if (file2.exists()) {
                        file2.delete();
                    }
                    m6897.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(file2));
                    if (file2.exists() && file2.length() > 0) {
                        arrayList.add(file2);
                    }
                }
            }
            m7167(arrayList, zipOutputStream);
            C2975.m7942(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 m6882(String str) {
        String sb;
        new File(C2975.f9251 + "/Backup/").mkdirs();
        try {
            if (C2975.m7928().getInt("apkname", 0) != 0) {
                sb = C2975.f9251 + "/Backup/" + str + ".ver." + m6873(m6975(str)) + ".build." + C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).versionCode + ".apks";
            } else {
                StringBuilder sb2 = new StringBuilder();
                sb2.append(C2975.f9251);
                sb2.append("/Backup/");
                sb2.append(m6873("" + ((Object) C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.loadLabel(C2975.m7932())) + ".ver." + m6975(str)));
                sb2.append(".build.");
                sb2.append(C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).versionCode);
                sb2.append(".apks");
                sb = sb2.toString();
            }
            if (new File(sb).exists()) {
                new File(sb).delete();
            }
            File m6881 = m6881(new File(sb), null, str);
            if (m6881 != null) {
                return m6881.getAbsolutePath();
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return "";
    }

    public static Element m6883(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 m6884() {
        String m6969 = m6969();
        if (!new File(m6969 + "/module.prop").exists()) {
            long m6905 = m6905();
            m7101(new File(m6969 + "/module.prop"), "id=luckypatcher\nname=Patches to Android (Lucky Patcher Module)\nversion=" + m6905 + "\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(m6905);
            C2975.m7942(sb.toString());
            return;
        }
        long m6958 = m6958();
        if (m6905() != m6958) {
            C2975.m7942("firmware updated: need clear magisk module android patches");
        }
        if (m6958 == 0 && m6959().equals("1.0")) {
            long m69052 = m6905();
            m7101(new File(m6969 + "/module.prop"), "id=luckypatcher\nname=Patches to Android (Lucky Patcher Module)\nversion=" + m69052 + "\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(m69052);
            C2975.m7942(sb2.toString());
        }
    }

    public static void m6885() {
        String m6970 = m6970();
        if (!new File(m6970 + "/module.prop").exists()) {
            m7101(new File(m6970 + "/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 m6886(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 m6887(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;
        m7094("chmod", "777", str);
        m7094("chown", "0:0", str);
        m7094("chown", "0.0", str);
        try {
            file = m6948(str2);
        } catch (Exception e) {
            e.printStackTrace();
            file = null;
        }
        if (str4 == null) {
            str5 = m6965(str2, str3);
        } else {
            str5 = str4;
        }
        if (str5 != null && new File(str5).exists()) {
            m7078(str5, "RW");
            new File(str5).delete();
        }
        new File(str2).getName();
        m6965(str2, str3);
        m6948(str2);
        m7176(new File(str2).getName(), "odex");
        try {
            if (m6935().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) {
                    C2975.m7942("dex-opt-art");
                    try {
                        C2975.m7942("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()) {
                            m7094("rm", file.getAbsolutePath());
                        }
                        C2975.m7942("try create oat with dex2oat:");
                        i = C2975.f9299;
                        str4 = r15 == true ? 1 : 0;
                    } catch (Exception e4) {
                        e = e4;
                        str4 = r15 == true ? 1 : 0;
                    }
                    try {
                        if (i >= 28) {
                            if (str8.equals("")) {
                                str8 = m6964(file, "--instruction-set");
                            }
                            C2975.m7942("classpath parametr:" + m6964(file, "classpath"));
                            String m6963 = m6963(file, "--class-loader-context");
                            C2975.m7942("class-loader_contex:" + m6963);
                            if (!m6963.equals("")) {
                                str9 = "--class-loader-context=" + m6963;
                            } 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};
                        }
                        C2975.m7942(m7098(strArr));
                        C2975.m7942("end");
                        if (file.exists() && file.length() != 0) {
                            C2975.m7942("oat created with dex2oat - length=" + file.length());
                        } else {
                            file.delete();
                            if (file.exists()) {
                                m7094("rm", file.getAbsolutePath());
                            }
                        }
                    } catch (Exception e5) {
                        e = e5;
                        e.printStackTrace();
                        z2 = false;
                        dexFile = null;
                        if (!m7049(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 (m6889(C2975.f9250, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        }
                        new File(str + "/temp.dex").delete();
                        if (file.exists()) {
                            file.delete();
                        }
                        if (!m7049(str2)) {
                        }
                        str7 = str4;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    } catch (Exception e7) {
                        e7.printStackTrace();
                        dexFile = null;
                        if (m6889(C2975.f9250, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        }
                        new File(str + "/temp.dex").delete();
                        if (file.exists()) {
                        }
                        if (!m7049(str2)) {
                        }
                        str7 = str4;
                        if (dexFile != null) {
                        }
                        if (str7 == null) {
                        }
                        if (str7 != null) {
                        }
                        return 1;
                    }
                    if (m6889(C2975.f9250, str + "/temp.dex", file.getAbsolutePath(), true, true)) {
                        C2975.m7942("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 (!m7049(str2)) {
                    m7094("chmod", "0644", file.getAbsolutePath());
                    m7094("chown", "0.0", file.getAbsolutePath());
                    m7094("chown", "0:0", file.getAbsolutePath());
                } else {
                    m7094("chmod", "0644", file.getAbsolutePath());
                    m7094("chown", "1000." + str3, file.getAbsolutePath());
                    m7094("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 m6888(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 m6948;
        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 m7098;
        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;
        m7094("chmod", "777", str);
        m7094("chown", "0:0", str);
        String str24 = "0.0";
        m7094("chown", "0.0", str);
        String m6965 = str4 == null ? m6965(str2, str3) : str4;
        String name = new File(str2).getName();
        String m69652 = m6965(str2, str3);
        File m69482 = m6948(str2);
        String name2 = new File(str2).getName();
        String m7176 = m7176(name2, "odex");
        m7176(name2, "dex");
        String str25 = str + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176;
        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 = m6965;
            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();
                }
            }
            m6965 = str26;
            str25 = str27;
        }
        String str28 = str25;
        String str29 = m6965;
        arrayList.clear();
        Iterator it3 = arrayList2.iterator();
        while (it3.hasNext()) {
            arrayList.add((File) it3.next());
        }
        try {
            z3 = m6935().contains("ART");
            try {
                Iterator<File> it4 = arrayList.iterator();
                while (it4.hasNext()) {
                    try {
                        File next2 = it4.next();
                        Iterator<File> it5 = it4;
                        String str30 = str6;
                        m7094("chmod", "777", str + InternalZipConstants.ZIP_FILE_SEPARATOR + next2.getName());
                        if (!next2.exists()) {
                            return 4;
                        }
                        m7094("chmod", "777", str + InternalZipConstants.ZIP_FILE_SEPARATOR + next2.getName());
                        m7094("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;
                m7094("chmod", "777", str + "/AndroidManifest.xml");
                m7094("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()) {
                    m7094("rm", str + InternalZipConstants.ZIP_FILE_SEPARATOR + name);
                }
                m6948 = m6948(str2);
                m6948.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) {
            C2975.m7942("dex-opt-art");
            z6 = z3;
            String m7165 = m7165(name, str, arrayList, file6, str2);
            if (!m7165.equals(obj) && new File(m7165).exists()) {
                StringBuilder sb3 = new StringBuilder();
                str16 = "1000:";
                sb3.append("apk found and copy created apk size ");
                str9 = "chown";
                str10 = "art";
                sb3.append(new File(m7165).length());
                C2975.m7942(sb3.toString());
                String str31 = !m6948.getAbsolutePath().contains("/arm/") ? "arm" : obj;
                if (m6948.getAbsolutePath().contains("/arm64/")) {
                    str31 = "arm64";
                }
                if (m6948.getAbsolutePath().contains("/x86/")) {
                    str31 = "x86";
                }
                if (m6948.getAbsolutePath().contains("/x86_64/")) {
                    str31 = "x86_64";
                }
                if (C2975.f9299 < 28) {
                    if (file != null) {
                        m6948 = file;
                    }
                    if (str31.equals(obj)) {
                        str31 = m6964(m6948, "--instruction-set");
                    }
                    C2975.m7942("classpath parametr:" + m6964(m6948, "classpath"));
                    String m6963 = m6963(m6948, "--class-loader-context");
                    C2975.m7942("class-loader_contex:" + m6963);
                    if (m6963.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=" + m6963;
                    }
                    StringBuilder sb4 = new StringBuilder();
                    sb4.append("--oat-file=");
                    str17 = str28;
                    sb4.append(str17);
                    strArr = new String[]{"dex2oat", "--dex-file=" + m7165, sb4.toString(), str23, "--instruction-set=" + str31};
                } else {
                    str17 = str28;
                    strArr = new String[]{"dex2oat", "--dex-file=" + m7165, "--oat-file=" + str17, "--instruction-set=" + str31};
                }
                new File(str17).delete();
                if (new File(str17).exists()) {
                    try {
                        m7094("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;
                        m7094("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 (m7049(str2)) {
                        }
                        new File(str7 + str11 + m69482.getName()).delete();
                        new File(str7 + str11 + m69482.getName()).delete();
                        new File(str7 + str11 + str12).delete();
                        if (new File(str7 + str11 + str12).exists()) {
                        }
                        z2 = z9;
                        z3 = z6;
                        if (dexFile != null) {
                        }
                        if (z5) {
                        }
                    }
                }
                C2975.m7942("try create oat with dex2oat:");
                C2975.m7942("rebuild_apk:" + m7165);
                C2975.m7942("oatFile:" + str17);
                C2975.m7942("instructions:" + str31);
                C2975.m7942(m7098(strArr));
                C2975.m7942("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());
                    C2975.m7942(sb5.toString());
                    m6906(new File(str17), arrayList, str2, m7165, false);
                } else {
                    String[] strArr2 = strArr;
                    new File(str17).delete();
                    z = strArr2;
                    if (new File(str17).exists()) {
                        m7094("rm", str17);
                        z = strArr2;
                    }
                }
                file3 = new File(str17);
                if (file3.exists() && file3.length() == 0) {
                    file3.delete();
                }
                if (!new File(file3.getAbsolutePath()).exists()) {
                    C2975.m7942("oat file found. try copy and permission apply.");
                    str18 = str29;
                    String m71762 = m7176(str18, "vdex");
                    str8 = "vdex";
                    String str32 = str10;
                    String m71763 = m7176(str18, str32);
                    if (new File(m71763).exists()) {
                        C2975.m7942("generated " + new File(m71763) + " found");
                    }
                    if (new File(m71762).exists()) {
                        C2975.m7942("generated " + new File(m71762) + " found");
                    }
                    String absolutePath = (str18.startsWith("/mnt/asec/") && m69482.exists()) ? m69482.getAbsolutePath() : str18;
                    new File(absolutePath).delete();
                    if (new File(absolutePath).exists()) {
                        str21 = m7165;
                        m7094("rm", absolutePath);
                    } else {
                        str21 = m7165;
                    }
                    if (new File(m7176(absolutePath, str32)).exists()) {
                        m7094("chmod", "777", m7176(absolutePath, str32));
                        new File(m7176(absolutePath, str32)).delete();
                    }
                    C2975.m7942("try copy to:" + absolutePath);
                    str10 = str32;
                    if (m6889(C2975.f9250, file3.getAbsolutePath(), absolutePath, true, true)) {
                        C2975.m7942("Free space for odex enougth.");
                        C2975.m7942("odex is (" + absolutePath + ") enougth.");
                        try {
                            if (str18.startsWith("/mnt/asec/") && m69482.exists()) {
                                m7094("chmod", "0644", absolutePath);
                                m7094(str9, "1000." + str3, absolutePath);
                                StringBuilder sb6 = new StringBuilder();
                                str19 = str16;
                                sb6.append(str19);
                                sb6.append(str3);
                                m7094(str9, sb6.toString(), absolutePath);
                                m7094("chmod", "0644", m71762);
                                m7094(str9, "1000." + str3, m71762);
                                m7094(str9, str19 + str3, m71762);
                                m7094("chmod", "0644", m71763);
                                m7094(str9, "1000." + str3, m71763);
                                m7094(str9, str19 + str3, m71763);
                                z2 = false;
                            } else {
                                str19 = str16;
                                z2 = true;
                            }
                        } catch (Exception e6) {
                            exc = e6;
                            z3 = z6;
                            z2 = true;
                        }
                        try {
                            if ((C2975.f9299 >= 23 && !m69482.exists()) || m69482.getAbsolutePath().equals(absolutePath)) {
                                str7 = str;
                                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                            } else if (m6889(C2975.f9250, str17, m69482.getAbsolutePath(), true, true)) {
                                m69482.getAbsolutePath();
                                if (new File(absolutePath + ".art").exists()) {
                                    new File(absolutePath + ".art").delete();
                                }
                                if (m7049(str2)) {
                                    m7094("chmod", "0644", absolutePath);
                                    m7094(str9, str5, absolutePath);
                                    m7094(str9, "0:0", absolutePath);
                                    m7094("chmod", "0644", m71762);
                                    m7094(str9, str5, m71762);
                                    m7094(str9, "0:0", m71762);
                                    m7094("chmod", "0644", m71763);
                                    m7094(str9, str5, m71763);
                                    m7094(str9, "0:0", m71763);
                                } else {
                                    m7094("chmod", "0644", absolutePath);
                                    m7094(str9, "1000." + str3, absolutePath);
                                    m7094(str9, str19 + str3, absolutePath);
                                    m7094("chmod", "0644", m71762);
                                    m7094(str9, "1000." + str3, m71762);
                                    m7094(str9, str19 + str3, m71762);
                                    m7094("chmod", "0644", m71763);
                                    m7094(str9, "1000." + str3, m71763);
                                    m7094(str9, str19 + str3, m71763);
                                }
                                str7 = str;
                                str18 = m6965(str2, str3);
                                str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                                z2 = true;
                            } else {
                                new File(m69652).delete();
                                if (new File(m69652).exists()) {
                                    m7094("rm", m69652);
                                }
                                boolean startsWith = m69652.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;
                        C2975.m7942("Error:Free space for odex not enougth.");
                        if (file3.exists()) {
                            file3.delete();
                        }
                        if (file3.exists()) {
                            m7094("rm", file3.getAbsolutePath());
                        }
                        new File(m69652).delete();
                        if (new File(m69652).exists()) {
                            m7094("rm", m69652);
                        }
                        if (new File(m6965(str2, str3)).exists()) {
                            C2975.m7942("Error:dont delete corrupt odex.");
                        }
                        String absolutePath2 = m69482.getAbsolutePath();
                        String str33 = str21;
                        if (!str33.equals(obj) && new File(str33).exists()) {
                            C2975.m7942("apk found and copy created apk2");
                            C2975.m7942("try create oat with DexFile2:");
                            StringBuilder sb7 = new StringBuilder();
                            str7 = str;
                            sb7.append(str7);
                            str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                            sb7.append(str11);
                            sb7.append(m69482.getName());
                            sb = sb7.toString();
                            new File(sb).delete();
                            if (new File(sb).exists()) {
                                m7094("rm", sb);
                            }
                            C2975.m7942("try create oat with dex2oat:");
                            C2975.m7942(m7098(z));
                            C2975.m7942("end");
                            if (new File(sb).exists()) {
                                str22 = absolutePath2;
                            } else {
                                C2975.m7942("oat2 created with dex2oat - length=" + new File(sb).length());
                                str22 = absolutePath2;
                                m6906(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 {
                                C2975.m7942("oat file found. try copy and permission apply.");
                                if (m6889(C2975.f9250, sb, m69482.getAbsolutePath(), true, true)) {
                                    str18 = m69482.getAbsolutePath();
                                    z2 = false;
                                    z10 = true;
                                    z11 = false;
                                } else {
                                    new File(m69652).delete();
                                    if (new File(m69652).exists()) {
                                        m7094("rm", m69652);
                                    }
                                    str18 = str22;
                                    z2 = false;
                                    z10 = false;
                                    z11 = false;
                                }
                            }
                        }
                        C2975.m7942("Error: dont create rebuild apk to /data/tmp/");
                        C2975.m7942("try create oat with DexFile2:");
                        StringBuilder sb72 = new StringBuilder();
                        str7 = str;
                        sb72.append(str7);
                        str11 = InternalZipConstants.ZIP_FILE_SEPARATOR;
                        sb72.append(str11);
                        sb72.append(m69482.getName());
                        sb = sb72.toString();
                        new File(sb).delete();
                        if (new File(sb).exists()) {
                        }
                        C2975.m7942("try create oat with dex2oat:");
                        C2975.m7942(m7098(z));
                        C2975.m7942("end");
                        if (new File(sb).exists()) {
                        }
                        file5 = new File(sb);
                        if (file5.exists()) {
                            file5.delete();
                        }
                        if (new File(file5.getAbsolutePath()).exists()) {
                        }
                    }
                    m7094("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 (m7049(str2)) {
                                    }
                                    new File(str7 + str11 + m69482.getName()).delete();
                                    new File(str7 + str11 + m69482.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 (m7049(str2)) {
                                }
                                new File(str7 + str11 + m69482.getName()).delete();
                                new File(str7 + str11 + m69482.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 {
                                C2500 c2500 = new C2500("1");
                                file4.delete();
                                if (file4.exists()) {
                                    c2500.m7194(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 (m7049(str2)) {
                                }
                                new File(str7 + str11 + m69482.getName()).delete();
                                new File(str7 + str11 + m69482.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 (m7049(str2)) {
                        try {
                            m7094("chmod", "0644", str15);
                            m7094(str9, str5, str15);
                            m7094(str9, "0:0", str15);
                            String str34 = str8;
                            m7094("chmod", "0644", m7176(str15, str34));
                            m7094(str9, str5, m7176(str15, str34));
                            m7094(str9, "0:0", m7176(str15, str34));
                            String str35 = str10;
                            m7094("chmod", "0644", m7176(str15, str35));
                            m7094(str9, str5, m7176(str15, str35));
                            m7094(str9, "0:0", m7176(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;
                        m7094("chmod", "0644", str15);
                        m7094(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;
                            m7094(strArr3);
                            m7094("chmod", "0644", m7176(str15, str36));
                            m7094(str9, "1000." + str3, m7176(str15, str36));
                            m7094(str9, str38 + str3, m7176(str15, str36));
                            m7094("chmod", "0644", m7176(str15, str37));
                            m7094(str9, "1000." + str3, m7176(str15, str37));
                            m7094(str9, str38 + str3, m7176(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 + m69482.getName()).delete();
                    new File(str7 + str11 + m69482.getName()).delete();
                    new File(str7 + str11 + str12).delete();
                    if (new File(str7 + str11 + str12).exists()) {
                        m7094("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;
                m7094("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 (m7049(str2)) {
                }
                new File(str7 + str11 + m69482.getName()).delete();
                new File(str7 + str11 + m69482.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:";
            C2975.m7942("Error: dont create rebuild apk to /data/tmp/");
            if (!m6948.getAbsolutePath().contains("/arm/")) {
            }
            if (m6948.getAbsolutePath().contains("/arm64/")) {
            }
            if (m6948.getAbsolutePath().contains("/x86/")) {
            }
            if (m6948.getAbsolutePath().contains("/x86_64/")) {
            }
            if (C2975.f9299 < 28) {
            }
            new File(str17).delete();
            if (new File(str17).exists()) {
            }
            C2975.m7942("try create oat with dex2oat:");
            C2975.m7942("rebuild_apk:" + m7165);
            C2975.m7942("oatFile:" + str17);
            C2975.m7942("instructions:" + str31);
            C2975.m7942(m7098(strArr));
            C2975.m7942("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;
            m7094("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 (m7049(str2)) {
            }
            new File(str7 + str11 + m69482.getName()).delete();
            new File(str7 + str11 + m69482.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);
            m7164(str12, str7, arrayList, sb9.toString());
            m7094("chmod", "777", str7 + str11 + str12);
            m7094(str9, "1000." + str3, str7 + str11 + str12);
            m7094(str9, "1000:" + str3, str7 + str11 + str12);
            if (new File(str7 + str11 + str12).exists()) {
                if (new File(str7 + str11 + str12).length() != 0) {
                    C2975.m7942("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 + m69482.getName()).delete();
                dexFile = DexFile.loadDex(str7 + str11 + str12, str7 + str11 + m69482.getName(), 0);
            } catch (RuntimeException e15) {
                e15.printStackTrace();
                dexFile = null;
                String name3 = m69482.getName();
                C2975.m7942(name3);
                C2975.m7942(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 (m7049(str2)) {
                }
                new File(str7 + str11 + m69482.getName()).delete();
                new File(str7 + str11 + m69482.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 = m69482.getName();
                C2975.m7942(name32);
                C2975.m7942(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 (m7049(str2)) {
                }
                new File(str7 + str11 + m69482.getName()).delete();
                new File(str7 + str11 + m69482.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 = m69482.getName();
            C2975.m7942(name322);
            C2975.m7942(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()) {
                m6909(file2, str2);
                if (m6889(C2975.f9250, str7 + str11 + name322, str39, true, true)) {
                    C2975.m7942("Free space for odex enougth.");
                    str14 = str39;
                    z7 = true;
                    if (z7 && !z6) {
                        try {
                        } catch (Exception e17) {
                            e = e17;
                            z8 = z7;
                        }
                        if (!new File(m69652).exists()) {
                            C2975.m7942("lackypatch: dexopt-wrapper used!");
                            m7094(str9, str5, str7 + "/dexopt-wrapper");
                            m7094(str9, "0:0", str7 + "/dexopt-wrapper");
                            m7094("chmod", "777", str7 + "/dexopt-wrapper");
                            String[] strArr4 = new String[3];
                            StringBuilder sb10 = new StringBuilder();
                            z8 = z7;
                            try {
                                sb10.append(C2975.f9250);
                                sb10.append("/dexopt-wrapper");
                                strArr4[0] = sb10.toString();
                                strArr4[1] = str7 + str11 + str12;
                                strArr4[2] = m69652;
                                m7098 = m7098(strArr4);
                                C2975.m7942(m7098);
                            } 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 (m7098.contains("succes") && !m7098.contains("failed")) {
                                m6909(new File(m69652), str2);
                                z2 = z8;
                                str15 = str14;
                                z5 = true;
                                z4 = false;
                                if (m7049(str2)) {
                                }
                                new File(str7 + str11 + m69482.getName()).delete();
                                new File(str7 + str11 + m69482.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(m69652).delete();
                                m7094("rm", m69652);
                                str15 = m69482.getAbsolutePath();
                                if (new File(m69652).exists()) {
                                    m7094("rm", str15);
                                }
                                m7094("rm", str7 + str11 + name322);
                                m7098(C2975.f9250 + "/dexopt-wrapper", str7 + str11 + str12, str7 + str11 + name322);
                                StringBuilder sb11 = new StringBuilder();
                                sb11.append(str7);
                                sb11.append(str11);
                                sb11.append(name322);
                                m7094("chmod", "777", sb11.toString());
                                StringBuilder sb12 = new StringBuilder();
                                sb12.append(str7);
                                sb12.append(str11);
                                sb12.append(name322);
                                m7094(str9, str5, sb12.toString());
                                m7094(str9, "0:0", str7 + str11 + name322);
                                m6909(new File(str7 + str11 + name322), str2);
                                m6877(str7 + str11 + name322, str15, false, true);
                                z2 = z8;
                                z5 = true;
                                z4 = false;
                                if (m7049(str2)) {
                                }
                                new File(str7 + str11 + m69482.getName()).delete();
                                new File(str7 + str11 + m69482.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 (m7049(str2)) {
                    }
                    new File(str7 + str11 + m69482.getName()).delete();
                    new File(str7 + str11 + m69482.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(m69652).delete();
                    if (new File(m69652).exists()) {
                        m7094("rm", m69652);
                    }
                    str14 = str39;
                    if (m6889(C2975.f9250, str7 + str11 + name322, m69482.getAbsolutePath(), true, true)) {
                        str39 = m69482.getAbsolutePath();
                    } else {
                        new File(m69652).delete();
                        if (new File(m69652).exists()) {
                            m7094("rm", m69652);
                        }
                        z7 = false;
                        if (z7) {
                            if (!new File(m69652).exists()) {
                            }
                        }
                        z8 = z7;
                        z2 = z8;
                        str15 = str14;
                        z5 = true;
                        z4 = false;
                        if (m7049(str2)) {
                        }
                        new File(str7 + str11 + m69482.getName()).delete();
                        new File(str7 + str11 + m69482.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 (m7049(str2)) {
            }
            new File(str7 + str11 + m69482.getName()).delete();
            new File(str7 + str11 + m69482.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 m6889(String str, String str2, String str3, boolean z, boolean z2) {
        File file = new File(str2);
        String m7176 = m7176(str2, "vdex");
        String m71762 = m7176(str3, "vdex");
        File file2 = new File(m7176);
        File file3 = new File(m71762);
        String m71763 = m7176(str2, "art");
        String m71764 = m7176(str3, "art");
        File file4 = new File(m71763);
        new File(m71764);
        File file5 = new File(str3);
        int i = 0;
        if (file.exists()) {
            m7078(str3, "RW");
            if (z && file2.exists()) {
                m7098("dd", "if=" + m7176, "of=" + m71762);
                String[] strArr = C2975.f9295;
                if (strArr != null) {
                    for (int length = strArr.length; i < length; length = length) {
                        String str4 = strArr[i];
                        String[] strArr2 = strArr;
                        if (new File(m71762).exists() && file2.length() == file3.length()) {
                            break;
                        }
                        m7098(str4, "dd", "if=" + m7176, "of=" + m71762);
                        i++;
                        strArr = strArr2;
                    }
                }
            }
            if (z2 && file4.exists()) {
                m7098("dd", "if=" + m71763, "of=" + m71764);
                String[] strArr3 = C2975.f9295;
                if (strArr3 != null) {
                    int length2 = strArr3.length;
                    int i2 = 0;
                    while (i2 < length2) {
                        String str5 = strArr3[i2];
                        if (new File(m71762).exists() && file2.length() == file3.length()) {
                            break;
                        }
                        m7098(str5, "dd", "if=" + m71763, "of=" + m71764);
                        i2++;
                        strArr3 = strArr3;
                    }
                }
            }
            m7098("dd", "if=" + str2, "of=" + str3);
            String[] strArr4 = C2975.f9295;
            if (strArr4 != null) {
                for (String str6 : strArr4) {
                    if (new File(m71762).exists() && file2.length() == file3.length()) {
                        break;
                    }
                    m7098(str6, "dd", "if=" + str2, "of=" + str3);
                }
            }
            if (file.length() != file5.length() && file.length() != 0) {
                file5.delete();
                C2975.m7942("Length of Files not equals. Destination deleted!");
                return false;
            }
            if (z && file2.exists()) {
                if (file2.length() != file3.length() && file2.length() != 0) {
                    file3.delete();
                    C2975.m7942("Length of Files not equals. Destination deleted!");
                    return false;
                }
                C2975.m7942(Long.valueOf(file3.length()));
                C2975.m7942("File copied!");
                return true;
            }
            C2975.m7942(Long.valueOf(file5.length()));
            C2975.m7942("File copied!");
            return true;
        }
        C2975.m7942("Source File not Found!");
        return false;
    }

    public static int m6890(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 m6964;
        StringBuilder sb;
        String str10;
        String[] strArr;
        C2975.m7942(str2);
        new File(str2).mkdirs();
        m7094("chmod", "777", str);
        m7094("chmod", "777", m6942(new File(str2)).getAbsolutePath());
        m7094("chown", "0:0", m6942(new File(str2)).getAbsolutePath());
        m7094("chown", "0.0", m6942(new File(str2)).getAbsolutePath());
        m7094("chmod", "777", str2);
        m7094("chown", "0:0", str2);
        m7094("chown", "0.0", str2);
        if (str3 == null) {
            str5 = m6965(str, str4);
        } else {
            str5 = str3;
        }
        if (str5 != null) {
            m7078(str5, InternalZipConstants.WRITE_MODE);
        }
        String m6965 = m6965(str, str4);
        String name = new File(str).getName();
        m7176(name, "odex");
        String str11 = str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176(name, "dex");
        try {
            File m6948 = m6948(str);
            m6948.getName();
            C2975.m7942("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()) {
                    }
                    m7094("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";
                    C2975.m7942("try create oat with DexFile.");
                    try {
                        new File(str11).delete();
                        DexFile.loadDex(str, str11, 0).close();
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    } catch (UnsatisfiedLinkError unused) {
                        C2975.m7942("withoutFramework");
                    }
                    C2975.m7942("end. check file. ");
                    if (new File(str11).exists()) {
                        C2975.m7942("found file " + str11 + " " + new File(str11).length());
                    }
                    if (new File(str5).exists()) {
                        C2975.m7942("found file " + str5 + " " + new File(str5).length());
                    }
                    if (new File(str11).exists() && new File(str11).length() != 0) {
                        C2975.m7942("odex file create to tmp dir.");
                    }
                    new File(str11).delete();
                    if (new File(str11).exists()) {
                        m7094("rm", str11);
                    }
                    if (!new File(str11).exists() || new File(str11).length() == 0) {
                        new File(str11).delete();
                        if (new File(str11).exists()) {
                            m7094("rm", str11);
                        }
                    }
                } else {
                    if (!m6948.getAbsolutePath().contains("/arm/")) {
                        str9 = "";
                    } else {
                        str9 = "arm";
                    }
                    if (m6948.getAbsolutePath().contains("/arm64/")) {
                        str9 = "arm64";
                    }
                    if (m6948.getAbsolutePath().contains("/x86/")) {
                        str9 = "x86";
                    }
                    if (m6948.getAbsolutePath().contains("/x86_64/")) {
                        str9 = "x86_64";
                    }
                    str7 = "0:0";
                    str8 = "0.0";
                    if (C2975.f9299 < 28) {
                        str6 = "chown";
                        strArr = new String[]{"dex2oat", "--dex-file=" + str, "--oat-file=" + str11, "--instruction-set=" + str9};
                    } else {
                        try {
                            if (str9.equals("")) {
                                str9 = m6964(m6948, "--instruction-set");
                            }
                            m6964 = m6964(m6948, "classpath");
                            sb = new StringBuilder();
                            str6 = "chown";
                        } catch (Exception e4) {
                            e = e4;
                            str6 = "chown";
                        }
                        try {
                            sb.append("classpath parametr:");
                            sb.append(m6964);
                            C2975.m7942(sb.toString());
                            String m6963 = m6963(m6948, "--class-loader-context");
                            C2975.m7942("class-loader_contex:" + m6963);
                            if (!m6963.equals("")) {
                                str10 = "--class-loader-context=" + m6963;
                            } 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);
                                C2975.m7942(str11);
                                C2975.m7942(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()) {
                                }
                                m7094("chmod", "644", str);
                                if (z3) {
                                }
                            }
                            if (new File(str11).exists()) {
                            }
                            listFiles = new File(str2).listFiles();
                            if (listFiles != null) {
                            }
                            if (new File(str2).exists()) {
                            }
                            m7094("chmod", "644", str);
                            if (z3) {
                            }
                        }
                    }
                    C2975.m7942("try create oat with dex2oat:");
                    C2975.m7942(m7098(strArr));
                    C2975.m7942("end");
                    if (new File(str11).exists() && new File(str11).length() != 0) {
                        C2975.m7942("odex file create to tmp dir.");
                    }
                    new File(str11).delete();
                    if (new File(str11).exists()) {
                        m7094("rm", str11);
                    }
                }
                i2 = 0;
            } catch (Exception e7) {
                e = e7;
                e.printStackTrace();
                i2 = 4;
                file = new File(str11);
                C2975.m7942(str11);
                C2975.m7942(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()) {
                }
                m7094("chmod", "644", str);
                if (z3) {
                }
            }
            file = new File(str11);
            C2975.m7942(str11);
            C2975.m7942(str5);
            if (file.exists() && file.length() == 0) {
                file.delete();
            }
            if (file.exists()) {
                C2975.m7942("oat file found. try copy and permission apply.");
                new File(m6965).delete();
                if (new File(m6965).exists()) {
                    m7094("rm", m6965);
                }
                if (m6889(C2975.f9250, file.getAbsolutePath(), str5, true, true)) {
                    C2975.m7942("Free space for odex enougth.");
                    z2 = true;
                } else {
                    C2975.m7942("Error:Free space for odex not enougth.");
                    if (file.exists()) {
                        file.delete();
                    }
                    if (file.exists()) {
                        m7094("rm", file.getAbsolutePath());
                    }
                    new File(m6965).delete();
                    if (new File(m6965).exists()) {
                        m7094("rm", m6965);
                    }
                    if (new File(m6965(str, str4)).exists()) {
                        C2975.m7942("Error:dont delete corrupt odex.");
                    }
                    z2 = false;
                }
                try {
                    if (m7049(str)) {
                        m7094("chmod", "0644", str5);
                        m7094(str6, str8, str5);
                        m7094(str6, str7, str5);
                    } else {
                        m7094("chmod", "0644", str5);
                        m7094(str6, "1000." + str4, str5);
                        m7094(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()) {
                    }
                    m7094("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();
        }
        m7094("chmod", "644", str);
        if (z3) {
            return 1;
        }
        return i;
    }

    public static void m6891() {
        int i;
        File file = new File(C2975.f9250 + "/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() == m6983(i)) {
            m7093("chmod 777 " + C2975.f9250 + "/dexopt-wrapper");
            m7093("chown 0.0 " + C2975.f9250 + "/dexopt-wrapper");
            m7093("chmod 0:0 " + C2975.f9250 + "/dexopt-wrapper");
            return;
        }
        try {
            m6984(i, new File(C2975.f9250 + "/dexopt-wrapper"));
        } catch (Exception unused) {
        }
        try {
            m6941(new File(C2975.f9250 + "/dexopt-wrapper"), 777);
        } catch (Exception e) {
            C2975.m7942(e);
            e.printStackTrace();
        }
        m7093("chmod 777 " + C2975.f9250 + "/dexopt-wrapper");
        m7093("chown 0.0 " + C2975.f9250 + "/dexopt-wrapper");
        m7093("chmod 0:0 " + C2975.f9250 + "/dexopt-wrapper");
    }

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

    public static final void m6893() {
        Intent intent = new Intent(C2975.f9245.mo1874(), C2975.f9245.m1860().getClass());
        intent.setFlags(131072);
        C2975.f9245.mo1874().startActivity(intent);
    }

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

    public static boolean m6895(boolean z) {
        return C2975.f9299 < 24;
    }

    public static float m6896(float f) {
        return f / C2975.m7929().getResources().getDisplayMetrics().density;
    }

    public static Bitmap m6897(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 m6898(String str) {
        if (new File(str).exists() && new File(str).canRead()) {
            return true;
        }
        if (C2975.f9283 && !C2975.f9323.booleanValue()) {
            if (new C2500("").m7211(C2975.f9284 + C1642.class.getName() + " '" + str + "'").contains("file found!")) {
                return true;
            }
        }
        return false;
    }

    public static void m6899() {
        boolean booleanValue = C2975.f9323.booleanValue();
        C2975.f9323 = Boolean.FALSE;
        if (booleanValue) {
            System.exit(0);
        }
    }

    public static void m6900() {
        if (!C2975.f9323.booleanValue()) {
            C2975.m7942("LuckyPatcher: exit root.");
            try {
                DataOutputStream dataOutputStream = C2975.f9307;
                if (dataOutputStream != null) {
                    dataOutputStream.writeBytes("exit\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                Process process = C2975.f9305;
                if (process != null) {
                    process.destroy();
                }
                try {
                    DataOutputStream dataOutputStream2 = C2975.f9307;
                    if (dataOutputStream2 != null) {
                        dataOutputStream2.close();
                    }
                } catch (IOException unused) {
                }
                try {
                    DataInputStream dataInputStream = C2975.f9306;
                    if (dataInputStream != null) {
                        dataInputStream.close();
                    }
                } catch (IOException unused2) {
                }
                try {
                    DataInputStream dataInputStream2 = C2975.f9308;
                    if (dataInputStream2 != null) {
                        dataInputStream2.close();
                    }
                } catch (IOException unused3) {
                }
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            C2975.f9305 = null;
            C2975.f9307 = null;
            C2975.f9306 = null;
            C2975.f9308 = null;
        }
        C2975.f9309.release();
    }

    public static void m6901() {
        File[] fileArr = new File[1];
        C3549.m8178(fileArr, new RunnableC2582(fileArr), null);
    }

    public static Intent m6902() {
        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 (C2975.m7932().resolveActivity(intent, 65536) != null) {
                return intent;
            }
        }
        return null;
    }

    private static C2973 m6903(String str) {
        m7179();
        try {
            ArrayList<C2973> m6962 = m6962();
            File file = new File(str);
            Iterator<C2973> it = m6962.iterator();
            while (it.hasNext()) {
                C2973 next = it.next();
                if (next.m7908().equals(file)) {
                    return next;
                }
            }
            ArrayList arrayList = new ArrayList();
            Iterator<C2973> it2 = m6962.iterator();
            while (it2.hasNext()) {
                C2973 next2 = it2.next();
                if (next2 != null && next2.m7908() != null && !next2.m7908().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                    String[] split = next2.m7908().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();
            C2973 c2973 = null;
            while (it3.hasNext()) {
                C2973 c29732 = (C2973) it3.next();
                if (c2973 == null) {
                    c2973 = c29732;
                }
                if (c2973.m7908().getAbsolutePath().length() < c29732.m7908().getAbsolutePath().length()) {
                    c2973 = c29732;
                }
            }
            if (c2973 != null) {
                C2975.m7942("recursive mount " + c2973.m7908().getAbsolutePath());
            } else if (f7061) {
                C2975.m7942("magisk mounts found");
                if (str.startsWith("/system")) {
                    Iterator<C2973> it4 = m6962.iterator();
                    while (it4.hasNext()) {
                        C2973 next3 = it4.next();
                        if (next3.m7908().getAbsolutePath().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                            c2973 = next3;
                        }
                    }
                }
            }
            return c2973;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ApkUtils.ZipSections m6904(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 m6905() {
        CRC32 crc32 = new CRC32();
        if (C2975.f9323.booleanValue()) {
            return C2975.f9324;
        }
        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 m6906(File file, ArrayList<File> arrayList, String str, String str2, boolean z) {
        java.util.zip.ZipInputStream zipInputStream;
        FileInputStream fileInputStream;
        C3864 c3864;
        int i;
        String m7176;
        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;
        m7094("chmod", "777", file.getAbsolutePath());
        if (str != null) {
            try {
                if (new File(str).exists() && new File(str).length() != 0) {
                    try {
                        C2975.m7942(str);
                        m7094("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;
                                            }
                                            C2975.m7942("crc " + name + ":" + i3);
                                            arrayList2.add(new C2618(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();
                                    C2975.m7942("Start alternative method.");
                                    try {
                                        C2975.m7942("start");
                                        c3864 = C3864.m8444(str);
                                    } catch (Exception e2) {
                                        e = e2;
                                        c3864 = null;
                                    }
                                    try {
                                        try {
                                            for (C3862 c3862 : c3864.m8446().values()) {
                                                if (c3862.m8433().startsWith("classes") && c3862.m8433().endsWith(".dex")) {
                                                    try {
                                                        i = c3862.m8428();
                                                        C2975.m7942("CRC32:" + i);
                                                        if (i == i5) {
                                                            CRC32 crc322 = new CRC32();
                                                            crc322.reset();
                                                            byte[] m8429 = c3862.m8429();
                                                            crc322.update(m8429, 0, m8429.length);
                                                            i = (int) crc322.getValue();
                                                            C2975.m7942("CRC32:" + i);
                                                        }
                                                    } catch (Exception e3) {
                                                        e3.printStackTrace();
                                                        i = 0;
                                                    }
                                                    arrayList2.add(new C2618(c3862.m8433(), i));
                                                    if (arrayList != null && arrayList.size() == arrayList2.size()) {
                                                        break;
                                                    }
                                                }
                                                i5 = -1;
                                            }
                                        } catch (Exception e4) {
                                            e = e4;
                                            e.printStackTrace();
                                            if (c3864 != null) {
                                            }
                                            arrayList2.sort(new C2576());
                                            if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                            }
                                            if (file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                            }
                                            if (new File(m7176).exists()) {
                                            }
                                        }
                                        if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                        }
                                        if (file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                                        }
                                        if (new File(m7176).exists()) {
                                        }
                                    } catch (Exception e5) {
                                        e5.printStackTrace();
                                        return;
                                    }
                                    if (c3864 != null) {
                                        c3864.m8445();
                                    }
                                    arrayList2.sort(new C2576());
                                }
                            } 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 C2576());
                        if (!file.getAbsolutePath().toLowerCase().endsWith(".vdex")) {
                            m7105(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)) {
                                                        C2975.m7942("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()) {
                                                            C2618 c2618 = (C2618) it.next();
                                                            String str7 = str6;
                                                            if (c2618.f7475.equals("classes.dex")) {
                                                                C2975.m7942(c2618.f7475 + " " + c2618.f7476);
                                                                int i10 = c2618.f7476;
                                                                if (i10 != 0) {
                                                                    map.put((byte) i10);
                                                                    map.force();
                                                                    map.put((byte) (c2618.f7476 >> 8));
                                                                    map.force();
                                                                    map.put((byte) (c2618.f7476 >> 16));
                                                                    map.force();
                                                                    map.put((byte) (c2618.f7476 >> 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()) {
                                                                            C2618 c26182 = (C2618) it2.next();
                                                                            Iterator it3 = it2;
                                                                            if (c26182.f7475.equals(str10)) {
                                                                                StringBuilder sb = new StringBuilder();
                                                                                bArr = bytes3;
                                                                                sb.append("oat ");
                                                                                sb.append(c26182.f7475);
                                                                                sb.append(" ");
                                                                                sb.append(c26182.f7476);
                                                                                C2975.m7942(sb.toString());
                                                                                int i16 = c26182.f7476;
                                                                                if (i16 != 0) {
                                                                                    map.put((byte) i16);
                                                                                    map.force();
                                                                                    map.put((byte) (c26182.f7476 >> 8));
                                                                                    map.force();
                                                                                    map.put((byte) (c26182.f7476 >> 16));
                                                                                    map.force();
                                                                                    map.put((byte) (c26182.f7476 >> 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")) {
                            m7176 = file.getAbsolutePath();
                        } else {
                            m7176 = m7176(file.getAbsolutePath(), "vdex");
                        }
                        if (new File(m7176).exists()) {
                            m7105(m7176);
                            FileChannel channel2 = new RandomAccessFile(m7176, 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");
                                C2975.m7942("VDEX version string:" + str11);
                                int intValue = new Integer(str11).intValue();
                                C2975.m7942("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()) {
                                        C2618 c26183 = (C2618) it4.next();
                                        C2975.m7942("vdex " + c26183.f7475 + " " + c26183.f7476);
                                        int i17 = c26183.f7476;
                                        if (i17 != 0) {
                                            map2.put((byte) i17);
                                            map2.force();
                                            map2.put((byte) (c26183.f7476 >> 8));
                                            map2.force();
                                            map2.put((byte) (c26183.f7476 >> 16));
                                            map2.force();
                                            map2.put((byte) (c26183.f7476 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e7) {
                                    e7.printStackTrace();
                                }
                            }
                            if (i2 >= 19 && i2 < 21) {
                                map2.position(20);
                                try {
                                    Iterator it5 = arrayList2.iterator();
                                    while (it5.hasNext()) {
                                        C2618 c26184 = (C2618) it5.next();
                                        C2975.m7942("vdex " + c26184.f7475 + " " + c26184.f7476);
                                        int i18 = c26184.f7476;
                                        if (i18 != 0) {
                                            map2.put((byte) i18);
                                            map2.force();
                                            map2.put((byte) (c26184.f7476 >> 8));
                                            map2.force();
                                            map2.put((byte) (c26184.f7476 >> 16));
                                            map2.force();
                                            map2.put((byte) (c26184.f7476 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e8) {
                                    e8.printStackTrace();
                                }
                            }
                            if (i2 >= 21 && i2 < 27) {
                                map2.position(28);
                                try {
                                    Iterator it6 = arrayList2.iterator();
                                    while (it6.hasNext()) {
                                        C2618 c26185 = (C2618) it6.next();
                                        C2975.m7942("vdex " + c26185.f7475 + " " + c26185.f7476);
                                        int i19 = c26185.f7476;
                                        if (i19 != 0) {
                                            map2.put((byte) i19);
                                            map2.force();
                                            map2.put((byte) (c26185.f7476 >> 8));
                                            map2.force();
                                            map2.put((byte) (c26185.f7476 >> 16));
                                            map2.force();
                                            map2.put((byte) (c26185.f7476 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e9) {
                                    e9.printStackTrace();
                                }
                            }
                            if (i2 >= 27) {
                                map2.position(60);
                                try {
                                    Iterator it7 = arrayList2.iterator();
                                    while (it7.hasNext()) {
                                        C2618 c26186 = (C2618) it7.next();
                                        C2975.m7942("vdex " + c26186.f7475 + " " + c26186.f7476);
                                        int i20 = c26186.f7476;
                                        if (i20 != 0) {
                                            map2.put((byte) i20);
                                            map2.force();
                                            map2.put((byte) (c26186.f7476 >> 8));
                                            map2.force();
                                            map2.put((byte) (c26186.f7476 >> 16));
                                            map2.force();
                                            map2.put((byte) (c26186.f7476 >> 24));
                                            map2.force();
                                        }
                                    }
                                } catch (Exception e10) {
                                    e10.printStackTrace();
                                }
                            }
                            channel2.close();
                        }
                    } catch (Exception e11) {
                        e11.printStackTrace();
                    }
                }
            } catch (Exception e12) {
                C2975.m7942(e12);
            }
        }
    }

    public static void m6907(String str) {
        String[] strArr;
        int i;
        C2975.m7942("fix selinux lp " + str);
        String str2 = "u:object_r:system_data_file:s0";
        String str3 = "u:object_r:media_rw_data_file:s0";
        if (C2975.f9323.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()) {
                C2975.m7942("use toybox");
                i = 3;
                strArr2 = new String[]{"toybox", "ls", "-dZ", "/data/media"};
                strArr3 = new String[]{"toybox", "ls", "-dZ", "/data"};
            } else {
                i = 3;
            }
            String m7098 = m7098(strArr2);
            String m70982 = m7098(strArr3);
            String m70983 = m7098(strArr4);
            String[] strArr5 = new String[i];
            strArr5[0] = "restorecon";
            strArr5[1] = "-v";
            strArr5[2] = str;
            m7094(strArr5);
            String[] strArr6 = new String[i];
            strArr6[0] = "chmod";
            strArr6[1] = "777";
            strArr6[2] = str;
            m7094(strArr6);
            if (!str.startsWith("/data/ru")) {
                m70982 = "";
            }
            if (!str.startsWith("/data/data/")) {
                m7098 = m70982;
            }
            if (!str.startsWith("/data/local/tmp")) {
                m70983 = m7098;
            }
            if (m70983 != null && !m70983.equals("")) {
                String[] split = m70983.split("\\s+");
                if (split.length > 4 && !split[0].contains(":") && !split[3].contains(":")) {
                    C2975.m7942("0:" + split[0]);
                    C2975.m7942("1:" + split[1]);
                    C2975.m7942("2:" + split[2]);
                    C2975.m7942("3:" + split[3]);
                    C2975.m7942(m70983);
                }
                if (split.length > 1) {
                    if (split[0].contains(":")) {
                        C2975.m7942(split[0]);
                        m7094("chcon", split[0].trim(), str);
                        return;
                    } else {
                        if (split.length > 4 && split[3].contains(":")) {
                            C2975.m7942(split[3]);
                            m7094("chcon", split[3].trim(), str);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (!str.startsWith("/data/ru")) {
                str2 = m70983;
            }
            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";
            }
            C2975.m7942("manual:" + str3);
            m7094("chcon", str3, str);
            return;
        }
        if (C2975.f9283) {
            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()) {
                C2975.m7942("use toybox");
                strArr = new String[]{"toybox", "ls", "-dZ", "/data/media"};
                strArr8 = new String[]{"toybox", "ls", "-dZ", "/data"};
            } else {
                strArr = strArr7;
            }
            String m70984 = m7098(strArr);
            String m70985 = m7098(strArr8);
            String m70986 = m7098(strArr9);
            m7093("restorecon -v " + str);
            m7093("chmod 777 " + str);
            if (!str.startsWith("/data/ru")) {
                m70985 = "";
            }
            if (!str.startsWith("/data/data/")) {
                m70984 = m70985;
            }
            if (!str.startsWith("/data/local/tmp")) {
                m70986 = m70984;
            }
            if (m70986 != null && !m70986.equals("")) {
                String[] split2 = m70986.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":") && !split2[3].contains(":")) {
                    C2975.m7942("0:" + split2[0]);
                    C2975.m7942("1:" + split2[1]);
                    C2975.m7942("2:" + split2[2]);
                    C2975.m7942("3:" + split2[3]);
                    C2975.m7942(m70986);
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        C2975.m7942(split2[0]);
                        m7093("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        C2975.m7942(split2[3]);
                        m7093("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            if (str.startsWith("/data/ru")) {
                m70986 = "u:object_r:system_data_file:s0";
            }
            if (!str.startsWith("/data/data/")) {
                str3 = m70986;
            }
            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";
            }
            C2975.m7942("manual:" + str3);
            m7093("chcon " + str3 + " " + str);
        }
    }

    public static void m6908(File file) {
        m7179();
        try {
            if (C2975.f9323.booleanValue()) {
                m7098("chmod", "777", file.getAbsolutePath());
            }
            m7174(file);
            m7170(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m6909(File file, String str) {
        java.util.zip.ZipInputStream zipInputStream;
        ZipEntry nextEntry;
        int i;
        int i2;
        int crc;
        int i3;
        int i4;
        m7179();
        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]) {
                    C2975.m7942("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();
                m7172(i6, i7, file);
                if (C2975.f9323.booleanValue()) {
                    m7094("chmod", "644", str);
                } else {
                    m7093("chmod 644 " + str);
                }
                if (str != null && new File(str).exists() && new File(str).length() != 0) {
                    try {
                        C3864 m8444 = C3864.m8444(str);
                        for (C3862 c3862 : m8444.m8446().values()) {
                            if (c3862.m8433().equals("classes.dex")) {
                                try {
                                    int m7052 = (int) m7052(c3862.m8435());
                                    C2975.m7942("Time:" + m7052);
                                    i3 = m7052;
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    i3 = 0;
                                }
                                try {
                                    i4 = c3862.m8428();
                                    C2975.m7942("CRC32:" + i4);
                                    if (i4 == -1) {
                                        CRC32 crc32 = new CRC32();
                                        crc32.reset();
                                        byte[] m8429 = c3862.m8429();
                                        crc32.update(m8429, 0, m8429.length);
                                        i4 = (int) crc32.getValue();
                                        C2975.m7942("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();
                                }
                                m8444.m8445();
                                return;
                            }
                        }
                        return;
                    } catch (Exception e5) {
                        C2975.m7942("alternative method");
                        e5.printStackTrace();
                        try {
                            C2975.m7942("start");
                            C2975.m7942(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();
                                C2975.m7942("for file:" + file);
                                C2975.m7942("time0:" + ((int) b));
                                map2.position(i8 + 1);
                                map2.put((byte) (i >> 8));
                                map2.force();
                                C2975.m7942("time1:" + (b >> 8));
                                map2.position(i8 + 2);
                                map2.put((byte) (i >> 16));
                                map2.force();
                                C2975.m7942("time2:" + (b >> RegisterType.UNINIT_REF));
                                map2.position(i8 + 3);
                                map2.put((byte) (i >> 24));
                                map2.force();
                                C2975.m7942("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) {
                C2975.m7942(e10);
            }
        } catch (Exception e11) {
            e11.printStackTrace();
        }
    }

    public static boolean m6910(File file, File file2, String str) {
        String m6968;
        String str2;
        try {
            m6968 = m6968(file);
            while (true) {
                file2 = m6942(file2);
                if (file2.getAbsolutePath().equals(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
                    str2 = "";
                    break;
                }
                File file3 = new File(file2.getAbsolutePath() + "/etc/permissions");
                if (file3.exists()) {
                    C2975.m7942("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_" + m6968 + ".xml");
            m7078(file4.getAbsolutePath(), "RW");
            File m6942 = m6942(file4);
            if (!m6942.exists()) {
                m6942.mkdirs();
            }
            ArrayList<String> m6972 = m6972(file);
            ArrayList<String> m6944 = m6944(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(m6968);
            createElement2.setAttributeNode(createAttribute);
            createElement.appendChild(createElement2);
            createElement.normalize();
            Iterator<String> it = m6972.iterator();
            while (it.hasNext()) {
                createElement2.appendChild(m6886(newDocument, it.next()));
                createElement2.normalize();
            }
            Iterator<String> it2 = m6944.iterator();
            while (it2.hasNext()) {
                createElement2.appendChild(m6883(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);
            m7094("chmod", "755", file4.getAbsolutePath());
            m7094("chown", "0:0", file4.getAbsolutePath());
            m7094("chown", "0.0", file4.getAbsolutePath());
            return true;
        }
        C2975.m7942("Not found dir for allow permissions.");
        return false;
    }

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

    public static void m6912(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
        if (C2975.f9299 >= 19) {
            m7037(linearLayout, new RunnableC2514(linearLayout, runnable, timer, timerTask), timer, timerTask);
        }
    }

    public static ArrayList<C2619> m6913(String str, ArrayList<C2619> arrayList, boolean z, boolean z2) {
        m7179();
        C2975.m7942("Get all methods scan: " + str);
        ArrayList<C2619> arrayList2 = new ArrayList<>();
        char c = 2;
        char c2 = 3;
        if (C2975.f9323.booleanValue()) {
            m7094("chmod", "777", str);
        } else if (C2975.f9283) {
            m7093("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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                    map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                    byte[] bArr = new byte[m7185];
                                    int i = 0;
                                    int i2 = 0;
                                    while (i < m7185) {
                                        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<C2619> it = arrayList.iterator();
                                        while (it.hasNext()) {
                                            C2619 next = it.next();
                                            if (m7157(map, next, m6874(bArr2[c], bArr2[c2]))) {
                                                byte b = bArr2[c3];
                                                byte[] bArr3 = next.f7481;
                                                if (b == bArr3[0] && bArr2[5] == bArr3[1]) {
                                                    if (bArr2[6] == bArr3[2] && bArr2[7] == bArr3[c2]) {
                                                        C2619 c2619 = new C2619("", next.f7478, next.f7479);
                                                        byte[] bArr4 = c2619.f7483;
                                                        byte b2 = (byte) i2;
                                                        bArr4[0] = b2;
                                                        byte b3 = (byte) (i2 >> 8);
                                                        bArr4[1] = b3;
                                                        byte[] bArr5 = next.f7483;
                                                        bArr5[0] = b2;
                                                        bArr5[1] = b3;
                                                        next.f7485 = true;
                                                        next.f7489 = true;
                                                        arrayList2.add(c2619);
                                                    }
                                                    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) {
                C2975.m7942(e3);
            }
        }
        return arrayList2;
    }

    public static String m6914(Context context, String str) {
        m7179();
        if (C2975.f9299 < 26) {
            return Settings.Secure.getString(context.getContentResolver(), "android_id");
        }
        File file = new File("/data/system/users/" + ("" + (Process.myUid() / 100000)) + "/settings_ssaid.xml");
        try {
            try {
                m7093("chmod 0777 " + file.getAbsolutePath());
                C2975.m7942(new C2500("").m7211(C2975.f9284 + C1668.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");
                m7105(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);
                    C2975.m7942(element.getAttribute("package"));
                    if (element.getAttribute("package").equals(C2975.f9253.f10046)) {
                        return element.getAttribute("value");
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
        } catch (DOMException unused) {
            m7093("chmod 0777 " + file.getAbsolutePath());
            C2975.m7942(new C2500("").m7211(C2975.f9284 + C1668.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");
            m7105(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 (m7016(newPullParser, "package").equals(str)) {
                                        return m7016(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();
        }
        C2975.m7942("Android_ID is empty.");
        return "";
    }

    public static String m6915(String str) {
        if (C2975.f9299 < 19) {
            return "DALVIK";
        }
        try {
            FileInputStream fileInputStream = new FileInputStream(m6947(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]) {
                    C2975.m7942("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 {
                C2975.m7942("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 (C2975.f9299 >= 21) {
                    return "ART";
                }
                return "DALVIK";
            }
        }
    }

    public static ByteBuffer m6916(DataSource dataSource) throws IOException, ApkFormatException {
        CentralDirectoryRecord centralDirectoryRecord;
        m7179();
        try {
            ApkUtils.ZipSections m6904 = m6904(dataSource);
            Iterator<CentralDirectoryRecord> it = V1SchemeVerifier.parseZipCentralDirectory(dataSource, m6904).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, m6904.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 String m6917() {
        switch (C2975.f9299) {
            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 " + C2975.f9299 + ")";
        }
    }

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

    public static Drawable m6919(String str) {
        m7179();
        PackageManager m7932 = C2975.m7932();
        PackageInfo packageArchiveInfo = m7932.getPackageArchiveInfo(str, 1);
        if (packageArchiveInfo != null) {
            ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo.loadIcon(m7932);
        }
        return null;
    }

    public static ApplicationInfo m6920(String str) {
        m7179();
        PackageInfo packageArchiveInfo = C2975.m7932().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 = m6968(new File(str));
            return applicationInfo2;
        } catch (Throwable th) {
            th.printStackTrace();
            return null;
        }
    }

    public static String m6921(String str) {
        m7179();
        PackageManager m7932 = C2975.m7932();
        PackageInfo packageArchiveInfo = m7932.getPackageArchiveInfo(str, 1);
        if (packageArchiveInfo != null) {
            ApplicationInfo applicationInfo = packageArchiveInfo.applicationInfo;
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo.loadLabel(m7932).toString();
        }
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(str, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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()) {
                    C2975.m7942(androidBinXmlParser.getName());
                    for (int i = 0; i < androidBinXmlParser.getAttributeCount(); i++) {
                        if ("label".equals(androidBinXmlParser.getAttributeName(i)) && androidBinXmlParser.getNamespace().isEmpty()) {
                            C2975.m7942(Integer.valueOf(androidBinXmlParser.getAttributeValueType(i)));
                            int attributeValueType = androidBinXmlParser.getAttributeValueType(i);
                            if (attributeValueType != 1) {
                                if (attributeValueType == 3) {
                                    C3867 c3867 = new C3867(m6987(DataSources.asDataSource(randomAccessFile)));
                                    c3867.m8460();
                                    C3961 m8459 = c3867.m8459();
                                    try {
                                        return m8459.m8686(androidBinXmlParser.getAttributeIntValue(i)).get(0).m8688().mo8670(m8459, null);
                                    } catch (Throwable unused) {
                                        return null;
                                    }
                                }
                            } else {
                                return androidBinXmlParser.getAttributeStringValue(i);
                            }
                        }
                    }
                    return null;
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return null;
    }

    public static PackageInfo m6922(String str, int i) {
        PackageInfo packageInfo;
        m7179();
        PackageManager m7932 = C2975.m7932();
        try {
            C2975.m7942(str);
            packageInfo = m7932.getPackageArchiveInfo(str, i);
        } catch (Throwable th) {
            th.printStackTrace();
            packageInfo = null;
        }
        if (packageInfo != null) {
            return packageInfo;
        }
        try {
            C2975.m7942("Alternative method get PackageInfo used");
            return m6967(new File(str));
        } catch (Throwable th2) {
            th2.printStackTrace();
            return null;
        }
    }

    public static String m6923(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 m6921(m6928(file).getAbsolutePath());
                    } catch (Throwable th2) {
                        th2.printStackTrace();
                        return "Unknown";
                    }
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m6924(File file) {
        String str;
        String comment;
        try {
            comment = new ZipFile(file).getComment();
            C2975.m7942(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 m6922(m6928(file).getAbsolutePath(), 1).packageName;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m6925(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 "" + m6922(m6928(file).getAbsolutePath(), 1).versionCode;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static String m6926(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 "" + m6922(m6928(file).getAbsolutePath(), 1).versionName;
                }
                return str;
            }
            throw new Exception("Bad comment!");
        }
        str = "";
        if (!str.equals("")) {
        }
    }

    public static void m6927(String str, String str2) throws IOException {
        m7179();
        new File(str2).mkdirs();
        InputStream open = C2975.m7933().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 m6928(File file) {
        File file2 = new File(m7005() + "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 (m6921(file3.getAbsolutePath()) != null) {
                            C2975.m7942("apk label:" + m6921(file3.getAbsolutePath()));
                            return file3;
                        }
                        continue;
                    } else {
                        if (m6921(file3.getAbsolutePath()) == null) {
                            return null;
                        }
                        C2975.m7942("apk label:" + m6921(file3.getAbsolutePath()));
                        return file3;
                    }
                }
                C2975.m7942("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 (m6921(file3.getAbsolutePath()) != null) {
                            return file3;
                        }
                    } catch (FileNotFoundException e3) {
                        e3.printStackTrace();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                }
            }
            C2975.m7942("base.apk not found!");
            return null;
        } catch (ZipException e5) {
            e5.printStackTrace();
            C2975.m7942("base.apk not found!");
            return null;
        }
        e5.printStackTrace();
        C2975.m7942("base.apk not found!");
        return null;
    }

    public static File m6929(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 (m6921(next2.getAbsolutePath()) != null) {
                    return next2;
                }
            }
            return null;
        }
        return null;
    }

    public static String m6930(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("{"))) {
                            C2975.m7942("" + 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-------- " + m7007(R.string.next_custom_patch) + " --------\n";
                            }
                        }
                    } else {
                        fileInputStream.close();
                        return str;
                    }
                } catch (FileNotFoundException unused) {
                    str2 = str;
                    C2975.m7942("Custom Patch not Found in\n/sdcard/LuckyPatcher/\n");
                    return str2;
                } catch (IOException e) {
                    e = e;
                    C2975.m7942("" + e);
                    return str;
                }
            }
        } catch (FileNotFoundException unused2) {
        } catch (IOException e2) {
            e = e2;
            str = "";
        }
    }

    public static String[] m6931() {
        String[] m6995 = m6995();
        for (String str : m6995) {
            File file = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9355);
            if (file.exists() && file.canRead()) {
                try {
                    String[] split = m7072(file).split("%chelpus%");
                    if (split != null && split.length > 0) {
                        for (int i = 0; i < split.length; i++) {
                            if (i == 4) {
                                return m6871(split[i]);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                C2975.m7942("Lucky Patcher not found utils.");
            }
        }
        return null;
    }

    public static List<X509Certificate> m6932(byte[] bArr) {
        m7179();
        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 m6933(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 m6934(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 m6935() {
        try {
            if (C2975.f9246.contains("ART")) {
                return "ART";
            }
            if (!C2975.f9246.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");
                        C2975.m7942(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<C2614> m6936(String str) {
        m7179();
        ArrayList<C2614> arrayList = new ArrayList<>();
        try {
            File[] fileArr = C2975.f9256;
            int i = 0;
            if (fileArr == null || fileArr.length == 0 || C2975.f9257) {
                C2975.m7938(C2975.m7929());
                try {
                    C2975.f9251 = C2975.m7928().getString("basepath", C2975.f9251);
                    File file = new File(C2975.f9251 + "/CustomPatches");
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    C2975.f9256 = new File[file.listFiles().length];
                    C2975.f9256 = file.listFiles();
                    ArrayList arrayList2 = new ArrayList();
                    arrayList2.clear();
                    int i2 = 0;
                    while (true) {
                        File[] fileArr2 = C2975.f9256;
                        if (i2 >= fileArr2.length) {
                            break;
                        }
                        if (fileArr2[i2].isFile() && C2975.f9256[i2].getName().endsWith(".txt")) {
                            arrayList2.add(C2975.f9256[i2]);
                        }
                        i2++;
                    }
                    if (arrayList2.size() > 0) {
                        File[] fileArr3 = new File[arrayList2.size()];
                        C2975.f9256 = fileArr3;
                        C2975.f9256 = (File[]) arrayList2.toArray(fileArr3);
                    }
                } catch (Exception unused) {
                    C2975.m7942("Not found dir by Lucky Patcher. Custom patch not found.");
                }
                C2975.f9257 = false;
            }
            File[] fileArr4 = C2975.f9256;
            if (fileArr4 != null && fileArr4.length > 0) {
                while (true) {
                    File[] fileArr5 = C2975.f9256;
                    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 C2614(C2975.f9256[i]));
                        } else if (name.contains("_%ALL%.txt") && name.contains("%ALL%_") && str.contains(name.split("%ALL%_")[1].replace("_%ALL%.txt", ""))) {
                            arrayList.add(new C2614(C2975.f9256[i]));
                        }
                    }
                    if (name.replace(".txt", "").endsWith(str)) {
                        arrayList.add(new C2614(C2975.f9256[i]));
                    }
                    i++;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return arrayList;
    }

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

    public static void m6938(File file, ArrayList<C2632> arrayList, ArrayList<Integer> arrayList2) {
        boolean z;
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C2975.m7942("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()) {
                                C2632 c2632 = arrayList.get(it.next().intValue());
                                if (c2632.f7603.equals("") || dexBackedClassDef.getType().equals(c2632.f7603)) {
                                    for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                        if (dexBackedMethod != null && ((dexBackedMethod.getName().toLowerCase().contains(c2632.f7586.toLowerCase()) && !c2632.f7606) || (dexBackedMethod.getName().toLowerCase().equals(c2632.f7586.toLowerCase()) && c2632.f7606))) {
                                            if (dexBackedMethod.getReturnType().equals(c2632.f7590) || c2632.f7590.equals("")) {
                                                DexBackedMethodImplementation implementation = dexBackedMethod.getImplementation();
                                                if (implementation != null) {
                                                    if (!c2632.f7588.equals("")) {
                                                        String[] split = c2632.f7588.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++) {
                                                                C2975.m7942("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 >= c2632.f7579.length) {
                                                                c2632.f7584.add(Integer.valueOf(i2));
                                                                c2632.f7582.add(Integer.valueOf(instructionsSize));
                                                                c2632.f7578 = true;
                                                            } else {
                                                                c2632.f7604 = true;
                                                                C2975.m7942(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 m6939(File file, C2612 c2612) {
        String str;
        boolean z;
        String str2;
        String str3 = "";
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C2975.m7942("run patchWithRestoreMethodsDex");
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                try {
                    for (DexBackedClassDef dexBackedClassDef : DexBackedDexFile.fromInputStream(null, bufferedInputStream2).getClasses()) {
                        if (dexBackedClassDef != null) {
                            Iterator<C2631> it = c2612.f7443.iterator();
                            while (it.hasNext()) {
                                C2631 next = it.next();
                                for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                    if (dexBackedMethod != null && dexBackedMethod.getName().equals(next.f7565) && ((next.f7564.equals(str3) || dexBackedMethod.getDefiningClass().equals(next.f7564)) && (next.f7563.equals(str3) || dexBackedMethod.getReturnType().equals(next.f7563)))) {
                                        C2975.m7942("find " + dexBackedMethod.getName());
                                        DexBackedMethodImplementation implementation = dexBackedMethod.getImplementation();
                                        if (implementation != null) {
                                            if (!next.f7566.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.f7566.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;
                                                        C2975.m7942("instr size:" + instructionsSize);
                                                        C2975.m7942("patch.repByte.length:" + next.f7552.length);
                                                        C2975.m7942("all size:" + implementation.getSizeToByte());
                                                        C2975.m7942("tries count:" + implementation.getTryBlocks().size());
                                                        if (implementation.getTryBlocks().size() > 0 && next.f7550 == null) {
                                                            instructionsSize = (implementation.getSizeToByte() / 2) * 2;
                                                            if (instructionsSize == implementation.getSizeToByte()) {
                                                                C2975.m7942("put new size up:" + (instructionsSize / 2));
                                                            } else {
                                                                C2975.m7942("put new size up:" + ((implementation.getSizeToByte() + 1) / 2));
                                                                instructionsSize = implementation.getSizeToByte() + 1;
                                                            }
                                                            next.f7570.add(Integer.valueOf(implementation.codeOffset + 6));
                                                            next.f7571.add(Integer.valueOf(i3));
                                                        } else {
                                                            next.f7570.add(0);
                                                            next.f7571.add(0);
                                                        }
                                                        if (instructionsSize >= next.f7552.length) {
                                                            next.f7568.add(Integer.valueOf(i2));
                                                            C2975.m7942("startMethodsAddress:" + next.f7568);
                                                            next.f7569.add(Integer.valueOf(instructionsSize));
                                                            next.f7573 = true;
                                                        } else {
                                                            next.f7574 = true;
                                                            c2612.m7269(C2604.m7263("Method patch") + ":\n" + next.f7567 + "\n" + C2597.f7278 + " " + m7007(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");
                                                            C2975.m7942(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 m6940() {
        new File("/data/local/tmp/").mkdirs();
        return "/data/local/tmp/";
    }

    public static int m6941(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 File m6942(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 m6943(C2420 c2420, C2419 c2419) {
        Bitmap bitmap;
        if (c2419 != null) {
            try {
                int i = (int) ((C2975.m7933().getDisplayMetrics().density * 35.0f) + 0.5f);
                try {
                    bitmap = BitmapFactory.decodeStream(c2420.m6613(c2419));
                } 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> m6944(File file) throws ApkFormatException, IOException {
        m7179();
        ArrayList<String> arrayList = new ArrayList<>();
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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) {
                                    C3867 c3867 = new C3867(m6987(DataSources.asDataSource(randomAccessFile)));
                                    c3867.m8460();
                                    C3961 m8459 = c3867.m8459();
                                    arrayList.add(m8459.m8686(androidBinXmlParser.getAttributeIntValue(i)).get(0).m8688().mo8670(m8459, null));
                                }
                            } else {
                                arrayList.add(androidBinXmlParser.getAttributeStringValue(i));
                            }
                        }
                    }
                }
            }
            randomAccessFile.close();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static byte[] m6945(File file) throws IOException {
        m7179();
        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[] m6946(File file, int i) {
        m7179();
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] bArr = new byte[i];
            fileInputStream.read(bArr);
            return bArr;
        } catch (IOException unused) {
            return null;
        }
    }

    public static File m6947(String str) {
        String str2;
        String str3;
        if (C2975.f9299 >= 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 m7176 = m7176(file.getName(), "odex");
            if (!m7049(str)) {
                if (str3.equals("/arm64")) {
                    File file2 = new File(m6942(file) + "/oat/arm/" + m7176);
                    if (file2.exists()) {
                    }
                }
                str4 = str3;
                File file3 = new File(m6942(file) + "/oat" + str4 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176);
                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 (C2975.f9323.booleanValue()) {
            try {
                str2 = new C2500("").m7196(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("")) {
                C2975.m7942("" + 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 m6948(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()) {
                C2975.m7942("\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";
        C2975.m7942("dalvikfile: " + str4);
        File file = null;
        for (int i2 = 9; i < i2; i2 = 9) {
            String str5 = strArr[i];
            if (new File(str5 + str4).exists()) {
                C2975.m7942("\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 (!m6898("/data/dalvik-cache/arm") && !m6898("/data/dalvik-cache/arm64") && !m6898("/data/dalvik-cache/x86") && !m6898("/data/dalvik-cache/x86_64")) {
                file = new File("/data/dalvik-cache/" + str4);
            } else {
                if (m6898("/data/dalvik-cache/arm")) {
                    file = new File("/data/dalvik-cache/arm/" + str4);
                }
                if (m6898("/data/dalvik-cache/arm64")) {
                    file = new File("/data/dalvik-cache/arm64/" + str4);
                }
                if (m6898("/data/dalvik-cache/x86")) {
                    file = new File("/data/dalvik-cache/x86/" + str4);
                }
                if (m6898("/data/dalvik-cache/x86_64")) {
                    file = new File("/data/dalvik-cache/x86_64/" + str4);
                }
            }
        }
        if (C2975.f9299 >= 23 && !str.startsWith("/system/")) {
            File file2 = new File(str);
            String str6 = "/x86_64";
            String str7 = "/x86";
            String str8 = "/arm";
            if (C2975.f9323.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 m7176 = m7176(file2.getName(), "odex");
                if (!m7049(str)) {
                    if (str6.equals("/arm64")) {
                        File file3 = new File(m6942(file2) + "/oat/arm/" + m7176);
                        if (file3.exists()) {
                        }
                    }
                    str8 = str6;
                    File file4 = new File(m6942(file2) + "/oat" + str8 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176);
                    if (file4.exists()) {
                        return file4;
                    }
                }
            } else {
                if (m6898("/data/dalvik-cache/arm")) {
                    str2 = "/arm";
                }
                if (m6898("/data/dalvik-cache/arm64")) {
                    str2 = "/arm64";
                }
                if (!m6898("/data/dalvik-cache/x86")) {
                    str7 = str2;
                }
            }
        }
        return file;
    }

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

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

    public static String m6951(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 m6952(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 (m7038(uri)) {
                    documentId3 = DocumentsContract.getDocumentId(uri);
                    return Environment.getExternalStorageDirectory() + InternalZipConstants.ZIP_FILE_SEPARATOR + documentId3.split(":")[1];
                }
                if (m7034(uri)) {
                    documentId2 = DocumentsContract.getDocumentId(uri);
                    uri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId2).longValue());
                } else if (m7042(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];
                }
            }
        }
        C2975.m7942(uri.getScheme());
        if ("content".equalsIgnoreCase(uri.getScheme())) {
            C2975.m7942("LP: content scheme analize.");
            C2975.m7942("Lucky Patcher: alternative get path from uri");
            try {
                File file = new File(C2975.f9251 + "/tmp2/forAdd." + str2);
                StringBuilder sb = new StringBuilder();
                sb.append(C2975.f9251);
                sb.append("/tmp2/");
                new File(sb.toString()).mkdirs();
                InputStream openInputStream = C2975.m7929().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();
                        C2975.m7942(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> m6953(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 = m7176(str2, str);
            }
            if (new File(str2).exists()) {
                arrayList.add(new File(str2));
            }
        }
        return arrayList;
    }

    public static void m6954(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 C2939(C2975.m7929(), file2, false).f9151) && m7029(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 C2939(C2975.m7929(), file4, false).f9151) && m7029(file4)) {
                                            arrayList.add(file4);
                                        }
                                    } catch (Exception e2) {
                                        e2.printStackTrace();
                                    }
                                }
                            }
                        }
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                }
            }
            return;
        }
        C2975.m7942("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
    }

    public static ArrayList<File> m6955(C2608 c2608) {
        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> m6953 = m6953(strArr, "");
        ArrayList<File> m69532 = m6953(strArr, "vdex");
        ArrayList<File> m69533 = m6953(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> m69534 = m6953(strArr2, "");
        ArrayList<File> m69535 = m6953(strArr2, "vdex");
        ArrayList<File> m69536 = m6953(strArr2, "art");
        ArrayList<File> m69537 = m6953(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> m69538 = m6953(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> m69539 = m6953(new String[]{"/system/framework/conscrypt.jar", "/system/apex/com.android.conscrypt/javalib/conscrypt.jar"}, "");
        ArrayList<File> m695310 = m6953(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> m695311 = m6953(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> m695312 = m6953(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> m695313 = m6953(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> m695314 = m6953(strArr3, "");
        ArrayList<File> m695315 = m6953(strArr3, "art");
        ArrayList<File> m695316 = m6953(strArr3, "vdex");
        ArrayList<File> m695317 = m6953(new String[]{"/system/framework/services.jar"}, "");
        ArrayList<File> m695318 = m6953(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> m695319 = m6953(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> m695320 = m6953(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> m695321 = m6953(new String[]{"/system/framework/framework.jar"}, "");
        ArrayList<File> m695322 = m6953(new String[]{"/system/framework/boot-framework.vdex"}, "");
        if (c2608.f7404) {
            Iterator<File> it = m69536.iterator();
            while (it.hasNext()) {
                arrayList3.add(it.next());
            }
        }
        if (c2608.f7402) {
            Iterator<File> it2 = m69533.iterator();
            while (it2.hasNext()) {
                arrayList3.add(it2.next());
            }
        }
        if (c2608.f7405) {
            Iterator<File> it3 = m69535.iterator();
            while (it3.hasNext()) {
                arrayList3.add(it3.next());
            }
        }
        if (c2608.f7403) {
            Iterator<File> it4 = m69532.iterator();
            while (it4.hasNext()) {
                arrayList3.add(it4.next());
            }
        }
        if (c2608.f7407) {
            Iterator<File> it5 = m69534.iterator();
            while (it5.hasNext()) {
                arrayList3.add(it5.next());
            }
        }
        if (c2608.f7406) {
            Iterator<File> it6 = m6953.iterator();
            while (it6.hasNext()) {
                arrayList3.add(it6.next());
            }
        }
        if (c2608.f7409) {
            Iterator<File> it7 = m69537.iterator();
            while (it7.hasNext()) {
                arrayList3.add(it7.next());
            }
        }
        if (c2608.f7408) {
            Iterator<File> it8 = m69538.iterator();
            while (it8.hasNext()) {
                arrayList3.add(it8.next());
            }
        }
        if (c2608.f7410) {
            Iterator<File> it9 = m69539.iterator();
            while (it9.hasNext()) {
                arrayList3.add(it9.next());
            }
        }
        if (c2608.f7412) {
            Iterator<File> it10 = m695312.iterator();
            while (it10.hasNext()) {
                arrayList3.add(it10.next());
            }
        }
        if (c2608.f7411) {
            Iterator<File> it11 = m695310.iterator();
            while (it11.hasNext()) {
                arrayList3.add(it11.next());
            }
        }
        if (c2608.f7413) {
            if (m695311.size() > 0) {
                Iterator<File> it12 = m695311.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 (c2608.f7415) {
            Iterator<File> it13 = m695314.iterator();
            while (it13.hasNext()) {
                arrayList3.add(it13.next());
            }
        }
        if (c2608.f7416) {
            Iterator<File> it14 = m695315.iterator();
            while (it14.hasNext()) {
                arrayList3.add(it14.next());
            }
        }
        if (c2608.f7417) {
            Iterator<File> it15 = m695316.iterator();
            while (it15.hasNext()) {
                arrayList3.add(it15.next());
            }
        }
        if (c2608.f7414) {
            Iterator<File> it16 = m695313.iterator();
            while (it16.hasNext()) {
                arrayList3.add(it16.next());
            }
        }
        if (c2608.f7418) {
            Iterator<File> it17 = m695317.iterator();
            while (it17.hasNext()) {
                arrayList3.add(it17.next());
            }
        }
        if (c2608.f7419) {
            Iterator<File> it18 = m695318.iterator();
            while (it18.hasNext()) {
                arrayList3.add(it18.next());
            }
        }
        if (c2608.f7421) {
            Iterator<File> it19 = m695320.iterator();
            while (it19.hasNext()) {
                arrayList3.add(it19.next());
            }
        }
        if (c2608.f7420) {
            Iterator<File> it20 = m695319.iterator();
            while (it20.hasNext()) {
                arrayList3.add(it20.next());
            }
        }
        if (c2608.f7424) {
            Iterator<File> it21 = m695321.iterator();
            while (it21.hasNext()) {
                arrayList3.add(it21.next());
            }
        }
        if (c2608.f7425) {
            Iterator<File> it22 = m695322.iterator();
            while (it22.hasNext()) {
                arrayList3.add(it22.next());
            }
        }
        Iterator it23 = arrayList3.iterator();
        while (it23.hasNext()) {
            File file3 = (File) it23.next();
            if (c2608.f7426) {
                File m6880 = m6880(file3.getAbsolutePath());
                if (c2608.f7425 && m6880.exists() && m6880.getAbsolutePath().endsWith(".vdex")) {
                    arrayList = arrayList4;
                    arrayList.add(m6880);
                } else {
                    arrayList = arrayList4;
                }
                if (m6880.exists() && (m6880.getAbsolutePath().endsWith(".oat") || m6880.getAbsolutePath().endsWith(".odex") || m6880.getAbsolutePath().endsWith(".jar"))) {
                    arrayList.add(m6880);
                }
            } else {
                arrayList = arrayList4;
                arrayList.add(file3);
            }
            arrayList4 = arrayList;
        }
        return arrayList4;
    }

    public static Drawable m6956(File file) {
        Bitmap bitmap;
        m7179();
        try {
            C2420 c2420 = new C2420(file);
            C2419 m6612 = c2420.m6612("icon.png");
            if (m6612 != null) {
                int i = (int) ((C2975.m7933().getDisplayMetrics().density * 35.0f) + 0.5f);
                try {
                    bitmap = BitmapFactory.decodeStream(c2420.m6613(m6612));
                } 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 m6919(m6928(file).getAbsolutePath());
    }

    public static Drawable m6957(File file) {
        Bitmap bitmap;
        m7179();
        if (file != null) {
            try {
                if (file.exists()) {
                    int i = (int) ((C2975.m7933().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 m6958() {
        String[] split;
        String m6969 = m6969();
        long j = 0;
        if (new File(m6969 + "/module.prop").exists()) {
            try {
                String m7072 = m7072(new File(m6969 + "/module.prop"));
                if (m7072 != null && (split = m7072.split("\n")) != null) {
                    for (String str : split) {
                        if (str.startsWith("version=")) {
                            try {
                                j = Long.decode(str.substring(str.indexOf("=") + 1)).longValue();
                            } catch (Throwable unused) {
                            }
                            C2975.m7942("firmware crc:" + j);
                            return j;
                        }
                    }
                }
            } catch (Throwable unused2) {
            }
        }
        return j;
    }

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

    public static boolean m6960(String str, ArrayList<C2619> arrayList, boolean z, boolean z2) {
        Iterator it;
        char c;
        m7179();
        C2975.m7942("scan: " + str);
        ArrayList arrayList2 = new ArrayList();
        char c2 = 2;
        char c3 = 3;
        boolean z3 = false;
        if (C2975.f9323.booleanValue()) {
            m7094("chmod", "777", str);
        } else if (C2975.f9283) {
            m7093("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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                    int m71852 = m7185(map.get(), map.get(), map.get(), map.get());
                                    C2975.m7942("LuckyPatcher offset_to_data=" + Integer.toHexString(m71852));
                                    map.position(m71852);
                                    int i = 0;
                                    int i2 = 0;
                                    while (true) {
                                        c = 4;
                                        if (i >= m7185) {
                                            break;
                                        }
                                        byte[] bArr = {map.get(), map.get(), map.get(), map.get()};
                                        Iterator<C2619> it2 = arrayList.iterator();
                                        while (it2.hasNext()) {
                                            C2619 next = it2.next();
                                            byte b = bArr[0];
                                            byte[] bArr2 = next.f7480;
                                            if (b == bArr2[0] && bArr[1] == bArr2[1] && bArr[2] == bArr2[2] && bArr[3] == bArr2[3]) {
                                                byte[] bArr3 = next.f7482;
                                                bArr3[0] = (byte) i2;
                                                bArr3[1] = (byte) (i2 >> 8);
                                                next.f7486 = true;
                                            }
                                        }
                                        i2++;
                                        i++;
                                    }
                                    Iterator<C2619> it3 = arrayList.iterator();
                                    boolean z4 = false;
                                    while (it3.hasNext()) {
                                        if (it3.next().f7486) {
                                            z4 = true;
                                        }
                                    }
                                    if (z4) {
                                        map.position(88);
                                        int m71853 = m7185(map.get(), map.get(), map.get(), map.get());
                                        map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                        byte[] bArr4 = new byte[m71853];
                                        int i3 = 0;
                                        boolean z5 = false;
                                        int i4 = 0;
                                        while (i3 < m71853) {
                                            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<C2619> it4 = arrayList.iterator();
                                                while (it4.hasNext()) {
                                                    C2619 next2 = it4.next();
                                                    byte b2 = bArr5[0];
                                                    byte[] bArr6 = next2.f7482;
                                                    if (b2 == bArr6[0] && bArr5[1] == bArr6[1] && m7157(map, next2, m6874(bArr5[c2], bArr5[3]))) {
                                                        byte b3 = bArr5[4];
                                                        byte[] bArr7 = next2.f7481;
                                                        if (b3 == bArr7[0] && bArr5[5] == bArr7[1] && bArr5[6] == bArr7[c2] && bArr5[7] == bArr7[3]) {
                                                            if (!z2 || !next2.f7485) {
                                                                if (next2.f7485) {
                                                                    C2619 c2619 = new C2619(next2);
                                                                    byte[] bArr8 = c2619.f7483;
                                                                    bArr8[0] = (byte) i4;
                                                                    bArr8[1] = (byte) (i4 >> 8);
                                                                    c2619.f7485 = true;
                                                                    c2619.f7489 = true;
                                                                    arrayList2.add(c2619);
                                                                } 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));
                                                                    C2975.m7942(sb.toString());
                                                                    byte[] bArr9 = next2.f7483;
                                                                    bArr9[0] = b4;
                                                                    bArr9[1] = b5;
                                                                    next2.f7485 = true;
                                                                    next2.f7489 = 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) {
                C2975.m7942(e4);
            }
        }
        it = arrayList2.iterator();
        while (it.hasNext()) {
            arrayList.add((C2619) it.next());
        }
        return z3;
    }

    public static void m6961(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 ArrayList<C2973> m6962() {
        String m7098;
        boolean z;
        boolean z2;
        m7179();
        if (!C2975.f9323.booleanValue()) {
            m7098 = new C2500("").m7211(C2975.f9250 + "/busybox mount");
            if (m7098.startsWith("~")) {
                m6900();
                try {
                    C2975.m7937();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                m7098 = new C2500("").m7211("mount");
                if (m7098.startsWith("~")) {
                    m7098 = new C2500("").m7211("busybox mount");
                }
                if (m7098.startsWith("~")) {
                    m7098 = new C2500("").m7211("toolbox mount");
                }
            }
        } else {
            m7098 = m7098(C2975.f9250 + "/busybox", "mount");
            if (m7098.startsWith("~")) {
                m7098 = m7098("mount");
                if (m7098.startsWith("~")) {
                    m7098 = m7098("busybox", "mount");
                }
                if (m7098.startsWith("~")) {
                    m7098 = m7098("toolbox", "mount");
                }
            }
        }
        String[] split = m7098.split("\n");
        ArrayList<C2973> 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 {
                            f7061 = true;
                            z2 = true;
                        } catch (Exception e2) {
                            e = e2;
                            z2 = true;
                            e.printStackTrace();
                            return z ? arrayList : arrayList;
                        }
                    }
                    arrayList.add(new C2973(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) {
            C2975.m7942("LuckyPatcher: get mounts from /proc/mounts");
            if (!C2975.f9323.booleanValue()) {
                m6877("/proc/mounts", "/data/local/RootToolsMounts", false, true);
                m7093("chmod 777 /data/local/RootToolsMounts");
            } else {
                m6877("/proc/mounts", "/data/local/RootToolsMounts", false, true);
                m7094("chmod", "777", "/data/local/RootToolsMounts");
            }
            arrayList.clear();
            try {
                LineNumberReader lineNumberReader = new LineNumberReader(new FileReader("/data/local/RootToolsMounts"));
                ArrayList<C2973> arrayList2 = new ArrayList<>();
                while (true) {
                    try {
                        String readLine = lineNumberReader.readLine();
                        if (readLine != null) {
                            String[] split3 = readLine.split(" ");
                            arrayList2.add(new C2973(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 m6963(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 m6964(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");
                C2975.m7942(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 String m6965(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 = C2975.f9323;
        if (bool != null && bool.booleanValue()) {
            C2975.m7942("Start under Root");
        } else {
            if (C2975.f9323 == null) {
                C2975.m7942("uderRoot not defined");
            }
            if (!C2975.f9323.booleanValue()) {
                C2975.m7942("uderRoot false");
            }
        }
        File file = new File(str);
        boolean z = false;
        if (C2975.f9299 >= 23) {
            String m7176 = m7176(file.getName(), "odex");
            if (C2975.f9323.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()) {
                            C2975.m7942(str12 + " to dalvik cache found");
                            C2975.m7942("check " + m6942(file) + "/oat" + str12);
                            if (new File(m6942(file) + "/oat" + str12).exists()) {
                            }
                            new File(m6942(file) + "/oat" + str12).mkdirs();
                            C2975.m7942("try make dirs");
                            if (new File(m6942(file) + "/oat" + str12).exists()) {
                                C2975.m7942("dirs created");
                                if (!str2.equals("0")) {
                                    m7094("chmod", "755", m6942(file) + "/oat");
                                    m7094("chown", "1000." + str2, m6942(file) + "/oat");
                                    m7094("chown", "1000:" + str2, m6942(file) + "/oat");
                                    StringBuilder sb = new StringBuilder();
                                    sb.append(m6942(file));
                                    sb.append("/oat");
                                    sb.append(str12);
                                    m7094("chmod", "755", sb.toString());
                                    m7094("chown", "1000." + str2, m6942(file) + "/oat" + str12);
                                    m7094("chown", "1000:" + str2, m6942(file) + "/oat" + str12);
                                } else {
                                    m7094("chmod", "755", m6942(file) + "/oat");
                                    m7094("chown", "0." + str2, m6942(file) + "/oat");
                                    m7094("chown", "0:" + str2, m6942(file) + "/oat");
                                    StringBuilder sb2 = new StringBuilder();
                                    sb2.append(m6942(file));
                                    sb2.append("/oat");
                                    sb2.append(str12);
                                    m7094("chmod", "755", sb2.toString());
                                    m7094("chown", "0." + str2, m6942(file) + "/oat" + str12);
                                    m7094("chown", "0:" + str2, m6942(file) + "/oat" + str12);
                                }
                            }
                        }
                    }
                }
            } else {
                if (m6898("/data/dalvik-cache/arm")) {
                    str10 = "/arm";
                } else {
                    str10 = "";
                }
                if (m6898("/data/dalvik-cache/arm64")) {
                    str10 = "/arm64";
                }
                if (m6898("/data/dalvik-cache/x86")) {
                    str11 = "/x86";
                } else {
                    str11 = str10;
                }
                if (m6898("/data/dalvik-cache/x86_64")) {
                    str12 = "/x86_64";
                } else {
                    str12 = str11;
                }
                if (!str12.equals("")) {
                    if (m6898("/data/dalvik-cache" + str12)) {
                        if (!m6898(m6942(file) + "/oat" + str12)) {
                            m7093("mkdir -p '" + m6942(file) + "/oat" + str12 + "'");
                            if (m6898(m6942(file) + "/oat" + str12)) {
                                if (!str2.equals("0")) {
                                    m7093("chmod 755 " + m6942(file) + "/oat");
                                    m7093("chown 1000." + str2 + " " + m6942(file) + "/oat");
                                    m7093("chown 1000:" + str2 + " " + m6942(file) + "/oat");
                                    StringBuilder sb3 = new StringBuilder();
                                    sb3.append("chmod 755 ");
                                    sb3.append(m6942(file));
                                    sb3.append("/oat");
                                    sb3.append(str12);
                                    m7093(sb3.toString());
                                    m7093("chown 1000." + str2 + " " + m6942(file) + "/oat" + str12);
                                    m7093("chown 1000:" + str2 + " " + m6942(file) + "/oat" + str12);
                                } else {
                                    m7093("chmod 755 " + m6942(file) + "/oat");
                                    m7093("chown 0." + str2 + " " + m6942(file) + "/oat");
                                    m7093("chown 0:" + str2 + " " + m6942(file) + "/oat");
                                    StringBuilder sb4 = new StringBuilder();
                                    sb4.append("chmod 755 ");
                                    sb4.append(m6942(file));
                                    sb4.append("/oat");
                                    sb4.append(str12);
                                    m7093(sb4.toString());
                                    m7093("chown 0." + str2 + " " + m6942(file) + "/oat" + str12);
                                    m7093("chown 0:" + str2 + " " + m6942(file) + "/oat" + str12);
                                }
                            }
                        }
                    }
                }
            }
            if (str12.equals("/arm64")) {
                File file2 = new File(m6942(file) + "/oat/arm/" + m7176);
                if (file2.exists() && file2.length() != 0) {
                    str13 = "/arm";
                    return m6942(file) + "/oat" + str13 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176;
                }
            }
            str13 = str12;
            return m6942(file) + "/oat" + str13 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176;
        }
        if (C2975.f9323.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()) {
                        C2975.m7942(str6 + " to dalvik cache found");
                        C2975.m7942("check " + m6942(file) + str6);
                        if (new File(m6942(file) + str6).exists()) {
                        }
                        new File(m6942(file) + str6).mkdirs();
                        C2975.m7942("try make dirs");
                        if (new File(m6942(file) + str6).exists()) {
                            C2975.m7942("dirs created");
                            if (!str2.equals("0")) {
                                m7094("chmod", "755", m6942(file) + str6);
                                m7094("chown", "1000." + str2, m6942(file) + str6);
                                m7094("chown", "1000:" + str2, m6942(file) + str6);
                            } else {
                                m7094("chmod", "755", m6942(file) + str6);
                                m7094("chown", "0." + str2, m6942(file) + str6);
                                m7094("chown", "0:" + str2, m6942(file) + str6);
                            }
                        }
                        z = true;
                    }
                }
            }
            if (!z) {
                return m6942(file) + str6 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176(file.getName(), "odex");
            }
            return m7176(str, "odex");
        }
        if (m6898("/data/dalvik-cache/arm")) {
            str3 = "/arm";
        } else {
            str3 = "";
        }
        if (m6898("/data/dalvik-cache/arm64")) {
            str4 = "/arm64";
        } else {
            str4 = str3;
        }
        if (m6898("/data/dalvik-cache/x86")) {
            str5 = "/x86";
        } else {
            str5 = str4;
        }
        if (m6898("/data/dalvik-cache/x86_64")) {
            str6 = "/x86_64";
        } else {
            str6 = str5;
        }
        if (!str6.equals("")) {
            if (m6898("/data/dalvik-cache" + str6)) {
                if (!m6898(m6942(file) + str6)) {
                    m7093("mkdir -p '" + m6942(file) + str6 + "'");
                    if (m6898(m6942(file) + str6)) {
                        if (!str2.equals("0")) {
                            m7093("chmod 755 " + m6942(file) + str6);
                            m7093("chown 1000." + str2 + " " + m6942(file) + str6);
                            m7093("chown 1000:" + str2 + " " + m6942(file) + str6);
                        } else {
                            m7093("chmod 755 " + m6942(file) + str6);
                            m7093("chown 0." + str2 + " " + m6942(file) + str6);
                            m7093("chown 0:" + str2 + " " + m6942(file) + str6);
                        }
                    }
                }
                z = true;
            }
        }
        if (!z) {
        }
    }

    public static boolean m6966(boolean z) {
        return C2975.f9299 < 28;
    }

    public static PackageInfo m6967(File file) throws ApkFormatException, IOException {
        m7179();
        try {
            PackageInfo packageInfo = new PackageInfo();
            packageInfo.applicationInfo = new C2580(file);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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();
            C2975.m7942("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml");
            return null;
        }
    }

    public static String m6968(File file) throws ApkFormatException, IOException {
        RandomAccessFile randomAccessFile;
        m7179();
        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(m6916(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 String m6969() {
        if (new File("/sbin/.magisk/modules/").exists()) {
            return "/sbin/.magisk/modules/luckypatcher";
        }
        if (new File("/data/adb/modules/").exists() || m6898("/data/adb/modules/")) {
            return "/data/adb/modules/luckypatcher";
        }
        if (m6898("/sbin/.magisk/modules/")) {
            return "/sbin/.magisk/modules/luckypatcher";
        }
        return "";
    }

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

    public static String m6971(String str) {
        if (!C2975.f9323.booleanValue()) {
            String trim = m7098(C2975.f9250 + "/busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
            C2975.m7942(trim);
            if (!trim.matches("(\\d+)")) {
                C2975.m7942("try get permission again");
                trim = m7098("busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
            }
            if (!trim.matches("(\\d+)")) {
                return "";
            }
            return trim;
        }
        String trim2 = m7098(C2975.f9250 + "/busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
        C2975.m7942("'" + trim2 + "'");
        if (!trim2.matches("(\\d+)")) {
            C2975.m7942("try get permission again");
            trim2 = m7098("busybox", "stat", "-c", "%a", str).replaceAll("\n", "").replaceAll("\r", "").trim();
        }
        if (!trim2.matches("(\\d+)")) {
            return "";
        }
        return trim2;
    }

    public static ArrayList<String> m6972(File file) throws ApkFormatException, IOException {
        m7179();
        ArrayList<String> arrayList = new ArrayList<>();
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.READ_MODE);
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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) {
                                    C3867 c3867 = new C3867(m6987(DataSources.asDataSource(randomAccessFile)));
                                    c3867.m8460();
                                    C3961 m8459 = c3867.m8459();
                                    arrayList.add(m8459.m8686(androidBinXmlParser.getAttributeIntValue(i)).get(0).m8688().mo8670(m8459, null));
                                }
                            } else {
                                arrayList.add(androidBinXmlParser.getAttributeStringValue(i));
                            }
                        }
                    }
                }
            }
            randomAccessFile.close();
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

    public static ArrayList<File> m6973(String str, boolean z) {
        String str2;
        ArrayList<File> arrayList = new ArrayList<>();
        if (!z) {
            str2 = "";
        } else {
            str2 = m6970();
        }
        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 C2939(C2975.m7929(), file2, false).f9151)) {
                                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 C2939(C2975.m7929(), file4, z2).f9151)) {
                                                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 {
                C2975.m7942("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
            }
        }
        return arrayList;
    }

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

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

    public static String m6976(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 (C2975.f9299 >= 23) {
            String m7176 = m7176(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 (!m6898("/data/dalvik-cache/arm")) {
                    str5 = "";
                }
                if (!m6898("/data/dalvik-cache/arm64")) {
                    str4 = str5;
                }
                if (!m6898("/data/dalvik-cache/x86")) {
                    str3 = str4;
                }
                if (!m6898("/data/dalvik-cache/x86_64")) {
                    str2 = str3;
                }
                if (!str2.equals("")) {
                    m6898("/data/dalvik-cache" + str2);
                }
            }
            return m6942(file) + "/oat" + str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176;
        }
        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 (!m6898("/data/dalvik-cache/arm")) {
                str5 = "";
            }
            if (!m6898("/data/dalvik-cache/arm64")) {
                str4 = str5;
            }
            if (!m6898("/data/dalvik-cache/x86")) {
                str3 = str4;
            }
            if (!m6898("/data/dalvik-cache/x86_64")) {
                str2 = str3;
            }
            if (!str2.equals("")) {
            }
            z2 = false;
        }
        if (z2) {
            return m6942(file) + str2 + InternalZipConstants.ZIP_FILE_SEPARATOR + m7176(file.getName(), "odex");
        }
        return m7176(str, "odex");
    }

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

    public static long m6978(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 m6979(int i) {
        StringBuilder sb = new StringBuilder(i);
        for (int i2 = 0; i2 < i; i2++) {
            sb.append("abcdefghijklmnopqrstuvwxyz".charAt(f7068.nextInt(26)));
        }
        return sb.toString();
    }

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

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

    public static byte[] m6982(int i, int i2) {
        m7179();
        try {
            byte[] bArr = new byte[i2];
            C2975.m7933().openRawResource(i).read(bArr);
            return bArr;
        } catch (IOException unused) {
            return null;
        }
    }

    public static long m6983(int i) {
        m7179();
        try {
            InputStream openRawResource = C2975.m7933().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 {
                    C2975.m7942("LuckyPatcher (RAW): length = " + j);
                    return j;
                }
            }
        } catch (IOException unused) {
            return 0L;
        }
    }

    public static boolean m6984(int i, File file) {
        m7179();
        if (file.exists()) {
            file.delete();
        } else {
            m6942(file).mkdirs();
        }
        C2975.m7942("try get file from raw");
        try {
            byte[] bArr = new byte[ItemType.CLASS_DATA_ITEM];
            InputStream openRawResource = C2975.m7933().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();
            C2975.m7942("get file from raw");
            return true;
        } catch (IOException unused) {
            return false;
        }
    }

    public static C2471 m6985(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://144.217.79.205/luckypatcher/" + str3, "https://198.244.149.102/luckypatcher/" + str3};
        C2471 c2471 = null;
        int i = 0;
        while (i < 6) {
            if (i < 4) {
                str2 = strArr2[i];
            } else {
                double d = i;
                double floor = Math.floor(i / 4);
                double d2 = 4;
                Double.isNaN(d2);
                Double.isNaN(d);
                str2 = strArr2[(int) (d - (floor * d2))];
            }
            C2975.m7942(str2);
            i++;
            try {
                c2471 = C2471.m6814(str2);
                c2471.m6821();
                c2471.m6818();
                c2471.m6838("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:65.0) Gecko/20100101 Firefox/65.0");
                c2471.m6838("Accept-Encoding", "gzip,deflate");
                c2471.m6823(false);
                c2471.m6820(false);
                c2471.m6833(true);
                c2471.m6836().setRequestMethod("GET");
                c2471.m6836().setRequestProperty("Cache-Control", "no-cache");
                if (!str.equals("")) {
                    c2471.m6836().setRequestProperty("Range", "bytes=" + str + "-");
                }
                c2471.m6827(1000000);
                c2471.m6836().setDoInput(true);
                c2471.m6836().setDoOutput(true);
                c2471.m6836().setReadTimeout(30000);
                c2471.m6836().setConnectTimeout(30000);
                int m6826 = c2471.m6826();
                C2975.m7942("RequestCode:" + m6826);
                if (m6826 == 200 || m6826 == 206 || m6826 == 301) {
                    if (c2471.m6829() > 0) {
                        C2975.m7942("select host:" + str2);
                        return c2471;
                    }
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
                c2471.m6832();
            } catch (C2471.C2478 e2) {
                e2.printStackTrace();
                C2975.m7942(str2);
                c2471.m6832();
            } catch (Throwable th) {
                th.printStackTrace();
                C2975.m7942(str2);
                c2471.m6832();
            }
        }
        return null;
    }

    public static void m6986(String str, String str2, ArrayList<C2912> arrayList) throws IOException {
        JarEntry jarEntry;
        m6942(new File(str2)).mkdirs();
        C3864 m8444 = C3864.m8444(str);
        JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(str2));
        for (C3862 c3862 : m8444.m8446().values()) {
            if (!C2975.f9323.booleanValue()) {
                try {
                    C3549.m8185(m7007(R.string.patch_step7) + "\n" + c3862.m8433());
                } catch (Throwable unused) {
                }
            }
            try {
                if (c3862.m8427() == 0) {
                    jarEntry = new JarEntry(c3862.m8433());
                    jarEntry.setMethod(0);
                    Iterator<C2912> it = arrayList.iterator();
                    boolean z = false;
                    while (it.hasNext()) {
                        C2912 next = it.next();
                        if (c3862.m8433().equals(next.f9078.replace(next.f9079, ""))) {
                            try {
                                File file = new File(next.f9078);
                                byte[] bArr = new byte[(int) file.length()];
                                FileInputStream fileInputStream = new FileInputStream(next.f9078);
                                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(c3862.m8435());
                                z = true;
                            } catch (Exception e) {
                                C2975.m7942(e);
                            }
                        }
                    }
                    if (!z) {
                        jarEntry.setCompressedSize(c3862.m8434());
                        jarEntry.setSize(c3862.m8434());
                        CRC32 crc322 = new CRC32();
                        crc322.update(c3862.m8429());
                        jarEntry.setCrc(crc322.getValue());
                        jarEntry.setTime(c3862.m8435());
                    }
                } else {
                    jarEntry = new JarEntry(c3862.m8433());
                    jarEntry.setTime(c3862.m8435());
                    jarEntry.setMethod(c3862.m8427());
                }
                Iterator<C2912> it2 = arrayList.iterator();
                boolean z2 = false;
                while (it2.hasNext()) {
                    C2912 next2 = it2.next();
                    if (c3862.m8433().equals(next2.f9078.replace(next2.f9079, ""))) {
                        try {
                            File file2 = new File(next2.f9078);
                            byte[] bArr2 = new byte[ItemType.CLASS_DATA_ITEM];
                            FileInputStream fileInputStream2 = new FileInputStream(next2.f9078);
                            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();
                                C2975.m7942("LuckyPatcher (signer): Additional files added! " + next2);
                                z2 = true;
                            } catch (Exception e2) {
                                e = e2;
                                z2 = true;
                                C2975.m7942(e);
                            }
                        } catch (Exception e3) {
                            e = e3;
                        }
                    }
                }
                if (!z2) {
                    jarOutputStream.putNextEntry(jarEntry);
                    InputStream m8431 = c3862.m8431();
                    byte[] bArr3 = new byte[ItemType.CLASS_DATA_ITEM];
                    while (true) {
                        int read2 = m8431.read(bArr3);
                        if (read2 <= 0) {
                            break;
                        } else {
                            jarOutputStream.write(bArr3, 0, read2);
                        }
                    }
                    jarOutputStream.flush();
                    m8431.close();
                }
            } catch (Exception e4) {
                C2975.m7942(e4);
                e4.printStackTrace();
            }
        }
        m8444.m8445();
        jarOutputStream.close();
    }

    public static ByteBuffer m6987(DataSource dataSource) throws IOException, ApkFormatException {
        CentralDirectoryRecord centralDirectoryRecord;
        m7179();
        try {
            ApkUtils.ZipSections m6904 = m6904(dataSource);
            Iterator<CentralDirectoryRecord> it = V1SchemeVerifier.parseZipCentralDirectory(dataSource, m6904).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, m6904.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 m6988() {
        if (!C2975.f9323.booleanValue()) {
            try {
                if (C2975.f9305 == null) {
                    C2975.m7942("LuckyPatcher: GET ROOT.");
                    C2975.f9305 = Runtime.getRuntime().exec("su");
                    C2975.f9307 = new DataOutputStream(C2975.f9305.getOutputStream());
                    C2975.f9306 = new DataInputStream(C2975.f9305.getInputStream());
                    C2975.f9308 = new DataInputStream(C2975.f9305.getErrorStream());
                } else {
                    try {
                        C2975.f9307.writeBytes("echo chelpusstart!\n");
                    } catch (Exception unused) {
                        m6900();
                        C2975.f9305 = Runtime.getRuntime().exec("su");
                        C2975.f9307 = new DataOutputStream(C2975.f9305.getOutputStream());
                        C2975.f9306 = new DataInputStream(C2975.f9305.getInputStream());
                        C2975.f9308 = new DataInputStream(C2975.f9305.getErrorStream());
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

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

    public static String m6990() {
        String str;
        String str2 = "/system/bin/dalvikvm32";
        String str3 = "/system/bin/dalvikvm";
        try {
            if ((C2975.f9299 >= 23 && C2975.m7928().getBoolean("use_app_process", false)) || C2975.m7928().getBoolean("force_use_app_process", false)) {
                C2975.m7942("Use app_process");
                str = "app_process -Djava.class.path=" + App.getInstance().getPackageCodePath() + " /system/bin ";
            } else {
                C2975.m7942("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 m6991() {
        String str;
        String str2 = "/system/bin/dalvikvm32";
        String str3 = "/system/bin/dalvikvm";
        try {
            if ((C2975.f9299 >= 23 && C2975.m7928().getBoolean("use_app_process", false)) || C2975.m7928().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 void m6992(File file) {
        try {
            new C2500("").m7194(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        file.mkdirs();
    }

    public static String m6993() {
        String[] m6995 = m6995();
        for (String str : m6995) {
            new File(str);
            File file = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9355);
            if (file.exists() && file.canRead()) {
                try {
                    String[] split = m7072(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 {
                C2975.m7942("Lucky Patcher not found utils.");
            }
        }
        return "";
    }

    public static C2635 m6994(File file) throws ApkFormatException, IOException {
        m7179();
        try {
            C2635 c2635 = new C2635();
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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()) {
                                c2635.f7644 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                            if (("minSdkVersion".equals(androidBinXmlParser.getAttributeName(i)) || (androidBinXmlParser.getAttributeValueType(i) == 2 && androidBinXmlParser.getAttributeNameResourceId(i) == 16843276)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                c2635.f7645 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                            if (("targetSdkVersion".equals(androidBinXmlParser.getAttributeName(i)) || (androidBinXmlParser.getAttributeValueType(i) == 2 && androidBinXmlParser.getAttributeNameResourceId(i) == 16843376)) && androidBinXmlParser.getNamespace().isEmpty()) {
                                c2635.f7643 = androidBinXmlParser.getAttributeIntValue(i);
                            }
                        }
                    }
                }
            }
            return c2635;
        } catch (AndroidBinXmlParser.XmlParserException e) {
            e.printStackTrace();
            C2975.m7942("Unable to determine APK package name: malformed binary resource: AndroidManifest.xml");
            return null;
        }
    }

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

    private static void m6996() {
        try {
            m6927("testkey.pk8", C2975.f9251 + "/Modified/Keys");
            m6927("testkey.sbt", C2975.f9251 + "/Modified/Keys");
            m6927("testkey.x509.pem", C2975.f9251 + "/Modified/Keys");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static List<X509Certificate> m6997(File file) throws ApkFormatException, IOException, NoSuchAlgorithmException {
        int i = C2975.f9299;
        if (i <= 21) {
            i = 21;
        }
        ApkVerifier.Result verify = new ApkVerifier.Builder(file).setMinCheckedPlatformVersion(i).setMaxCheckedPlatformVersion(34).build().verify();
        verify.isVerified();
        List<X509Certificate> signerCertificates = verify.getSignerCertificates();
        for (ApkVerifier.IssueWithParams issueWithParams : verify.getErrors()) {
            System.err.println("ERROR: " + issueWithParams);
        }
        return signerCertificates;
    }

    public static String m6998(String str) {
        String group;
        if (C2975.f9323.booleanValue()) {
            Matcher matcher = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(m7098("ls", "-l", str));
            if (matcher.find()) {
                group = matcher.group(1);
                C2975.m7942("Symlink found: " + group);
            } else {
                String m7098 = m7098(C2975.f9250 + "/busybox", "ls", "-l", str);
                C2975.m7942(m7098);
                Matcher matcher2 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(m7098);
                if (matcher2.find()) {
                    group = matcher2.group(1);
                    C2975.m7942("Symlink found: " + group);
                } else {
                    C2975.m7942("No symlink found!");
                    return "";
                }
            }
            return group;
        }
        Matcher matcher3 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(new C2500("").m7211("ls -l " + str));
        if (matcher3.find()) {
            String group2 = matcher3.group(1);
            C2975.m7942("Symlink found: " + group2);
            return group2;
        }
        Matcher matcher4 = Pattern.compile("^.*?\\-\\>\\s+(.*)$").matcher(new C2500("").m7211(C2975.f9250 + "/busybox ls -l " + str));
        if (matcher4.find()) {
            String group3 = matcher4.group(1);
            C2975.m7942("Symlink found: " + group3);
            return group3;
        }
        C2975.m7942("No symlink found!");
        return "";
    }

    public static ArrayList<File> m6999(File file) {
        ArrayList<File> arrayList = new ArrayList<>();
        try {
            ZipFile zipFile = new ZipFile(file);
            File file2 = new File(m7005() + "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 && m6921(file3.getAbsolutePath()) == null) {
                        arrayList.add(file3);
                    } else {
                        file3.delete();
                    }
                }
            }
            return arrayList;
        } catch (Throwable th) {
            th.printStackTrace();
            return arrayList;
        }
    }

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

    public static void m7001() {
        try {
            C2975.m7942("Android 11 permission request");
            Intent intent = new Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION");
            intent.setData(Uri.parse("package:" + PkgName.getPkgName()));
            C2975 c2975 = C2975.f9245;
            if (c2975 != null) {
                c2975.m1860().startActivity(intent);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static ArrayList<File> m7002() {
        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> m7003() {
        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<C2627> m7004(String str, ArrayList<String> arrayList, boolean z) {
        boolean z2;
        boolean z3;
        m7179();
        C2975.m7942("scan: " + str);
        int i = 1;
        if (C2975.f9323.booleanValue()) {
            m7094("chmod", "777", str);
        } else if (C2975.f9283) {
            m7093("chmod 777 " + str);
        }
        ArrayList<C2627> arrayList2 = new ArrayList<>();
        int i2 = 4;
        try {
        } catch (Exception e) {
            C2975.m7942(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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                int[] iArr = new int[m7185];
                                for (int i3 = 0; i3 < m7185; i3++) {
                                    iArr[i3] = m7185(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 < m7185) {
                                    int i7 = 0;
                                    while (i7 < size) {
                                        int m7181 = m7181(map.get(iArr[i5]));
                                        if (m7181 == iArr2[i7]) {
                                            byte[] bArr = new byte[m7181];
                                            map.position(iArr[i5] + 1);
                                            for (int i8 = 0; i8 < m7181; 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 C2627(strArr[i7], bArr2, z3));
                                                }
                                                z3 = true;
                                                arrayList2.add(new C2627(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 m71852 = m7185(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m71852 + 56);
                int m71853 = m7185(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m7185(map2.get(), map2.get(), map2.get(), map2.get()) + m71852);
                int[] iArr3 = new int[m71853];
                for (int i9 = 0; i9 < m71853; i9++) {
                    iArr3[i9] = m7185(map2.get(), map2.get(), map2.get(), map2.get()) + m71852;
                }
                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 < m71853) {
                    int i13 = 0;
                    while (i13 < size2) {
                        int m71812 = m7181(map2.get(iArr3[i11]));
                        if (m71812 == iArr4[i13]) {
                            byte[] bArr3 = new byte[m71812];
                            map2.position(iArr3[i11] + i);
                            for (int i14 = 0; i14 < m71812; 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 C2627(strArr2[i13], bArr4, z2));
                                    i13++;
                                    i = 1;
                                }
                                z2 = true;
                                arrayList2.add(new C2627(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 m7005() {
        String str = C2975.m7929().getDir("tmp", 0).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR;
        new File(str).mkdirs();
        return str;
    }

    public static String m7006() {
        return C2975.f9251 + "/tmp/";
    }

    public static String m7007(int i) {
        return C2975.m7933().getString(i);
    }

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

    public static String m7009(int i, String... strArr) {
        String string = C2975.m7933().getString(i);
        try {
            return String.format(string, strArr);
        } catch (Throwable unused) {
            return string;
        }
    }

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

    public static boolean m7011(String str, ArrayList<C3497> arrayList, boolean z) {
        m7179();
        C2975.m7942("scan: " + str);
        boolean z2 = false;
        if (C2975.f9323.booleanValue()) {
            m7094("chmod", "777", str);
        } else if (C2975.f9283) {
            m7093("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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                    int m71852 = m7185(map.get(), map.get(), map.get(), map.get());
                                    C2975.m7942("LuckyPatcher offset_to_data=" + Integer.toHexString(m71852));
                                    map.position(m71852);
                                    int i = 0;
                                    for (int i2 = 0; i2 < m7185; i2++) {
                                        byte[] bArr = {map.get(), map.get(), map.get(), map.get()};
                                        Iterator<C3497> it = arrayList.iterator();
                                        while (it.hasNext()) {
                                            C3497 next = it.next();
                                            byte b = bArr[0];
                                            byte[] bArr2 = next.f10126;
                                            if (b == bArr2[0] && bArr[1] == bArr2[1] && bArr[2] == bArr2[2] && bArr[3] == bArr2[3]) {
                                                byte[] bArr3 = next.f10127;
                                                bArr3[0] = (byte) i;
                                                bArr3[1] = (byte) (i >> 8);
                                                next.f10130 = true;
                                                next.f10129 = true;
                                            }
                                        }
                                        i++;
                                    }
                                    Iterator<C3497> it2 = arrayList.iterator();
                                    while (it2.hasNext()) {
                                        if (it2.next().f10129) {
                                            z2 = true;
                                        }
                                    }
                                }
                                channel.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            } catch (Exception e3) {
                C2975.m7942(e3);
            }
        }
        return z2;
    }

    public static void m7012(String str, String str2, ArrayList<C2912> arrayList, ArrayList<C2630> arrayList2) throws IOException {
        m6942(new File(str2)).mkdirs();
        C2426 c2426 = null;
        try {
            C2420 c2420 = new C2420(str);
            try {
                C2426 c24262 = new C2426(new File(str2));
                try {
                    Enumeration<C2419> m6611 = c2420.m6611();
                    while (m6611.hasMoreElements()) {
                        C2419 nextElement = m6611.nextElement();
                        String name = nextElement.getName();
                        Iterator<C2912> it = arrayList.iterator();
                        boolean z = false;
                        while (it.hasNext()) {
                            C2912 next = it.next();
                            if (name.equals(next.f9078.replace(next.f9079, ""))) {
                                File file = new File(next.f9078);
                                C2419 c2419 = new C2419(name);
                                c2419.setTime(nextElement.getTime());
                                c2419.setCrc(nextElement.getCrc());
                                if (nextElement.getMethod() == 8) {
                                    c2419.setMethod(8);
                                } else {
                                    c2419.setMethod(0);
                                }
                                c24262.m6637(c2419);
                                C2975.m7942("entry:" + name);
                                C2975.m7942("hex crc orig:" + Long.toHexString(nextElement.getCrc()));
                                c24262.m6644(new FileInputStream(file));
                                c24262.m6632();
                                z = true;
                            }
                        }
                        if (!z) {
                            C2975.m7942("dont change:" + name);
                            c24262.m6633(nextElement, c2420);
                        }
                    }
                    try {
                        c2420.close();
                        c24262.close();
                    } catch (Throwable th) {
                        th = th;
                        c2426 = c24262;
                        try {
                            th.printStackTrace();
                            throw th;
                        } catch (Throwable th2) {
                            if (c2426 != null) {
                                c2426.close();
                            }
                            throw th2;
                        }
                    }
                } catch (Throwable th3) {
                    th = th3;
                    c2426 = c24262;
                    try {
                        c2420.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 int m7013(File file) throws ApkFormatException, IOException {
        m7179();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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 m7014(File file) throws ApkFormatException, IOException {
        m7179();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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> m7015() {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.clear();
        try {
            if (m7098(C2975.f9250 + "/busybox").contains("error execute command " + C2975.f9250 + "/busybox")) {
                C2975.m7942("binaries tool " + C2975.f9250 + "/busybox not found and skipped");
            } else {
                C2975.m7942("binaries tool " + C2975.f9250 + "/busybox found and worked");
                StringBuilder sb = new StringBuilder();
                sb.append(C2975.f9250);
                sb.append("/busybox");
                arrayList.add(sb.toString());
            }
            for (String str : C2975.f9296) {
                if (m7098(str).contains("error execute command " + str)) {
                    C2975.m7942("binaries tool " + str + " not found and skipped");
                } else {
                    C2975.m7942("binaries tool " + str + " found and worked");
                    arrayList.add(str);
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return arrayList;
    }

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

    public static int m7017() {
        m7179();
        if (!C2975.m7928().getBoolean("32" + C2975.f9288, false)) {
            try {
                C3864 m8444 = C3864.m8444(C2975.m7929().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 (C3862 c3862 : m8444.m8446().values()) {
                    if (z2 && z3 && i4 == i5 && i4 != 0) {
                        C2975.m7928().edit().putBoolean("32" + C2975.f9288, z).commit();
                        return 32;
                    }
                    if (c3862.m8433().equals(new String(bArr, "utf-8"))) {
                        InputStream m8431 = c3862.m8431();
                        m8431.skip(41L);
                        m8431.read(bArr3, 0, 4);
                        m8431.close();
                        i5 = m7185(bArr3[3], bArr3[2], bArr3[1], bArr3[0]);
                        z2 = true;
                    }
                    if (c3862.m8433().equals(new String(bArr2, "utf-8"))) {
                        i4 = c3862.m8434();
                        z3 = true;
                    }
                    z = true;
                }
                return 22;
            } catch (Throwable th) {
                th.printStackTrace();
                return 22;
            }
        }
        return 32;
    }

    public static int m7018(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 (C3862 c3862 : C3864.m8444(file.getAbsolutePath()).m8446().values()) {
                    if (c3862.m8433().toLowerCase().startsWith("classes") && c3862.m8433().toLowerCase().endsWith(".dex")) {
                        i++;
                    }
                }
                return i;
            } catch (Throwable th2) {
                th2.printStackTrace();
                return i;
            }
        }
    }

    public static String m7019(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 C2500("w").m7212(2000L);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e2) {
                e2.printStackTrace();
            }
        }
        if (process != null) {
            process.destroy();
        }
        return str2;
    }

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

    public static void m7021() {
        File[] fileArr = new File[1];
        C3549.m8176(fileArr, new RunnableC2553(fileArr), ".zip");
    }

    @SuppressLint({"NewApi"})
    public static int m7022() {
        String[] strArr;
        JSONObject jSONObject;
        JSONObject jSONObject2;
        String[] m6995 = m6995();
        int length = m6995.length;
        Integer[] numArr = new Integer[length];
        for (int i = 0; i < length; i++) {
            numArr[i] = 0;
        }
        int i2 = 0;
        while (i2 < m6995.length) {
            String str = m6995[i2];
            if (new File(str + "/xposed").exists()) {
                new File(str + "/xposed").renameTo(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356));
            }
            if (!new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).exists()) {
                if (!new File(str).exists()) {
                    if (C2975.f9323.booleanValue()) {
                        new File(str).mkdirs();
                        try {
                            strArr = m6995;
                            try {
                                new File(str).setWritable(true, false);
                                new File(str).setReadable(true, false);
                                m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                            } catch (NoSuchMethodError e) {
                                e = e;
                                e.printStackTrace();
                                m7094("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 (!C2975.f9323.booleanValue()) {
                                }
                                new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
                                jSONObject = new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
                                jSONObject.getBoolean("module_on");
                                numArr[i2] = 1;
                                i2++;
                                m6995 = strArr;
                            }
                        } catch (NoSuchMethodError e2) {
                            e = e2;
                            strArr = m6995;
                        }
                        m7094("chmod", "777", str);
                    } else {
                        strArr = m6995;
                        m7093("mkdir " + str);
                        try {
                            new File(str).setWritable(true, false);
                            new File(str).setReadable(true, false);
                        } catch (NoSuchMethodError e3) {
                            e3.printStackTrace();
                        }
                        m6907(str);
                    }
                } else {
                    strArr = m6995;
                }
                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 (!C2975.f9323.booleanValue()) {
                    m7101(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356), jSONObject2.toString());
                    try {
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setWritable(true, false);
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setReadable(true, false);
                        m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                    } catch (NoSuchMethodError e5) {
                        e5.printStackTrace();
                    }
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                } else {
                    m7101(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356), jSONObject2.toString());
                    try {
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setWritable(true, false);
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setReadable(true, false);
                    } catch (NoSuchMethodError e6) {
                        e6.printStackTrace();
                    }
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                }
            } else {
                strArr = m6995;
                if (C2975.f9323.booleanValue()) {
                    try {
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setWritable(true, false);
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setReadable(true, false);
                        m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                    } catch (NoSuchMethodError e7) {
                        e7.printStackTrace();
                    }
                    m7094("chmod", "777", str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                } else {
                    try {
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setWritable(true, false);
                        new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).setReadable(true, false);
                    } catch (NoSuchMethodError e8) {
                        e8.printStackTrace();
                    }
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                }
            }
            try {
                new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
            } catch (JSONException unused) {
                m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
            }
            try {
                jSONObject = new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
            } 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 (C2975.f9323.booleanValue()) {
                    m7101(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356), jSONObject3.toString());
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                } else {
                    m7101(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356), jSONObject3.toString());
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                }
                try {
                    jSONObject = new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
                } catch (JSONException e11) {
                    m6907(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356);
                    e11.printStackTrace();
                    numArr[i2] = 0;
                    jSONObject = jSONObject3;
                }
            }
            try {
                jSONObject.getBoolean("module_on");
                numArr[i2] = 1;
            } catch (JSONException e12) {
                e12.printStackTrace();
            }
            i2++;
            m6995 = 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 m7023(Activity activity, File file, Integer num) {
        if (activity != null) {
            if (num == null) {
                C2975.m7954(new RunnableC2537(file, activity));
            } else {
                C2975.m7954(new RunnableC2544(file, activity, num));
            }
        }
    }

    public static String m7024(String str, String str2, boolean z, boolean z2) {
        File file;
        File file2;
        File file3;
        try {
            String str3 = "pm install -r ";
            if (C2975.f9299 >= 34 && str != null && m6994(new File(str)).f7643 < (C2975.f9299 - 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 (C2975.f9299 >= 28) {
                    File file4 = new File(str);
                    if (!file4.exists() || !file4.canRead()) {
                        return "";
                    }
                    String str4 = C2975.m7929().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());
                        m6875(file4, file2);
                    }
                    if (file2.getAbsolutePath().startsWith("/data/data/") || file2.getAbsolutePath().startsWith("/data/user/")) {
                        File file5 = file2;
                        do {
                            m7093("chmod 777 '" + file5.getAbsolutePath() + "'");
                            file5 = m6942(file5);
                            if (file5.getAbsolutePath().toLowerCase().equals("/data/data") || file5.getAbsolutePath().toLowerCase().equals("/data/user")) {
                                break;
                            }
                        } while (file5.getAbsolutePath().length() > 10);
                    }
                    String m7211 = new C2500("").m7211(str3 + "-i " + str2 + " '" + file2.getAbsolutePath() + "'");
                    if (!file4.getAbsolutePath().startsWith(str4)) {
                        file2.delete();
                    }
                    if (!m7211.contains("IllegalArgumentException") && !C2975.f9298.contains("IllegalArgumentException")) {
                        return m7211;
                    }
                    String m6940 = m6940();
                    new File(m6940).mkdirs();
                    if (file4.getAbsolutePath().startsWith(m6940)) {
                        file3 = file4;
                    } else {
                        file3 = new File(m6940 + file4.getName());
                        m6875(file4, file3);
                    }
                    if (file3.getAbsolutePath().startsWith("/data/")) {
                        File file6 = file3;
                        while (true) {
                            m7093("chmod 777 '" + file6.getAbsolutePath() + "'");
                            file6 = m6942(file6);
                            Object obj2 = obj;
                            if (file6.getAbsolutePath().toLowerCase().equals(obj2) || file6.getAbsolutePath().length() <= 5) {
                                break;
                            }
                            obj = obj2;
                        }
                    }
                    String m72112 = new C2500("").m7211(str3 + "-i " + str2 + " '" + file3.getAbsolutePath() + "'");
                    if (!file4.getAbsolutePath().startsWith(m6940)) {
                        file3.delete();
                        return m72112;
                    }
                    return m72112;
                }
                if (str.startsWith("/data/data/") || str.startsWith("/data/user/")) {
                    File file7 = new File(str);
                    do {
                        m7093("chmod 777 '" + file7.getAbsolutePath() + "'");
                        file7 = m6942(file7);
                        if (file7.getAbsolutePath().toLowerCase().equals("/data/data") || file7.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            break;
                        }
                    } while (file7.getAbsolutePath().length() > 10);
                }
                return new C2500("").m7211(str3 + "-i " + str2 + " '" + str + "'");
            }
            if (C2975.f9299 >= 28) {
                File file8 = new File(str);
                if (!file8.exists() || !file8.canRead()) {
                    return "";
                }
                String str5 = C2975.m7929().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());
                    m6875(file8, file);
                }
                if (file.getAbsolutePath().startsWith("/data/data/")) {
                    File file9 = file;
                    do {
                        m7093("chmod 777 '" + file9.getAbsolutePath() + "'");
                        file9 = m6942(file9);
                        if (file9.getAbsolutePath().toLowerCase().equals("/data/data") || file9.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            break;
                        }
                    } while (file9.getAbsolutePath().length() > 10);
                }
                String m72113 = new C2500("").m7211(str3 + "'" + file.getAbsolutePath() + "'");
                file.delete();
                if (!m72113.contains("IllegalArgumentException") && !C2975.f9298.contains("IllegalArgumentException")) {
                    return m72113;
                }
                String m69402 = m6940();
                new File(m69402).mkdirs();
                if (!file8.getAbsolutePath().startsWith(m69402)) {
                    File file10 = new File(m69402 + file8.getName());
                    m6875(file8, file10);
                    file8 = file10;
                }
                if (file8.getAbsolutePath().startsWith("/data/")) {
                    File file11 = file8;
                    do {
                        m7093("chmod 777 '" + file11.getAbsolutePath() + "'");
                        file11 = m6942(file11);
                        if (file11.getAbsolutePath().toLowerCase().equals("/data")) {
                            break;
                        }
                    } while (file11.getAbsolutePath().length() > 5);
                }
                String m72114 = new C2500("").m7211(str3 + "'" + file8.getAbsolutePath() + "'");
                file8.delete();
                return m72114;
            }
            if (str.startsWith("/data/data/") || str.startsWith("/data/user/")) {
                File file12 = new File(str);
                do {
                    m7093("chmod 777 '" + file12.getAbsolutePath() + "'");
                    file12 = m6942(file12);
                    if (file12.getAbsolutePath().toLowerCase().equals("/data/data") || file12.getAbsolutePath().toLowerCase().equals("/data/user")) {
                        break;
                    }
                } while (file12.getAbsolutePath().length() > 10);
            }
            return new C2500("").m7211(str3 + "'" + str + "'");
        } catch (ApkFormatException e) {
            throw new RuntimeException(e);
        } catch (IOException e2) {
            throw new RuntimeException(e2);
        }
    }

    public static String m7025(File file, ArrayList<File> arrayList, String str, boolean z, boolean z2) {
        String str2;
        ZipFile zipFile;
        String str3;
        try {
            if (C2975.f9283) {
                String str4 = "pm install-create -r ";
                if (C2975.f9299 >= 34) {
                    if (file != null) {
                        if (m6994(m6928(file)).f7643 < (C2975.f9299 - 34) + 23) {
                            str4 = "pm install-create -r --bypass-low-target-sdk-block ";
                        }
                    } else if (arrayList != null && arrayList.size() > 0 && m6994(m6929(arrayList)).f7643 < (C2975.f9299 - 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 m7211 = new C2500("").m7211(str4);
                C2975.m7942(m7211);
                Matcher matcher = Pattern.compile("(\\d+)").matcher(m7211);
                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 = m7211;
                        if (fileName.toLowerCase().endsWith(".apk")) {
                            C2975.m7942("for " + fileName);
                            String m7005 = m7005();
                            if (!file.getAbsolutePath().startsWith(m7005)) {
                                m6992(new File(m7005));
                            }
                            File file2 = new File(m7005 + 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();
                            C2975.m7942("file " + file2.getName() + " extracted");
                            if (file2.getAbsolutePath().startsWith("/data/data/") || file2.getAbsolutePath().startsWith("/data/user/")) {
                                File file3 = file2;
                                do {
                                    m7093("chmod 777 '" + file3.getAbsolutePath() + "'");
                                    file3 = m6942(file3);
                                    if (file3.getAbsolutePath().toLowerCase().equals(str5) || file3.getAbsolutePath().toLowerCase().equals("/data/user")) {
                                        break;
                                    }
                                } while (file3.getAbsolutePath().length() > 10);
                            }
                            C2500 c2500 = new C2500("");
                            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 m7207 = c2500.m7207(sb.toString(), new FileInputStream(file2));
                            C2975.m7942(m7207);
                            file2.delete();
                            m7211 = m7207;
                        } else {
                            str2 = str5;
                            zipFile = zipFile2;
                            str3 = str6;
                            m7211 = 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;
                            C2500 c25002 = new C2500("");
                            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("'");
                            m7211 = c25002.m7207(sb2.toString(), new BufferedInputStream(new FileInputStream(next)));
                            C2975.m7942(m7211);
                        }
                        File file4 = next;
                        do {
                            m7093("chmod 777 '" + file4.getAbsolutePath() + "'");
                            file4 = m6942(file4);
                            if (!file4.getAbsolutePath().toLowerCase().equals(str8) && !file4.getAbsolutePath().toLowerCase().equals("/data/user")) {
                            }
                            break;
                        } while (file4.getAbsolutePath().length() > 10);
                        C2500 c250022 = new C2500("");
                        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("'");
                        m7211 = c250022.m7207(sb22.toString(), new BufferedInputStream(new FileInputStream(next)));
                        C2975.m7942(m7211);
                    }
                }
                String m72112 = new C2500("").m7211("pm install-commit " + parseInt + " ");
                if (file != null && file.getName().toLowerCase().endsWith(".xapk") && ((m72112.toLowerCase().contains("success") || C2975.f9298.toLowerCase().contains("success")) && !m7096(file))) {
                    m7130(C2975.f9259, m7007(R.string.warning), m7007(R.string.error_expansion_copy_to_sdcard));
                }
                if (!m72112.toLowerCase().contains("success") && !C2975.f9298.toLowerCase().contains("success")) {
                    String str11 = C2975.f9298;
                    new C2500().m7211(C2975.f9284 + C1696.class.getName() + " temp");
                    C2975.f9298 = str11;
                }
                C2975.m7942(m7211);
                m6992(new File(m7005()));
                return m72112;
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return "";
    }

    public static final boolean m7026(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.") && !str.contains(".bidmachine.") && !str.contains(".mbridge.") && !str.contains(".bytedance.") && !str.contains(".kidoz.")) {
            return false;
        }
        return true;
    }

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

    public static boolean m7028(C3478 c3478) {
        boolean z;
        boolean z2;
        boolean z3;
        ApplicationInfo applicationInfo;
        String str;
        try {
            try {
                applicationInfo = C2975.m7932().getApplicationInfo(c3478.f10046, ItemType.CLASS_DATA_ITEM);
                str = applicationInfo.sourceDir;
            } catch (PackageManager.NameNotFoundException unused) {
                C2975.m7942("LuckyPatcher: app is deleted - " + c3478.f10046);
                C2975.f9249.m7892(c3478.f10046);
                return false;
            }
        } catch (Throwable th) {
            th = th;
            z = false;
        }
        if (((int) (m7020(c3478.f10046, false) / 1000)) != c3478.f10063) {
            C2975.m7942("pkg install time changed:" + str + " " + c3478.f10063);
            return true;
        }
        if (!str.equals(c3478.f10067)) {
            C2975.m7942("pkg dir changed:" + str + " " + c3478.f10067);
            return true;
        }
        if ((applicationInfo.flags & 1) != 0) {
            z2 = true;
        } else {
            z2 = false;
        }
        try {
            if (C2975.f9249 == null) {
                C2975.f9249 = new C2938(C2975.m7929());
            }
            if (m7046(str)) {
                if (!c3478.f10062) {
                    return true;
                }
            } else if (c3478.f10062) {
                return true;
            }
        } catch (Throwable th2) {
            z = z2;
            th = th2;
            th.printStackTrace();
            z2 = z;
            if (!m7033(c3478.f10046)) {
            }
            if (!m7043(c3478.f10046)) {
            }
            z3 = c3478.f10061;
            if (!z3) {
            }
            if (!m7030(c3478.f10046)) {
            }
            return false;
        }
        if (!m7033(c3478.f10046)) {
            if (!c3478.f10056) {
                return true;
            }
        } else if (c3478.f10056) {
            return true;
        }
        if (!m7043(c3478.f10046)) {
            if (!c3478.f10060) {
                return true;
            }
        } else if (c3478.f10060) {
            return true;
        }
        z3 = c3478.f10061;
        if ((!z3 && !z2) || (!z3 && z2)) {
            return true;
        }
        if (!m7030(c3478.f10046)) {
            if (!c3478.f10054) {
                return true;
            }
        } else if (c3478.f10054) {
            return true;
        }
        return false;
    }

    public static boolean m7029(File file) {
        m7179();
        try {
            AndroidBinXmlParser androidBinXmlParser = new AndroidBinXmlParser(m6916(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()) {
                    C2975.m7942(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 m7030(String str) {
        m7179();
        File[] listFiles = C2975.m7929().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 m7031() {
        C2608 c2608 = new C2608();
        c2608.f7407 = true;
        c2608.f7412 = true;
        c2608.f7409 = true;
        if (m6955(c2608).size() > 0) {
            return true;
        }
        return false;
    }

    public static boolean m7032(File file, C2612 c2612) {
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C2975.m7942("run containNativeMethod");
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                try {
                    for (DexBackedClassDef dexBackedClassDef : DexBackedDexFile.fromInputStream(null, bufferedInputStream2).getClasses()) {
                        if (dexBackedClassDef != null) {
                            Iterator<C2631> it = c2612.f7443.iterator();
                            while (it.hasNext()) {
                                C2631 next = it.next();
                                for (DexBackedMethod dexBackedMethod : dexBackedClassDef.getMethods()) {
                                    if (dexBackedMethod != null && (dexBackedMethod.getAccessFlags() & EnumC4369.NATIVE.getValue()) != 0 && dexBackedMethod.getName().equals(next.f7565) && (next.f7564.equals("") || dexBackedMethod.getDefiningClass().equals(next.f7564))) {
                                        if (next.f7563.equals("") || dexBackedMethod.getReturnType().equals(next.f7563)) {
                                            C2975.m7942(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 m7033(String str) {
        File[] fileArr;
        m7179();
        try {
            File[] fileArr2 = C2975.f9256;
            if (fileArr2 == null || fileArr2.length == 0 || C2975.f9257) {
                C2975.m7938(C2975.m7929());
                try {
                    C2975.f9251 = C2975.m7928().getString("basepath", C2975.f9251);
                    File file = new File(C2975.f9251 + "/CustomPatches");
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    C2975.f9256 = new File[file.listFiles().length];
                    C2975.f9256 = file.listFiles();
                    ArrayList arrayList = new ArrayList();
                    arrayList.clear();
                    int i = 0;
                    while (true) {
                        File[] fileArr3 = C2975.f9256;
                        if (i >= fileArr3.length) {
                            break;
                        }
                        if (fileArr3[i].isFile() && C2975.f9256[i].getName().endsWith(".txt")) {
                            arrayList.add(C2975.f9256[i]);
                        }
                        i++;
                    }
                    if (arrayList.size() > 0) {
                        File[] fileArr4 = new File[arrayList.size()];
                        C2975.f9256 = fileArr4;
                        C2975.f9256 = (File[]) arrayList.toArray(fileArr4);
                    }
                } catch (Exception unused) {
                    C2975.m7942("Not found dir by Lucky Patcher. Custom patch not found.");
                }
                C2975.f9257 = false;
            }
            fileArr = C2975.f9256;
        } 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 m7034(Uri uri) {
        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
    }

    public static boolean m7035(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();
            C2975.m7942("Check file: is ELF.");
            return true;
        }
        channel.close();
        C2975.m7942("Check file: is not ELF.");
        return false;
    }

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

    public static void m7037(LinearLayout linearLayout, Runnable runnable, Timer timer, TimerTask timerTask) {
        C2975 c2975;
        if (linearLayout.findViewWithTag("UnityBanner") == null && (c2975 = C2975.f9245) != null) {
            UnityAds.initialize((Activity) c2975.mo1874(), "5531053", (IUnityAdsListener) new C2517(), false, true);
            C2975.m7942(Float.valueOf(m6896(C2975.m7933().getDisplayMetrics().widthPixels)));
            BannerView bannerView = new BannerView(C2975.f9245.mo1874(), "banner", UnityBannerSize.getDynamicSize(C2975.f9245.mo1874()));
            bannerView.setListener(new C2519(timer, timerTask, linearLayout, runnable));
            ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2, 0.0f);
            bannerView.setTag("UnityBanner");
            C2975.m7942("unity banner wight:" + bannerView.getSize().getWidth());
            linearLayout.addView(bannerView, layoutParams);
            bannerView.load();
        }
    }

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

    public static boolean m7039() {
        if (C2975.f9344 == null) {
            C2975.f9344 = Boolean.FALSE;
        }
        if (!C2975.f9344.booleanValue()) {
            Boolean bool = C2975.f9345;
            if (bool == null) {
                if (C2975.m7929().getApplicationInfo().packageName.contains("installer")) {
                    C2975.f9345 = Boolean.TRUE;
                    return true;
                }
                C2975.f9345 = Boolean.FALSE;
                return false;
            }
            return bool.booleanValue();
        }
        C2975.f9345 = Boolean.FALSE;
        return false;
    }

    public static boolean m7040(String str) {
        String str2;
        if (C2975.f9299 > 7) {
            try {
                if ((C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.flags & 262144) == 262144) {
                    return true;
                }
                return false;
            } catch (PackageManager.NameNotFoundException unused) {
            }
        }
        try {
            str2 = C2975.m7932().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 m7041(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(C2975.f9237.toLowerCase())) {
            return false;
        }
        return true;
    }

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

    public static boolean m7043(String str) {
        m7179();
        byte[] bArr = null;
        try {
            bArr = C2975.m7932().getPackageInfo(str, 8256).signatures[0].toByteArray();
            if (C2975.m7928().getBoolean(str, false)) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        if (C2641.m7294(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 m7044() {
        if (C2975.m7928().getBoolean("option_force_turn_off_magisk", false) || !m7060()) {
            return false;
        }
        C2500 c2500 = new C2500();
        return !c2500.m7211(C2975.f9284 + C1666.class.getName()).contains("Magisk modules not found");
    }

    public static void m7045() {
        File[] listFiles;
        m7179();
        m7078("/system", "ro");
        if (C2975.f9323.booleanValue()) {
            if (C2975.f9299 >= 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")) {
                                        C2975.m7942("delete folder:" + file2.getAbsolutePath());
                                        new C2500("").m7194(file2);
                                    }
                                }
                            }
                        }
                    }
                } catch (Exception unused) {
                }
            }
            m7094("rm", "/data/dalvik-cache/*.dex");
            m7094("rm", "/data/dalvik-cache/*.oat");
            m7094("rm", "/data/dalvik-cache/*.art");
            m7094("rm", "/data/dalvik-cache/arm/*.dex");
            m7094("rm", "/data/dalvik-cache/arm/*.art");
            m7094("rm", "/data/dalvik-cache/arm/*.oat");
            m7094("rm", "/data/dalvik-cache/arm64/*.dex");
            m7094("rm", "/data/dalvik-cache/arm64/*.art");
            m7094("rm", "/data/dalvik-cache/arm64/*.oat");
            m7094("rm", "/data/dalvik-cache/x86/*.dex");
            m7094("rm", "/data/dalvik-cache/x86/*.art");
            m7094("rm", "/data/dalvik-cache/x86/*.oat");
            m7094("rm", "/data/dalvik-cache/x86_64/*.dex");
            m7094("rm", "/data/dalvik-cache/x86_64/*.art");
            m7094("rm", "/data/dalvik-cache/x86_64/*.oat");
            return;
        }
        m7093("rm /data/dalvik-cache/*.dex");
        m7093("rm /data/dalvik-cache/*.oat");
        m7093("rm /data/dalvik-cache/*.art");
        m7093("rm /data/dalvik-cache/arm/*.dex");
        m7093("rm /data/dalvik-cache/arm/*.art");
        m7093("rm /data/dalvik-cache/arm/*.oat");
        m7093("rm /data/dalvik-cache/arm64/*.dex");
        m7093("rm /data/dalvik-cache/arm64/*.art");
        m7093("rm /data/dalvik-cache/arm64/*.oat");
        m7093("rm /data/dalvik-cache/x86/*.dex");
        m7093("rm /data/dalvik-cache/x86/*.art");
        m7093("rm /data/dalvik-cache/x86/*.oat");
        m7093("rm /data/dalvik-cache/x86_64/*.dex");
        m7093("rm /data/dalvik-cache/x86_64/*.art");
        m7093("rm /data/dalvik-cache/x86_64/*.oat");
    }

    public static boolean m7046(String str) {
        try {
            File file = new File(str);
            String m7176 = m7176(file.getName(), "odex");
            if (C2975.f9299 >= 23) {
                if (new File(m6942(file) + "/oat/arm/" + m7176).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/oat/arm64/" + m7176).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/oat/x86/" + m7176).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/oat/x86_64/" + m7176).exists()) {
                    return true;
                }
            } else {
                if (new File(m7176(str, "odex")).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/arm/" + m7176(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/arm64/" + m7176(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/x86/" + m7176(file.getName(), "odex")).exists()) {
                    return true;
                }
                if (new File(m6942(file) + "/x86_64/" + m7176(file.getName(), "odex")).exists()) {
                    return true;
                }
            }
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

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

    public static final boolean m7048(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 m7049(String str) {
        if (!str.startsWith("/data/") && !str.startsWith("/mnt/")) {
            return true;
        }
        return false;
    }

    public static boolean m7050(byte[] bArr) {
        String replaceAll = C2641.m7294(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 boolean m7051() {
        if (C2975.f9299 >= 23) {
            String m7211 = new C2500("").m7211(C2975.f9284 + C1686.class.getName() + " 123");
            C2975.f9323 = Boolean.FALSE;
            if (m7211.contains("withoutFramework") || C2975.f9298.contains("java.lang.ClassNotFoundException:")) {
                return false;
            }
            C2975.m7942("WithFramework support");
            return true;
        }
        String m72112 = new C2500("").m7211(C2975.f9285 + C1686.class.getName() + " 123");
        C2975.f9323 = Boolean.FALSE;
        if (m72112.contains("withoutFramework") || C2975.f9298.contains("java.lang.ClassNotFoundException:")) {
            return false;
        }
        C2975.m7942("WithFramework support");
        return true;
    }

    public static long m7052(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 m7053(String str) {
        if (!C2975.f9323.booleanValue()) {
            m7054(str);
        } else if (C2975.f9283) {
            m7054(str);
        }
    }

    public static boolean m7054(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;
        }
        C2975.m7942(str2);
        if (!C2975.f9323.booleanValue()) {
            C2500 c2500 = new C2500("");
            StringBuilder sb2 = new StringBuilder();
            Object obj = "0";
            sb2.append(C2975.f9250);
            sb2.append("/busybox ps |grep '");
            sb2.append(str2);
            sb2.append("'");
            String m7211 = c2500.m7211(sb2.toString());
            if (m7211.startsWith("~")) {
                m6900();
                try {
                    C2975.m7937();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                m7211 = new C2500("").m7211(C2975.f9250 + "/busybox ps");
                if (m7211.startsWith("~")) {
                    i2 = 1;
                    m7211 = new C2500("").m7211("busybox ps");
                } else {
                    i2 = 1;
                }
                if (m7211.startsWith("~")) {
                    C2500 c25002 = new C2500("");
                    String[] strArr2 = new String[i2];
                    strArr2[0] = "ps";
                    m7211 = c25002.m7211(strArr2);
                }
            }
            if (!m7211.equals("~") && !m7211.equals("")) {
                String[] split = m7211.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("*");
                                    C2975.m7942(sb.toString());
                                    String str4 = split2[0];
                                    arrayList.add(str4);
                                    C2975.m7942("Found pid: " + str4 + " for " + str2);
                                } catch (Exception e3) {
                                    e = e3;
                                    C2975.m7942("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();
                            C2975.m7942("Kill: " + str5 + " for " + str2);
                            Object obj2 = obj;
                            if (!str5.equals(obj2)) {
                                new C2500("").m7211("kill -9 " + str5);
                                new C2500("").m7211("am force-stop " + str);
                                new C2500("").m7211("am kill --user all " + str);
                            }
                            obj = obj2;
                        }
                        return true;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
        if (C2975.f9283) {
            String m7098 = m7098(C2975.f9250 + "/busybox", "ps", "grep", str2);
            if (m7098.startsWith("~")) {
                if (m7098.startsWith("~")) {
                    c2 = 0;
                    c = 1;
                    m7098 = m7098(C2975.f9250 + "/busybox", "ps");
                } else {
                    c = 1;
                    c2 = 0;
                }
                if (m7098.startsWith("~")) {
                    i = 2;
                    String[] strArr3 = new String[2];
                    strArr3[c2] = "busybox";
                    strArr3[c] = "ps";
                    m7098 = m7098(strArr3);
                } else {
                    i = 2;
                }
                if (m7098.startsWith("~")) {
                    String[] strArr4 = new String[i];
                    strArr4[c2] = "toolbox";
                    strArr4[c] = "ps";
                    m7098 = m7098(strArr4);
                }
            }
            if (!m7098.equals("~") && !m7098.equals("")) {
                String[] split3 = m7098.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);
                                    C2975.m7942("Found pid: " + str7 + " for " + str2);
                                } catch (Exception e4) {
                                    C2975.m7942("Error with regex! " + e4);
                                }
                            }
                        }
                    }
                    if (arrayList2.size() > 0) {
                        Iterator it2 = arrayList2.iterator();
                        while (it2.hasNext()) {
                            String str8 = (String) it2.next();
                            C2975.m7942("Kill: " + str8 + " for " + str2);
                            if (!str8.equals("0")) {
                                m7098("kill", "-9", str8);
                                m7098("am", "force-stop", str);
                                m7098("am", "kill", "--user", "all", str);
                            }
                        }
                        return true;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
        return false;
    }

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

    public static void m7056(boolean z) {
        if (C2975.f9283) {
            new Thread(new RunnableC2556(z)).start();
        }
    }

    public static void m7057(boolean z) {
        PackageInfo packageInfo;
        ServiceInfo[] serviceInfoArr;
        if (C2975.f9283) {
            new ArrayList();
            try {
                packageInfo = C2975.m7932().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")) && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", packageInfo.services[i].name)) != 2) {
                                    new C2500("").m7211("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")) && C2975.m7932().getComponentEnabledSetting(new ComponentName("com.android.vending", packageInfo.services[i].name)) != 1) {
                            new C2500("").m7211("pm enable 'com.android.vending/" + packageInfo.services[i].name + "'", "skipOut");
                        }
                        i++;
                    } else {
                        return;
                    }
                }
            }
        }
    }

    public static void m7058(boolean z) {
        if (C2975.f9283) {
            new Thread(new RunnableC2559(z)).start();
        }
    }

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

    public static boolean m7060() {
        return !m6969().equals("") && C2975.f9299 >= 23;
    }

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

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

    public static void m7063(String str, String str2, String str3, String str4, String str5) {
        C2975.m7942("uid:" + str4);
        if (str.contains("copyDC") || str.contains("deleteDC")) {
            File m6947 = m6947(str2);
            if (m6947 != null) {
                m6947.delete();
                if (str.contains("copyDC")) {
                    m6875(new File(str3), m6947);
                    if (m6947.exists() && m6947.length() == new File(str3).length()) {
                        new File(str3).delete();
                        m7094("chmod", "644", m6947.getAbsolutePath());
                        m7094("chown", "1000:" + str4, m6947.getAbsolutePath());
                        m7094("chown", "1000." + str4, m6947.getAbsolutePath());
                        return;
                    }
                    return;
                }
                return;
            }
            if (str.contains("copyDC")) {
                File m6948 = m6948(str2);
                m6875(new File(str3), m6948);
                if (m6948.exists() && m6948.length() == new File(str3).length()) {
                    new File(str3).delete();
                    m7094("chmod", "644", m6948.getAbsolutePath());
                    m7094("chown", "1000:" + str4, m6948.getAbsolutePath());
                    m7094("chown", "1000." + str4, m6948.getAbsolutePath());
                }
            }
        }
    }

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

    public static void m7065(boolean z, boolean z2, boolean z3) {
        File file = new File(C2975.f9250 + "/pinapp.apk");
        long m6983 = m6983(R.raw.pinapp);
        if (!file.exists() || file.length() != m6983) {
            if (file.length() != m6983) {
                File file2 = new File(C2975.f9250 + "/pinapp.apk");
                if (file2.exists()) {
                    file2.delete();
                }
                C2975.m7942("LuckyPatcher: p.info version updated. " + m6983 + " " + file.length());
                if (file.exists()) {
                    file.delete();
                }
            }
            try {
                m6984(R.raw.pinapp, new File(C2975.f9250 + "/pinapp.apk"));
            } catch (Exception unused) {
            }
            try {
                m6941(new File(file.getAbsolutePath()), 3583);
            } catch (Exception e) {
                C2975.m7942(e);
                e.printStackTrace();
            }
            if (C2975.f9283) {
                m7093("chmod 06777 " + file.getAbsolutePath());
                m7093("chown 0.0 " + file.getAbsolutePath());
                m7093("chown 0:0 " + file.getAbsolutePath());
            }
        }
        boolean z4 = false;
        if (((new File(C2975.f9250 + "/pinapp.apk").canRead() && !C2975.m7928().getBoolean("dont_show_pinapp", false)) || z) && !z2) {
            boolean z5 = true;
            PackageInfo m6922 = m6922(C2975.f9250 + "/pinapp.apk", 1);
            String str = m6922.packageName;
            try {
            } catch (PackageManager.NameNotFoundException unused2) {
                if (!z3) {
                    z5 = false;
                    z4 = true;
                    if (!z4) {
                        C2975.m7954(new RunnableC2528(z5, str, file));
                        return;
                    }
                    return;
                }
                z5 = false;
                if (!z4) {
                }
            }
        } else {
            if (!new File(C2975.f9250 + "/pinapp.apk").canRead()) {
                m7130(C2975.f9259, m7007(R.string.warning), m7007(R.string.warning_internal_data_folder_corrupt));
            }
        }
    }

    public static void m7066() {
        File file = new File(C2975.f9250 + "/p.apk");
        long m6983 = m6983(R.raw.p);
        if (!file.exists() || file.length() != m6983) {
            if (file.length() != m6983) {
                File file2 = new File(C2975.f9250 + "/p_gp.apk");
                if (file2.exists()) {
                    file2.delete();
                }
                C2975.m7942("LuckyPatcher: p.info version updated. " + m6983 + " " + file.length());
                if (file.exists()) {
                    file.delete();
                }
            }
            try {
                m6984(R.raw.p, new File(C2975.f9250 + "/p.apk"));
            } catch (Exception unused) {
            }
            try {
                m6941(new File(file.getAbsolutePath()), 3583);
            } catch (Exception e) {
                C2975.m7942(e);
                e.printStackTrace();
            }
            m7093("chmod 06777 " + file.getAbsolutePath());
            m7093("chown 0.0 " + file.getAbsolutePath());
            m7093("chown 0:0 " + file.getAbsolutePath());
        }
        File file3 = new File(C2975.f9250 + "/empty_class");
        long m69832 = m6983(R.raw.pcl);
        if (!file3.exists() || file3.length() != m69832) {
            if (file3.length() != m69832) {
                C2975.m7942("LuckyPatcher: pcl.info version updated. " + m69832 + " " + file3.length());
                if (file3.exists()) {
                    file3.delete();
                }
            }
            try {
                m6984(R.raw.pcl, new File(C2975.f9250 + "/empty_class"));
            } catch (Exception unused2) {
            }
            try {
                m6941(new File(file3.getAbsolutePath()), 3583);
            } catch (Exception e2) {
                C2975.m7942(e2);
                e2.printStackTrace();
            }
            m7093("chmod 06777 " + file3.getAbsolutePath());
            m7093("chown 0.0 " + file3.getAbsolutePath());
            m7093("chown 0:0 " + file3.getAbsolutePath());
        }
    }

    public static void m7067(PackageInfo packageInfo) {
        ZipOutputStream zipOutputStream;
        FileOutputStream fileOutputStream;
        try {
            int m7018 = m7018(new File(packageInfo.applicationInfo.sourceDir));
            File file = new File(C2975.f9250 + "/p_gp.apk");
            if (file.exists() && m7018(file) == m7018) {
                return;
            }
            C2975.m7942("" + m7018);
            C2975.m7942("22222222222222222222222222222222222222222222222222222222222");
            byte[] bArr = new byte[4096];
            FileOutputStream fileOutputStream2 = null;
            try {
                if (file.exists()) {
                    file.delete();
                }
                FileInputStream fileInputStream = new FileInputStream(C2975.f9250 + "/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 <= m7018; i++) {
                            FileInputStream fileInputStream2 = new FileInputStream(C2975.f9250 + "/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();
                        }
                        m7093("chmod 06777 " + C2975.f9250 + "/p_gp.apk");
                        m7093("chown 0.0 " + C2975.f9250 + "/p_gp.apk");
                        m7093("chown 0:0 " + C2975.f9250 + "/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 m7068(float f) {
        return f * C2975.m7933().getDisplayMetrics().density;
    }

    public static String m7069(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 m7070(MappedByteBuffer mappedByteBuffer) {
        int i;
        int i2 = 0;
        int i3 = 0;
        do {
            int i4 = mappedByteBuffer.get() & 255;
            i2 |= (i4 & 127) << (i3 * 7);
            i3++;
            i = i4 & Opcode.VOLATILE_FIELD_ACCESSOR;
            if (i != 128) {
                break;
            }
        } while (i3 < 5);
        if (i == 128) {
            C2975.m7942("LuckyPatcher:invalid LEB128 sequence");
        }
        return i2;
    }

    public static JSONObject m7071() throws JSONException {
        JSONObject jSONObject = null;
        for (String str : m6995()) {
            try {
                if (new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).exists()) {
                    if (new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356).canRead()) {
                        jSONObject = new JSONObject(m7072(new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9356)));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return jSONObject;
    }

    public static String m7072(File file) {
        m7179();
        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 m7073() {
        if (!C2975.f9323.booleanValue()) {
            try {
                new C2500("").m7211("reboot");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/bin/reboot");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/xbin/reboot");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2500("").m7211("busybox reboot");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m7019("reboot");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m7093("reboot");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C2975.f9259.runOnUiThread(new RunnableC2503());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2500("w").m7212(5000L);
            try {
                m7093(C2975.m7929().getFilesDir() + "/reboot");
                return;
            } catch (Exception e8) {
                e8.printStackTrace();
                return;
            }
        }
        try {
            m7098("reboot");
        } catch (Exception e9) {
            e9.printStackTrace();
        }
        try {
            m7098("/system/bin/reboot");
        } catch (Exception e10) {
            e10.printStackTrace();
        }
        try {
            m7098("/system/xbin/reboot");
        } catch (Exception e11) {
            e11.printStackTrace();
        }
        try {
            m7098("busybox reboot");
        } catch (Exception e12) {
            e12.printStackTrace();
        }
        try {
            m7019("reboot");
        } catch (Exception e13) {
            e13.printStackTrace();
        }
        try {
            m7094("reboot");
        } catch (Exception e14) {
            e14.printStackTrace();
        }
        try {
            m7094(C2975.f9250 + "/reboot");
        } catch (Exception e15) {
            e15.printStackTrace();
        }
    }

    public static void m7074() {
        if (!C2975.f9323.booleanValue()) {
            try {
                new C2500("").m7211("reboot bootloader");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/bin/reboot bootloader");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/xbin/reboot bootloader");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2500("").m7211("busybox reboot bootloader");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m7019("reboot bootloader");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m7093("reboot bootloader");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C2975.f9259.runOnUiThread(new RunnableC2522());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2500("w").m7212(5000L);
            try {
                m7093(C2975.m7929().getFilesDir() + "/reboot");
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
    }

    public static void m7075() {
        if (!C2975.f9323.booleanValue()) {
            try {
                new C2500("").m7211("reboot recovery");
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/bin/reboot recovery");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            try {
                new C2500("").m7211("/system/xbin/reboot recovery");
            } catch (Exception e3) {
                e3.printStackTrace();
            }
            try {
                new C2500("").m7211("busybox reboot recovery");
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            try {
                m7019("reboot recovery");
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            try {
                m7093("reboot recovery");
            } catch (Exception e6) {
                e6.printStackTrace();
            }
            try {
                C2975.f9259.runOnUiThread(new RunnableC2513());
            } catch (Exception e7) {
                e7.printStackTrace();
            }
            new C2500("w").m7212(5000L);
            try {
                m7093(C2975.m7929().getFilesDir() + "/reboot");
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
    }

    public static void m7076(String str, String str2, ArrayList<C2630> arrayList, File file) throws IOException {
        m6942(new File(str2)).mkdirs();
        try {
            C2420 c2420 = new C2420(str);
            try {
                C2426 c2426 = new C2426(new File(str2));
                Enumeration<C2419> m6611 = c2420.m6611();
                while (m6611.hasMoreElements()) {
                    C2419 nextElement = m6611.nextElement();
                    String name = nextElement.getName();
                    if (!name.toLowerCase().endsWith(".dex") && !name.toLowerCase().endsWith(".so") && !name.toLowerCase().endsWith(".xml") && !name.toLowerCase().endsWith(".arsc")) {
                        c2426.m6633(nextElement, c2420);
                    }
                    Iterator<C2630> it = arrayList.iterator();
                    boolean z = false;
                    while (it.hasNext()) {
                        C2630 next = it.next();
                        if (name.equals(next.f7546)) {
                            c2426.m6634(nextElement, c2420, next.f7547, next.f7548);
                            if (nextElement.getCrc() != next.f7547) {
                                C2975.m7942("correct entry " + next.f7546);
                            }
                            z = true;
                        }
                    }
                    if (!z) {
                        m7130(C2975.f9259, m7007(R.string.warning), m7009(R.string.error_file_not_found_in_original_apk, name, file.getName()));
                        c2426.m6633(nextElement, c2420);
                    }
                }
                c2426.close();
                c2420.close();
            } finally {
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void m7077(String str, String str2, ArrayList<C2616> arrayList, ArrayList<String> arrayList2, ArrayList<C2610> arrayList3, ArrayList<String> arrayList4) throws IOException {
        m6942(new File(str2)).mkdirs();
        try {
            C2420 c2420 = new C2420(str);
            try {
                C2426 c2426 = new C2426(new File(str2));
                ArrayList arrayList5 = new ArrayList();
                if (arrayList3 != null) {
                    Iterator<C2610> it = arrayList3.iterator();
                    while (it.hasNext()) {
                        C2610 next = it.next();
                        if (c2420.m6612(next.f7431) != null) {
                            C2975.m7942("Found file to zip:" + next.f7430);
                            arrayList5.add(next.f7431);
                            C2975.m7942("Remove file from zip:" + next.f7431);
                        }
                        try {
                            File file = new File(next.f7430);
                            C2419 c2419 = new C2419(next.f7431);
                            c2419.setTime(file.lastModified());
                            if (next.f7434) {
                                c2419.setMethod(8);
                            } else {
                                c2419.setMethod(0);
                            }
                            c2426.m6638(c2419);
                            c2426.m6644(new FileInputStream(file));
                            c2426.m6632();
                            C2975.m7942("LuckyPatcher (signer): Add file to entries: " + next.f7430);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                Enumeration<C2419> m6611 = c2420.m6611();
                while (m6611.hasMoreElements()) {
                    C2419 nextElement = m6611.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<C2616> it3 = arrayList.iterator();
                        while (it3.hasNext()) {
                            C2616 next2 = it3.next();
                            if (name.equals(next2.f7470)) {
                                C2975.m7942("Found file to zip:" + next2.f7470);
                                nextElement.m6601(next2.f7471);
                            }
                        }
                    }
                    if (arrayList2 != null) {
                        Iterator<String> it4 = arrayList2.iterator();
                        while (it4.hasNext()) {
                            String next3 = it4.next();
                            if (name.equals(next3)) {
                                C2975.m7942("Found file to zip:" + next3);
                                C2975.m7942("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)) {
                                C2975.m7942("Found folder to zip:" + next4);
                                C2975.m7942("Remove file in folder from zip:" + name);
                                z = true;
                            }
                        }
                    }
                    if (!z) {
                        c2426.m6633(nextElement, c2420);
                    }
                }
                c2426.close();
                c2420.close();
            } finally {
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static boolean m7078(String str, String str2) {
        int i;
        C2973 m6903;
        String str3;
        String str4 = str;
        m7179();
        if (!C2975.f9323.booleanValue()) {
            if (str.toLowerCase().startsWith("/system")) {
                str3 = "LuckyPatcher:not remount ";
                new C2500("").m7211("stop ric");
                if (m6898("/sbin/ric") || m6898("/system/bin/ric")) {
                    new C2500("").m7211("stop ric");
                    m7093("pkill -f /sbin/ric");
                    m7093("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));
            }
            C2973 m69032 = m6903(str4);
            if (m69032 != null) {
                Set<String> m7907 = m69032.m7907();
                Locale locale = Locale.US;
                boolean contains = m7907.contains(str2.toLowerCase(locale));
                if (m69032.m7908().getAbsolutePath().equals("/data")) {
                    C2975.m7942("skip remount for " + m69032.m7908().getAbsolutePath());
                    contains = true;
                }
                if (!contains) {
                    try {
                        C2975.m7942("Run command remount:mount -o remount," + str2.toLowerCase(locale) + " " + m69032.m7906().getAbsolutePath() + " " + m69032.m7908().getAbsolutePath());
                        StringBuilder sb = new StringBuilder();
                        sb.append("blockdev --setrw ");
                        sb.append(m69032.m7906().getAbsolutePath());
                        m7093(sb.toString());
                        m7093("mount -o remount," + str2.toLowerCase(locale) + " " + m69032.m7906().getAbsolutePath() + " " + m69032.m7908().getAbsolutePath());
                        C2973 m69033 = m6903(str4);
                        if (!m69033.m7907().contains(str2.toLowerCase(locale))) {
                            m7093("mount -o remount " + str2.toLowerCase(locale) + " " + m69033.m7906().getAbsolutePath() + " " + m69033.m7908().getAbsolutePath());
                        }
                    } catch (Exception unused) {
                    }
                    m69032 = m6903(str4);
                }
                if (m69032 != null) {
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append(m69032.m7907());
                    sb2.append(" AND ");
                    Locale locale2 = Locale.US;
                    sb2.append(str2.toLowerCase(locale2));
                    C2975.m7942(sb2.toString());
                    if (m69032.m7907().toString().contains(str2.toLowerCase(locale2))) {
                        C2975.m7942("Lucky Patcher: remount " + str4 + " to " + str2);
                        return true;
                    }
                }
            }
            C2975.m7942(str3 + str4 + " to " + str2);
            return false;
        }
        if (str.toLowerCase().startsWith("/system")) {
            m7098("stop", "ric");
            if (new File("/sbin/ric").exists() || new File("/system/bin/ric").exists()) {
                i = 0;
                m7098("stop", "ric");
                m7094("pkill", "-f", "/sbin/ric");
                m7094("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));
                }
                m6903 = m6903(str4);
                if (m6903 != null) {
                    Set<String> m79072 = m6903.m7907();
                    Locale locale3 = Locale.US;
                    boolean contains2 = m79072.contains(str2.toLowerCase(locale3));
                    if (m6903.m7908().getAbsolutePath().equals("/data")) {
                        C2975.m7942("skip remount for " + m6903.m7908().getAbsolutePath());
                        contains2 = true;
                    }
                    if (!contains2) {
                        try {
                            C2975.m7942("Run command remount:mount -o remount," + str2.toLowerCase(locale3) + " " + m6903.m7906().getAbsolutePath() + " " + m6903.m7908().getAbsolutePath());
                            m7094("blockdev", "--setrw", m6903.m7906().getAbsolutePath());
                            StringBuilder sb3 = new StringBuilder();
                            sb3.append("remount,");
                            sb3.append(str2.toLowerCase(locale3));
                            m7094("mount", "-o", sb3.toString(), m6903.m7906().getAbsolutePath(), m6903.m7908().getAbsolutePath());
                            C2973 m69034 = m6903(str4);
                            if (!m69034.m7907().contains(str2.toLowerCase(locale3))) {
                                m7094("mount", "-o", "remount", str2.toLowerCase(locale3), m69034.m7906().getAbsolutePath(), m69034.m7908().getAbsolutePath());
                            }
                        } catch (Exception unused2) {
                        }
                        m6903 = m6903(str4);
                    }
                    if (m6903 != null) {
                        StringBuilder sb4 = new StringBuilder();
                        sb4.append(m6903.m7907());
                        sb4.append(" AND ");
                        Locale locale4 = Locale.US;
                        sb4.append(str2.toLowerCase(locale4));
                        C2975.m7942(sb4.toString());
                        if (m6903.m7907().toString().contains(str2.toLowerCase(locale4))) {
                            C2975.m7942("Lucky Patcher: remount " + str4 + " to " + str2);
                            return true;
                        }
                    }
                }
                C2975.m7942("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));
        }
        m6903 = m6903(str4);
        if (m6903 != null) {
        }
        C2975.m7942("LuckyPatcher:not remount " + str4 + " to " + str2);
        return false;
    }

    public static String m7079(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 m7080(String str) {
        String str2;
        Iterator it;
        m7078("/system", InternalZipConstants.WRITE_MODE);
        try {
            str2 = C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.sourceDir;
        } catch (Exception e) {
            e = e;
            str2 = "";
        }
        try {
            String str3 = C2975.m7932().getPackageInfo(str, ItemType.CLASS_DATA_ITEM).applicationInfo.dataDir;
            m7078(str2, "RW");
            m7093("chmod 777 " + str2);
            m7093("chattr -ai " + str2);
        } catch (Exception e2) {
            e = e2;
            e.printStackTrace();
            if (!str2.equals("")) {
                m7081(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/")) {
            m7081(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 C2939(C2975.m7929(), file2, false).f9151)) {
                                m7081(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 C2939(C2975.m7929(), file4, false).f9151)) {
                                                m7081(file4);
                                                m7093("rm -rf '" + file3.getAbsolutePath() + "'");
                                            }
                                        } catch (Exception e4) {
                                            e4.printStackTrace();
                                        }
                                    }
                                }
                            }
                        } catch (Exception e5) {
                            e5.printStackTrace();
                        }
                    }
                }
            } else {
                C2975.m7942("LuckyPatcher: 0 packages found in " + file.getAbsolutePath());
            }
        }
    }

    public static void m7081(File file) {
        String m6998 = m6998(file.getAbsolutePath());
        if (!m6998.equals("")) {
            m7093("chmod 777 '" + m6998 + "'");
            m7093("rm '" + m6998 + "'");
        }
        File m6948 = m6948(file.getAbsolutePath());
        if (m6948 != null && m6948.exists()) {
            m7093("rm '" + m6948.getAbsolutePath() + "'");
            m7093("rm '" + m7176(m6948.getAbsolutePath(), "art") + "'");
            m7093("rm '" + m7176(m6948.getAbsolutePath(), "vdex") + "'");
        }
        m7093("chmod 777 '" + file.getAbsolutePath() + "'");
        m7093("rm '" + file.getAbsolutePath() + "'");
        m7093("rm '" + m6976(file.getAbsolutePath(), false) + "'");
        File m6942 = m6942(file);
        String name = m6942.getName();
        if (m6942.getAbsolutePath().startsWith("/system/") && !name.toLowerCase().equals("app") && !name.toLowerCase().equals("priv-app")) {
            m7093("rm -rf '" + m6942.getAbsolutePath() + "'");
        }
    }

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

    public static int m7083(String str, String[] strArr, boolean z, String[] strArr2) {
        m7179();
        C2975.m7942("scan: " + str);
        int i = 0;
        m7094("chmod", "777", str);
        new ArrayList();
        try {
        } catch (Exception e) {
            C2975.m7942(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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                    byte[] bArr = new byte[m7185 / 4];
                                    map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                    int[] iArr = new int[m7185];
                                    for (int i2 = 0; i2 < m7185; i2++) {
                                        iArr[i2] = m7185(map.get(), map.get(), map.get(), map.get());
                                    }
                                    int i3 = 0;
                                    for (int i4 = 0; i4 < m7185; i4++) {
                                        try {
                                            int i5 = iArr[i4];
                                            map.position(i5);
                                            int m7070 = m7070(map);
                                            int position = map.position();
                                            byte[] m7155 = m7155(map, m7070);
                                            for (int i6 = 0; i6 < strArr.length; i6++) {
                                                if (new String(m7155, "UTF-16LE").equals(strArr[i6])) {
                                                    strArr2[i6].getBytes();
                                                    if (strArr2[i6].length() <= m7070) {
                                                        map.position(i5);
                                                        m7163(map, strArr2[i6].length());
                                                        map.position(position);
                                                        m7162(map, strArr2[i6]);
                                                        map.force();
                                                        C2975.m7942("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 m71852 = m7185(map2.get(), map2.get(), map2.get(), map2.get());
                map2.position(m71852 + 56);
                int m71853 = m7185(map2.get(), map2.get(), map2.get(), map2.get());
                int m71854 = m7185(map2.get(), map2.get(), map2.get(), map2.get()) + m71852;
                C2975.m7942("LuckyPatcher offset_to_data=" + Integer.toHexString(m71854));
                map2.position(m71854);
                int[] iArr2 = new int[m71853];
                for (int i7 = 0; i7 < m71853; i7++) {
                    iArr2[i7] = m7185(map2.get(), map2.get(), map2.get(), map2.get()) + m71852;
                }
                int i8 = 0;
                for (int i9 = 0; i9 < m71853; i9++) {
                    try {
                        int i10 = iArr2[i9];
                        map2.position(i10);
                        int m70702 = m7070(map2);
                        int position2 = map2.position();
                        byte[] m71552 = m7155(map2, m70702);
                        for (int i11 = 0; i11 < strArr.length; i11++) {
                            if (new String(m71552).equals(strArr[i11])) {
                                strArr2[i11].getBytes();
                                if (strArr2[i11].length() <= m70702) {
                                    map2.position(i10);
                                    m7163(map2, strArr2[i11].length());
                                    map2.position(position2);
                                    m7162(map2, strArr2[i11]);
                                    map2.force();
                                    C2975.m7942("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 m7084(String str, String[] strArr) {
        int i;
        m7179();
        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] = m7143(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;
            }
        }
        m7094("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;
                                                    C2975.m7942(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 m7085(String str, String[] strArr, String[] strArr2) {
        int i;
        char[] cArr;
        m7179();
        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];
                        C2975.m7942("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;
                                                    C2975.m7942(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 m7086(ArrayList<C2631> arrayList) {
        if (arrayList != null) {
            Iterator<C2631> it = arrayList.iterator();
            while (it.hasNext()) {
                C2631 next = it.next();
                if (!next.f7565.equals("")) {
                    next.f7573 = false;
                    next.f7569.clear();
                    next.f7568.clear();
                    next.f7574 = false;
                }
            }
        }
    }

    public static boolean m7087(String str, String str2, ArrayList<C2912> arrayList, boolean z, File file, boolean z2, ArrayList<C2630> arrayList2, File file2, C2597 c2597) throws MinSdkVersionException {
        String str3;
        String str4;
        boolean z3;
        boolean z4;
        boolean z5;
        Throwable th;
        Enumeration<C2419> m6611;
        List<X509Certificate> list;
        int i;
        C2975.m7942("source apk:" + str);
        C2975.m7942("dest apk:" + str2);
        m7179();
        if (file2 != null) {
            file2.getName();
        }
        ArrayList arrayList3 = new ArrayList();
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        if (c2597 != null) {
            Iterator<C2621> it = c2597.f7287.iterator();
            while (it.hasNext()) {
                C2621 next = it.next();
                if (next.f7492 == 24) {
                    Iterator<C2610> it2 = next.f7502.iterator();
                    while (it2.hasNext()) {
                        C2610 next2 = it2.next();
                        if (next2.f7433) {
                            arrayList3.add(next2);
                            C2975.m7942("file added " + next2.f7430 + " for add zip " + str2);
                        }
                    }
                }
                if (next.f7492 == 25) {
                    Iterator<C2616> it3 = next.f7503.iterator();
                    while (it3.hasNext()) {
                        arrayList4.add(it3.next());
                    }
                }
                if (next.f7492 == 26) {
                    Iterator<String> it4 = next.f7500.iterator();
                    while (it4.hasNext()) {
                        arrayList5.add(it4.next());
                    }
                }
                if (next.f7492 == 28) {
                    Iterator<String> it5 = next.f7501.iterator();
                    while (it5.hasNext()) {
                        arrayList6.add(it5.next());
                    }
                }
            }
        }
        m6996();
        int i2 = 1;
        ArrayList<SignerParams> arrayList7 = new ArrayList(1);
        SignerParams signerParams = new SignerParams();
        signerParams.setKeyFile(C2975.f9251 + "/Modified/Keys/testkey.pk8");
        signerParams.setCertFile(C2975.f9251 + "/Modified/Keys/testkey.x509.pem");
        arrayList7.add(signerParams);
        ArrayList arrayList8 = new ArrayList(arrayList7.size());
        PasswordRetriever passwordRetriever = new PasswordRetriever();
        try {
            int i3 = 0;
            for (SignerParams signerParams2 : arrayList7) {
                i3 += i2;
                signerParams2.setName("signer #" + i3);
                ApkSigner.SignerConfig signerConfig = ApkSignerTool.getSignerConfig(signerParams2, passwordRetriever);
                if (signerConfig == null) {
                    passwordRetriever.close();
                    return false;
                }
                arrayList8.add(signerConfig);
                i2 = 1;
            }
            passwordRetriever.close();
            if (arrayList3.size() > 0 || arrayList4.size() > 0 || arrayList5.size() > 0 || arrayList6.size() > 0) {
                try {
                    m7077(str, str2 + ".tmp", arrayList4, arrayList5, arrayList3, arrayList6);
                    str3 = str2 + ".tmp";
                } catch (Throwable th2) {
                    th2.printStackTrace();
                }
                if (z2 || file2 == null) {
                    str4 = str3;
                } else {
                    str4 = str3 + ".tmp";
                    if (!str3.equals(str2 + ".tmp")) {
                        str4 = str2 + ".tmp";
                    }
                    try {
                        m7076(str3, str4, arrayList2, file2);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                z3 = !m6895(z);
                z4 = !m6966(z);
                if (z && file != null) {
                    ApkSigner.orig_certificates = null;
                    ApkSigner.entry_old_for_cert = "";
                    ApkSigner.orig_certificates = null;
                    ApkSigner.file_for_use_original_signature = file;
                    try {
                        if (file.exists()) {
                            C2975.m7942(44);
                        }
                        C2420 c2420 = new C2420(ApkSigner.file_for_use_original_signature);
                        m6611 = c2420.m6611();
                        while (m6611.hasMoreElements()) {
                            C2419 nextElement = m6611.nextElement();
                            String upperCase = nextElement.getName().toUpperCase();
                            if (upperCase.startsWith("META-INF/") && (upperCase.endsWith(".RSA") || upperCase.endsWith(".DSA"))) {
                                ApkSigner.entry_old_for_cert = upperCase;
                                byte[] m6538 = C2413.m6538(c2420.m6613(nextElement));
                                ApkSigner.original_signature_bytes = m6538;
                                X509Certificate[] certificates = new PKCS7(m6538).getCertificates();
                                if (certificates != null && certificates.length > 0) {
                                    ApkSigner.orig_certificates = new ArrayList();
                                    for (int i4 = 0; i4 < certificates.length; i4++) {
                                        ApkSigner.orig_certificates.add(certificates[i4]);
                                        System.out.printf("  --OrigSignaturefromFileHash[%d]: %08x\n", Integer.valueOf(i4), Integer.valueOf(certificates[i4].hashCode()));
                                    }
                                }
                            }
                            if (upperCase.startsWith("META-INF/") && upperCase.endsWith(".SF")) {
                                ApkSigner.entry_old_for_sf = upperCase;
                            }
                        }
                        list = ApkSigner.orig_certificates;
                        if (list != null) {
                        }
                        try {
                            C2975.m7942("try get signature v2");
                            try {
                                ApkSigner.orig_certificates = m6997(ApkSigner.file_for_use_original_signature);
                                C2975.m7942("2:" + ApkSigner.orig_certificates);
                                for (i = 0; i < ApkSigner.orig_certificates.size(); i++) {
                                    System.out.printf("  --OrigSignatureV2fromFileHash[%d]: %08x\n", Integer.valueOf(i), Integer.valueOf(ApkSigner.orig_certificates.get(i).hashCode()));
                                }
                            } catch (Throwable th3) {
                                th3.printStackTrace();
                            }
                            z5 = false;
                            z3 = true;
                        } catch (Throwable th4) {
                            th = th4;
                            z5 = false;
                            z3 = true;
                            th.printStackTrace();
                            if (z4) {
                            }
                            ApkSigner.Builder signingCertificateLineage = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(z5).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
                            signingCertificateLineage.setMinSdkVersion(r2);
                            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;
                            C3549.m8185(m7009(R.string.patch_step8, new File(str2).getName()));
                            if (new File(str2 + ".tmp").exists()) {
                            }
                            if (new File(str4 + ".tmp").exists()) {
                            }
                            return z3;
                        }
                    } catch (Throwable th5) {
                        th = th5;
                        z5 = true;
                    }
                    int i5 = z4 ? C2975.f9299 : 14;
                    ApkSigner.Builder signingCertificateLineage2 = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(z5).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
                    signingCertificateLineage2.setMinSdkVersion(i5);
                    ApkSigner build2 = signingCertificateLineage2.build();
                    ApkSigner.use_original_signature = z;
                    ApkSigner.use_zip_crc_image = z2;
                    ApkSigner.files_for_add_to_zip = arrayList;
                    build2.sign();
                    z3 = build2.mV2SigningEnabled;
                    C3549.m8185(m7009(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;
                }
                z5 = true;
                if (z4) {
                }
                ApkSigner.Builder signingCertificateLineage22 = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(z5).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
                signingCertificateLineage22.setMinSdkVersion(i5);
                ApkSigner build22 = signingCertificateLineage22.build();
                ApkSigner.use_original_signature = z;
                ApkSigner.use_zip_crc_image = z2;
                ApkSigner.files_for_add_to_zip = arrayList;
                build22.sign();
                z3 = build22.mV2SigningEnabled;
                C3549.m8185(m7009(R.string.patch_step8, new File(str2).getName()));
                if (new File(str2 + ".tmp").exists()) {
                }
                if (new File(str4 + ".tmp").exists()) {
                }
                return z3;
            }
            str3 = str;
            if (z2) {
            }
            str4 = str3;
            z3 = !m6895(z);
            z4 = !m6966(z);
            if (z) {
                ApkSigner.orig_certificates = null;
                ApkSigner.entry_old_for_cert = "";
                ApkSigner.orig_certificates = null;
                ApkSigner.file_for_use_original_signature = file;
                if (file.exists()) {
                }
                C2420 c24202 = new C2420(ApkSigner.file_for_use_original_signature);
                m6611 = c24202.m6611();
                while (m6611.hasMoreElements()) {
                }
                list = ApkSigner.orig_certificates;
                if (list != null) {
                }
                C2975.m7942("try get signature v2");
                ApkSigner.orig_certificates = m6997(ApkSigner.file_for_use_original_signature);
                C2975.m7942("2:" + ApkSigner.orig_certificates);
                while (i < ApkSigner.orig_certificates.size()) {
                }
                z5 = false;
                z3 = true;
                if (z4) {
                }
                ApkSigner.Builder signingCertificateLineage222 = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(z5).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
                signingCertificateLineage222.setMinSdkVersion(i5);
                ApkSigner build222 = signingCertificateLineage222.build();
                ApkSigner.use_original_signature = z;
                ApkSigner.use_zip_crc_image = z2;
                ApkSigner.files_for_add_to_zip = arrayList;
                build222.sign();
                z3 = build222.mV2SigningEnabled;
                C3549.m8185(m7009(R.string.patch_step8, new File(str2).getName()));
                if (new File(str2 + ".tmp").exists()) {
                }
                if (new File(str4 + ".tmp").exists()) {
                }
                return z3;
            }
            z5 = true;
            if (z4) {
            }
            ApkSigner.Builder signingCertificateLineage2222 = new ApkSigner.Builder(arrayList8).setInputApk(new File(str4)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(z5).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
            signingCertificateLineage2222.setMinSdkVersion(i5);
            ApkSigner build2222 = signingCertificateLineage2222.build();
            ApkSigner.use_original_signature = z;
            ApkSigner.use_zip_crc_image = z2;
            ApkSigner.files_for_add_to_zip = arrayList;
            build2222.sign();
            z3 = build2222.mV2SigningEnabled;
            C3549.m8185(m7009(R.string.patch_step8, new File(str2).getName()));
            if (new File(str2 + ".tmp").exists()) {
            }
            if (new File(str4 + ".tmp").exists()) {
            }
            return z3;
        } finally {
        }
    }

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

    public static boolean m7089(String str, String str2, ArrayList<C2912> arrayList, boolean z, boolean z2) throws MinSdkVersionException {
        int i;
        m7179();
        m6996();
        ArrayList<SignerParams> arrayList2 = new ArrayList(1);
        SignerParams signerParams = new SignerParams();
        signerParams.setKeyFile(C2975.f9251 + "/Modified/Keys/testkey.pk8");
        signerParams.setCertFile(C2975.f9251 + "/Modified/Keys/testkey.x509.pem");
        arrayList2.add(signerParams);
        ArrayList arrayList3 = new ArrayList(arrayList2.size());
        PasswordRetriever passwordRetriever = new PasswordRetriever();
        try {
            int i2 = 0;
            for (SignerParams signerParams2 : arrayList2) {
                i2++;
                signerParams2.setName("signer #" + i2);
                ApkSigner.SignerConfig signerConfig = ApkSignerTool.getSignerConfig(signerParams2, passwordRetriever);
                if (signerConfig == null) {
                    passwordRetriever.close();
                    return false;
                }
                arrayList3.add(signerConfig);
            }
            passwordRetriever.close();
            boolean z3 = !m6895(z);
            boolean z4 = !m6895(z);
            if (z4) {
                i = C2975.f9299;
            } else {
                i = 14;
            }
            ApkSigner.Builder signingCertificateLineage = new ApkSigner.Builder(arrayList3).setInputApk(new File(str)).setOutputApk(new File(str2)).setOtherSignersSignaturesPreserved(false).setV1SigningEnabled(true).setV2SigningEnabled(z3).setV3SigningEnabled(z4).setV4SigningEnabled(false).setForceSourceStampOverwrite(false).setVerityEnabled(false).setV4ErrorReportingEnabled(false).setDebuggableApkPermitted(true).setSigningCertificateLineage(null);
            signingCertificateLineage.setMinSdkVersion(i);
            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 void m7090(String str) {
        ArrayList<File> m7003 = m7003();
        if (m7003 != null) {
            try {
                if (m7003.size() > 0) {
                    Iterator<File> it = m7003.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 m7091(String str) {
        int i;
        File m6942 = m6942(new File(str));
        if (C2975.f9323.booleanValue()) {
            String[] strArr = {"ls", "-dZ", m6942.getAbsolutePath()};
            if (new File("/system/bin/toybox").exists()) {
                C2975.m7942("use toybox");
                i = 3;
                strArr = new String[]{"toybox", "ls", "-dZ", m6942.getAbsolutePath()};
            } else {
                i = 3;
            }
            String m7098 = m7098(strArr);
            String[] strArr2 = new String[i];
            strArr2[0] = "chmod";
            strArr2[1] = "777";
            strArr2[2] = str;
            m7094(strArr2);
            if (m7098 != null && !m7098.equals("")) {
                String[] split = m7098.split("\\s+");
                if (split.length > 4 && !split[0].contains(":") && !split[3].contains(":")) {
                    C2975.m7942("0:" + split[0]);
                    C2975.m7942("1:" + split[1]);
                    C2975.m7942("2:" + split[2]);
                    C2975.m7942("3:" + split[3]);
                    C2975.m7942(m7098);
                }
                if (split.length > 1) {
                    if (split[0].contains(":")) {
                        C2975.m7942(split[0]);
                        m7094("chcon", split[0].trim(), str);
                        return;
                    } else {
                        if (split.length > 4 && split[3].contains(":")) {
                            C2975.m7942(split[3]);
                            m7094("chcon", split[3].trim(), str);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            C2975.m7942("manual:u:object_r:media_rw_data_file:s0");
            m7094("chcon", "u:object_r:media_rw_data_file:s0", str);
            return;
        }
        if (C2975.f9283) {
            String[] strArr3 = {"ls -dZ " + m6942.getAbsolutePath()};
            if (new File("/system/bin/toybox").exists()) {
                C2975.m7942("use toybox");
                strArr3 = new String[]{"toybox ls -dZ " + m6942.getAbsolutePath()};
            }
            String m7211 = new C2500("").m7211(strArr3);
            m7093("chmod 777 " + str);
            if (m7211 != null && !m7211.equals("")) {
                String[] split2 = m7211.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":") && !split2[3].contains(":")) {
                    C2975.m7942("0:" + split2[0]);
                    C2975.m7942("1:" + split2[1]);
                    C2975.m7942("2:" + split2[2]);
                    C2975.m7942("3:" + split2[3]);
                    C2975.m7942(m7211);
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        C2975.m7942(split2[0]);
                        m7093("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        C2975.m7942(split2[3]);
                        m7093("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            C2975.m7942("manual:u:object_r:media_rw_data_file:s0");
            m7093("chcon u:object_r:media_rw_data_file:s0 " + str);
        }
    }

    public static String m7092(Class cls, String... strArr) {
        String str = " " + cls.getName();
        for (String str2 : strArr) {
            str = str + " '" + str2 + "'";
        }
        return new C2500("").m7211(C2975.f9284 + str);
    }

    public static void m7093(String str) {
        try {
            m7158();
            if (C2975.f9283) {
                if (C2975.f9295 == null) {
                    C2975.f9295 = new String[0];
                }
                String[] strArr = C2975.f9295;
                int i = 1;
                String[] strArr2 = new String[strArr.length + 1];
                strArr2[0] = str;
                for (String str2 : strArr) {
                    strArr2[i] = str2 + " " + str;
                    i++;
                }
                new C2500("").m7211(strArr2);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7094(String... strArr) {
        try {
            m7158();
            m7098(strArr);
            String[] strArr2 = C2975.f9295;
            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 : C2975.f9295) {
                    strArr3[0] = str2;
                    m7098(strArr3);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static boolean m7095(File file, String str) {
        JSONObject jSONObject;
        if (file.exists()) {
            try {
                jSONObject = new JSONObject(m7072(file));
            } catch (JSONException e) {
                e.printStackTrace();
                jSONObject = null;
            }
        } else {
            jSONObject = new JSONObject();
        }
        try {
            jSONObject.put("label", str);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        C2975.m7942(jSONObject.toString());
        m7101(file, jSONObject.toString());
        if (file.exists() && file.length() > 0) {
            return true;
        }
        return false;
    }

    public static boolean m7096(File file) {
        JSONArray jSONArray;
        C2975.m7942("save expansion from xapk");
        try {
            C2420 c2420 = new C2420(file);
            try {
                jSONArray = new JSONObject(new String(C2413.m6538(c2420.m6613(c2420.m6612("manifest.json"))), "utf-8")).getJSONArray("expansions");
            } catch (Throwable unused) {
                C2975.m7942("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 (C2975.f9299 >= 30 && C2975.f9283) {
                    if (!new C2500().m7211(C2975.f9284 + C1545.class.getName() + " '" + file.getAbsolutePath() + "' '" + string + "' '" + file2.getAbsolutePath() + "'").contains("File copied!")) {
                        return false;
                    }
                } else if (!m6876(c2420.m6613(c2420.m6612(string)), file2)) {
                    return false;
                }
            }
            return true;
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    public static boolean m7097(Drawable drawable, File file) {
        if (drawable != null) {
            try {
                Bitmap m6897 = m6897(drawable);
                if (m6897 != null) {
                    if (file.exists()) {
                        file.delete();
                    }
                    m6897.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 String m7098(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;
                    C2975.f9298 = 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;
                    C2975.f9298 = 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;
                    C2975.f9298 = 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 RunnableC2482(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());
                    C2975.f9308 = dataInputStream;
                    byte[] bArr = new byte[dataInputStream.available()];
                    C2975.f9308.read(bArr);
                    C2975.f9298 = new String(bArr);
                    if (!new String(bArr).trim().equals("")) {
                        C2975.f9298 = new String(bArr);
                    } else {
                        C2975.f9298 = "";
                    }
                } catch (Throwable th2) {
                    num = num2;
                    th = th2;
                    C2975.f9298 = 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 {
                    C2975.f9298 = e3.toString();
                } catch (IOException e4) {
                    num = num2;
                    e = e4;
                    C2975.f9298 = 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;
                    C2975.f9298 = 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 boolean m7099(File file, String str) {
        m7179();
        try {
            if (!file.exists()) {
                m6942(file).mkdirs();
                file.createNewFile();
            }
            C2975.m7942("...rrunning my app...");
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, InternalZipConstants.WRITE_MODE);
            long length = file.length();
            randomAccessFile.seek(file.length());
            randomAccessFile.write(str.getBytes());
            C2975.m7942("...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 m7100(File file, File file2) {
        m7179();
        try {
            C2975.m7942("...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 m7101(File file, String str) {
        m7179();
        try {
            if (!file.exists()) {
                m6942(file).mkdirs();
                file.createNewFile();
                try {
                    file.setReadable(true, false);
                    file.setWritable(true, false);
                } catch (NoSuchMethodError e) {
                    e.printStackTrace();
                }
            }
            C2975.m7942("...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 m7102(File file, String str) {
        m7179();
        try {
            if (!file.exists()) {
                return false;
            }
            C2975.m7942("...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;
                }
            }
            C2975.m7942("...file length..." + randomAccessFile.length());
            randomAccessFile.close();
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean m7103(String str) {
        C2975.m7942(str);
        return false;
    }

    public static boolean m7104(String str) {
        C2975.m7942(str);
        return false;
    }

    public static void m7105(String str) {
        int i;
        int i2;
        if (C2975.f9323.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 m7098 = m7098(strArr);
            String[] strArr2 = new String[i];
            strArr2[0] = "restorecon";
            strArr2[1] = "-v";
            strArr2[2] = str;
            m7098(strArr2);
            String[] strArr3 = new String[i];
            strArr3[0] = "chmod";
            strArr3[1] = "777";
            strArr3[2] = str;
            m7094(strArr3);
            if (m7098 != null && !m7098.equals("")) {
                String[] split = m7098.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;
                        m7094(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;
                        m7094(strArr5);
                        return;
                    }
                    return;
                }
                return;
            }
            m7094("chcon", "u:object_r:media_rw_data_file:s0", str);
            return;
        }
        if (C2975.f9283) {
            String[] strArr6 = {"ls", "-dZ", "/data/media"};
            if (new File("/system/bin/toybox").exists()) {
                strArr6 = new String[]{"toybox", "ls", "-dZ", "/data/media"};
            }
            String m70982 = m7098(strArr6);
            new C2500("").m7211("restorecon -v " + str);
            m7093("chmod 777 " + str);
            if (m70982 != null && !m70982.equals("")) {
                String[] split2 = m70982.split("\\s+");
                if (split2.length > 4 && !split2[0].contains(":")) {
                    split2[3].contains(":");
                }
                if (split2.length > 1) {
                    if (split2[0].contains(":")) {
                        m7093("chcon " + split2[0].trim() + " " + str);
                        return;
                    }
                    if (split2.length > 4 && split2[3].contains(":")) {
                        m7093("chcon " + split2[3].trim() + " " + str);
                        return;
                    }
                    return;
                }
                return;
            }
            m7093("chcon u:object_r:media_rw_data_file:s0 " + str);
        }
    }

    public static void m7106(C2939 c2939, 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=")) {
                        c2939.f9154 = str.substring(str.lastIndexOf("=") + 1, str.length());
                    }
                    if (str.contains("versionCode=")) {
                        try {
                            c2939.f9155 = Integer.valueOf(str.substring(str.lastIndexOf("=") + 1, str.length())).intValue();
                        } catch (Throwable th) {
                            th.printStackTrace();
                            c2939.f9155 = 0;
                        }
                    }
                }
            }
        } catch (ZipException e) {
            e.printStackTrace();
        } catch (Throwable th2) {
            th2.printStackTrace();
        }
    }

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

    public static Context m7108(Context context) {
        Locale locale;
        Context createConfigurationContext;
        Context createConfigurationContext2;
        try {
            String string = C2975.m7928().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();
        }
        C2975.f9343 = null;
        return null;
    }

    public static void m7109(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) {
                    m7098("chown", str3, str4);
                    m7098("chown", str3.replace(":", "."), str4);
                }
                z = true;
                if (!split[i].equals("")) {
                    str4 = str4 + InternalZipConstants.ZIP_FILE_SEPARATOR;
                }
            }
        }
    }

    public static void m7110(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) {
                    m7098("chmod", str3, str4);
                }
                z = true;
                if (!split[i].equals("")) {
                    str4 = str4 + InternalZipConstants.ZIP_FILE_SEPARATOR;
                }
            }
        }
    }

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

    public static void m7112(String str) {
        ArrayList<File> m7003 = m7003();
        if (m7003 != null) {
            try {
                if (m7003.size() > 0) {
                    Iterator<File> it = m7003.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 (C2975.f9283) {
                                    new C2500("").m7201(file, "777");
                                }
                                file.renameTo(file3);
                            } else {
                                if (C2975.f9283) {
                                    new C2500("").m7201(file3, "777");
                                }
                                file3.delete();
                                if (C2975.f9283) {
                                    new C2500("").m7201(file, "777");
                                }
                                file.renameTo(file3);
                            }
                        }
                        if (file2.exists()) {
                            if (!file4.exists()) {
                                if (C2975.f9283) {
                                    new C2500("").m7201(file2, "777");
                                }
                                file2.renameTo(file4);
                            } else {
                                if (C2975.f9283) {
                                    new C2500("").m7201(file4, "777");
                                }
                                file4.delete();
                                if (C2975.f9283) {
                                    new C2500("").m7201(file2, "777");
                                }
                                file2.renameTo(file4);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static int m7113(String str, byte[][] bArr, byte b, String str2) {
        byte[] bArr2;
        int i;
        int i2;
        int i3;
        byte[][] bArr3 = bArr;
        m7179();
        C2975.m7942("scan: " + str);
        int i4 = 0;
        int i5 = 2;
        m7094("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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                        byte[] bArr5 = new byte[m7185 / 4];
                                        map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                        int[] iArr = new int[m7185];
                                        for (int i6 = 0; i6 < m7185; i6++) {
                                            try {
                                                iArr[i6] = m7185(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;
                                                        C2975.m7942(e);
                                                        return i4;
                                                    }
                                                }
                                            }
                                        }
                                        int i7 = 0;
                                        int i8 = 0;
                                        while (i7 < m7185) {
                                            try {
                                                map.position(iArr[i7]);
                                                int m7070 = m7070(map);
                                                byte[] bArr6 = new byte[m7070];
                                                int position = map.position();
                                                for (int i9 = 0; i9 < m7070; i9++) {
                                                    bArr6[i9] = map.get();
                                                }
                                                int i10 = 0;
                                                while (i10 < bArr3.length) {
                                                    byte[] bArr7 = (byte[]) Array.get(bArr3, i10);
                                                    if (bArr7.length <= m7070 && bArr7.length > i5 && (bArr4 == null || m7070 > bArr4.length)) {
                                                        int i11 = 0;
                                                        boolean z = false;
                                                        while (i11 < m7070) {
                                                            if (bArr4 != null) {
                                                                i = m7185;
                                                                if (bArr6[0] == bArr4[0] && m7070 > bArr4.length) {
                                                                    int i12 = 0;
                                                                    while (i12 < bArr4.length) {
                                                                        boolean z2 = z;
                                                                        if (bArr6[i12] != bArr4[i12]) {
                                                                            z = true;
                                                                            break;
                                                                        }
                                                                        i12++;
                                                                        z = z2;
                                                                    }
                                                                }
                                                                i10++;
                                                                m7185 = i;
                                                                bArr3 = bArr;
                                                                bArr4 = bArr4;
                                                                i5 = 2;
                                                            } else {
                                                                i = m7185;
                                                            }
                                                            z = z;
                                                            byte[] bArr8 = bArr4;
                                                            if (bArr6[i11] == bArr7[0] && !z) {
                                                                int i13 = 1;
                                                                while (i13 < bArr7.length && (i3 = i11 + i13) < m7070 && 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) < m7070 && bArr6[i2] == bArr2[i14]) {
                                                                    i14++;
                                                                    if (i14 == bArr2.length) {
                                                                        z = true;
                                                                    }
                                                                }
                                                            }
                                                            i11++;
                                                            m7185 = i;
                                                            bArr4 = bArr8;
                                                        }
                                                    }
                                                    i = m7185;
                                                    i10++;
                                                    m7185 = 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 m7114(String str) {
        try {
            Signature signature = Signature.getInstance("SHA1withRSA");
            signature.initSign(m6977(f7070));
            signature.update(str.getBytes());
            return C2641.m7294(signature.sign());
        } catch (InvalidKeyException e) {
            e.printStackTrace();
            return "";
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
            return "";
        } catch (SignatureException e3) {
            e3.printStackTrace();
            return "";
        }
    }

    public static String m7115(String str) {
        try {
            Signature signature = Signature.getInstance("SHA256withRSA");
            signature.initSign(m6977(f7070));
            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 m7116(String str) {
        if (C2975.f9245 != null) {
            C2975.m7954(new RunnableC2549(str));
        }
    }

    public static void m7117(Dialog dialog) {
        try {
            C2975.m7954(new RunnableC2536(dialog));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7118(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z, Runnable runnable, long j) {
        f7059 = false;
        try {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C2913 c2913 = new C2913(C2975.f9245.mo1874(), true);
                LinearLayout linearLayout = (LinearLayout) View.inflate(C2975.f9259, 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));
                c2913.m7858(linearLayout);
                f7060 = c2913.m7883().m7860(str).m7872(R.drawable.ic_vopros).m7875(str3, onClickListener).m7878(m7007(R.string.no), onClickListener2).m7881(onCancelListener).m7851();
                if (!C2975.m7928().getBoolean("remove_ads", false)) {
                    C2975.m7942("Try show ads dialog");
                    try {
                        Timer timer = new Timer("ads timer");
                        C2501 c2501 = new C2501(runnable);
                        C2975.m7942("Start timer");
                        timer.schedule(c2501, j);
                        m6912(linearLayout, new RunnableC2512(timer, c2501), timer, c2501);
                        return;
                    } catch (Throwable th2) {
                        m7120(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z);
                        C2975.m7951(11);
                        th2.printStackTrace();
                        return;
                    }
                }
                m7120(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z);
                C2975.m7951(11);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7119(Dialog dialog) {
        try {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                if (C2975.f9357.size() == 0 || C2975.f9357.size() == 1) {
                    dialog.show();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7120(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z) {
        C2975.m7954(new RunnableC2507(str, str2, str3, onClickListener, onClickListener2, onCancelListener, z));
    }

    public static void m7121(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, String str4, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C2975.m7954(new RunnableC2523(str4, str, str2, str3, onClickListener, onClickListener2, onCancelListener));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7122(String str, SpannableStringBuilder spannableStringBuilder, String str2, DialogInterface.OnClickListener onClickListener, String str3, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C2913 c2913 = new C2913(C2975.f9259);
                if (str3 != null && !str3.equals("")) {
                    Dialog m7851 = c2913.m7860(str).m7874(spannableStringBuilder).m7872(R.drawable.ic_vopros).m7875(str2, onClickListener).m7878(str3, onClickListener2).m7882(true).m7881(onCancelListener).m7851();
                    m7119(m7851);
                    m7851.findViewById(android.R.id.message);
                } else {
                    Dialog m78512 = c2913.m7860(str).m7874(spannableStringBuilder).m7872(R.drawable.ic_vopros).m7875(str2, onClickListener).m7882(true).m7881(onCancelListener).m7851();
                    m7119(m78512);
                    m78512.findViewById(android.R.id.message);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static long m7123(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 void m7124(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, String str4, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        try {
            MainActivity mainActivity = C2975.f9259;
            if (mainActivity != null && !mainActivity.isFinishing()) {
                C2913 c2913 = new C2913(C2975.f9259);
                if (str4 != null && !str4.equals("")) {
                    Dialog m7851 = c2913.m7860(str).m7876(str2).m7872(R.drawable.ic_vopros).m7875(str3, onClickListener).m7878(str4, onClickListener2).m7882(true).m7881(onCancelListener).m7851();
                    m7119(m7851);
                    m7851.findViewById(android.R.id.message);
                } else {
                    Dialog m78512 = c2913.m7860(str).m7876(str2).m7872(R.drawable.ic_vopros).m7875(str3, onClickListener).m7882(true).m7881(onCancelListener).m7851();
                    m7119(m78512);
                    m78512.findViewById(android.R.id.message);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7125(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        if (C2975.f9245 != null) {
            C2975.m7954(new RunnableC2574(str, str2, onClickListener, onClickListener2, onCancelListener));
        }
    }

    public static void m7126(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) {
        C2975.m7954(new RunnableC2505(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, str4, onCheckedChangeListener2, z2, z3));
    }

    public static void m7127(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z2) {
        C2975.m7954(new RunnableC2504(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, z2));
    }

    public static void m7128(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener, boolean z2) {
        C2975.m7954(new RunnableC2506(str, str2, onClickListener, onClickListener2, onCancelListener, str3, onCheckedChangeListener, z, z2));
    }

    public static void m7129(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2, DialogInterface.OnCancelListener onCancelListener) {
        if (C2975.f9245 != null) {
            C2975.m7954(new RunnableC2516(str, str2, onClickListener, onClickListener2, onCancelListener));
        }
    }

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

    public static void m7131(String str, String str2, String str3, CompoundButton.OnCheckedChangeListener onCheckedChangeListener, boolean z, DialogInterface.OnClickListener onClickListener, boolean z2) {
        C2975.m7954(new RunnableC2542(str, str2, onClickListener, str3, onCheckedChangeListener, z, z2));
    }

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

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

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

    public static void m7135(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) {
        try {
            C2975.m7954(new RunnableC2586(str, str2, onClickListener, onCancelListener));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void m7136(int i, String str, String str2, String str3) {
        NotificationChannel notificationChannel;
        if (!C2975.m7928().getBoolean("hide_notify", false)) {
            System.currentTimeMillis();
            C2975.m7929();
            NotificationManager notificationManager = (NotificationManager) C2975.m7929().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 C0476.C0479(C2975.m7929(), "default_channel_id").m1497(PendingIntent.getActivity(C2975.m7929(), 0, new Intent(C2975.m7929(), (Class<?>) MainActivity.class), 0)).m1499(str).m1498(str3).m1502(R.drawable.ic_notify).m1494());
        }
    }

    public static void m7137(String str, String str2, View.OnClickListener onClickListener, View.OnClickListener onClickListener2) {
        WindowManager windowManager = (WindowManager) C2975.m7929().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 = C2975.m7929().getPackageName();
        layoutParams.buttonBrightness = 1.0f;
        layoutParams.windowAnimations = android.R.style.Animation.Dialog;
        View inflate = View.inflate(C2975.m7929(), 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 ViewOnKeyListenerC2581(windowManager));
        windowManager.addView(inflate, layoutParams);
    }

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

    public static boolean m7139(String str, String str2) {
        try {
            WindowManager windowManager = (WindowManager) C2975.m7929().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 = C2975.m7929().getPackageName();
            layoutParams.buttonBrightness = 1.0f;
            layoutParams.windowAnimations = R.style.full_screen_dialog;
            View inflate = View.inflate(C2975.m7929(), 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 ViewOnClickListenerC2585(windowManager));
            button.setOnKeyListener(new ViewOnKeyListenerC2587(windowManager));
            windowManager.addView(inflate, layoutParams);
            return true;
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    public static void m7140(String str) {
        Intent launchIntentForPackage = C2975.m7932().getLaunchIntentForPackage(str);
        if (str == null) {
            C2975.m7942("Error LP: pkgname is null");
        }
        if (launchIntentForPackage == null) {
            C2975.m7942("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 = C2975.m7932().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 (C2975.f9283) {
            if (launchIntentForPackage != null) {
                new C2500("").m7211("am start -n " + str + InternalZipConstants.ZIP_FILE_SEPARATOR + launchIntentForPackage.getComponent().getClassName());
                return;
            }
            return;
        }
        MainActivity mainActivity = C2975.f9259;
        if (mainActivity != null && launchIntentForPackage != null) {
            mainActivity.startActivity(launchIntentForPackage);
        }
    }

    public static void m7141() {
        String[] split;
        System.out.println("SU Java-Code Running!");
        C2975.f9323 = Boolean.TRUE;
        C2975.f9250 = "";
        Thread.setDefaultUncaughtExceptionHandler(new C2551());
        for (String str : m6995()) {
            new File(str);
            File file = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9355);
            if (file.exists() && file.canRead() && (split = m7072(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) {
                                    }
                                    C2975.f9297 = true;
                                    C2975.f9295 = m6871(split[i]);
                                }
                                C2975.f9247 = split[i];
                                C2975.f9297 = true;
                                C2975.f9295 = m6871(split[i]);
                            }
                        } else {
                            C2975.f9299 = Integer.parseInt(split[i]);
                        }
                        C2975.f9246 = split[i];
                        C2975.f9247 = split[i];
                        C2975.f9297 = true;
                        C2975.f9295 = m6871(split[i]);
                    } else {
                        C2975.f9250 = split[i];
                    }
                }
            }
        }
    }

    public static void m7142(Object obj) {
        if (obj != null) {
            System.out.println("SU Java-Code Running! " + obj.getClass().getName());
        }
        C2975.f9323 = Boolean.TRUE;
        C2975.f9250 = "";
        Thread.setDefaultUncaughtExceptionHandler(new C2518());
        for (String str : m6995()) {
            new File(str);
            File file = new File(str + InternalZipConstants.ZIP_FILE_SEPARATOR + C2975.f9355);
            if (file.exists() && file.canRead()) {
                String[] split = m7072(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) {
                                        }
                                        C2975.f9297 = true;
                                        C2975.f9295 = m6871(split[i]);
                                    }
                                    C2975.f9247 = split[i];
                                    C2975.f9297 = true;
                                    C2975.f9295 = m6871(split[i]);
                                }
                            } else {
                                C2975.f9299 = Integer.parseInt(split[i]);
                            }
                            C2975.f9246 = split[i];
                            C2975.f9247 = split[i];
                            C2975.f9297 = true;
                            C2975.f9295 = m6871(split[i]);
                        } else {
                            C2975.f9250 = split[i];
                        }
                    }
                }
                if (obj != null) {
                    System.out.println("tools read:" + C2975.f9250 + "/busybox");
                }
                if (new File(C2975.f9250 + "/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 String m7143(String str) {
        byte[] bytes = str.getBytes();
        int length = bytes.length - 1;
        byte b = bytes[length];
        if (b == 122) {
            bytes[length] = 65;
        } else if (b == 90) {
            int i = length - 1;
            bytes[i] = (byte) (bytes[i] + 1);
        } else {
            bytes[length] = (byte) (b + 1);
        }
        return new String(bytes);
    }

    public static boolean m7144(boolean z, String str) {
        C2975.m7942("test path.");
        try {
            if (!new File(str).exists()) {
                new File(str).mkdirs();
            }
            if (!new File(str).exists()) {
                m7130(C2975.f9259, m7007(R.string.warning), m7007(R.string.messagePath));
                return false;
            }
            if (new File(str + "/tmp.txt").createNewFile()) {
                new File(str + "/tmp.txt").delete();
                return true;
            }
            if (z) {
                m7130(C2975.f9259, m7007(R.string.warning), m7007(R.string.messagePath));
            }
            return false;
        } catch (IOException unused) {
            if (z) {
                m7130(C2975.f9259, m7007(R.string.warning), m7007(R.string.messagePath));
            }
            return false;
        }
    }

    public static void m7145(Context context, String str, String str2) {
        C2975.m7954(new RunnableC2562(str2, str));
    }

    private static byte[] m7146(int i, int i2) {
        throw new IllegalArgumentException("bad utf-8 byte " + C2232.m6151(i) + " at offset " + C2232.m6152(i2));
    }

    public static String m7147(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 String m7148(String str) {
        int i;
        char[] cArr = new char[str.length()];
        try {
            String pkgName = PkgName.getPkgName();
            char[] charArray = str.toCharArray();
            char[] charArray2 = pkgName.toCharArray();
            for (int i2 = 0; i2 < charArray.length; i2++) {
                char c = charArray[i2];
                int i3 = i2 + 3;
                int length = charArray2.length - 1;
                if (i3 > length) {
                    i3 -= length * (i3 / length);
                }
                char c2 = charArray2[i3];
                if (c > c2) {
                    i = c - c2;
                } else {
                    i = c2 - c;
                }
                if (i > 62) {
                    i -= (i / 62) * 62;
                }
                cArr[i2] = "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(i);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return new String(cArr).toLowerCase();
    }

    public static boolean m7149(String[] strArr, String str) {
        m7179();
        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()) {
                        m6875(new File(strArr[i] + InternalZipConstants.ZIP_FILE_SEPARATOR + str), new File(strArr[i3] + InternalZipConstants.ZIP_FILE_SEPARATOR + str));
                        m6907(strArr[i] + InternalZipConstants.ZIP_FILE_SEPARATOR + str);
                        m6907(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());
                    }
                }
            }
            C2975.m7942("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 m7150(String str) {
        String string = C2975.m7928().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch1")) {
            C2975.m7928().edit().putString("patch_dalvik_on_boot_patterns", string.replaceAll("patch1", "")).commit();
        }
        String string2 = C2975.m7928().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch2")) {
            C2975.m7928().edit().putString("patch_dalvik_on_boot_patterns", string2.replaceAll("patch2", "")).commit();
        }
        String string3 = C2975.m7928().getString("patch_dalvik_on_boot_patterns", "");
        if (str.contains("patch3")) {
            C2975.m7928().edit().putString("patch_dalvik_on_boot_patterns", string3.replaceAll("patch3", "")).commit();
        }
    }

    public static final void m7151() {
        C2975.m7928().edit().putString("patch_dalvik_on_boot_patterns", "").commit();
    }

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

    public static void m7153(Activity activity, String str, Integer num) {
        if (activity != null) {
            if (num == null) {
                C2975.m7954(new RunnableC2547(str, activity));
            } else {
                C2975.m7954(new RunnableC2575(str, activity, num));
            }
        }
    }

    public static boolean m7154(File file, String str, File file2) {
        Iterator<C3862> it;
        byte[] bArr = new byte[4096];
        boolean z = false;
        try {
            C3864 m8444 = C3864.m8444(file.getAbsolutePath());
            Iterator<C3862> it2 = m8444.m8446().values().iterator();
            boolean z2 = false;
            while (it2.hasNext()) {
                try {
                    C3862 next = it2.next();
                    String m8433 = next.m8433();
                    if (m8433.equals(str)) {
                        InputStream m8431 = next.m8431();
                        if (file2.exists()) {
                            file2.delete();
                        }
                        FileOutputStream fileOutputStream = new FileOutputStream(file2);
                        while (true) {
                            int read = m8431.read(bArr);
                            it = it2;
                            if (read == -1) {
                                break;
                            }
                            fileOutputStream.write(bArr, 0, read);
                            it2 = it;
                        }
                        fileOutputStream.close();
                        if (C2975.f9323.booleanValue()) {
                            if (C2975.f9283) {
                                m7098("chmod", "777", file2.getAbsolutePath());
                            }
                        } else if (C2975.f9283) {
                            m7093("chmod 777 " + file2.getAbsolutePath());
                        }
                        C2975.m7942("unpack " + m8433);
                        if (file2.exists()) {
                            z2 = true;
                        }
                    } else {
                        it = it2;
                    }
                    it2 = it;
                } catch (Throwable th) {
                    th = th;
                    z = z2;
                    th.printStackTrace();
                    return z;
                }
            }
            if (m8444.m8446().values().size() == 0) {
                C2975.m7942("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, m6942(file2).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR);
                            new File(m6942(file2).getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR + fileName).renameTo(file2);
                            if (file2.exists()) {
                                z2 = true;
                            }
                            if (C2975.f9323.booleanValue()) {
                                if (C2975.f9283) {
                                    m7098("chmod", "777", file2.getAbsolutePath());
                                }
                            } else if (C2975.f9283) {
                                m7093("chmod 777 " + file2.getAbsolutePath());
                            }
                            C2975.m7942("unpack " + fileName);
                        }
                    }
                    return z2;
                } catch (Throwable th2) {
                    z = z2;
                    th2.printStackTrace();
                    return z;
                }
            }
            return z2;
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static byte[] m7155(MappedByteBuffer mappedByteBuffer, int i) throws UnsupportedEncodingException {
        ThreadLocal<char[]> threadLocal = f7062;
        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 m7146(i3, mappedByteBuffer.position());
                    }
                case 8:
                case 9:
                case 10:
                case 11:
                default:
                    return m7146(i3, mappedByteBuffer.position());
                case 12:
                case 13:
                    int i4 = mappedByteBuffer.get() & 255;
                    if ((i4 & 192) != 128) {
                        return m7146(i4, mappedByteBuffer.position());
                    }
                    i3 = ((i3 & 31) << 6) | (i4 & 63);
                    if (i3 != 0 && i3 < 128) {
                        return m7146(i4, mappedByteBuffer.position());
                    }
                    break;
                case 14:
                    int i5 = mappedByteBuffer.get() & 255;
                    if ((i5 & 192) != 128) {
                        return m7146(i5, mappedByteBuffer.position());
                    }
                    int i6 = mappedByteBuffer.get() & 255;
                    if ((i6 & 192) != 128) {
                        return m7146(i6, mappedByteBuffer.position());
                    }
                    i3 = ((i3 & 15) << 12) | ((i5 & 63) << 6) | (i6 & 63);
                    if (i3 >= 2048) {
                        break;
                    } else {
                        return m7146(i6, mappedByteBuffer.position());
                    }
            }
            cArr[i2] = (char) i3;
            i2++;
            i--;
        }
        return new String(cArr, 0, i2).getBytes("UTF-16LE");
    }

    public static boolean m7156(boolean z, boolean z2) {
        if (z) {
            return C2975.f9299 < 23 || z2;
        }
        return false;
    }

    public static boolean m7157(MappedByteBuffer mappedByteBuffer, C2619 c2619, int i) {
        m7179();
        int position = mappedByteBuffer.position();
        if (!c2619.f7487) {
            return true;
        }
        mappedByteBuffer.position(72);
        m7185(mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get());
        mappedByteBuffer.position(m7185(mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get(), mappedByteBuffer.get()) + (i * 12));
        if (c2619.f7488[0] == mappedByteBuffer.get() && c2619.f7488[1] == mappedByteBuffer.get() && c2619.f7488[2] == mappedByteBuffer.get() && c2619.f7488[3] == mappedByteBuffer.get()) {
            mappedByteBuffer.position(position);
            return true;
        }
        mappedByteBuffer.position(position);
        return false;
    }

    public static void m7158() {
        m7179();
        if (C2975.f9283 && !C2975.f9297) {
            if (!C2975.f9323.booleanValue()) {
                String m7211 = new C2500().m7211(C2975.f9284 + C1682.class.getName() + " ");
                C2975.m7942(m7211);
                String[] split = m7211.split("\n");
                int length = split.length;
                int i = 0;
                while (true) {
                    if (i >= length) {
                        break;
                    }
                    String str = split[i];
                    if (str.contains("{") && str.contains("}")) {
                        C2975.m7942(str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1));
                        ArrayList<String> m6870 = m6870(str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1));
                        C2975.f9295 = (String[]) m6870.toArray(new String[m6870.size()]);
                        break;
                    }
                    i++;
                }
                C2975.f9297 = true;
            } else {
                ArrayList<String> m7015 = m7015();
                C2975.f9295 = (String[]) m7015.toArray(new String[m7015.size()]);
                C2975.f9297 = true;
            }
        }
        if (C2975.f9295 == null) {
            C2975.f9295 = new String[0];
        }
    }

    public static void m7159(String str, String str2) {
        C2975.f9298 = "";
        new C2500("").m7211(str + " " + str2);
        if (!C2975.f9298.equals("")) {
            new C2500("").m7211("busybox " + str + " " + str2);
        }
        if (!C2975.f9298.equals("")) {
            new C2500("").m7211(C2975.f9250 + "/busybox " + str + " " + str2);
        }
    }

    public static void m7160(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()) {
            m7159("mkdir", "-p '" + trim2 + "'");
        }
        if (!new File(trim).exists()) {
            m7159("mkdir", "-p '" + trim + "'");
        }
        try {
            new File(str5 + "test.txt").createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        m7093("echo '' >'" + str5 + "test.txt'");
        if (!m6898(str6 + "test.txt")) {
            m7093("umount '" + trim2 + "'");
            C2975.m7942("data: " + str5 + "test.txt");
            C2975.m7942("target: " + str6 + "test.txt");
            try {
                new File(str5 + "test.txt").createNewFile();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            m7093("echo '' >'" + str5 + "test.txt'");
            if (!m6898(str6 + "test.txt")) {
                new C2500("").m7211("busybox " + str + " " + str2);
                try {
                    new File(str5 + "test.txt").createNewFile();
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
                m7093("echo '' >'" + str5 + "test.txt'");
                if (!m6898(str6 + "test.txt")) {
                    new C2500("").m7211(C2975.f9250 + "/busybox " + str + " " + str2);
                    new C2500("").m7211("busybox " + str + " " + str2);
                    try {
                        new File(str5 + "test.txt").createNewFile();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                    m7093("echo '' >'" + str5 + "test.txt'");
                    if (!m6898(str6 + "test.txt")) {
                        C2975.m7942("LuckyPatcher(Binder error): bind not created!");
                    }
                }
            }
        } else {
            C2975.m7942("LuckyPatcher(Binder): " + trim2 + " exists!");
        }
        if (m6898(str5 + "test.txt")) {
            if (m6898(str6 + "test.txt")) {
                C2975.m7942("LuckyPatcher(Binder): " + trim2 + " binded!");
            } else {
                C2975.m7942("LuckyPatcher(Binder error): " + trim2 + " not binded!");
            }
            new File(str5 + "test.txt").delete();
            if (m6898(str5 + "test.txt")) {
                m7093("rm '" + str5 + "test.txt'");
            }
        }
    }

    public static String m7161(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 = f7065;
            cArr[i3] = cArr2[i2 >>> 4];
            cArr[i3 + 1] = cArr2[i2 & 15];
        }
        return new String(cArr);
    }

    public static void m7162(MappedByteBuffer mappedByteBuffer, String str) throws IOException {
        int length = str.length();
        if (f7063.length <= str.length() * 3) {
            f7063 = new byte[str.length() * 3];
        }
        byte[] bArr = f7063;
        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 & '?') | Opcode.VOLATILE_FIELD_ACCESSOR);
            } else {
                int i4 = i + 1;
                bArr[i] = (byte) (((charAt >> '\f') & 15) | 224);
                int i5 = i4 + 1;
                bArr[i4] = (byte) (((charAt >> 6) & 63) | Opcode.VOLATILE_FIELD_ACCESSOR);
                bArr[i5] = (byte) ((charAt & '?') | Opcode.VOLATILE_FIELD_ACCESSOR);
                i = i5 + 1;
            }
        }
        mappedByteBuffer.put(bArr, 0, i);
    }

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

    public static void m7164(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 m7165(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;
        m7094("chmod", "777", "/data/tmp");
        FileOutputStream fileOutputStream2 = null;
        try {
            C2975.m7942("Try create tmp.");
            new File("/data/tmp").mkdir();
            if (!new File("/data/tmp").exists()) {
                C2975.m7942("tmp dir not found. Try create with root.");
                new File("/data/tmp").mkdirs();
                if (!new File("/data/tmp").exists()) {
                    m7094("mkdir", "/data/tmp");
                }
                if (!new File("/data/tmp").exists()) {
                    C2975.m7942("tmp dir not created.");
                } else {
                    m7094("chmod", "777", "/data/tmp");
                }
            } else {
                m7094("chmod", "777", "/data/tmp");
                try {
                    File[] listFiles = new File("/data/tmp").listFiles();
                    if (listFiles != null) {
                        for (File file2 : listFiles) {
                            C2500 c2500 = new C2500("1");
                            file2.delete();
                            if (file2.exists()) {
                                c2500.m7194(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()) {
                            C2975.m7942("Dir delta created.");
                        }
                        C2975.m7942("Path to create zip: " + str4);
                        C2975.m7942("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 m7166(List<File> list, File file) {
        FileOutputStream fileOutputStream;
        byte[] bArr = new byte[4096];
        ZipOutputStream zipOutputStream = null;
        try {
            try {
                fileOutputStream = new FileOutputStream(file);
                try {
                    ZipOutputStream zipOutputStream2 = new ZipOutputStream(fileOutputStream);
                    try {
                        for (File file2 : list) {
                            System.out.println("Added " + file2);
                            ZipEntry zipEntry = new ZipEntry(file2.getName());
                            zipEntry.setTime(file2.lastModified());
                            zipEntry.setMethod(8);
                            zipOutputStream2.putNextEntry(zipEntry);
                            FileInputStream fileInputStream = new FileInputStream(file2);
                            while (true) {
                                int read = fileInputStream.read(bArr);
                                if (read > 0) {
                                    zipOutputStream2.write(bArr, 0, read);
                                }
                            }
                            fileInputStream.close();
                        }
                        System.out.println("Done");
                        zipOutputStream2.closeEntry();
                        zipOutputStream2.close();
                    } catch (Throwable th) {
                        th = th;
                        zipOutputStream = zipOutputStream2;
                        try {
                            th.printStackTrace();
                            if (zipOutputStream != null) {
                                zipOutputStream.closeEntry();
                            }
                            if (zipOutputStream != null) {
                                zipOutputStream.close();
                            }
                            if (fileOutputStream == null) {
                                return;
                            }
                            fileOutputStream.close();
                        } catch (Throwable th2) {
                            if (zipOutputStream != null) {
                                try {
                                    zipOutputStream.closeEntry();
                                } catch (Throwable unused) {
                                    throw th2;
                                }
                            }
                            if (zipOutputStream != null) {
                                zipOutputStream.close();
                            }
                            if (fileOutputStream != null) {
                                fileOutputStream.close();
                            }
                            throw th2;
                        }
                    }
                } catch (Throwable th3) {
                    th = th3;
                }
            } catch (Throwable th4) {
                th = th4;
                fileOutputStream = null;
            }
            fileOutputStream.close();
        } catch (Throwable unused2) {
        }
    }

    public static void m7167(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 m7168(File file) {
        m7179();
        C2975.m7942("zipalign " + file.getName());
        File file2 = new File(file.getAbsolutePath() + ".tmp");
        file.renameTo(file2);
        try {
            C2449.m6718(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 m7169(ArrayList<File> arrayList) {
        String str = "{";
        if (arrayList != null) {
            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 + "}";
    }

    private static final void m7170(File file) {
        m7179();
        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 String m7171(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 + "}";
    }

    private static void m7172(int i, int i2, File file) {
        m7179();
        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 boolean m7173(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<C3862> it = C3864.m8444(file.getAbsolutePath()).m8446().values().iterator();
            while (it.hasNext()) {
                if (it.next().m8433().toLowerCase().equals("classes.dex")) {
                    return true;
                }
            }
            return false;
        }
    }

    private static final void m7174(File file) {
        m7179();
        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 File m7175(File file) {
        if (file.getAbsolutePath().startsWith("/sbin/.magisk/modules/luckypatcher_apps")) {
            return new File(file.getAbsolutePath().replaceFirst("/sbin/.magisk/modules/luckypatcher_apps", ""));
        }
        if (file.getAbsolutePath().startsWith("/data/adb/modules/luckypatcher_apps")) {
            return new File(file.getAbsolutePath().replaceFirst("/data/adb/modules/luckypatcher_apps", ""));
        }
        return null;
    }

    public static String m7176(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 m7177() {
        try {
            if (m7060() && C2975.m7928().getBoolean("warning_magisk", true)) {
                C2975.m7954(new RunnableC2577());
            }
        } catch (Throwable unused) {
            C2975.m7942("LP:Magisk root not found.");
        }
    }

    public static int m7178(String str, String str2, String str3) {
        String str4 = str2;
        m7179();
        String str5 = "L" + str4.replaceAll("\\.", InternalZipConstants.ZIP_FILE_SEPARATOR);
        String str6 = "L" + str3.replaceAll("\\.", InternalZipConstants.ZIP_FILE_SEPARATOR);
        C2975.m7942(str5 + " " + str6);
        StringBuilder sb = new StringBuilder();
        sb.append("scan: ");
        sb.append(str);
        C2975.m7942(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 m7185 = m7185(map.get(), map.get(), map.get(), map.get());
                                    byte[] bArr = new byte[m7185 / 4];
                                    map.position(m7185(map.get(), map.get(), map.get(), map.get()));
                                    int[] iArr = new int[m7185];
                                    for (int i2 = 0; i2 < m7185; i2++) {
                                        iArr[i2] = m7185(map.get(), map.get(), map.get(), map.get());
                                    }
                                    int i3 = 0;
                                    while (i < m7185) {
                                        try {
                                            int i4 = iArr[i];
                                            map.position(i4);
                                            int m7070 = m7070(map);
                                            int position = map.position();
                                            byte[] m7155 = m7155(map, m7070);
                                            int length = m7155.length;
                                            int i5 = m7185;
                                            if (m7070 >= str3.length() && new String(m7155, "UTF-16LE").contains(str4)) {
                                                String replaceAll = new String(m7155, "UTF-16LE").replaceAll(str4, str3);
                                                if (replaceAll.getBytes("UTF-16LE").length <= length) {
                                                    map.position(i4);
                                                    m7163(map, replaceAll.length());
                                                    map.position(position);
                                                    m7162(map, replaceAll);
                                                    map.force();
                                                    i3++;
                                                }
                                            }
                                            if (m7070 >= str5.length() && new String(m7155, "UTF-16LE").contains(str5)) {
                                                String replaceAll2 = new String(m7155, "UTF-16LE").replaceAll(str5, str6);
                                                if (replaceAll2.getBytes("UTF-16LE").length <= length) {
                                                    map.position(i4);
                                                    m7163(map, replaceAll2.length());
                                                    map.position(position);
                                                    m7162(map, replaceAll2);
                                                    map.force();
                                                    i3++;
                                                }
                                            }
                                            i++;
                                            m7185 = 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) {
                C2975.m7942(e4);
            }
        }
        return i;
    }

    public static void m7179() {
    }

    public static boolean m7180(C2933 c2933) {
        String str;
        String str2;
        if (c2933.f9128.trim().startsWith("~chelpus_disabled~")) {
            return false;
        }
        String trim = c2933.f9127.trim();
        String trim2 = c2933.f9128.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()) {
            m7159("mkdir", "-p '" + trim2 + "'");
        }
        if (!new File(trim).exists()) {
            m7159("mkdir", "-p '" + trim + "'");
        }
        try {
            new File(str + "test.txt").createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        m7093("echo '' >'" + str + "test.txt'");
        if (!m6898(str2 + "test.txt")) {
            new File(str + "test.txt").delete();
            if (m6898(str + "test.txt")) {
                m7093("rm '" + str + "test.txt'");
            }
            return false;
        }
        new File(str + "test.txt").delete();
        if (m6898(str + "test.txt")) {
            m7093("rm '" + str + "test.txt'");
            return true;
        }
        return true;
    }

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

    public static boolean m7182() {
        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 m7183(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 + "}";
    }

    public static boolean m7184() {
        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 int m7185(byte b, byte b2, byte b3, byte b4) {
        return (b & 255) | ((b2 & 255) << 8) | ((b3 & 255) << 16) | (b4 << DerValue.tag_GeneralizedTime);
    }

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

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

    public static boolean m7188() {
        String str;
        String str2 = "chelpa";
        int i = 8256;
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA");
            messageDigest.update(C2975.m7932().getPackageInfo("android", 8256).signatures[0].toByteArray());
            str = C2641.m7294(messageDigest.digest()).trim().replaceAll("\n", "");
        } catch (Exception unused) {
            str = "chelpa";
        }
        try {
            MessageDigest messageDigest2 = MessageDigest.getInstance("SHA");
            messageDigest2.update(C2975.m7932().getPackageInfo(C2975.m7929().getPackageName(), 8256).signatures[0].toByteArray());
            str2 = C2641.m7294(messageDigest2.digest()).trim().replaceAll("\n", "");
        } catch (Exception unused2) {
        }
        String str3 = str2;
        String[] m7931 = C2975.m7931();
        if (m7931 != null && m7931.length > 0) {
            int length = m7931.length;
            int i2 = 0;
            while (i2 < length) {
                String str4 = m7931[i2];
                if (!str4.equals("android") && !str4.equals(PkgName.getPkgName())) {
                    try {
                        android.content.pm.Signature[] signatureArr = C2975.m7932().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 = C2641.m7294(messageDigest3.digest()).trim().replaceAll("\n", "");
                                    if (!replaceAll.equals(str) && !replaceAll.equals(str3)) {
                                        if (C2975.m7932().checkSignatures(str4, C2975.m7929().getPackageName()) == 0) {
                                            return true;
                                        }
                                        return false;
                                    }
                                } catch (Throwable th) {
                                    th.printStackTrace();
                                }
                            }
                        }
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                        C2975.m7942("dont get Android signature");
                    }
                }
                i2++;
                i = 8256;
            }
            return false;
        }
        return false;
    }

    public static void m7189(File file, C2612 c2612) {
        String str;
        String str2;
        boolean z;
        String str3;
        String str4 = "";
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                C2975.m7942("run convertNativeMethods for " + file.getName());
                if (m7032(file, c2612)) {
                    BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
                    try {
                        C1856 m5634 = C1856.m5634(C4373.m9798(), bufferedInputStream2);
                        C2188 c2188 = new C2188(C4373.m9798());
                        boolean z2 = false;
                        for (C1846 c1846 : m5634.m5636()) {
                            if (c1846 != null) {
                                ArrayList arrayList = new ArrayList();
                                ArrayList arrayList2 = new ArrayList();
                                for (C1862 c1862 : c1846.getFields()) {
                                    arrayList.add(c2188.m6066(c1862.getDefiningClass(), c1862.getName(), c1862.getType(), c1862.getAccessFlags(), c1862.getInitialValue(), c1862.getAnnotations()));
                                }
                                boolean z3 = z2;
                                for (C1863 c1863 : c1846.getMethods()) {
                                    int accessFlags = c1863.getAccessFlags();
                                    InterfaceC1978 implementation = c1863.getImplementation();
                                    Iterator<C2631> it = c2612.f7443.iterator();
                                    int i = accessFlags;
                                    while (it.hasNext()) {
                                        C2631 next = it.next();
                                        if ((EnumC4369.NATIVE.getValue() & i) != 0 && c1863.getName().equals(next.f7565) && ((next.f7564.equals(str4) || c1863.getDefiningClass().equals(next.f7564)) && (next.f7563.equals(str4) || c1863.getReturnType().equals(next.f7563)))) {
                                            C2975.m7942("find " + c1863.getName());
                                            if (!next.f7566.equals(str4)) {
                                                List<? extends CharSequence> parameterTypes = c1863.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.f7566.equals(str3)) {
                                                    z = false;
                                                    if (!z) {
                                                        C2975.m7942("reset native flag for method:" + c1863.getName());
                                                        if (!next.f7572) {
                                                            C2975.m7942("convert native method:" + c1863.getName());
                                                            C1783 c1783 = new C1783(10);
                                                            for (int i2 = 0; i2 < next.f7553.length + 1; i2++) {
                                                                c1783.m5511(new C1808(EnumC4371.f12350));
                                                            }
                                                            implementation = c1783.m5512();
                                                            next.f7572 = true;
                                                        }
                                                        i = c1863.getAccessFlags() & (EnumC4369.NATIVE.getValue() ^ (-1));
                                                        z3 = true;
                                                    }
                                                }
                                            } else {
                                                str2 = str4;
                                            }
                                            z = true;
                                            if (!z) {
                                            }
                                        } else {
                                            str2 = str4;
                                        }
                                        str4 = str2;
                                    }
                                    arrayList2.add(c2188.m6067(c1863.getDefiningClass(), c1863.getName(), c1863.getParameters(), c1863.getReturnType(), i, c1863.getAnnotations(), c2188.m6060(implementation)));
                                    str4 = str4;
                                }
                                str = str4;
                                c2188.m6065(c1846.getType(), c1846.getAccessFlags(), c1846.getSuperclass(), c1846.getInterfaces(), c1846.getSourceFile(), c1846.getAnnotations(), arrayList, arrayList2);
                                z2 = z3;
                            } else {
                                str = str4;
                            }
                            str4 = str;
                        }
                        if (z2) {
                            c2188.m5844(new C2213(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 m7190() {
        f7066 = new ServiceConnectionC2588();
        try {
            Intent intent = new Intent("com.ui.ITestServiceInterface.BIND");
            intent.setPackage("com.android.vending");
            if (!C2975.m7929().bindService(intent, f7066, 1)) {
                return false;
            }
            if (f7066 != null) {
                C2975.m7929().unbindService(f7066);
            }
            return true;
        } catch (SecurityException e) {
            e.printStackTrace();
            return false;
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public static ArrayList<File> m7191(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 m7192(long j) {
        long m6958 = m6958();
        if (j != m6958 && m6958 != 0 && m6958 != 1) {
            C2975.m7942("firmware updated: need clear magisk module android patches");
            return true;
        }
        return false;
    }

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

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

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

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

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

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

    public void m7199(ArrayList<File> arrayList, File file, String str) throws IOException {
        String str2;
        String str3;
        m7179();
        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) {
                    m7199(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 m7200(File file, String str) throws IOException {
        m7179();
        m7094("chown", str, file.getAbsolutePath());
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                m7094("chown", str, file.getAbsolutePath());
                m7200(file2, str);
            }
        }
    }

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

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

    public String m7203(boolean z, C2511 c2511) throws Exception {
        String str;
        C3746 c3746;
        String str2 = "";
        Timer timer = new Timer();
        C2510 c2510 = new C2510(c2511);
        if (!c2511.f7121[0].contains(" " + C1601.class.getName() + " ") && !c2511.f7121[0].contains("oatdump ") && !c2511.f7121[0].contains("pm install")) {
            timer.schedule(c2510, 600000L);
            C2975.m7942("Input a string within 3 minuten: ");
        }
        try {
            c2511.f7124 = C2975.f9306;
            str = "";
            while (true) {
                try {
                    String m7069 = m7069(c2511.f7124);
                    if (m7069 == null) {
                        break;
                    }
                    c2511.f7125 = System.currentTimeMillis();
                    if (z && (c3746 = C2975.f9277) != null && c3746.m8243()) {
                        if (m7069.contains("Get classes.dex.")) {
                            C2975.m7954(new RunnableC2543());
                        }
                        if (m7069.equals("String analysis.")) {
                            C2975.m7954(new RunnableC2546());
                        }
                        if (m7069.equals("Parse data for patch.")) {
                            C2975.m7954(new RunnableC2548());
                        }
                        if (m7069.startsWith("Progress size:")) {
                            C2975.m7954(new RunnableC2550(m7069));
                        }
                        if (m7069.startsWith("Size file:")) {
                            C2975.m7954(new RunnableC2552(m7069));
                        }
                        if (m7069.startsWith("Analise Results:")) {
                            C2975.m7954(new RunnableC2555());
                        }
                        if (m7069.startsWith("Create ODEX:")) {
                            C2975.m7954(new RunnableC2558());
                        }
                        if (m7069.startsWith("Optional Steps After Patch:")) {
                            C2975.m7954(new RunnableC2561());
                        }
                    }
                    if (m7069.contains(C1617.class.getName())) {
                        C2975.m7942(str);
                        str = "";
                    }
                    if (m7069.contains("chelpus done!")) {
                        break;
                    }
                    if (!m7069.contains("chelpusstart!")) {
                        str = str + m7069 + "\n";
                    }
                } catch (Throwable th) {
                    th = th;
                    str2 = str;
                    th.printStackTrace();
                    str = str2;
                    timer.cancel();
                    C2975.m7942("you have entered: " + str);
                    return str;
                }
            }
        } catch (Throwable th2) {
            th = th2;
        }
        timer.cancel();
        C2975.m7942("you have entered: " + str);
        return str;
    }

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

    public C2509 m7205(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();
        C2509 c2509 = new C2509();
        long currentTimeMillis = System.currentTimeMillis();
        Process process2 = null;
        if (C2975.f9299 >= 23) {
            C2975.m7942("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=" + m7202(next);
                        strArr[3] = "--method-filter=" + m7204(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) {
                                        c2509.f7115 = 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 {
                                        c2509.f7116.add(new C2508(str, i5, i4));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    bufferedReader.close();
                                    process.destroy();
                                }
                            } catch (IOException e2) {
                                e = e2;
                                e.printStackTrace();
                                C2975.f9298 = e.toString();
                                C2975.m7942(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) {
                                c2509.f7115 = 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 {
                                c2509.f7116.add(new C2508(str6, i, i2));
                            } catch (Exception e8) {
                                e8.printStackTrace();
                            }
                            if (i7 == arrayList.size()) {
                                break;
                            }
                            str6 = null;
                        }
                    }
                } catch (IOException e9) {
                    e = e9;
                    process2 = process;
                    C2975.f9298 = e.toString();
                    C2975.m7942(e.toString());
                    process = process2;
                    C2975.m7942("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
                    if (process != null) {
                    }
                    return c2509;
                } catch (Exception e10) {
                    e = e10;
                    process2 = process;
                    e.printStackTrace();
                    process = process2;
                    C2975.m7942("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
                    if (process != null) {
                    }
                    return c2509;
                }
            } catch (IOException e11) {
                e = e11;
            } catch (Exception e12) {
                e = e12;
            }
        }
        C2975.m7942("time oatdump:" + ((System.currentTimeMillis() - j) / 1000));
        if (process != null) {
            process.destroy();
        }
        return c2509;
    }

    public void m7206(File file) {
        boolean canRequestPackageInstalls;
        MainActivity mainActivity;
        C2975.m7942("install rootless.");
        if (C2975.f9299 >= 26) {
            canRequestPackageInstalls = C2975.m7932().canRequestPackageInstalls();
            if (!canRequestPackageInstalls && (mainActivity = C2975.f9259) != null) {
                mainActivity.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + PkgName.getPkgName())), C2975.f9397);
            }
        }
        C3549.m8159(m7007(R.string.wait), m7007(R.string.installer_prepare), 3, false, false);
        Thread thread = new Thread(new RunnableC2540(file));
        thread.setPriority(10);
        thread.start();
    }

    public String m7207(String str, InputStream inputStream) {
        m7179();
        try {
        } catch (C3496 e) {
            e.printStackTrace();
        }
        if (C2975.f9323.booleanValue()) {
            throw new C3496("Application attempted to run a shell command from the main thread");
        }
        if (!C2975.f9283 && !str.equals("checkRoot")) {
            return "lucky patcher root not found!";
        }
        C2511 c2511 = new C2511(this, null);
        boolean z = true;
        c2511.f7121 = new String[]{str};
        c2511.f7122 = inputStream;
        c2511.start();
        try {
            if (!str.contains("-Xbootclasspath:") && !str.contains("app_process") && !str.contains("dd ") && !str.contains("cp ") && !str.contains("cat ") && !str.contains("pm ")) {
                z = false;
            }
            c2511.join();
            Integer unused = c2511.f7123;
        } catch (InterruptedException e2) {
            e2.printStackTrace();
            c2511.interrupt();
            Thread.currentThread().interrupt();
            m6900();
        }
        C2975.f9323 = Boolean.FALSE;
        return c2511.f7120;
    }

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

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

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

    public String m7211(String... strArr) {
        try {
            m7179();
        } catch (C3496 e) {
            e.printStackTrace();
        }
        try {
        } catch (C3496 e2) {
            e2.printStackTrace();
        }
        if (C2975.f9323.booleanValue()) {
            throw new C3496("Application attempted to run a shell command from the main thread");
        }
        if (!C2975.f9283 && !strArr[0].equals("checkRoot")) {
            return "lucky patcher root not found!";
        }
        C2511 c2511 = new C2511(this, null);
        c2511.f7121 = strArr;
        c2511.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) {
                c2511.join();
            } else {
                c2511.join();
                Integer unused = c2511.f7123;
            }
        } catch (InterruptedException e3) {
            e3.printStackTrace();
            c2511.interrupt();
            Thread.currentThread().interrupt();
            m6900();
        }
        C2975.f9323 = Boolean.FALSE;
        return c2511.f7120;
    }

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

    public C2500() {
    }
}