导航菜单

页面标题

页面副标题

CityMall v1.42.1 - d.java 源代码

正在查看: CityMall v1.42.1 应用的 d.java JAVA 源代码文件

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


package com.RNFetchBlob;

import android.content.res.AssetFileDescriptor;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.StatFs;
import android.os.SystemClock;
import android.util.Base64;
import com.adster.sdk.mediation.analytics.db.AnalyticsDatabaseContract;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import h0.AbstractC1082a;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;

class d {

    private static HashMap f9932e = new HashMap();

    private ReactApplicationContext f9933a;

    private DeviceEventManagerModule.RCTDeviceEventEmitter f9934b;

    private String f9935c = "base64";

    private OutputStream f9936d = null;

    class a extends AsyncTask {

        final Callback f9937a;

        a(Callback callback) {
            this.f9937a = callback;
        }

        @Override
        public Integer doInBackground(String... strArr) {
            WritableArray createArray = Arguments.createArray();
            if (strArr[0] == null) {
                this.f9937a.invoke("the path specified for lstat is either `null` or `undefined`.");
                return 0;
            }
            File file = new File(strArr[0]);
            if (!file.exists()) {
                this.f9937a.invoke("failed to lstat path `" + strArr[0] + "` because it does not exist or it is not a folder");
                return 0;
            }
            if (file.isDirectory()) {
                for (String str : file.list()) {
                    createArray.pushMap(d.D(file.getPath() + "/" + str));
                }
            } else {
                createArray.pushMap(d.D(file.getAbsolutePath()));
            }
            this.f9937a.invoke(null, createArray);
            return 0;
        }
    }

    class b implements MediaScannerConnection.OnScanCompletedListener {

        final Callback f9938a;

        b(Callback callback) {
            this.f9938a = callback;
        }

        @Override
        public void onScanCompleted(String str, Uri uri) {
            this.f9938a.invoke(null, Boolean.TRUE);
        }
    }

    class c extends AsyncTask {

        final Callback f9940a;

        c(Callback callback) {
            this.f9940a = callback;
        }

        @Override
        public Integer doInBackground(ReadableArray... readableArrayArr) {
            try {
                ArrayList arrayList = new ArrayList();
                for (int i5 = 0; i5 < readableArrayArr[0].size(); i5++) {
                    String string = readableArrayArr[0].getString(i5);
                    File file = new File(string);
                    if (file.exists() && !file.delete()) {
                        arrayList.add(string);
                    }
                }
                if (arrayList.isEmpty()) {
                    this.f9940a.invoke(null, Boolean.TRUE);
                } else {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Failed to delete: ");
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        sb.append((String) it.next());
                        sb.append(", ");
                    }
                    this.f9940a.invoke(sb.toString());
                }
            } catch (Exception e5) {
                this.f9940a.invoke(e5.getLocalizedMessage());
            }
            return Integer.valueOf(readableArrayArr[0].size());
        }
    }

    d(ReactApplicationContext reactApplicationContext) {
        this.f9933a = reactApplicationContext;
        this.f9934b = (DeviceEventManagerModule.RCTDeviceEventEmitter) reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
    }

    static void B(String str, String str2, int i5, int i6, String str3, Promise promise) {
        try {
            String w4 = w(str);
            File file = new File(w4);
            if (file.isDirectory()) {
                promise.reject("EISDIR", "Expecting a file but '" + w4 + "' is a directory");
                return;
            }
            if (!file.exists()) {
                promise.reject("ENOENT", "No such file '" + w4 + "'");
                return;
            }
            int length = (int) file.length();
            int min = Math.min(length, i6) - i5;
            FileInputStream fileInputStream = new FileInputStream(new File(w4));
            FileOutputStream fileOutputStream = new FileOutputStream(new File(str2));
            int skip = (int) fileInputStream.skip(i5);
            if (skip != i5) {
                promise.reject("EUNSPECIFIED", "Skipped " + skip + " instead of the specified " + i5 + " bytes, size is " + length);
                return;
            }
            byte[] bArr = new byte[10240];
            int i7 = 0;
            while (i7 < min) {
                int read = fileInputStream.read(bArr, 0, 10240);
                int i8 = min - i7;
                if (read <= 0) {
                    break;
                }
                fileOutputStream.write(bArr, 0, Math.min(i8, read));
                i7 += read;
            }
            fileInputStream.close();
            fileOutputStream.flush();
            fileOutputStream.close();
            promise.resolve(str2);
        } catch (Exception e5) {
            e5.printStackTrace();
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void C(String str, Callback callback) {
        try {
            String w4 = w(str);
            WritableMap D4 = D(w4);
            if (D4 == null) {
                callback.invoke("failed to stat path `" + w4 + "` because it does not exist or it is not a folder", null);
            } else {
                callback.invoke(null, D4);
            }
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage());
        }
    }

    static WritableMap D(String str) {
        try {
            String w4 = w(str);
            WritableMap createMap = Arguments.createMap();
            if (q(w4)) {
                String replace = w4.replace("bundle-assets://", "");
                AssetFileDescriptor openFd = RNFetchBlob.RCTContext.getAssets().openFd(replace);
                createMap.putString("filename", replace);
                createMap.putString("path", w4);
                createMap.putString("type", "asset");
                createMap.putString("size", String.valueOf(openFd.getLength()));
                createMap.putInt("lastModified", 0);
            } else {
                File file = new File(w4);
                if (!file.exists()) {
                    return null;
                }
                createMap.putString("filename", file.getName());
                createMap.putString("path", file.getPath());
                createMap.putString("type", file.isDirectory() ? "directory" : "file");
                createMap.putString("size", String.valueOf(file.length()));
                createMap.putString("lastModified", String.valueOf(file.lastModified()));
            }
            return createMap;
        } catch (Exception unused) {
            return null;
        }
    }

    private static byte[] E(String str, String str2) {
        return str2.equalsIgnoreCase("ascii") ? str.getBytes(Charset.forName("US-ASCII")) : str2.toLowerCase().contains("base64") ? Base64.decode(str, 2) : str2.equalsIgnoreCase("utf8") ? str.getBytes(Charset.forName("UTF-8")) : str.getBytes(Charset.forName("US-ASCII"));
    }

    static void F(String str, Callback callback) {
        try {
            e(new File(w(str)));
            callback.invoke(null, Boolean.TRUE);
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage(), Boolean.FALSE);
        }
    }

    static void G(String str, ReadableArray readableArray, Callback callback) {
        try {
            OutputStream outputStream = ((d) f9932e.get(str)).f9936d;
            byte[] bArr = new byte[readableArray.size()];
            for (int i5 = 0; i5 < readableArray.size(); i5++) {
                bArr[i5] = (byte) readableArray.getInt(i5);
            }
            outputStream.write(bArr);
            callback.invoke(new Object[0]);
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage());
        }
    }

    static void H(String str, String str2, Callback callback) {
        d dVar = (d) f9932e.get(str);
        try {
            dVar.f9936d.write(E(str2, dVar.f9935c));
            callback.invoke(new Object[0]);
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage());
        }
    }

    static void I(String str, ReadableArray readableArray, boolean z4, Promise promise) {
        try {
            File file = new File(str);
            File parentFile = file.getParentFile();
            if (!file.exists()) {
                if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
                    promise.reject("ENOTDIR", "Failed to create parent directory of '" + str + "'");
                    return;
                }
                if (!file.createNewFile()) {
                    promise.reject("ENOENT", "File '" + str + "' does not exist and could not be created");
                    return;
                }
            }
            FileOutputStream fileOutputStream = new FileOutputStream(file, z4);
            try {
                byte[] bArr = new byte[readableArray.size()];
                for (int i5 = 0; i5 < readableArray.size(); i5++) {
                    bArr[i5] = (byte) readableArray.getInt(i5);
                }
                fileOutputStream.write(bArr);
                fileOutputStream.close();
                promise.resolve(Integer.valueOf(readableArray.size()));
            } catch (Throwable th) {
                fileOutputStream.close();
                throw th;
            }
        } catch (FileNotFoundException unused) {
            promise.reject("ENOENT", "File '" + str + "' does not exist and could not be created");
        } catch (Exception e5) {
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void J(String str, String str2, String str3, boolean z4, Promise promise) {
        int length;
        FileOutputStream fileOutputStream;
        try {
            File file = new File(str);
            File parentFile = file.getParentFile();
            if (!file.exists()) {
                if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
                    promise.reject("EUNSPECIFIED", "Failed to create parent directory of '" + str + "'");
                    return;
                }
                if (!file.createNewFile()) {
                    promise.reject("ENOENT", "File '" + str + "' does not exist and could not be created");
                    return;
                }
            }
            if (str2.equalsIgnoreCase("uri")) {
                String w4 = w(str3);
                File file2 = new File(w4);
                if (!file2.exists()) {
                    promise.reject("ENOENT", "No such file '" + str + "' ('" + w4 + "')");
                    return;
                }
                byte[] bArr = new byte[10240];
                FileInputStream fileInputStream = null;
                try {
                    FileInputStream fileInputStream2 = new FileInputStream(file2);
                    try {
                        fileOutputStream = new FileOutputStream(file, z4);
                        length = 0;
                        while (true) {
                            try {
                                int read = fileInputStream2.read(bArr);
                                if (read <= 0) {
                                    break;
                                }
                                fileOutputStream.write(bArr, 0, read);
                                length += read;
                            } catch (Throwable th) {
                                th = th;
                                fileInputStream = fileInputStream2;
                                if (fileInputStream != null) {
                                    fileInputStream.close();
                                }
                                if (fileOutputStream != null) {
                                    fileOutputStream.close();
                                }
                                throw th;
                            }
                        }
                        fileInputStream2.close();
                        fileOutputStream.close();
                    } catch (Throwable th2) {
                        th = th2;
                        fileOutputStream = null;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    fileOutputStream = null;
                }
            } else {
                byte[] E4 = E(str3, str2);
                FileOutputStream fileOutputStream2 = new FileOutputStream(file, z4);
                try {
                    fileOutputStream2.write(E4);
                    length = E4.length;
                } finally {
                    fileOutputStream2.close();
                }
            }
            promise.resolve(Integer.valueOf(length));
        } catch (FileNotFoundException unused) {
            promise.reject("ENOENT", "File '" + str + "' does not exist and could not be created, or it is a directory");
        } catch (Exception e5) {
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void a(String str, Callback callback) {
        try {
            OutputStream outputStream = ((d) f9932e.get(str)).f9936d;
            f9932e.remove(str);
            outputStream.close();
            callback.invoke(new Object[0]);
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage());
        }
    }

    static void b(java.lang.String r4, java.lang.String r5, com.facebook.react.bridge.Callback r6) {
        throw new UnsupportedOperationException("Method not decompiled: com.RNFetchBlob.d.b(java.lang.String, java.lang.String, com.facebook.react.bridge.Callback):void");
    }

    static void c(String str, String str2, String str3, Promise promise) {
        try {
            File file = new File(str);
            boolean createNewFile = file.createNewFile();
            if (str3.equals("uri")) {
                File file2 = new File(str2.replace("RNFetchBlob-file://", ""));
                if (!file2.exists()) {
                    promise.reject("ENOENT", "Source file : " + str2 + " does not exist");
                    return;
                }
                FileInputStream fileInputStream = new FileInputStream(file2);
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                byte[] bArr = new byte[10240];
                for (int read = fileInputStream.read(bArr); read > 0; read = fileInputStream.read(bArr)) {
                    fileOutputStream.write(bArr, 0, read);
                }
                fileInputStream.close();
                fileOutputStream.close();
            } else {
                if (!createNewFile) {
                    promise.reject("EEXIST", "File `" + str + "` already exists");
                    return;
                }
                new FileOutputStream(file).write(E(str2, str3));
            }
            promise.resolve(str);
        } catch (Exception e5) {
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void d(String str, ReadableArray readableArray, Promise promise) {
        try {
            File file = new File(str);
            if (!file.createNewFile()) {
                promise.reject("EEXIST", "File at path `" + str + "` already exists");
                return;
            }
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            byte[] bArr = new byte[readableArray.size()];
            for (int i5 = 0; i5 < readableArray.size(); i5++) {
                bArr[i5] = (byte) readableArray.getInt(i5);
            }
            fileOutputStream.write(bArr);
            promise.resolve(str);
        } catch (Exception e5) {
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    private static void e(File file) {
        if (file.isDirectory()) {
            File[] listFiles = file.listFiles();
            if (listFiles == null) {
                throw new NullPointerException("Received null trying to list files of directory '" + file + "'");
            }
            for (File file2 : listFiles) {
                e(file2);
            }
        }
        if (file.delete()) {
            return;
        }
        throw new IOException("Failed to delete '" + file + "'");
    }

    static void f(Callback callback) {
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        WritableMap createMap = Arguments.createMap();
        createMap.putString("internal_free", String.valueOf(statFs.getFreeBytes()));
        createMap.putString("internal_total", String.valueOf(statFs.getTotalBytes()));
        StatFs statFs2 = new StatFs(Environment.getExternalStorageDirectory().getPath());
        createMap.putString("external_free", String.valueOf(statFs2.getFreeBytes()));
        createMap.putString("external_total", String.valueOf(statFs2.getTotalBytes()));
        callback.invoke(null, createMap);
    }

    private void g(String str, String str2, WritableArray writableArray) {
        WritableMap createMap = Arguments.createMap();
        createMap.putString(AnalyticsDatabaseContract.PersistedEvent.COLUMN_EVENT, str2);
        createMap.putArray("detail", writableArray);
        this.f9934b.emit(str, createMap);
    }

    private void h(String str, String str2, String str3) {
        WritableMap createMap = Arguments.createMap();
        createMap.putString(AnalyticsDatabaseContract.PersistedEvent.COLUMN_EVENT, str2);
        createMap.putString("detail", str3);
        this.f9934b.emit(str, createMap);
    }

    private void i(String str, String str2, String str3, String str4) {
        WritableMap createMap = Arguments.createMap();
        createMap.putString(AnalyticsDatabaseContract.PersistedEvent.COLUMN_EVENT, str2);
        createMap.putString("code", str3);
        createMap.putString("detail", str4);
        this.f9934b.emit(str, createMap);
    }

    static void j(String str, Callback callback) {
        if (q(str)) {
            try {
                RNFetchBlob.RCTContext.getAssets().openFd(str.replace("bundle-assets://", ""));
                callback.invoke(Boolean.TRUE, Boolean.FALSE);
                return;
            } catch (IOException unused) {
                Boolean bool = Boolean.FALSE;
                callback.invoke(bool, bool);
                return;
            }
        }
        String w4 = w(str);
        if (w4 == null) {
            Boolean bool2 = Boolean.FALSE;
            callback.invoke(bool2, bool2);
        } else {
            callback.invoke(Boolean.valueOf(new File(w4).exists()), Boolean.valueOf(new File(w4).isDirectory()));
        }
    }

    public static void k(ReactApplicationContext reactApplicationContext, Promise promise) {
        if (!Environment.getExternalStorageState().equals("mounted")) {
            promise.reject("RNFetchBlob.getSDCardApplicationDir", "External storage not mounted");
            return;
        }
        try {
            promise.resolve(reactApplicationContext.getExternalFilesDir(null).getParentFile().getAbsolutePath());
        } catch (Exception e5) {
            promise.reject("RNFetchBlob.getSDCardApplicationDir", e5.getLocalizedMessage());
        }
    }

    public static void l(Promise promise) {
        if (Environment.getExternalStorageState().equals("mounted")) {
            promise.resolve(Environment.getExternalStorageDirectory().getAbsolutePath());
        } else {
            promise.reject("RNFetchBlob.getSDCardDir", "External storage not mounted");
        }
    }

    static Map m(ReactApplicationContext reactApplicationContext) {
        HashMap hashMap = new HashMap();
        hashMap.put("DocumentDir", reactApplicationContext.getFilesDir().getAbsolutePath());
        hashMap.put("CacheDir", reactApplicationContext.getCacheDir().getAbsolutePath());
        hashMap.put("DCIMDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath());
        hashMap.put("PictureDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
        hashMap.put("MusicDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath());
        hashMap.put("DownloadDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
        hashMap.put("MovieDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath());
        hashMap.put("RingtoneDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES).getAbsolutePath());
        if (Environment.getExternalStorageState().equals("mounted")) {
            hashMap.put("SDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath());
            File externalFilesDir = reactApplicationContext.getExternalFilesDir(null);
            if (externalFilesDir != null) {
                hashMap.put("SDCardApplicationDir", externalFilesDir.getParentFile().getAbsolutePath());
            } else {
                hashMap.put("SDCardApplicationDir", "");
            }
        }
        hashMap.put("MainBundleDir", reactApplicationContext.getApplicationInfo().dataDir);
        return hashMap;
    }

    static String n(String str) {
        return RNFetchBlob.RCTContext.getFilesDir() + "/RNFetchBlobTmp_" + str;
    }

    static void o(String str, String str2, Promise promise) {
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("md5", "MD5");
            hashMap.put("sha1", "SHA-1");
            hashMap.put("sha224", "SHA-224");
            hashMap.put("sha256", "SHA-256");
            hashMap.put("sha384", "SHA-384");
            hashMap.put("sha512", "SHA-512");
            if (!hashMap.containsKey(str2)) {
                promise.reject("EINVAL", "Invalid algorithm '" + str2 + "', must be one of md5, sha1, sha224, sha256, sha384, sha512");
                return;
            }
            File file = new File(str);
            if (file.isDirectory()) {
                promise.reject("EISDIR", "Expecting a file but '" + str + "' is a directory");
                return;
            }
            if (!file.exists()) {
                promise.reject("ENOENT", "No such file '" + str + "'");
                return;
            }
            MessageDigest messageDigest = MessageDigest.getInstance((String) hashMap.get(str2));
            FileInputStream fileInputStream = new FileInputStream(str);
            byte[] bArr = new byte[1048576];
            if (file.length() != 0) {
                while (true) {
                    int read = fileInputStream.read(bArr);
                    if (read == -1) {
                        break;
                    } else {
                        messageDigest.update(bArr, 0, read);
                    }
                }
            }
            StringBuilder sb = new StringBuilder();
            for (byte b5 : messageDigest.digest()) {
                sb.append(String.format("%02x", Byte.valueOf(b5)));
            }
            promise.resolve(sb.toString());
        } catch (Exception e5) {
            e5.printStackTrace();
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    private static InputStream p(String str) {
        return str.startsWith("bundle-assets://") ? RNFetchBlob.RCTContext.getAssets().open(str.replace("bundle-assets://", "")) : new FileInputStream(new File(str));
    }

    static boolean q(String str) {
        return str != null && str.startsWith("bundle-assets://");
    }

    private static boolean r(String str) {
        if (!str.startsWith("bundle-assets://")) {
            return new File(str).exists();
        }
        try {
            RNFetchBlob.RCTContext.getAssets().open(str.replace("bundle-assets://", ""));
            return true;
        } catch (IOException unused) {
            return false;
        }
    }

    static void s(String str, Promise promise) {
        try {
            String w4 = w(str);
            File file = new File(w4);
            if (!file.exists()) {
                promise.reject("ENOENT", "No such file '" + w4 + "'");
                return;
            }
            if (!file.isDirectory()) {
                promise.reject("ENOTDIR", "Not a directory '" + w4 + "'");
                return;
            }
            String[] list = new File(w4).list();
            WritableArray createArray = Arguments.createArray();
            for (String str2 : list) {
                createArray.pushString(str2);
            }
            promise.resolve(createArray);
        } catch (Exception e5) {
            e5.printStackTrace();
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void t(String str, Callback callback) {
        new a(callback).execute(w(str));
    }

    static void u(String str, Promise promise) {
        File file = new File(str);
        if (file.exists()) {
            StringBuilder sb = new StringBuilder();
            sb.append(file.isDirectory() ? "Folder" : "File");
            sb.append(" '");
            sb.append(str);
            sb.append("' already exists");
            promise.reject("EEXIST", sb.toString());
            return;
        }
        try {
            if (file.mkdirs()) {
                promise.resolve(Boolean.TRUE);
                return;
            }
            promise.reject("EUNSPECIFIED", "mkdir failed to create some or all directories in '" + str + "'");
        } catch (Exception e5) {
            promise.reject("EUNSPECIFIED", e5.getLocalizedMessage());
        }
    }

    static void v(String str, String str2, Callback callback) {
        File file = new File(str);
        if (!file.exists()) {
            callback.invoke("Source file at path `" + str + "` does not exist");
            return;
        }
        try {
            FileInputStream fileInputStream = new FileInputStream(str);
            FileOutputStream fileOutputStream = new FileOutputStream(str2);
            byte[] bArr = new byte[1024];
            while (true) {
                int read = fileInputStream.read(bArr);
                if (read == -1) {
                    fileInputStream.close();
                    fileOutputStream.flush();
                    file.delete();
                    callback.invoke(new Object[0]);
                    return;
                }
                fileOutputStream.write(bArr, 0, read);
            }
        } catch (FileNotFoundException unused) {
            callback.invoke("Source file not found.");
        } catch (Exception e5) {
            callback.invoke(e5.toString());
        }
    }

    static String w(String str) {
        if (str == null) {
            return null;
        }
        if (!str.matches("\\w+\\:.*")) {
            return str;
        }
        if (str.startsWith("file://")) {
            return str.replace("file://", "");
        }
        return str.startsWith("bundle-assets://") ? str : AbstractC1082a.c(RNFetchBlob.RCTContext, Uri.parse(str));
    }

    static void x(java.lang.String r7, java.lang.String r8, com.facebook.react.bridge.Promise r9) {
        throw new UnsupportedOperationException("Method not decompiled: com.RNFetchBlob.d.x(java.lang.String, java.lang.String, com.facebook.react.bridge.Promise):void");
    }

    static void z(ReadableArray readableArray, Callback callback) {
        new c(callback).execute(readableArray);
    }

    void A(String[] strArr, String[] strArr2, Callback callback) {
        try {
            MediaScannerConnection.scanFile(this.f9933a, strArr, strArr2, new b(callback));
        } catch (Exception e5) {
            callback.invoke(e5.getLocalizedMessage(), null);
        }
    }

    void K(String str, String str2, boolean z4, Callback callback) {
        try {
            File file = new File(str);
            File parentFile = file.getParentFile();
            if (file.exists()) {
                if (file.isDirectory()) {
                    callback.invoke("EISDIR", "Expecting a file but '" + str + "' is a directory");
                    return;
                }
            } else {
                if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
                    callback.invoke("ENOTDIR", "Failed to create parent directory of '" + str + "'");
                    return;
                }
                if (!file.createNewFile()) {
                    callback.invoke("ENOENT", "File '" + str + "' does not exist and could not be created");
                    return;
                }
            }
            FileOutputStream fileOutputStream = new FileOutputStream(str, z4);
            this.f9935c = str2;
            String uuid = UUID.randomUUID().toString();
            f9932e.put(uuid, this);
            this.f9936d = fileOutputStream;
            callback.invoke(null, null, uuid);
        } catch (Exception e5) {
            callback.invoke("EUNSPECIFIED", "Failed to create write stream at path `" + str + "`; " + e5.getLocalizedMessage());
        }
    }

    void y(String str, String str2, int i5, int i6, String str3) {
        String w4 = w(str);
        String str4 = w4 != null ? w4 : str;
        try {
            int i7 = str2.equalsIgnoreCase("base64") ? 4095 : 4096;
            if (i5 > 0) {
                i7 = i5;
            }
            InputStream openInputStream = (w4 == null || !str4.startsWith("bundle-assets://")) ? w4 == null ? RNFetchBlob.RCTContext.getContentResolver().openInputStream(Uri.parse(str4)) : new FileInputStream(new File(str4)) : RNFetchBlob.RCTContext.getAssets().open(str4.replace("bundle-assets://", ""));
            byte[] bArr = new byte[i7];
            int i8 = -1;
            String str5 = "data";
            int i9 = 0;
            if (str2.equalsIgnoreCase("utf8")) {
                CharsetEncoder newEncoder = Charset.forName("UTF-8").newEncoder();
                while (true) {
                    int read = openInputStream.read(bArr);
                    if (read == -1) {
                        break;
                    }
                    newEncoder.encode(ByteBuffer.wrap(bArr).asCharBuffer());
                    h(str3, "data", new String(bArr, i9, read));
                    if (i6 > 0) {
                        SystemClock.sleep(i6);
                    }
                    i9 = 0;
                }
            } else if (str2.equalsIgnoreCase("ascii")) {
                while (true) {
                    int read2 = openInputStream.read(bArr);
                    if (read2 == -1) {
                        break;
                    }
                    WritableArray createArray = Arguments.createArray();
                    for (int i10 = 0; i10 < read2; i10++) {
                        createArray.pushInt(bArr[i10]);
                    }
                    g(str3, "data", createArray);
                    if (i6 > 0) {
                        SystemClock.sleep(i6);
                    }
                }
            } else {
                if (!str2.equalsIgnoreCase("base64")) {
                    i(str3, "error", "EINVAL", "Unrecognized encoding `" + str2 + "`, should be one of `base64`, `utf8`, `ascii`");
                    openInputStream.close();
                }
                while (true) {
                    int read3 = openInputStream.read(bArr);
                    if (read3 == i8) {
                        break;
                    }
                    if (read3 < i7) {
                        byte[] bArr2 = new byte[read3];
                        System.arraycopy(bArr, 0, bArr2, 0, read3);
                        h(str3, str5, Base64.encodeToString(bArr2, 2));
                    } else {
                        h(str3, str5, Base64.encodeToString(bArr, 2));
                    }
                    if (i6 > 0) {
                        SystemClock.sleep(i6);
                        str5 = str5;
                        i8 = -1;
                    }
                }
            }
            h(str3, "end", "");
            openInputStream.close();
        } catch (FileNotFoundException unused) {
            i(str3, "error", "ENOENT", "No such file '" + str4 + "'");
        } catch (Exception e5) {
            i(str3, "error", "EUNSPECIFIED", "Failed to convert data to " + str2 + " encoded string. This might be because this encoding cannot be used for this data.");
            e5.printStackTrace();
        }
    }
}