导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - XOneFileManager.java 源代码

正在查看: Minits v4.9.3.32 应用的 XOneFileManager.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.xone.android.script.runtimeobjects;

import C9.e;
import K9.d;
import K9.m;
import U9.G1;
import V9.b;
import V9.c;
import W1.E;
import W1.h;
import W1.i;
import W1.p;
import X1.j;
import Xa.V;
import Ya.a;
import a2.w;
import aa.k;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.StrictMode;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import androidx.annotation.Keep;
import com.cgsoft.db.impl.sqlite.SqliteConnection;
import com.xone.android.javascript.XOneJavascript;
import com.xone.android.utils.Utils;
import com.xone.annotations.ScriptAllowed;
import com.xone.interfaces.IRuntimeObject;
import com.xone.interfaces.IXoneApp;
import com.xone.interfaces.IXoneObject;
import fb.q;
import fb.t;
import ha.AbstractC0751f;
import ha.AbstractC0752g;
import ha.AbstractC0753h;
import j$.util.stream.Stream;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
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.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicInteger;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.C0893d0;
import org.mozilla.javascript.C0907k0;
import org.mozilla.javascript.C0932x0;
import org.mozilla.javascript.Q0;
import org.mozilla.javascript.Scriptable;
import qa.EnumC0975b;
import ua.InterfaceC1038m0;
import ua.O0;
import ua.W;

@ScriptAllowed
@Keep
public final class XOneFileManager extends BaseFunction implements IRuntimeObject {
    private static final String LINE_END = "\r\n";
    private static final String TWO_HYPENS = "--";
    private static final String WINDOWS_MOBILE_BOUNDARY = "123456789XONEFILE987654321";
    private final IXoneApp appData;
    private final Context context;
    private static final Map<String, W> mapTypeInfo = createTypeInfoData();
    private static final Map<String, d> mapOnDirectoryChangedListeners = new Hashtable();

    public XOneFileManager(Context context, IXoneApp iXoneApp) {
        this.context = context.getApplicationContext();
        this.appData = iXoneApp;
        XOneJavascript.addFunctions(this);
    }

    private static void DebugLog(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            return;
        }
        Utils.k("XOneAndroidFramework", charSequence);
    }

    private void addFileForZip(List<File> list, String str) {
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("Empty source file");
        }
        InterfaceC1038m0 app = getApp();
        File x1 = Utils.x1(app.Y(), app.T(), str, false);
        if (x1.exists()) {
            list.add(x1);
            return;
        }
        throw AbstractC0751f.b("File does not exist: " + x1.getAbsolutePath());
    }

    private static void addHeaders(i.a aVar, JSONObject jSONObject) {
        if (jSONObject == null) {
            return;
        }
        try {
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                aVar.a(next, jSONObject.getString(next));
            }
        } catch (JSONException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @SuppressLint({"NewApi"})
    private void applySecurityConfig(h hVar, boolean z) {
        if (z) {
            try {
                SSLContext sSLContext = SSLContext.getInstance("TLS");
                sSLContext.init(null, new c[]{new c()}, new SecureRandom());
                p r = hVar.r();
                r.M(sSLContext);
                r.J("##ALL##", new b());
                r.N(new c[]{new c()});
            } catch (KeyManagementException | NoSuchAlgorithmException e) {
                throw AbstractC0751f.e(e);
            }
        }
        Ya.c securityConfig = getAppData().getSecurityConfig();
        if (securityConfig == null) {
            return;
        }
        Ya.b b = securityConfig.b();
        if (!b.b() && Build.VERSION.SDK_INT >= 23) {
            StrictMode.VmPolicy vmPolicy = StrictMode.getVmPolicy();
            StrictMode.VmPolicy.Builder builder = vmPolicy != null ? new StrictMode.VmPolicy.Builder(vmPolicy) : new StrictMode.VmPolicy.Builder();
            builder.detectCleartextNetwork();
            builder.penaltyDeathOnCleartextNetwork();
            StrictMode.setVmPolicy(builder.build());
        }
        Ya.d a = b.a();
        if (a != null) {
            for (a aVar : a.b()) {
                hVar.r().J(aVar.d(), new R1.a(aVar.c()));
            }
        }
    }

    private void closeAndDeleteDatabase(File file) {
        SqliteConnection b;
        k database;
        File file2 = new File(file.getAbsolutePath() + "-wal");
        File file3 = new File(file.getAbsolutePath() + "-wal");
        if (file.exists()) {
            if (d2.a.e(file) && (b = d2.a.b(this.context, file)) != null && (database = b.getDatabase()) != null && database.isOpen()) {
                database.close();
            }
            if (!file.delete()) {
                throw AbstractC0751f.c("Cannot delete database file " + file.getAbsolutePath());
            }
        }
        if (file2.exists() && !file2.delete()) {
            throw AbstractC0751f.c("Cannot delete database file " + file2.getAbsolutePath());
        }
        if (!file3.exists() || file3.delete()) {
            return;
        }
        throw AbstractC0751f.c("Cannot delete database file " + file3.getAbsolutePath());
    }

    public static int compareLastModified(Q9.a aVar, Q9.a aVar2) {
        return Long.compare(aVar.b(), aVar2.b());
    }

    public static int compareNames(Q9.a aVar, Q9.a aVar2) {
        File a = aVar.a();
        File a2 = aVar2.a();
        if (a.isDirectory() && !a2.isDirectory()) {
            return -1;
        }
        if (a.isDirectory() || !a2.isDirectory()) {
            return a.getAbsolutePath().compareToIgnoreCase(a2.getAbsolutePath());
        }
        return 1;
    }

    private static Map<String, W> createTypeInfoData() {
        Hashtable hashtable = new Hashtable();
        Wa.d dVar = new Wa.d("Download", O0.a);
        dVar.c("url", 1, false);
        dVar.c("destination", 1, false);
        dVar.c("title", 1, true);
        String name = dVar.getName();
        Locale locale = Locale.US;
        hashtable.put(name.toLowerCase(locale), dVar);
        Wa.d dVar2 = new Wa.d("DownloadIfUpdated", O0.a);
        dVar2.c("url", 1, false);
        hashtable.put(dVar2.getName().toLowerCase(locale), dVar2);
        Wa.d dVar3 = new Wa.d("AsyncDownload", O0.a);
        dVar3.c("url", 1, false);
        dVar3.c("destination", 1, false);
        dVar3.c("title", 1, true);
        hashtable.put(dVar3.getName().toLowerCase(locale), dVar3);
        Wa.d dVar4 = new Wa.d("AsynchronousDownload", O0.a);
        dVar4.c("url", 1, false);
        dVar4.c("destination", 1, false);
        dVar4.c("title", 1, true);
        hashtable.put(dVar4.getName().toLowerCase(locale), dVar4);
        Wa.d dVar5 = new Wa.d("DownloadDatabase", O0.a);
        dVar5.c("url", 1, false);
        hashtable.put(dVar5.getName().toLowerCase(locale), dVar5);
        Wa.d dVar6 = new Wa.d("FileExists", O0.a);
        dVar6.c("path", 1, false);
        hashtable.put(dVar6.getName().toLowerCase(locale), dVar6);
        Wa.d dVar7 = new Wa.d("DirectoryExists", O0.a);
        dVar7.c("path", 1, false);
        hashtable.put(dVar7.getName().toLowerCase(locale), dVar7);
        Wa.d dVar8 = new Wa.d("ListFiles", O0.a);
        dVar8.c("path", 1, true);
        hashtable.put(dVar8.getName().toLowerCase(locale), dVar8);
        Wa.d dVar9 = new Wa.d("ListDirectories", O0.a);
        dVar9.c("path", 1, true);
        hashtable.put(dVar9.getName().toLowerCase(locale), dVar9);
        Wa.d dVar10 = new Wa.d("CreateDirectory", O0.a);
        dVar10.c("path", 1, false);
        hashtable.put(dVar10.getName().toLowerCase(locale), dVar10);
        Wa.d dVar11 = new Wa.d("Rename", O0.a);
        dVar11.c("source", 1, false);
        dVar11.c("dest", 1, false);
        hashtable.put(dVar11.getName().toLowerCase(locale), dVar11);
        Wa.d dVar12 = new Wa.d("Copy", O0.a);
        dVar12.c("source", 1, false);
        dVar12.c("dest", 1, false);
        hashtable.put(dVar12.getName().toLowerCase(locale), dVar12);
        Wa.d dVar13 = new Wa.d("Delete", O0.a);
        dVar13.c("path", 1, false);
        hashtable.put(dVar13.getName().toLowerCase(locale), dVar13);
        Wa.d dVar14 = new Wa.d("DeleteDirectory", O0.a);
        dVar14.c("path", 1, false);
        hashtable.put(dVar14.getName().toLowerCase(locale), dVar14);
        Wa.d dVar15 = new Wa.d("Move", O0.a);
        dVar15.c("source", 1, false);
        dVar15.c("destination", 1, false);
        hashtable.put(dVar15.getName().toLowerCase(locale), dVar15);
        Wa.d dVar16 = new Wa.d("DeleteDatabase", O0.a);
        dVar16.c("path", 1, false);
        hashtable.put(dVar16.getName().toLowerCase(locale), dVar16);
        Wa.d dVar17 = new Wa.d("Zip", O0.a);
        dVar17.c("path", 1, false);
        hashtable.put(dVar17.getName().toLowerCase(locale), dVar17);
        Wa.d dVar18 = new Wa.d("ZipAll", O0.a);
        dVar18.c("target", 1, false);
        hashtable.put(dVar18.getName().toLowerCase(locale), dVar18);
        Wa.d dVar19 = new Wa.d("Unzip", O0.a);
        dVar19.c("path", 1, false);
        hashtable.put(dVar19.getName().toLowerCase(locale), dVar19);
        Wa.d dVar20 = new Wa.d("OpenFile", O0.a);
        dVar20.c("path", 1, false);
        hashtable.put(dVar20.getName().toLowerCase(locale), dVar20);
        Wa.d dVar21 = new Wa.d("GetChecksum", O0.a);
        dVar21.c("file", 1, false);
        dVar21.c("checksumtype", 1, true);
        hashtable.put(dVar21.getName().toLowerCase(locale), dVar21);
        Wa.d dVar22 = new Wa.d("UploadFile", O0.a);
        dVar22.c("url", 1, false);
        dVar22.c("path", 1, false);
        dVar22.c("params", 1, true);
        dVar22.c("version", 2, true);
        hashtable.put(dVar22.getName().toLowerCase(locale), dVar22);
        Wa.d dVar23 = new Wa.d("ToBase64", O0.a);
        dVar23.c("file", 1, false);
        hashtable.put(dVar23.getName().toLowerCase(locale), dVar23);
        Wa.d dVar24 = new Wa.d("ToFile", O0.a);
        dVar24.c("base64string", 1, false);
        dVar24.c("file", 1, false);
        hashtable.put(dVar24.getName().toLowerCase(locale), dVar24);
        Wa.d dVar25 = new Wa.d("GetSize", O0.a);
        dVar25.c("file", 1, false);
        hashtable.put(dVar25.getName().toLowerCase(locale), dVar25);
        Wa.d dVar26 = new Wa.d("ReadFile", O0.a);
        dVar26.c("file", 1, false);
        dVar26.c("encoding", 1, true);
        hashtable.put(dVar26.getName().toLowerCase(locale), dVar26);
        Wa.d dVar27 = new Wa.d("SaveFile", O0.a);
        dVar27.c("file", 1, false);
        dVar27.c("data", 1, false);
        dVar27.c("append", 6, true);
        dVar27.c("encoding", 1, true);
        hashtable.put(dVar27.getName().toLowerCase(locale), dVar27);
        Wa.d dVar28 = new Wa.d("AddOnDirectoryChangedListener", O0.a);
        dVar28.c("path", 1, false);
        hashtable.put(dVar28.getName().toLowerCase(locale), dVar28);
        Wa.d dVar29 = new Wa.d("RemoveOnDirectoryChangedListener", O0.a);
        dVar29.c("path", 1, false);
        hashtable.put(dVar29.getName().toLowerCase(locale), dVar29);
        Wa.d dVar30 = new Wa.d("GetLastModifiedDate", O0.a);
        dVar30.c("path", 1, false);
        hashtable.put(dVar30.getName().toLowerCase(locale), dVar30);
        Wa.d dVar31 = new Wa.d("IsDirectoryEmpty", O0.a);
        dVar31.c("path", 1, false);
        hashtable.put(dVar31.getName().toLowerCase(locale), dVar31);
        return hashtable;
    }

    private Date doGetLastModifiedDateInternal(Object... objArr) {
        Utils.j("GetLastModifiedDate", objArr);
        Utils.g("GetLastModifiedDate", objArr, 1);
        File file = getFile(t.y(objArr[0]));
        if (file.exists()) {
            return new Date(file.lastModified());
        }
        throw AbstractC0751f.b("GetLastModifiedDate(): File " + file.getAbsolutePath() + " does not exists");
    }

    private Object doUploadFileInternal(File file, Uri uri, JSONObject jSONObject, Map<String, String> map, boolean z, Object obj, Object obj2, Object obj3) {
        m mVar;
        Object obj4;
        h B = h.B();
        if (TextUtils.equals(getScheme(uri), "https")) {
            applySecurityConfig(B, z);
        }
        j jVar = new j();
        jVar.W(file.getName(), file);
        for (Map.Entry<String, String> entry : map.entrySet()) {
            jVar.Y(entry.getKey(), t.y(entry.getValue()));
        }
        i.a e = new i.a().h(E.p).l(uri).e(jVar);
        addHeaders(e, jSONObject);
        IXoneObject selfObject = getSelfObject();
        if (obj == null && obj2 == null && obj3 == null) {
            mVar = null;
            obj4 = obj3;
        } else {
            obj4 = obj3;
            mVar = new m(this.context, obj, obj4, obj2, selfObject);
        }
        w o = B.o(e.b(), mVar);
        try {
            return (obj == null && obj2 == null && obj4 == null) ? o.get() : new FutureScriptWrapper(o);
        } catch (InterruptedException e2) {
            throw AbstractC0751f.e(e2);
        } catch (ExecutionException e3) {
            throw AbstractC0751f.f(e3);
        }
    }

    private Object doUploadFileInternalJavascript(String str, C0932x0 c0932x0) {
        JSONObject l0;
        String D = Q8.k.D(c0932x0, "url");
        if (!URLUtil.isHttpUrl(D) && !URLUtil.isHttpsUrl(D)) {
            throw new IllegalArgumentException(str + "(): Invalid URL");
        }
        Uri parse = Uri.parse(D);
        String filePath = getFilePath(Q8.k.D(c0932x0, "file"));
        if (TextUtils.isEmpty(filePath)) {
            throw AbstractC0751f.b(str + "(): Source file path not found");
        }
        File file = new File(filePath);
        if (!file.exists()) {
            throw AbstractC0751f.b(str + "(): File " + file.getAbsolutePath() + " does not exist");
        }
        C0932x0 w = Q8.k.w(c0932x0, "parameters", null);
        C0932x0 w2 = Q8.k.w(c0932x0, "headers", null);
        if (w2 != null) {
            try {
                l0 = Q8.k.l0(w2, false);
            } catch (JSONException e) {
                throw AbstractC0751f.e(e);
            }
        } else {
            l0 = null;
        }
        boolean a = Q8.k.a(c0932x0, "allowUnsafeCertificates", false);
        int o = Q8.k.o(c0932x0, "version", 2);
        HashMap hashMap = new HashMap();
        if (w != null) {
            Set entrySet = w.entrySet();
            Iterator it = entrySet.iterator();
            for (int i = 0; i < entrySet.size(); i++) {
                Map.Entry entry = (Map.Entry) it.next();
                hashMap.put(t.z(entry.getKey(), null), t.z(entry.getValue(), ""));
            }
        }
        return o == 1 ? doUploadFileInternalOld(file, parse, hashMap, a) : doUploadFileInternal(file, parse, l0, hashMap, a, Q8.k.z(c0932x0, "onSuccess", null), Q8.k.z(c0932x0, "onError", null), Q8.k.z(c0932x0, "onProgress", null));
    }

    private String doUploadFileInternalOld(File file, Uri uri, Map<String, String> map, boolean z) {
        char c;
        FileInputStream fileInputStream;
        OutputStream outputStream;
        ?? r10;
        URL url;
        HttpURLConnection httpURLConnection = null;
        try {
            url = new URL(uri.toString());
            fileInputStream = new FileInputStream(file);
        } catch (IOException e) {
            e = e;
            c = 2;
            fileInputStream = null;
            outputStream = null;
        } catch (Throwable th) {
            th = th;
            c = 2;
            fileInputStream = null;
            outputStream = null;
        }
        try {
            HttpURLConnection httpURLConnection2 = (HttpURLConnection) url.openConnection();
            try {
                if ((httpURLConnection2 instanceof HttpsURLConnection) && z) {
                    try {
                        try {
                            SSLContext sSLContext = SSLContext.getInstance("TLS");
                            sSLContext.init(null, new c[]{new c()}, new SecureRandom());
                            ((HttpsURLConnection) httpURLConnection2).setSSLSocketFactory(sSLContext.getSocketFactory());
                            ((HttpsURLConnection) httpURLConnection2).setHostnameVerifier(new b());
                        } catch (KeyManagementException | NoSuchAlgorithmException e2) {
                            throw AbstractC0751f.e(e2);
                        }
                    } catch (IOException e3) {
                        e = e3;
                        outputStream = null;
                        r10 = 0;
                        httpURLConnection = httpURLConnection2;
                        c = 2;
                        try {
                            throw AbstractC0751f.e(e);
                        } catch (Throwable th2) {
                            th = th2;
                            Utils.r0(httpURLConnection);
                            ?? r2 = new Closeable[3];
                            r2[0] = r10;
                            r2[1] = outputStream;
                            r2[c] = fileInputStream;
                            Utils.P(r2);
                            throw th;
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        outputStream = null;
                        r10 = 0;
                        httpURLConnection = httpURLConnection2;
                        c = 2;
                        Utils.r0(httpURLConnection);
                        ?? r22 = new Closeable[3];
                        r22[0] = r10;
                        r22[1] = outputStream;
                        r22[c] = fileInputStream;
                        Utils.P(r22);
                        throw th;
                    }
                }
                httpURLConnection2.setDoInput(true);
                httpURLConnection2.setDoOutput(true);
                httpURLConnection2.setUseCaches(false);
                httpURLConnection2.setRequestMethod("POST");
                httpURLConnection2.setRequestProperty("Connection", "Keep-Alive");
                httpURLConnection2.setRequestProperty("Content-Type", "multipart/form-data;boundary=123456789XONEFILE987654321");
                httpURLConnection2.setConnectTimeout(60000);
                httpURLConnection2.setReadTimeout(30000);
                outputStream = httpURLConnection2.getOutputStream();
                try {
                    r10 = new DataOutputStream(outputStream);
                    if (map != null) {
                        try {
                            for (Map.Entry<String, String> entry : map.entrySet()) {
                                String key = entry.getKey();
                                String value = entry.getValue();
                                r10.writeBytes("--123456789XONEFILE987654321\r\n");
                                StringBuilder sb2 = new StringBuilder();
                                c = 2;
                                try {
                                    sb2.append("Content-Disposition: form-data; name=\"");
                                    sb2.append(key);
                                    sb2.append("\"");
                                    sb2.append(LINE_END);
                                    sb2.append(LINE_END);
                                    sb2.append(value);
                                    sb2.append(LINE_END);
                                    sb2.append(TWO_HYPENS);
                                    sb2.append(WINDOWS_MOBILE_BOUNDARY);
                                    sb2.append(LINE_END);
                                    r10.writeBytes(sb2.toString());
                                } catch (IOException e4) {
                                    e = e4;
                                    httpURLConnection = httpURLConnection2;
                                    r10 = r10;
                                    throw AbstractC0751f.e(e);
                                } catch (Throwable th4) {
                                    th = th4;
                                    httpURLConnection = httpURLConnection2;
                                    Utils.r0(httpURLConnection);
                                    ?? r222 = new Closeable[3];
                                    r222[0] = r10;
                                    r222[1] = outputStream;
                                    r222[c] = fileInputStream;
                                    Utils.P(r222);
                                    throw th;
                                }
                            }
                        } catch (IOException e5) {
                            e = e5;
                            c = 2;
                            httpURLConnection = httpURLConnection2;
                            r10 = r10;
                            throw AbstractC0751f.e(e);
                        } catch (Throwable th5) {
                            th = th5;
                            c = 2;
                            httpURLConnection = httpURLConnection2;
                            Utils.r0(httpURLConnection);
                            ?? r2222 = new Closeable[3];
                            r2222[0] = r10;
                            r2222[1] = outputStream;
                            r2222[c] = fileInputStream;
                            Utils.P(r2222);
                            throw th;
                        }
                    }
                    c = 2;
                    r10.writeBytes("--123456789XONEFILE987654321\r\n");
                    r10.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + file.getName() + "\"" + LINE_END);
                    String mimeType = getMimeType(file);
                    if (!TextUtils.isEmpty(mimeType)) {
                        r10.writeBytes("Content-Type: " + mimeType + LINE_END);
                    }
                    r10.writeBytes(LINE_END);
                    int min = Math.min(fileInputStream.available(), 1048576);
                    byte[] bArr = new byte[min];
                    int read = fileInputStream.read(bArr, 0, min);
                    while (read > 0) {
                        r10.write(bArr, 0, min);
                        min = Math.min(fileInputStream.available(), 1048576);
                        read = fileInputStream.read(bArr, 0, min);
                    }
                    r10.writeBytes(LINE_END);
                    r10.writeBytes("--123456789XONEFILE987654321--\r\n");
                    r10.flush();
                    try {
                        String readResponse = readResponse(httpURLConnection2);
                        Utils.r0(httpURLConnection2);
                        Utils.P(new Closeable[]{r10, outputStream, fileInputStream});
                        return readResponse;
                    } catch (IOException e6) {
                        e = e6;
                        httpURLConnection = httpURLConnection2;
                        r10 = r10;
                        throw AbstractC0751f.e(e);
                    } catch (Throwable th6) {
                        th = th6;
                        httpURLConnection = httpURLConnection2;
                        Utils.r0(httpURLConnection);
                        ?? r22222 = new Closeable[3];
                        r22222[0] = r10;
                        r22222[1] = outputStream;
                        r22222[c] = fileInputStream;
                        Utils.P(r22222);
                        throw th;
                    }
                } catch (IOException e7) {
                    e = e7;
                    c = 2;
                    r10 = 0;
                } catch (Throwable th7) {
                    th = th7;
                    c = 2;
                    r10 = 0;
                }
            } catch (IOException e10) {
                e = e10;
                c = 2;
                outputStream = null;
                r10 = 0;
            } catch (Throwable th8) {
                th = th8;
                c = 2;
                outputStream = null;
                r10 = 0;
            }
        } catch (IOException e11) {
            e = e11;
            c = 2;
            outputStream = null;
            r10 = outputStream;
            throw AbstractC0751f.e(e);
        } catch (Throwable th9) {
            th = th9;
            c = 2;
            outputStream = null;
            r10 = outputStream;
            Utils.r0(httpURLConnection);
            ?? r222222 = new Closeable[3];
            r222222[0] = r10;
            r222222[1] = outputStream;
            r222222[c] = fileInputStream;
            Utils.P(r222222);
            throw th;
        }
    }

    private String doUploadFileInternalVbscript(String str, Object[] objArr) {
        Utils.h(str, objArr, 2, 4);
        String y = t.y(objArr[0]);
        if (!URLUtil.isHttpUrl(y) && !URLUtil.isHttpsUrl(y)) {
            throw new IllegalArgumentException(str + "(): Invalid URL");
        }
        Uri parse = Uri.parse(y);
        String filePath = getFilePath(objArr[1]);
        if (TextUtils.isEmpty(filePath)) {
            throw AbstractC0751f.b(str + "(): Source file path not found");
        }
        File file = new File(filePath);
        if (!file.exists()) {
            throw AbstractC0751f.b(str + "(): File " + file.getAbsolutePath() + " does not exist");
        }
        HashMap hashMap = new HashMap();
        if (objArr.length > 2) {
            String[] split = t.y(objArr[2]).split(":");
            if (split.length % 2 != 0) {
                throw new IllegalArgumentException(str + "(): Incorrect URL parameter count, it must be an even number");
            }
            int i = 0;
            while (i < split.length - 1) {
                String str2 = split[i];
                i++;
                hashMap.put(str2, split[i]);
            }
        }
        Object doUploadFileInternalOld = Utils.u(objArr, 3, 2) == 1 ? doUploadFileInternalOld(file, parse, hashMap, false) : doUploadFileInternal(file, parse, null, hashMap, false, null, null, null);
        return doUploadFileInternalOld instanceof CharSequence ? doUploadFileInternalOld.toString() : "";
    }

    private w downloadFileAsync(String str, String str2, String str3, boolean z, boolean z2, Object obj, Object obj2, Object obj3, boolean z3, JSONObject jSONObject, JSONObject jSONObject2) {
        if (z) {
            str2 = str2 + ".partial";
        }
        File file = new File(str2);
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            throw AbstractC0751f.c("Cannot create parent folder " + parentFile.getAbsolutePath());
        }
        if (!str.startsWith("http://") && !str.startsWith("https://")) {
            throw new IllegalArgumentException("Invalid URL");
        }
        i.a f = new i.a().h(E.n).l(Uri.parse(str)).j(z).k(15000).f(jSONObject2);
        addHeaders(f, jSONObject);
        K9.c cVar = new K9.c(this.context, str3, obj, obj2, obj3, z3);
        h B = h.B();
        applySecurityConfig(B, z2);
        return B.k(f.b(), file, cVar);
    }

    private boolean downloadFileSync(String str, String str2, String str3, Object obj) {
        File file = new File(str2);
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            DebugLog("Cannot create parent folder!");
            return false;
        }
        if (!str.startsWith("http://") && !str.startsWith("https://")) {
            throw new IllegalArgumentException("Invalid URL");
        }
        DebugLog("Downloading file " + str + " to " + str2 + "...");
        try {
            i b = new i.a().h(E.n).l(Uri.parse(str)).k(15000).b();
            K9.c cVar = new K9.c(this.context, str3, obj);
            h B = h.B();
            applySecurityConfig(B, false);
            File file2 = (File) B.k(b, file, cVar).get();
            cVar.e();
            if (file2 != null && file2.exists() && file2.isFile()) {
                DebugLog("Download OK!");
                return true;
            }
            DebugLog("Download failed!");
            return false;
        } catch (Exception e) {
            e.printStackTrace();
            DebugLog("Download failed!");
            return false;
        }
    }

    private static int downloadFileSyncIfUpdatedAsync(String str, String str2, Object obj) {
        File file = new File(str2);
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            DebugLog("Cannot create parent folder!");
            return 1;
        }
        if (!str.startsWith("http://") && !str.startsWith("https://")) {
            throw new IllegalArgumentException("Invalid URL");
        }
        if (file.exists()) {
            String encode = Uri.encode(Utils.z2(file));
            boolean contains = str.contains("?");
            StringBuilder sb2 = new StringBuilder();
            sb2.append(str);
            sb2.append(contains ? "&" : "?");
            sb2.append("hash=");
            sb2.append(encode);
            str = sb2.toString();
        }
        DebugLog("Downloading file " + str + " to " + str2 + "...");
        try {
            AtomicInteger atomicInteger = new AtomicInteger(0);
            FutureTask futureTask = new FutureTask(new J9.c(str, file, atomicInteger, obj));
            Executors.newFixedThreadPool(1).execute(futureTask);
            futureTask.get();
            return atomicInteger.get();
        } catch (Exception e) {
            e.printStackTrace();
            DebugLog("Download failed!");
            return 1;
        }
    }

    public boolean lambda$internalListFiles$0(Set<String> set, Date date, Date date2, File file) {
        boolean z = (date == null && date2 == null) ? false : true;
        if (!file.isFile()) {
            return false;
        }
        if (set == null) {
            if (z) {
                return isDateValid(file, date, date2);
            }
            return true;
        }
        if (!set.contains(Utils.t1(file))) {
            return false;
        }
        if (z) {
            return isDateValid(file, date, date2);
        }
        return true;
    }

    private InterfaceC1038m0 getApp() {
        return (InterfaceC1038m0) this.context;
    }

    private IXoneApp getAppData() {
        IXoneApp G0 = getApp().G0();
        if (G0 != null) {
            return G0;
        }
        throw new NullPointerException("appData == null");
    }

    private static long getDirectorySize(File file) {
        long directorySize;
        if (!file.isDirectory()) {
            throw new IllegalArgumentException("Path is not a directory: " + file.getAbsolutePath());
        }
        File[] listFiles = file.listFiles();
        long j = 0;
        if (listFiles != null && listFiles.length != 0) {
            for (File file2 : listFiles) {
                if (file2.isFile()) {
                    directorySize = file2.length();
                } else if (file2.isDirectory()) {
                    directorySize = getDirectorySize(file2);
                }
                j += directorySize;
            }
        }
        return j;
    }

    private File getFile(String str) {
        InterfaceC1038m0 app = getApp();
        return Utils.w1(app.Y(), app.T(), str);
    }

    private String getFilePath(Object obj) {
        return getFilePath(t.y(obj));
    }

    private static String getMimeType(File file) {
        if (file == null) {
            return null;
        }
        String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath());
        if (TextUtils.isEmpty(fileExtensionFromUrl)) {
            return null;
        }
        return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtensionFromUrl);
    }

    private static String getScheme(Uri uri) {
        String scheme = uri.getScheme();
        return TextUtils.isEmpty(scheme) ? "" : scheme.trim().toLowerCase(Locale.US);
    }

    private IXoneObject getSelfObject() {
        Q0 m = XOneJavascript.m();
        if (m == null) {
            return null;
        }
        Object obj = m.get("self");
        if (obj instanceof IXoneObject) {
            return (IXoneObject) obj;
        }
        return null;
    }

    private List<File> internalListDirectories(Object... objArr) {
        String e;
        File[] listFiles;
        if (objArr != null) {
            Utils.g("ListDirectories", objArr, 1);
            e = t.y(objArr[0]);
        } else {
            e = AbstractC0752g.e(this.context, getAppData().getApplicationName());
        }
        if (TextUtils.isEmpty(e)) {
            return null;
        }
        String filePath = getFilePath(e);
        if (TextUtils.isEmpty(filePath)) {
            return null;
        }
        File file = new File(filePath);
        if (!file.exists() || (listFiles = file.listFiles(new FileFilter() {
            @Override
            public final boolean accept(File file2) {
                return file2.isDirectory();
            }
        })) == null || listFiles.length == 0) {
            return null;
        }
        return Arrays.asList(listFiles);
    }

    private java.util.List<Q9.a> internalListFiles(java.lang.Object[] r13) {
        throw new UnsupportedOperationException("Method not decompiled: com.xone.android.script.runtimeobjects.XOneFileManager.internalListFiles(java.lang.Object[]):java.util.List");
    }

    private static boolean isDateValid(File file, Date date, Date date2) {
        Date date3 = new Date(file.lastModified());
        if (date != null && date3.before(date)) {
            return false;
        }
        if (date2 != null) {
            return true ^ date3.after(date2);
        }
        return true;
    }

    private V listDirectoriesVbs(Object... objArr) {
        return toXOneVBScriptArray("ListDirectories", internalListDirectories(objArr));
    }

    private static List<File> listFilesRecursive(File file) {
        ArrayList arrayList = new ArrayList();
        listFilesRecursive(arrayList, file);
        return arrayList;
    }

    private V listFilesVbs(Object... objArr) {
        return toXOneVBScriptArray("ListFiles", internalListFiles(objArr));
    }

    private static Date parseDate(SimpleDateFormat simpleDateFormat, String str) {
        try {
            return simpleDateFormat.parse(str);
        } catch (ParseException e) {
            throw AbstractC0751f.e(e);
        }
    }

    private String readResponse(HttpURLConnection httpURLConnection) {
        DataInputStream dataInputStream;
        InputStreamReader inputStreamReader;
        ?? r11;
        InputStreamReader inputStreamReader2;
        InputStream inputStream = null;
        try {
            int responseCode = httpURLConnection.getResponseCode();
            InputStream inputStream2 = responseCode == 200 ? httpURLConnection.getInputStream() : httpURLConnection.getErrorStream();
            try {
                if (inputStream2 == null) {
                    if (responseCode == 200) {
                        Utils.P(inputStream2, null, null, null);
                        return "";
                    }
                    throw AbstractC0751f.c("Connection was not completed successfully, server returned HTTP status code " + responseCode);
                }
                dataInputStream = new DataInputStream(inputStream2);
                try {
                    inputStreamReader = new InputStreamReader(dataInputStream);
                } catch (IOException e) {
                    e = e;
                    inputStreamReader = null;
                    inputStreamReader2 = inputStreamReader;
                    inputStream = inputStream2;
                    e = e;
                    r11 = inputStreamReader2;
                    try {
                        throw AbstractC0751f.e(e);
                    } catch (Throwable th) {
                        th = th;
                        Utils.P(new Closeable[]{inputStream, dataInputStream, inputStreamReader, r11});
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    inputStreamReader = null;
                    r11 = inputStreamReader;
                    inputStream = inputStream2;
                    th = th;
                    Utils.P(new Closeable[]{inputStream, dataInputStream, inputStreamReader, r11});
                    throw th;
                }
                try {
                    r11 = new BufferedReader(inputStreamReader);
                    try {
                        StringBuilder sb2 = new StringBuilder();
                        while (true) {
                            String readLine = r11.readLine();
                            if (readLine == null) {
                                break;
                            }
                            sb2.append(readLine);
                            sb2.append(LINE_END);
                        }
                        if (responseCode == 200) {
                            String sb3 = sb2.toString();
                            Utils.P(new Closeable[]{inputStream2, dataInputStream, inputStreamReader, r11});
                            return sb3;
                        }
                        StringBuilder sb4 = new StringBuilder();
                        sb4.append("Connection was not completed successfully, server returned HTTP status code ");
                        sb4.append(responseCode);
                        sb4.append(' ');
                        sb4.append(AbstractC0753h.b(responseCode));
                        if (!TextUtils.isEmpty(sb2)) {
                            sb4.append(".\nError response: ");
                            sb4.append((CharSequence) sb2);
                        }
                        throw AbstractC0751f.c(sb4.toString());
                    } catch (IOException e2) {
                        inputStream = inputStream2;
                        e = e2;
                        r11 = r11;
                        throw AbstractC0751f.e(e);
                    } catch (Throwable th3) {
                        inputStream = inputStream2;
                        th = th3;
                        Utils.P(new Closeable[]{inputStream, dataInputStream, inputStreamReader, r11});
                        throw th;
                    }
                } catch (IOException e3) {
                    e = e3;
                    inputStreamReader2 = null;
                    inputStream = inputStream2;
                    e = e;
                    r11 = inputStreamReader2;
                    throw AbstractC0751f.e(e);
                } catch (Throwable th4) {
                    th = th4;
                    r11 = 0;
                    inputStream = inputStream2;
                    th = th;
                    Utils.P(new Closeable[]{inputStream, dataInputStream, inputStreamReader, r11});
                    throw th;
                }
            } catch (IOException e4) {
                e = e4;
                dataInputStream = null;
                inputStreamReader = null;
            } catch (Throwable th5) {
                th = th5;
                dataInputStream = null;
                inputStreamReader = null;
            }
        } catch (IOException e5) {
            e = e5;
            dataInputStream = null;
            inputStreamReader = null;
            r11 = 0;
        } catch (Throwable th6) {
            th = th6;
            dataInputStream = null;
            inputStreamReader = null;
            r11 = 0;
        }
    }

    private static V toXOneVBScriptArray(String str, List<?> list) {
        if (list == null) {
            return null;
        }
        int size = list.size();
        int[] iArr = {size};
        V v = new V(str + ".result", iArr, null);
        for (int i = 0; i < size; i++) {
            try {
                iArr[0] = i;
                v.g(iArr).a(list.get(i));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return v;
    }

    @Override
    public Object GetPropertyManager(String str, Object[] objArr) {
        return null;
    }

    @Override
    public W GetTypeInfo(String str) {
        String lowerCase = str.toLowerCase(Locale.US);
        Map<String, W> map = mapTypeInfo;
        if (map.containsKey(lowerCase)) {
            return map.get(lowerCase);
        }
        return null;
    }

    @Override
    public Object Invoke(String str, EnumC0975b enumC0975b, Object[] objArr) {
        String lowerCase = str.toLowerCase(Locale.US);
        lowerCase.getClass();
        switch (lowerCase) {
            case "getcachedirectory":
                return getCacheDirectory(objArr);
            case "directoryexists":
                return Integer.valueOf(directoryExists(objArr));
            case "savefile":
                return Boolean.valueOf(saveFile(objArr));
            case "fileexists":
                return Integer.valueOf(fileExists(objArr));
            case "getcodecachedirectory":
                return getCodeCacheDirectory(objArr);
            case "tobase64":
                return toBase64(objArr);
            case "delete":
                return Integer.valueOf(delete(objArr));
            case "addondirectorychangedlistener":
                return addOnDirectoryChangedListener(objArr);
            case "listfiles":
                return listFilesVbs(objArr);
            case "rename":
                return Integer.valueOf(rename(objArr));
            case "tofile":
                return Integer.valueOf(toFile(objArr));
            case "readfile":
                return readFile(objArr);
            case "listdirectories":
                return listDirectoriesVbs(objArr);
            case "getchecksum":
                return getChecksum(objArr);
            case "clearcache":
                return clearCache(objArr);
            case "zipall":
                return Integer.valueOf(zipAll(objArr));
            case "asyncdownload":
            case "asynchronousdownload":
                return Integer.valueOf(asyncDownload(objArr));
            case "openfile":
                return Integer.valueOf(openFile(objArr));
            case "deletedatabase":
                return Integer.valueOf(deleteDatabase(objArr));
            case "uploadfile":
                return uploadFile(objArr);
            case "createdirectory":
                return Integer.valueOf(createDirectory(objArr));
            case "getsize":
                return Long.valueOf(getSize(objArr));
            case "zip":
                return Integer.valueOf(zip(objArr));
            case "copy":
                return Integer.valueOf(copy(objArr));
            case "move":
                return Integer.valueOf(move(objArr));
            case "unzip":
                return Integer.valueOf(unzip(objArr));
            case "downloadifupdated":
                return Integer.valueOf(downloadIfUpdated(objArr));
            case "getrootdirectory":
                return getRootDirectory(objArr);
            case "isdirectoryempty":
                return Boolean.valueOf(isDirectoryEmpty(objArr));
            case "downloaddatabase":
                return Integer.valueOf(downloadDatabase(objArr));
            case "removeondirectorychangedlistener":
                return removeOnDirectoryChangedListener(objArr);
            case "download":
                return download(objArr);
            case "getlastmodifieddate":
                return doGetLastModifiedDateInternal(objArr);
            case "deletedirectory":
                return Integer.valueOf(deleteDirectory(objArr));
            default:
                throw new IllegalArgumentException(getName() + ": Function/method/property " + str + " not implemented.");
        }
    }

    @ScriptAllowed
    public XOneFileManager addOnDirectoryChangedListener(Object... objArr) {
        Utils.j("AddOnDirectoryChangedListener", objArr);
        Utils.g("AddOnDirectoryChangedListener", objArr, 2);
        String y = t.y(objArr[0]);
        Object obj = objArr[1];
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("AddOnDirectoryChangedListener(): Empty directory path");
        }
        if (obj == null) {
            throw new IllegalArgumentException("AddOnDirectoryChangedListener(): Null callback parameter");
        }
        File file = new File(getFilePath(y));
        if (!file.exists()) {
            throw AbstractC0751f.b("AddOnDirectoryChangedListener(): Directory " + file.getAbsolutePath() + " does not exists");
        }
        if (!file.isDirectory()) {
            throw AbstractC0751f.c("AddOnDirectoryChangedListener(): Path " + file.getAbsolutePath() + " is not a directory");
        }
        Map<String, d> map = mapOnDirectoryChangedListeners;
        d dVar = map.get(y);
        if (dVar != null) {
            dVar.a(obj);
            return this;
        }
        d dVar2 = new d(getApp(), file, obj);
        dVar2.startWatching();
        map.put(y, dVar2);
        return this;
    }

    @ScriptAllowed
    public int asyncDownload(Object... objArr) {
        String f;
        String str;
        String str2;
        String str3;
        String str4;
        boolean z;
        Utils.j("AsyncDownload", objArr);
        Utils.h("AsyncDownload", objArr, 1, 4);
        Object obj = objArr[0];
        if (obj instanceof C0932x0) {
            C0932x0 c0932x0 = (C0932x0) obj;
            String E = Q8.k.E(c0932x0, "url", "");
            String E2 = Q8.k.E(c0932x0, "destination", "");
            String E3 = Q8.k.E(c0932x0, "title", "");
            String E4 = Q8.k.E(c0932x0, "mimeType", "");
            str = E;
            z = Q8.k.a(c0932x0, "notification", true);
            str3 = E2;
            str4 = E3;
            str2 = E4;
            f = null;
        } else {
            String y = t.y(obj);
            if (objArr.length >= 2) {
                String filePath = getFilePath(objArr[1]);
                String y2 = objArr.length >= 3 ? t.y(objArr[2]) : null;
                if (objArr.length >= 4) {
                    str2 = t.y(objArr[3]);
                    str = y;
                    str3 = filePath;
                    str4 = y2;
                    f = null;
                } else {
                    str = y;
                    str3 = filePath;
                    str4 = y2;
                    str2 = null;
                    f = null;
                }
            } else {
                f = AbstractC0752g.f(this.context, getApp().Y(), "");
                str = y;
                str2 = null;
                str3 = null;
                str4 = null;
            }
            z = true;
        }
        if (!URLUtil.isValidUrl(str)) {
            return -1;
        }
        int nextInt = z ? new Random().nextInt() : 0;
        new W9.d(this.context, str2, str, str3, f, str4, false, z, nextInt).i();
        return nextInt;
    }

    @ScriptAllowed
    @Deprecated
    public int asynchronousDownload(Object... objArr) {
        return asyncDownload(objArr);
    }

    @Override
    public Object call(org.mozilla.javascript.Context context, Scriptable scriptable, Scriptable scriptable2, Object[] objArr) {
        return new XOneFileManager(this.context, this.appData);
    }

    @ScriptAllowed
    public Object clearCache(Object... objArr) {
        Utils.j("ClearCache", objArr);
        Utils.g("ClearCache", objArr, 1);
        C0932x0 c0932x0 = (C0932x0) objArr[0];
        long t = Q8.k.t(c0932x0, "maxSize", -1L);
        Date j = Q8.k.j(c0932x0, "olderThan", null);
        if (t < 0 && j == null) {
            throw new IllegalArgumentException("Must specify maxSize or olderThan parameters");
        }
        File cacheDir = this.context.getCacheDir();
        if (t == 0) {
            deleteDirectory(cacheDir);
            return null;
        }
        if (t > 0 && getDirectorySize(cacheDir) > t) {
            deleteDirectory(cacheDir);
            return null;
        }
        if (j != null) {
            long time = j.getTime();
            for (File file : listFilesRecursive(cacheDir)) {
                if (file.lastModified() < time) {
                    Utils.l0(file);
                }
            }
        }
        return null;
    }

    @ScriptAllowed
    public int copy(Object... objArr) {
        Utils.j("Copy", objArr);
        Utils.g("Copy", objArr, 2);
        String filePath = getFilePath(objArr[0]);
        String filePath2 = getFilePath(objArr[1]);
        if (TextUtils.isEmpty(filePath) || TextUtils.isEmpty(filePath2)) {
            return -1;
        }
        File file = new File(filePath);
        File file2 = new File(filePath2);
        if (!file.exists()) {
            DebugLog("Copy(): File " + file.getAbsolutePath() + " does not exist");
            return -1;
        }
        if (!TextUtils.equals(filePath2, "gestion.db")) {
            Utils.Z(file, file2);
            return 0;
        }
        IXoneApp appData = getAppData();
        File file3 = new File(appData.getAppPath(), appData.getDataBasePath());
        SqliteConnection b = d2.a.b(this.context, file3);
        if (b != null) {
            b.getDatabase().close();
        }
        Utils.Z(file, file2);
        d2.a.b(this.context, file3);
        return 0;
    }

    @ScriptAllowed
    public int createDirectory(Object... objArr) {
        Utils.j("CreateDirectory", objArr);
        Utils.g("CreateDirectory", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file = new File(filePath);
        if (file.exists() && file.isDirectory()) {
            return 1;
        }
        if (file.exists() && file.isFile()) {
            return 2;
        }
        if (filePath.contains("Android/data/" + this.context.getPackageName() + "/files")) {
            this.context.getFilesDir();
            this.context.getExternalFilesDirs(null);
        }
        return file.mkdirs() ? 0 : -1;
    }

    @ScriptAllowed
    public int delete(Object... objArr) {
        Utils.j("Delete", objArr);
        Utils.g("Delete", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file = new File(filePath);
        if (file.exists()) {
            return file.delete() ? 0 : -1;
        }
        DebugLog("Delete(): File " + file.getAbsolutePath() + " does not exist");
        return -1;
    }

    @ScriptAllowed
    public int deleteDatabase(Object... objArr) {
        SqliteConnection b;
        Utils.j("DeleteDatabase", objArr);
        Utils.g("DeleteDatabase", objArr, 1);
        String y = t.y(objArr[0]);
        IXoneApp appData = getAppData();
        String applicationName = appData.getApplicationName();
        String appPath = appData.getAppPath();
        String E0 = Utils.E0(applicationName, appPath, y, false, 4);
        if (TextUtils.isEmpty(E0)) {
            return -1;
        }
        File file = new File(E0);
        if (!file.exists()) {
            DebugLog("DeleteDatabase(): File " + file.getAbsolutePath() + " does not exist");
            return -1;
        }
        if (d2.a.e(file) && (b = d2.a.b(this.context, file)) != null) {
            b.getDatabase().close();
        }
        if (!file.delete()) {
            return -1;
        }
        String E02 = Utils.E0(applicationName, appPath, y + "-wal", false, 4);
        String E03 = Utils.E0(applicationName, appPath, y + "-shm", false, 4);
        if (!TextUtils.isEmpty(E02)) {
            File file2 = new File(E02);
            if (file2.exists() && !file2.delete()) {
                DebugLog("DeleteDatabase(): Cannot delete file " + file2.getAbsolutePath());
                return -1;
            }
        }
        if (!TextUtils.isEmpty(E03)) {
            File file3 = new File(E03);
            if (file3.exists() && !file3.delete()) {
                DebugLog("DeleteDatabase(): Cannot delete file " + file3.getAbsolutePath());
                return -1;
            }
        }
        return 0;
    }

    @ScriptAllowed
    public int deleteDirectory(Object... objArr) {
        Utils.j("DeleteDirectory", objArr);
        Utils.g("DeleteDirectory", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file = new File(filePath);
        return (file.exists() && file.isDirectory() && deleteDirectory(file)) ? 0 : -1;
    }

    @ScriptAllowed
    public int directoryExists(Object... objArr) {
        Utils.j("DirectoryExists", objArr);
        Utils.g("DirectoryExists", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file = new File(filePath);
        return (file.exists() && file.isDirectory()) ? 0 : -1;
    }

    @ScriptAllowed
    public Object download(Object... objArr) {
        Object obj;
        boolean z;
        JSONObject jSONObject;
        Utils.j("Download", objArr);
        Utils.h("Download", objArr, 1, 4);
        if (objArr.length != 1) {
            String y = t.y(objArr[0]);
            String filePath = getFilePath(objArr[1]);
            String A = t.A(objArr, 2, "");
            Object w = Utils.w(objArr, 3, null);
            if (TextUtils.isEmpty(y)) {
                throw new IllegalArgumentException("Download(): Empty URL parameter");
            }
            if (!TextUtils.isEmpty(filePath)) {
                return Integer.valueOf(downloadFileSync(y, filePath, A, w) ? 0 : -1);
            }
            throw new IllegalArgumentException("Download(): Empty destination file parameter");
        }
        Object obj2 = objArr[0];
        if (!(obj2 instanceof C0932x0)) {
            throw new IllegalArgumentException("Download(): Invalid argument type");
        }
        C0932x0 c0932x0 = (C0932x0) obj2;
        String E = Q8.k.E(c0932x0, "source", "");
        String filePath2 = getFilePath(Q8.k.E(c0932x0, "target", ""));
        String E2 = Q8.k.E(c0932x0, "mimeType", "");
        Object z2 = Q8.k.z(c0932x0, "onSuccess", null);
        Object z3 = Q8.k.z(c0932x0, "onProgress", null);
        Object z4 = Q8.k.z(c0932x0, "onError", null);
        boolean a = Q8.k.a(c0932x0, "unzip", false);
        C0932x0 w2 = Q8.k.w(c0932x0, "headers", null);
        JSONObject n0 = w2 != null ? Q8.k.n0(w2, false) : null;
        boolean a2 = Q8.k.a(c0932x0, "resumeEnabled", false);
        boolean a3 = Q8.k.a(c0932x0, "allowUnsafeCertificates", false);
        C0932x0 w3 = Q8.k.w(c0932x0, "parameters", null);
        if (w3 != null) {
            obj = z3;
            z = a;
            jSONObject = Q8.k.n0(w3, false);
        } else {
            obj = z3;
            z = a;
            jSONObject = null;
        }
        if (TextUtils.isEmpty(E)) {
            throw new IllegalArgumentException("Download(): Empty URL parameter");
        }
        if (!TextUtils.isEmpty(filePath2)) {
            return new FutureScriptWrapper(downloadFileAsync(E, filePath2, E2, a2, a3, z2, obj, z4, z, n0, jSONObject));
        }
        throw new IllegalArgumentException("Download(): Empty destination file parameter");
    }

    @ScriptAllowed
    public int downloadDatabase(Object... objArr) {
        Utils.j("DownloadDatabase", objArr);
        Utils.g("DownloadDatabase", objArr, 1);
        String y = t.y(objArr[0]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("DownloadDatabase(): Empty URL argument");
        }
        Uri parse = Uri.parse(y);
        String lastPathSegment = parse.getLastPathSegment();
        if (TextUtils.isEmpty(lastPathSegment)) {
            throw new IllegalArgumentException("DownloadDatabase(): Cannot obtain database file name");
        }
        if (!lastPathSegment.endsWith(".db")) {
            throw new IllegalArgumentException("DownloadDatabase(): Path " + lastPathSegment + " is not a database file");
        }
        IXoneApp appData = getAppData();
        String E0 = Utils.E0(appData.getApplicationName(), appData.getAppPath(), lastPathSegment, false, 4);
        if (TextUtils.isEmpty(E0)) {
            throw new IllegalArgumentException("DownloadDatabase(): Cannot obtain full path to database file");
        }
        File file = new File(E0);
        File file2 = new File(file.getAbsolutePath() + "_temp");
        try {
            Utils.s0(parse, file2);
            closeAndDeleteDatabase(file);
            if (file2.renameTo(file)) {
                return 0;
            }
            DebugLog("DownloadDatabase(): Cannot rename database");
            return -1;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    @ScriptAllowed
    public int downloadIfUpdated(Object... objArr) {
        Utils.j("DownloadIfUpdated", objArr);
        Utils.h("DownloadIfUpdated", objArr, 2, 4);
        return downloadFileSyncIfUpdatedAsync(t.y(objArr[0]), getFilePath(objArr[1]), objArr.length >= 4 ? objArr[3] : null);
    }

    @ScriptAllowed
    public int fileExists(Object... objArr) {
        Utils.j("FileExists", objArr);
        Utils.g("FileExists", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file = new File(filePath);
        return (file.exists() && file.isFile()) ? 0 : -1;
    }

    @ScriptAllowed
    public String getCacheDirectory(Object... objArr) {
        return this.context.getCacheDir().getAbsolutePath();
    }

    @ScriptAllowed
    public String getChecksum(Object... objArr) {
        Utils.j("GetChecksum", objArr);
        Utils.h("GetChecksum", objArr, 1, 3);
        String filePath = getFilePath(objArr[0]);
        String y = objArr.length >= 2 ? t.y(objArr[1]) : "crc32";
        boolean l = objArr.length >= 3 ? t.l(t.y(objArr[2]), false) : false;
        if (TextUtils.isEmpty(filePath)) {
            throw new IllegalArgumentException("sSource == null");
        }
        File file = new File(filePath);
        if (!file.exists()) {
            throw AbstractC0751f.b("File " + file.getAbsolutePath() + " does not exist");
        }
        if (!file.isDirectory()) {
            return Utils.s1(file, y, l);
        }
        throw AbstractC0751f.c("File " + file.getAbsolutePath() + " is a directory");
    }

    @ScriptAllowed
    public String getCodeCacheDirectory(Object... objArr) {
        return this.context.getCodeCacheDir().getAbsolutePath();
    }

    @Override
    public String getDefaultMethod() {
        return null;
    }

    @ScriptAllowed
    public C0932x0 getFileInfo(Object... objArr) {
        long j;
        Path path;
        BasicFileAttributes readAttributes;
        FileTime creationTime;
        Utils.g("GetFileInfo", objArr, 1);
        String z = t.z(objArr[0], null);
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("GetFileInfo(): Empty path argument");
        }
        InterfaceC1038m0 app = getApp();
        File x1 = Utils.x1(app.Y(), app.T(), z, false);
        if (!x1.exists()) {
            throw AbstractC0751f.b("GetFileInfo(): File " + x1.getAbsolutePath() + " does not exist");
        }
        long length = x1.length();
        try {
            if (Build.VERSION.SDK_INT >= 26) {
                path = Paths.get(x1.getAbsolutePath(), new String[0]);
                readAttributes = Files.readAttributes(path, (Class<BasicFileAttributes>) G1.a(), new LinkOption[0]);
                creationTime = readAttributes.creationTime();
                j = creationTime.toMillis();
            } else {
                j = 0;
            }
            long lastModified = x1.lastModified();
            boolean isHidden = x1.isHidden();
            boolean canRead = x1.canRead();
            boolean canExecute = x1.canExecute();
            boolean canWrite = x1.canWrite();
            C0932x0 c0932x0 = new C0932x0();
            Q8.k.Q(c0932x0, "size", length);
            Q8.k.M(c0932x0, "creationDate", j);
            Q8.k.M(c0932x0, "modificationDate", lastModified);
            Q8.k.L(c0932x0, "isHidden", isHidden);
            Q8.k.L(c0932x0, "canRead", canRead);
            Q8.k.L(c0932x0, "canExecute", canExecute);
            Q8.k.L(c0932x0, "canWrite", canWrite);
            return c0932x0;
        } catch (IOException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    public C0907k0 getLastModifiedDate(Object... objArr) {
        return (C0907k0) Q8.m.C(doGetLastModifiedDateInternal(objArr));
    }

    @Override
    public String getName() {
        return "FileManager";
    }

    @ScriptAllowed
    public String getRootDirectory(Object... objArr) {
        return (Build.VERSION.SDK_INT >= 24 ? this.context.getDataDir() : new File(this.context.getApplicationInfo().dataDir)).getAbsolutePath();
    }

    @Override
    public ua.V getScope() {
        return null;
    }

    @ScriptAllowed
    public long getSize(Object... objArr) {
        Utils.j("GetSize", objArr);
        Utils.g("GetSize", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (filePath != null) {
            File file = new File(filePath);
            return file.isDirectory() ? getDirectorySize(file) : file.length();
        }
        throw new IllegalArgumentException("GetSize(): Error, file path is empty");
    }

    @ScriptAllowed
    public boolean isDirectoryEmpty(Object... objArr) {
        Path path;
        boolean isDirectory;
        Stream convert;
        Utils.j("IsDirectoryEmpty", objArr);
        Utils.g("IsDirectoryEmpty", objArr, 1);
        String y = t.y(objArr[0]);
        if (Build.VERSION.SDK_INT < 26) {
            File[] listFiles = new File(y).listFiles();
            return listFiles == null || listFiles.length == 0;
        }
        path = Paths.get(y, new String[0]);
        isDirectory = Files.isDirectory(path, new LinkOption[0]);
        if (!isDirectory) {
            return false;
        }
        try {
            convert = Stream.VivifiedWrapper.convert(Files.list(path));
            try {
                boolean z = !convert.findFirst().isPresent();
                convert.close();
                return z;
            } finally {
            }
        } catch (IOException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    public C0893d0 listDirectories(Object... objArr) {
        List<File> internalListDirectories = internalListDirectories(objArr);
        if (internalListDirectories == null) {
            return null;
        }
        int size = internalListDirectories.size();
        String[] strArr = new String[size];
        for (int i = 0; i < size; i++) {
            strArr[i] = internalListDirectories.get(i).getAbsolutePath();
        }
        return new C0893d0(strArr);
    }

    @ScriptAllowed
    public C0893d0 listFiles(Object... objArr) {
        List<Q9.a> internalListFiles = internalListFiles(objArr);
        if (internalListFiles == null) {
            return null;
        }
        int size = internalListFiles.size();
        String[] strArr = new String[size];
        for (int i = 0; i < size; i++) {
            strArr[i] = internalListFiles.get(i).a().getAbsolutePath();
        }
        return new C0893d0(strArr);
    }

    @ScriptAllowed
    public int move(Object... objArr) {
        Utils.j("Move", objArr);
        Utils.g("Move", objArr, 2);
        String filePath = getFilePath(objArr[0]);
        String filePath2 = getFilePath(objArr[1]);
        if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(filePath2)) {
            File file = new File(filePath);
            File file2 = new File(filePath2);
            if (!file.exists()) {
                DebugLog("Move(): Source file does not exist");
                return -1;
            }
            try {
                if (TextUtils.equals(filePath2, "gestion.db")) {
                    IXoneApp appData = getAppData();
                    File file3 = new File(appData.getAppPath(), appData.getDataBasePath());
                    SqliteConnection b = d2.a.b(this.context, file3);
                    if (b != null) {
                        b.getDatabase().close();
                    }
                    Utils.Z(file, file2);
                    d2.a.b(this.context, file3);
                } else {
                    Utils.Z(file, file2);
                }
                if (file.delete()) {
                    return 0;
                }
                DebugLog("Move(): Error deleting source file");
                return -1;
            } catch (Exception e) {
                e.printStackTrace();
                DebugLog("Move(): Error copying file to target path");
            }
        }
        return -1;
    }

    @ScriptAllowed
    public int openFile(Object... objArr) {
        URL url;
        Utils.j("OpenFile", objArr);
        Utils.g("OpenFile", objArr, 1);
        String y = t.y(objArr[0]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("OpenFile(): Empty path argument");
        }
        try {
            url = new URL(y);
        } catch (Exception unused) {
            url = null;
        }
        if (url != null && url.getProtocol().startsWith("http")) {
            File l0 = getApp().l0(Utils.U2("cache/" + url.getFile()));
            if (!l0.exists()) {
                try {
                    Utils.u0(url, l0.getAbsolutePath());
                } catch (IOException | InterruptedException e) {
                    throw AbstractC0751f.e(e);
                }
            }
            y = l0.getAbsolutePath();
        }
        InterfaceC1038m0 app = getApp();
        File w1 = Utils.w1(app.Y(), app.T(), y);
        if (!w1.exists()) {
            throw AbstractC0751f.b("OpenFile(): File " + w1.getAbsolutePath() + " not found");
        }
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addFlags(268435456);
        intent.addFlags(1);
        String mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(Utils.u1(w1.getAbsolutePath()));
        TextUtils.equals(mimeTypeFromExtension, "application/vnd.android.package-archive");
        Context context = (Context) app;
        Uri B1 = Utils.B1(context, w1);
        if (TextUtils.isEmpty(mimeTypeFromExtension)) {
            intent.setData(B1);
        } else {
            intent.setDataAndType(B1, mimeTypeFromExtension);
        }
        try {
            app.startActivity(intent);
            return 0;
        } catch (ActivityNotFoundException e2) {
            if (!TextUtils.equals(mimeTypeFromExtension, "application/vnd.android.package-archive") || Build.VERSION.SDK_INT >= 24) {
                throw e2;
            }
            if (!e.q(context, "android.permission.WRITE_EXTERNAL_STORAGE")) {
                throw new SecurityException("OpenFile(): External storage permission is needed to install APKs on API levels < 24");
            }
            File file = new File(Environment.getExternalStorageDirectory(), "temp.apk");
            Utils.Z(w1, file);
            intent.setDataAndType(Uri.fromFile(file), mimeTypeFromExtension);
            app.startActivity(intent);
            return 0;
        }
    }

    @ScriptAllowed
    public String readFile(Object... objArr) {
        Utils.j("ReadFile", objArr);
        Utils.h("ReadFile", objArr, 1, 2);
        String filePath = getFilePath(objArr[0]);
        if (filePath == null) {
            throw new IllegalArgumentException("ReadFile(): Error, sFilePath == null");
        }
        String z = objArr.length > 1 ? t.z(objArr[1], "UTF-8") : "UTF-8";
        File file = new File(filePath);
        if (file.exists() && file.isFile()) {
            try {
                return Utils.z3(file, z).toString();
            } catch (IOException e) {
                throw AbstractC0751f.e(e);
            }
        }
        throw new IllegalArgumentException("ReadFile(): Error, file " + file.getAbsolutePath() + " doesn't exist");
    }

    @ScriptAllowed
    public XOneFileManager removeOnDirectoryChangedListener(Object... objArr) {
        Utils.j("RemoveOnDirectoryChangedListener", objArr);
        Utils.g("RemoveOnDirectoryChangedListener", objArr, 1);
        String y = t.y(objArr[0]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("RemoveOnDirectoryChangedListener(): Empty directory path");
        }
        d remove = mapOnDirectoryChangedListeners.remove(y);
        if (remove != null) {
            remove.stopWatching();
        }
        return this;
    }

    @ScriptAllowed
    public int rename(Object... objArr) {
        Utils.j("Rename", objArr);
        Utils.g("Rename", objArr, 2);
        String filePath = getFilePath(objArr[0]);
        String filePath2 = getFilePath(objArr[1]);
        if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(filePath2)) {
            File file = new File(filePath);
            File file2 = new File(filePath2);
            if (!file.exists()) {
                DebugLog("Rename(): File does not exist");
                return -1;
            }
            if (file.renameTo(file2)) {
                return 0;
            }
        }
        return -1;
    }

    @ScriptAllowed
    public boolean saveFile(Object... objArr) {
        Utils.j("SaveFile", objArr);
        Utils.h("SaveFile", objArr, 2, 4);
        String filePath = getFilePath(objArr[0]);
        Object b = Q8.m.b(objArr[1]);
        boolean f = objArr.length > 2 ? q.f(objArr[2], false) : false;
        if (filePath == null) {
            throw new IllegalArgumentException("SaveFile(): Error, sFilePath == null");
        }
        String z = objArr.length > 3 ? t.z(objArr[3], "UTF-8") : "UTF-8";
        File file = new File(filePath);
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            throw AbstractC0751f.c("SaveFile(): Cannot create parent directory " + parentFile.getAbsolutePath());
        }
        try {
            if (b instanceof byte[]) {
                Utils.S3(file, f, (byte[]) b);
            } else {
                Utils.T3(file, f, z, b.toString());
            }
            return true;
        } catch (IOException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    public String toBase64(Object... objArr) {
        FileInputStream fileInputStream;
        Utils.j("ToBase64", objArr);
        Utils.g("ToBase64", objArr, 1);
        String filePath = getFilePath(objArr[0]);
        if (filePath == null) {
            throw new IllegalArgumentException("ToBase64(): Error, sFilePath == null");
        }
        File file = new File(filePath);
        int length = (int) file.length();
        byte[] bArr = new byte[length];
        FileInputStream fileInputStream2 = null;
        try {
            try {
                fileInputStream = new FileInputStream(file);
            } catch (IOException e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            fileInputStream.read(bArr, 0, length);
            int read = fileInputStream.read();
            if (read == -1) {
                String encodeToString = Base64.encodeToString(bArr, 2);
                Utils.N(fileInputStream);
                return encodeToString;
            }
            throw AbstractC0751f.c("ToBase64(): nResult == " + read);
        } catch (IOException e2) {
            e = e2;
            fileInputStream2 = fileInputStream;
            throw AbstractC0751f.e(e);
        } catch (Throwable th2) {
            th = th2;
            fileInputStream2 = fileInputStream;
            Utils.N(fileInputStream2);
            throw th;
        }
    }

    @ScriptAllowed
    public int toFile(Object... objArr) {
        Throwable th;
        IOException e;
        ?? r0 = "ToFile";
        Utils.j("ToFile", objArr);
        Utils.g("ToFile", objArr, 2);
        String y = t.y(objArr[0]);
        String filePath = getFilePath(objArr[1]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("ToFile(): Error, empty base64 string argument");
        }
        if (filePath == null) {
            throw new IllegalArgumentException("ToFile(): Error, sDestinationPath == null");
        }
        byte[] decode = Base64.decode(y, 0);
        File file = new File(filePath);
        if (file.exists() && !file.delete()) {
            throw AbstractC0751f.c("ToFile(): Error, cannot delete previous file " + file.getAbsolutePath());
        }
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            throw AbstractC0751f.c("ToFile(): Cannot create parent folder " + parentFile.getAbsolutePath());
        }
        try {
            try {
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                try {
                    fileOutputStream.write(decode, 0, decode.length);
                    Utils.N(fileOutputStream);
                    return 0;
                } catch (IOException e2) {
                    e = e2;
                    throw AbstractC0751f.e(e);
                }
            } catch (Throwable th2) {
                th = th2;
                Utils.N(r0);
                throw th;
            }
        } catch (IOException e3) {
            e = e3;
        } catch (Throwable th3) {
            r0 = 0;
            th = th3;
            Utils.N(r0);
            throw th;
        }
    }

    @ScriptAllowed
    public String toString() {
        return "XOneFileManager script runtime object";
    }

    @ScriptAllowed
    public int unzip(Object... objArr) {
        Utils.j("Unzip", objArr);
        Utils.h("Unzip", objArr, 1, 2);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            throw new NullPointerException("Unzip(): Empty source path");
        }
        File file = objArr.length > 1 ? new File(getFilePath(objArr[1])) : null;
        File file2 = new File(filePath);
        if (file2.exists() && file2.isFile()) {
            try {
                if (file != null) {
                    Utils.C4(file2, file);
                } else {
                    Utils.B4(file2);
                }
                return 0;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return -1;
    }

    @ScriptAllowed
    public Object uploadFile(Object... objArr) {
        Utils.j("UploadFile", objArr);
        Utils.h("UploadFile", objArr, 1, 4);
        Object obj = objArr[0];
        return obj instanceof C0932x0 ? doUploadFileInternalJavascript("UploadFile", (C0932x0) obj) : doUploadFileInternalVbscript("UploadFile", objArr);
    }

    @ScriptAllowed
    public int zip(Object... objArr) {
        File file;
        Utils.j("Zip", objArr);
        Utils.h("Zip", objArr, 1, 2);
        String filePath = getFilePath(objArr[0]);
        if (TextUtils.isEmpty(filePath)) {
            return -1;
        }
        File file2 = new File(filePath);
        if (objArr.length > 1) {
            file = new File(getFilePath(objArr[1]));
        } else {
            file = new File(filePath + ".zip");
        }
        if (!file2.exists()) {
            return -1;
        }
        if (!file2.isFile()) {
            if (file2.isDirectory()) {
                return Utils.D4(file2, file);
            }
            return -1;
        }
        try {
            ArrayList arrayList = new ArrayList();
            arrayList.add(file2);
            Utils.E4(file, arrayList);
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    @ScriptAllowed
    public int zipAll(Object... objArr) {
        Utils.j("ZipAll", objArr);
        Utils.h("ZipAll", objArr, 1, -1);
        String filePath = getFilePath(objArr[0]);
        try {
            if (TextUtils.isEmpty(filePath)) {
                throw new IllegalArgumentException("ZipAll(): Empty target zip file");
            }
            File file = new File(filePath);
            ArrayList arrayList = new ArrayList();
            for (int i = 1; i < objArr.length; i++) {
                Object obj = objArr[i];
                if (obj instanceof C0893d0) {
                    for (String str : (String[]) Q8.m.h((C0893d0) obj, String[].class)) {
                        addFileForZip(arrayList, str);
                    }
                } else {
                    addFileForZip(arrayList, t.z(obj, null));
                }
            }
            Utils.E4(file, arrayList);
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    private String getFilePath(String str) {
        InterfaceC1038m0 app = getApp();
        return Utils.i2(app.Y(), app.T(), str);
    }

    private static void listFilesRecursive(List<File> list, File file) {
        File[] listFiles = file.listFiles();
        if (listFiles == null) {
            return;
        }
        for (File file2 : listFiles) {
            if (file2.isDirectory()) {
                listFilesRecursive(list, file2);
            } else if (file2.isFile()) {
                list.add(file2);
            }
        }
    }

    private static boolean deleteDirectory(File file) {
        String[] list;
        if (file == null) {
            return false;
        }
        if (file.exists() && file.isDirectory() && (list = file.list()) != null) {
            for (String str : list) {
                if (!deleteDirectory(new File(file, str))) {
                    return false;
                }
            }
        }
        return file.delete();
    }
}