导航菜单

页面标题

页面副标题

Tasker v6.5.11 - g8.java 源代码

正在查看: Tasker v6.5.11 应用的 g8.java JAVA 源代码文件

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


package com.joaomgcd.taskerm.util;

import android.annotation.TargetApi;
import android.content.ClipData;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64InputStream;
import android.util.Base64OutputStream;
import android.webkit.MimeTypeMap;
import androidx.core.content.FileProvider;
import com.joaomgcd.taskerm.util.k;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import cyanogenmod.app.ProfileManager;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import net.dinglisch.android.taskerm.dq;
import net.dinglisch.android.taskerm.yd;
import tf.c;

public final class g8 {
    private static final lj.j a = lj.k.b(b.i);

    static final class a extends yj.q implements xj.a<File> {
        final String i;

        a(String str) {
            super(0);
            this.i = str;
        }

        @Override
        public final File invoke() {
            return g8.D0(this.i, true);
        }
    }

    static final class b extends yj.q implements xj.a<String> {
        public static final b i = new b();

        b() {
            super(0);
        }

        @Override
        public final String invoke() {
            return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data";
        }
    }

    static final class c extends yj.q implements xj.a<String> {
        final Uri i;
        final Context q;

        c(Uri uri, Context context) {
            super(0);
            this.i = uri;
            this.q = context;
        }

        @Override
        public final String invoke() {
            return g8.W(this.i, this.q);
        }
    }

    static final class d extends yj.q implements xj.a<File> {
        final String i;

        d(String str) {
            super(0);
            this.i = str;
        }

        @Override
        public final File invoke() {
            return g8.D0(this.i, true);
        }
    }

    static final class e extends yj.q implements xj.a<String> {
        final Uri i;
        final Context q;

        e(Uri uri, Context context) {
            super(0);
            this.i = uri;
            this.q = context;
        }

        @Override
        public final String invoke() {
            return g8.Y(this.i, this.q);
        }
    }

    static final class f extends yj.q implements xj.a<String> {
        final Uri i;
        final Context q;

        f(Uri uri, Context context) {
            super(0);
            this.i = uri;
            this.q = context;
        }

        @Override
        public final String invoke() {
            return net.dinglisch.android.taskerm.h4.u(this.i, this.q);
        }
    }

    static final class g extends yj.q implements xj.a<String> {
        final Uri i;
        final Context q;

        g(Uri uri, Context context) {
            super(0);
            this.i = uri;
            this.q = context;
        }

        @Override
        public final String invoke() {
            Uri buildDocumentUri = DocumentsContract.buildDocumentUri(this.i.getAuthority(), DocumentsContract.getDocumentId(this.i));
            yj.p.h(buildDocumentUri, "buildDocumentUri(...)");
            return g8.Y(buildDocumentUri, this.q);
        }
    }

    static final class h extends yj.q implements xj.a<String> {
        final Uri i;
        final Context q;

        h(Uri uri, Context context) {
            super(0);
            this.i = uri;
            this.q = context;
        }

        @Override
        public final String invoke() {
            Uri uri = this.i;
            Uri buildDocumentUriUsingTree = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri));
            yj.p.h(buildDocumentUriUsingTree, "buildDocumentUriUsingTree(...)");
            return g8.Y(buildDocumentUriUsingTree, this.q);
        }
    }

    static final class i extends yj.q implements xj.a<File> {
        final StorageVolume i;

        i(StorageVolume storageVolume) {
            super(0);
            this.i = storageVolume;
        }

        @Override
        public final File invoke() {
            StorageVolume storageVolume = this.i;
            if (storageVolume != null) {
                return (File) o8.l(storageVolume.getClass(), "mPath", null, true).get(storageVolume);
            }
            throw new u1("reflection instance is null", null, 2, null);
        }
    }

    @TargetApi(30)
    public static final List<String> A(Context context) {
        yj.p.i(context, "<this>");
        ArrayList<String> t = net.dinglisch.android.taskerm.h4.t(context);
        yj.p.h(t, "getExtSdCardPaths(...)");
        return t;
    }

    public static final boolean A0(File file, Context context) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        String absolutePath = file.getAbsolutePath();
        yj.p.f(absolutePath);
        if (o0(absolutePath)) {
            return true;
        }
        List<String> A = A(context);
        if (!(A instanceof Collection) || !A.isEmpty()) {
            Iterator<T> it = A.iterator();
            while (it.hasNext()) {
                if (hk.o.I(absolutePath, (String) it.next(), false, 2, null)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static final File B(String str) {
        File c1;
        if (str == null || str.length() == 0 || (c1 = dq.c1()) == null) {
            return null;
        }
        String str2 = File.separator;
        yj.p.h(str2, "separator");
        return hk.o.I(str, str2, false, 2, null) ? new File(str) : new File(c1, str);
    }

    public static final boolean B0(String str) {
        yj.p.i(str, "<this>");
        return hk.o.I(str, "http", false, 2, null);
    }

    public static final String C(Uri uri, Context context) {
        int columnIndex;
        String str;
        yj.p.i(uri, "<this>");
        yj.p.i(context, "context");
        String str2 = null;
        if (yj.p.d(uri.getScheme(), "content")) {
            try {
                Cursor query = context.getContentResolver().query(uri, null, null, null, null);
                if (query != null) {
                    try {
                        String string = (!query.moveToFirst() || (columnIndex = query.getColumnIndex("_display_name")) == -1) ? null : query.getString(columnIndex);
                        try {
                            lj.e0 e0Var = lj.e0.a;
                            try {
                                vj.b.a(query, null);
                            } catch (Exception unused) {
                            }
                            str2 = string;
                        } catch (Throwable th2) {
                            String str3 = string;
                            th = th2;
                            str2 = str3;
                            try {
                                throw th;
                            } finally {
                            }
                        }
                    } catch (Throwable th3) {
                        th = th3;
                    }
                }
            } catch (Exception unused2) {
            }
        }
        if (str2 == null) {
            str2 = uri.getLastPathSegment();
        }
        if (str2 == null || str2.length() == 0) {
            String type = context.getContentResolver().getType(uri);
            String extensionFromMimeType = type != null ? MimeTypeMap.getSingleton().getExtensionFromMimeType(type) : "bin";
            long currentTimeMillis = System.currentTimeMillis();
            if (extensionFromMimeType != null) {
                str = "." + extensionFromMimeType;
            } else {
                str = "";
            }
            str2 = "shared_file_" + currentTimeMillis + str;
        }
        return new hk.k("[^a-zA-Z0-9._-]").h(str2, "_");
    }

    public static final boolean C0(File file) {
        jf.d bVar;
        yj.p.i(file, "<this>");
        Context b2 = p7.b("mkParentDirs");
        if (b2 == null || (bVar = jf.a.b(b2, file, true)) == null) {
            bVar = new jf.b(file);
        }
        if (!bVar.E() && (bVar = bVar.w()) == null) {
            return false;
        }
        if (bVar.V()) {
            return true;
        }
        return b2 != null ? bVar.q(b2) : bVar.z().mkdirs();
    }

    public static final String D(String str) {
        yj.p.i(str, "<this>");
        if (!hk.o.I(str, "/", false, 2, null)) {
            return str;
        }
        return "file://" + str;
    }

    public static final File D0(String str, boolean z) throws t1 {
        yj.p.i(str, "<this>");
        File c1 = dq.c1();
        if (c1 == null) {
            E0(z, 2131887974);
        }
        if (str.length() == 0) {
            E0(z, 2131887967);
        }
        String str2 = File.separator;
        yj.p.h(str2, "separator");
        return hk.o.I(str, str2, false, 2, null) ? new File(str) : new File(c1, str);
    }

    public static final String E(String str) {
        yj.p.i(str, "<this>");
        return hk.o.I(str, "file://", false, 2, null) ? hk.o.q0(str, "file://") : str;
    }

    private static final void E0(boolean z, int i2) {
        if (z) {
            throw new t1(i2);
        }
    }

    public static final List<String> F(Intent intent, Context context, boolean z, boolean z2, boolean z3) {
        ArrayList arrayList;
        String uri;
        String string;
        yj.p.i(context, "context");
        if (intent == null) {
            throw new RuntimeException("Couldn't get result");
        }
        if (z) {
            Bundle extras = intent.getExtras();
            if (extras == null || (string = extras.getString("path")) == null) {
                throw new RuntimeException("Couldn't get result");
            }
            if (z2) {
                string = dq.B2(string);
            }
            return kotlin.collections.r.d(string);
        }
        ClipData clipData = intent.getClipData();
        if (intent.getDataString() != null) {
            arrayList = kotlin.collections.r.f(intent.getDataString());
        } else {
            if (clipData == null) {
                throw new RuntimeException("Couldn't get result");
            }
            arrayList = new ArrayList();
            int itemCount = clipData.getItemCount();
            for (int i2 = 0; i2 < itemCount; i2++) {
                Uri uri2 = clipData.getItemAt(i2).getUri();
                if (uri2 != null && (uri = uri2.toString()) != null) {
                    arrayList.add(uri);
                }
            }
        }
        return p(arrayList, context, z2, false, false, z3, 12, null);
    }

    public static final boolean F0(File file, Context context, boolean z, String str) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        yj.p.i(str, "chooserTitle");
        return H0(file, context, z, str, null, null, 24, null);
    }

    @TargetApi(26)
    public static final InputStream G(String str, Context context) throws t1 {
        InputStream openInputStream;
        byte[] m;
        yj.p.i(str, "<this>");
        yj.p.i(context, "context");
        File file = (File) x2.U4(null, new d(str), 1, null);
        if (file != null && file.exists()) {
            return H(file, context);
        }
        if (B0(str)) {
            return dg.o0.t(str);
        }
        if (v0(str)) {
            return H(new File(E(str)), context);
        }
        if (p0(str)) {
            c.a aVar = tf.c.a;
            PackageManager packageManager = context.getPackageManager();
            yj.p.h(packageManager, "getPackageManager(...)");
            Bitmap h2 = c.a.h(aVar, packageManager, str, null, null, 12, null);
            if (h2 == null || (m = tf.e.m(h2)) == null || (openInputStream = x2.f1(m)) == null) {
                throw new RuntimeException("Could not get android resource image " + str);
            }
        } else {
            if (!r0(str)) {
                return x0(str) ? k(str) : H(D0(str, true), context);
            }
            openInputStream = context.getContentResolver().openInputStream(Uri.parse(str));
            if (openInputStream == null) {
                throw new RuntimeException("Could not get content resource " + str);
            }
        }
        return openInputStream;
    }

    public static final boolean G0(File file, Context context, boolean z, String str, String str2, xj.l<? super String, lj.e0> lVar) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        yj.p.i(str, "chooserTitle");
        return dq.l3(context, c0(file, context, str2, null, lVar, z, str, 4, null));
    }

    private static final InputStream H(File file, Context context) {
        jf.d l = jf.a.l(file, context, false, 2, (Object) null);
        if (!l.V()) {
            throw new RuntimeException("File doesn't exist: " + file);
        }
        InputStream R = l.R();
        if (R != null) {
            return R;
        }
        throw new RuntimeException("Could not open: " + file);
    }

    public static boolean H0(File file, Context context, boolean z, String str, String str2, xj.l lVar, int i2, Object obj) {
        boolean z2 = (i2 & 2) != 0 ? true : z;
        if ((i2 & 4) != 0) {
            str = "";
        }
        return G0(file, context, z2, str, (i2 & 8) != 0 ? null : str2, (i2 & 16) != 0 ? null : lVar);
    }

    @TargetApi(24)
    public static final String I(StorageVolume storageVolume, Context context, String str) {
        String description;
        yj.p.i(context, "context");
        yj.p.i(str, "path");
        if (storageVolume == null) {
            return str;
        }
        if (k.a.o()) {
            return x2.Q4(2131887755, context, new Object[0]);
        }
        description = storageVolume.getDescription(context);
        return kotlin.collections.r.m0(kotlin.collections.l.N(new String[]{e0(storageVolume), description, str}), " - ", null, null, 0, null, null, 62, null);
    }

    public static final void I0(File file) {
        yj.p.i(file, "<this>");
        file.setExecutable(true, false);
        file.setReadable(true, false);
        file.setWritable(true, false);
    }

    public static final String J(File file) {
        yj.p.i(file, "<this>");
        return z3.a(file);
    }

    public static final void J0(File file, Context context) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        L0(file, context, null, 2, null);
    }

    public static final String K(File file) {
        yj.p.i(file, "<this>");
        return dq.H0(file);
    }

    public static final void K0(File file, Context context, String str) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        yj.p.i(str, "mimeType");
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addCategory("android.intent.category.DEFAULT");
        intent.setDataAndType(l0(file, context, null, intent, false, 10, null), str);
        if (dq.l3(context, intent)) {
            return;
        }
        dq.b0(context, "no viewer activity found", new Object[0]);
    }

    public static final String L(String str) {
        yj.p.i(str, "<this>");
        return dq.H0(new File(E(str)));
    }

    public static void L0(File file, Context context, String str, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str = "text/plain";
        }
        K0(file, context, str);
    }

    public static final FileDescriptor M(File file, Context context) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        return O(file, context, null, null, 6, null);
    }

    public static final void M0(File file, String str) {
        yj.p.i(file, "<this>");
        yj.p.i(str, "content");
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
        try {
            bufferedWriter.write(str);
            lj.e0 e0Var = lj.e0.a;
            vj.b.a(bufferedWriter, null);
        } finally {
        }
    }

    public static final FileDescriptor N(File file, Context context, String str, String str2) {
        Uri parse;
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        if (s0(file, context, true)) {
            parse = net.dinglisch.android.taskerm.h4.q(context, file, false, str, str2).n();
        } else {
            String absolutePath = file.getAbsolutePath();
            yj.p.h(absolutePath, "getAbsolutePath(...)");
            parse = Uri.parse(D(absolutePath));
        }
        ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(parse, "w");
        if (openFileDescriptor != null) {
            return openFileDescriptor.getFileDescriptor();
        }
        return null;
    }

    public static FileDescriptor O(File file, Context context, String str, String str2, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str = null;
        }
        if ((i2 & 4) != 0) {
            str2 = null;
        }
        return N(file, context, str, str2);
    }

    public static final File P(String str, Context context, String str2, String str3) {
        File B;
        yj.p.i(str, "<this>");
        yj.p.i(context, "context");
        File D0 = D0(str, true);
        if (!D0.isDirectory()) {
            return D0;
        }
        Uri n = z2.n(str);
        String W = n != null ? W(n, context) : null;
        net.dinglisch.android.taskerm.r7.f("UtilFile", "getOutputStreamFromPath real path for output: " + W);
        if (str3 == null) {
            str3 = (W == null || (B = B(W)) == null) ? null : B.getName();
            if (str3 == null) {
                if (str2 == null) {
                    throw new RuntimeException("Output file is a directory. Must provide fromPathDirectory");
                }
                str3 = new File(str2).getName();
            }
        }
        return new File(D0, str3);
    }

    public static File Q(String str, Context context, String str2, String str3, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str2 = str;
        }
        if ((i2 & 4) != 0) {
            str3 = null;
        }
        return P(str, context, str2, str3);
    }

    public static final OutputStream R(File file, Context context, String str, String str2) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        if (!s0(file, context, true)) {
            return new FileOutputStream(file);
        }
        OutputStream Q = net.dinglisch.android.taskerm.h4.Q(context.getContentResolver(), net.dinglisch.android.taskerm.h4.q(context, file, false, str, str2));
        return Q == null ? new FileOutputStream(file) : Q;
    }

    public static final OutputStream S(String str, Context context, String str2, String str3, String str4) {
        yj.p.i(str, "<this>");
        yj.p.i(context, "context");
        return R(Q(str, context, str3, null, 4, null), context, str2, str4);
    }

    @TargetApi(30)
    public static final File T(StorageVolume storageVolume) {
        File directory;
        yj.p.i(storageVolume, "<this>");
        if (k.a.t()) {
            return (File) x2.U4(null, new i(storageVolume), 1, null);
        }
        directory = storageVolume.getDirectory();
        return directory;
    }

    public static final String U(StorageVolume storageVolume) {
        yj.p.i(storageVolume, "<this>");
        File T = T(storageVolume);
        if (T != null) {
            return T.toString();
        }
        return null;
    }

    public static final File V(File file, String str) {
        yj.p.i(file, "<this>");
        if (file.exists()) {
            return (file.isFile() || str == null) ? file : new File(file, str);
        }
        String name = file.getName();
        yj.p.h(name, "getName(...)");
        return hk.o.N(name, ".", false, 2, null) ? file : str != null ? new File(file, str) : file;
    }

    public static final String W(Uri uri, Context context) {
        yj.p.i(uri, "<this>");
        yj.p.i(context, "context");
        String str = (String) a0(null, new e(uri, context), 1, null);
        if (str != null) {
            return str;
        }
        String str2 = (String) a0(null, new g(uri, context), 1, null);
        if (str2 != null) {
            return str2;
        }
        String str3 = (String) a0(null, new h(uri, context), 1, null);
        return str3 != null ? str3 : (String) a0(null, new f(uri, context), 1, null);
    }

    public static final String X(String str, Context context) {
        yj.p.i(str, "<this>");
        yj.p.i(context, "context");
        Uri parse = Uri.parse(str);
        yj.p.h(parse, "parse(...)");
        return W(parse, context);
    }

    public static final String Y(Uri uri, Context context) {
        List l;
        List l2;
        Uri uri2 = null;
        if (DocumentsContract.isDocumentUri(context, uri)) {
            String documentId = DocumentsContract.getDocumentId(uri);
            yj.p.f(documentId);
            if (hk.o.I(documentId, "raw:", false, 2, null)) {
                return hk.o.q0(documentId, "raw:");
            }
            if (u0(uri)) {
                List<String> j = new hk.k(ConstantsCommonTaskerServer.ID_SEPARATOR).j(documentId, 0);
                if (!j.isEmpty()) {
                    ListIterator<String> listIterator = j.listIterator(j.size());
                    while (listIterator.hasPrevious()) {
                        if (listIterator.previous().length() != 0) {
                            l2 = kotlin.collections.r.H0(j, listIterator.nextIndex() + 1);
                            break;
                        }
                    }
                }
                l2 = kotlin.collections.r.l();
                String[] strArr = (String[]) l2.toArray(new String[0]);
                String str = strArr[0];
                if (hk.o.u("primary", str, true)) {
                    String file = Environment.getExternalStorageDirectory().toString();
                    String str2 = (String) kotlin.collections.l.a0(strArr, 1);
                    if (str2 == null) {
                        str2 = "";
                    }
                    return file + "/" + str2;
                }
                String str3 = (String) kotlin.collections.l.a0(strArr, 1);
                if (str3 == null) {
                    return null;
                }
                return net.dinglisch.android.taskerm.h4.A(str, context) + "/" + str3;
            }
            if (t0(uri)) {
                Long o = hk.o.o(documentId);
                if (o == null) {
                    throw new s1(uri);
                }
                Uri withAppendedId = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), o.longValue());
                yj.p.h(withAppendedId, "withAppendedId(...)");
                String y = y(context, withAppendedId, null, null);
                if (y != null) {
                    return y;
                }
                throw new s1(uri);
            }
            if (w0(uri)) {
                List<String> j2 = new hk.k(ConstantsCommonTaskerServer.ID_SEPARATOR).j(documentId, 0);
                if (!j2.isEmpty()) {
                    ListIterator<String> listIterator2 = j2.listIterator(j2.size());
                    while (listIterator2.hasPrevious()) {
                        if (listIterator2.previous().length() != 0) {
                            l = kotlin.collections.r.H0(j2, listIterator2.nextIndex() + 1);
                            break;
                        }
                    }
                }
                l = kotlin.collections.r.l();
                String[] strArr2 = (String[]) l.toArray(new String[0]);
                String str4 = strArr2[0];
                if (yj.p.d("image", str4)) {
                    uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                } else if (yj.p.d("video", str4)) {
                    uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                } else if (yj.p.d("audio", str4)) {
                    uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                }
                return y(context, uri2, "_id=?", new String[]{strArr2[1]});
            }
        } else {
            String scheme = uri.getScheme();
            yj.p.f(scheme);
            if (hk.o.u("content", scheme, true)) {
                return y(context, uri, null, null);
            }
            String scheme2 = uri.getScheme();
            yj.p.f(scheme2);
            if (hk.o.u("file", scheme2, true)) {
                return uri.getPath();
            }
        }
        return null;
    }

    private static final <T> T Z(xj.l<? super Throwable, ? extends T> lVar, xj.a<? extends T> aVar) {
        try {
            return aVar.invoke();
        } catch (Throwable th2) {
            if (th2 instanceof s1) {
                throw th2;
            }
            net.dinglisch.android.taskerm.r7.g("TRYORNULL", "Error", th2);
            if (lVar != null) {
                return lVar.invoke(th2);
            }
            return null;
        }
    }

    static Object a0(xj.l lVar, xj.a aVar, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            lVar = null;
        }
        return Z(lVar, aVar);
    }

    @TargetApi(26)
    public static final void b(Context context, String str, File file) {
        yj.p.i(context, "<this>");
        yj.p.i(str, "base64String");
        yj.p.i(file, "to");
        d(context, str, file, null, 4, null);
    }

    public static final Intent b0(File file, Context context, String str, String str2, xj.l<? super String, lj.e0> lVar, boolean z, String str3) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        yj.p.i(str2, "action");
        if (TextUtils.isEmpty(str)) {
            str = dq.H0(file);
        }
        Intent intent = new Intent(str2);
        if (!TextUtils.isEmpty(str)) {
            Uri l0 = l0(file, context, null, intent, false, 10, null);
            intent.putExtra("android.intent.extra.STREAM", l0);
            intent.setDataAndType(l0, str);
        } else if (lVar != null) {
            lVar.invoke("couldn't determine MIME type of " + file);
        }
        if (!z) {
            return intent;
        }
        if (str3 == null) {
            str3 = "Select App";
        }
        Intent createChooser = Intent.createChooser(intent, str3);
        yj.p.h(createChooser, "createChooser(...)");
        return createChooser;
    }

    @TargetApi(26)
    public static final void c(Context context, String str, File file, String str2) {
        yj.p.i(context, "<this>");
        yj.p.i(str, "base64String");
        yj.p.i(file, "to");
        jf.d k = jf.a.k(file, context, true);
        if (str2 == null) {
            str2 = "application/octet-stream";
        }
        OutputStream d0 = k.d0(str2, false);
        if (d0 == null) {
            throw new RuntimeException("Couldn't get output file");
        }
        vj.a.b(k(str), d0, 0, 2, null);
    }

    public static Intent c0(File file, Context context, String str, String str2, xj.l lVar, boolean z, String str3, int i2, Object obj) {
        return b0(file, context, (i2 & 2) != 0 ? null : str, (i2 & 4) != 0 ? "android.intent.action.SEND" : str2, (i2 & 8) != 0 ? null : lVar, (i2 & 16) != 0 ? false : z, (i2 & 32) == 0 ? str3 : null);
    }

    public static void d(Context context, String str, File file, String str2, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            str2 = null;
        }
        c(context, str, file, str2);
    }

    public static final StorageVolume d0(Context context, String str) {
        StorageVolume[] s;
        yj.p.i(str, "path");
        if (context == null || (s = s(context)) == null) {
            return null;
        }
        for (StorageVolume storageVolume : s) {
            File T = T(storageVolume);
            if (yj.p.d(T != null ? T.getAbsolutePath() : null, str)) {
                return storageVolume;
            }
        }
        return null;
    }

    public static final void e(Context context, File file, File file2) {
        yj.p.i(context, "<this>");
        yj.p.i(file, "from");
        yj.p.i(file2, "to");
        if (!yj.p.d(file, file2)) {
            vj.a.b(H(file, context), R(file2, context, K(file), "copyFile"), 0, 2, null);
            return;
        }
        net.dinglisch.android.taskerm.r7.f("E", "Copy file: source same as dest: " + file2);
    }

    @TargetApi(24)
    public static final String e0(StorageVolume storageVolume) {
        Field field;
        String obj;
        if (storageVolume == null || k.a.o()) {
            return null;
        }
        Field[] i2 = o8.i(storageVolume.getClass());
        int length = i2.length;
        int i3 = 0;
        while (true) {
            if (i3 >= length) {
                field = null;
                break;
            }
            field = i2[i3];
            String name = field.getName();
            yj.p.h(name, "getName(...)");
            if (hk.o.N(name, "SubSystem", false, 2, null)) {
                break;
            }
            i3++;
        }
        if (field == null) {
            return null;
        }
        field.setAccessible(true);
        Object obj2 = field.get(storageVolume);
        if (obj2 == null || (obj = obj2.toString()) == null) {
            return null;
        }
        String upperCase = obj.toUpperCase();
        yj.p.h(upperCase, "toUpperCase(...)");
        return upperCase;
    }

    public static final void f(Context context, InputStream inputStream, File file, String str) throws t1 {
        yj.p.i(context, "<this>");
        yj.p.i(inputStream, "inputStreamFrom");
        yj.p.i(file, "to");
        vj.a.b(inputStream, R(file, context, str, "copyFile"), 0, 2, null);
    }

    public static final String f0(File file) {
        yj.p.i(file, "<this>");
        if (!file.exists()) {
            return null;
        }
        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
        try {
            String g0 = g0(bufferedInputStream);
            vj.b.a(bufferedInputStream, null);
            return g0;
        } finally {
        }
    }

    public static final void g(Context context, InputStream inputStream, String str, String str2, String str3) throws t1 {
        yj.p.i(context, "<this>");
        yj.p.i(inputStream, "inputStreamFrom");
        yj.p.i(str, "to");
        vj.a.b(inputStream, S(str, context, str2, str3, "copyFile"), 0, 2, null);
    }

    public static final String g0(InputStream inputStream) {
        if (inputStream == null) {
            return null;
        }
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, hk.d.b), 8192);
        try {
            String f2 = vj.i.f(bufferedReader);
            vj.b.a(bufferedReader, null);
            return f2;
        } finally {
        }
    }

    public static final void h(Context context, String str, String str2) throws t1 {
        yj.p.i(context, "<this>");
        yj.p.i(str, "from");
        yj.p.i(str2, "to");
        if (!yj.p.d(str, str2)) {
            g(context, G(str, context), str2, L(str), str);
            return;
        }
        net.dinglisch.android.taskerm.r7.f("E", "Copy file: source same as dest: " + str2);
    }

    public static final Uri h0(File file, Context context, String[] strArr) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        return l0(file, context, strArr, null, false, 12, null);
    }

    public static void i(Context context, InputStream inputStream, File file, String str, int i2, Object obj) throws t1 {
        if ((i2 & 4) != 0) {
            str = null;
        }
        f(context, inputStream, file, str);
    }

    public static final Uri i0(File file, Context context, String[] strArr, Intent intent) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        return l0(file, context, strArr, intent, false, 8, null);
    }

    public static final boolean j(File file) {
        yj.p.i(file, "<this>");
        return C0(file);
    }

    public static final Uri j0(File file, Context context, String[] strArr, Intent intent, boolean z) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        if (p.j(context)) {
            Uri fromFile = Uri.fromFile(file);
            yj.p.f(fromFile);
            return fromFile;
        }
        Uri h2 = FileProvider.h(context, context.getPackageName() + ".fileprovider", file);
        int i2 = z ? 67 : 65;
        if (intent != null) {
            intent.addFlags(i2);
        }
        if (strArr != null) {
            for (String str : strArr) {
                context.grantUriPermission(str, h2, i2);
            }
        }
        yj.p.f(h2);
        return h2;
    }

    @TargetApi(26)
    public static final InputStream k(String str) {
        yj.p.i(str, "<this>");
        byte[] bytes = str.getBytes(hk.d.b);
        yj.p.h(bytes, "getBytes(...)");
        return new Base64InputStream(new ByteArrayInputStream(bytes), 0);
    }

    public static final Uri k0(String str, Context context, String[] strArr, Intent intent, boolean z) {
        yj.p.i(str, "<this>");
        yj.p.i(context, "context");
        File file = new File(hk.o.C(str, "file://", "", false, 4, null));
        if (file.exists()) {
            return j0(file, context, strArr, intent, z);
        }
        return null;
    }

    public static final boolean l(Context context, String str) {
        yj.p.i(context, "<this>");
        yj.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
        return n(context, str, null, 2, null);
    }

    public static Uri l0(File file, Context context, String[] strArr, Intent intent, boolean z, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            strArr = null;
        }
        if ((i2 & 4) != 0) {
            intent = null;
        }
        if ((i2 & 8) != 0) {
            z = true;
        }
        return j0(file, context, strArr, intent, z);
    }

    public static final boolean m(Context context, String str, String str2) {
        yj.p.i(context, "<this>");
        yj.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
        File v = v(context, str, str2);
        if (v.exists()) {
            return v.delete();
        }
        return false;
    }

    public static Uri m0(String str, Context context, String[] strArr, Intent intent, boolean z, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            strArr = null;
        }
        if ((i2 & 4) != 0) {
            intent = null;
        }
        if ((i2 & 8) != 0) {
            z = true;
        }
        return k0(str, context, strArr, intent, z);
    }

    public static boolean n(Context context, String str, String str2, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str2 = null;
        }
        return m(context, str, str2);
    }

    public static final String n0(File file, Context context, String str) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        yj.p.i(str, "destinationPacakge");
        String uri = l0(file, context, new String[]{str}, null, false, 12, null).toString();
        yj.p.h(uri, "toString(...)");
        return uri;
    }

    public static final List<String> o(Collection<String> collection, Context context, boolean z, boolean z2, boolean z3, boolean z4) {
        Uri m0;
        String uri;
        yj.p.i(collection, "<this>");
        yj.p.i(context, "context");
        if (!z) {
            return kotlin.collections.r.N0(collection);
        }
        Collection<String> collection2 = collection;
        ArrayList<String> arrayList = new ArrayList(kotlin.collections.r.v(collection2, 10));
        for (String str : collection2) {
            String X = X(str, context);
            if (X != null) {
                str = X;
            }
            arrayList.add(str);
        }
        ArrayList<String> arrayList2 = new ArrayList(kotlin.collections.r.v(arrayList, 10));
        for (String str2 : arrayList) {
            if (z3) {
                str2 = D(str2);
            }
            arrayList2.add(str2);
        }
        ArrayList<String> arrayList3 = new ArrayList(kotlin.collections.r.v(arrayList2, 10));
        for (String str3 : arrayList2) {
            if (z2 && (m0 = m0(str3, context, null, null, false, 14, null)) != null && (uri = m0.toString()) != null) {
                str3 = uri;
            }
            arrayList3.add(str3);
        }
        ArrayList arrayList4 = new ArrayList(kotlin.collections.r.v(arrayList3, 10));
        for (String str4 : arrayList3) {
            if (z4) {
                str4 = dq.B2(str4);
            }
            arrayList4.add(str4);
        }
        return arrayList4;
    }

    public static final boolean o0(String str) {
        yj.p.i(str, "<this>");
        return false;
    }

    public static List p(Collection collection, Context context, boolean z, boolean z2, boolean z3, boolean z4, int i2, Object obj) {
        return o(collection, context, (i2 & 2) != 0 ? true : z, (i2 & 4) != 0 ? false : z2, (i2 & 8) != 0 ? false : z3, (i2 & 16) != 0 ? true : z4);
    }

    public static final boolean p0(String str) {
        yj.p.i(str, "<this>");
        return hk.o.I(str, "android.resource", false, 2, null);
    }

    public static final String q(String str) {
        File file;
        yj.p.i(str, "<this>");
        if (B0(str) || p0(str) || r0(str) || q0(str) || (file = (File) x2.U4(null, new a(str), 1, null)) == null || !file.exists()) {
            return null;
        }
        return file.getAbsolutePath();
    }

    public static final boolean q0(String str) {
        yj.p.i(str, "<this>");
        return hk.o.I(str, tf.e.w(), false, 2, null) || hk.o.I(str, tf.e.v(), false, 2, null);
    }

    @TargetApi(30)
    public static final File[] r(Context context) {
        File directory;
        boolean isPrimary;
        yj.p.i(context, "<this>");
        if (k.a.o()) {
            File[] a2 = yd.a0.a(context, "external pre nougat");
            yj.p.h(a2, "getExternalFilesDirs(...)");
            return (File[]) kotlin.collections.l.M(a2, 1).toArray(new File[0]);
        }
        StorageVolume[] s = s(context);
        ArrayList arrayList = new ArrayList();
        for (StorageVolume storageVolume : s) {
            isPrimary = storageVolume.isPrimary();
            if (!isPrimary) {
                arrayList.add(storageVolume);
            }
        }
        if (!k.a.t()) {
            ArrayList arrayList2 = new ArrayList();
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                directory = b8.a(it.next()).getDirectory();
                if (directory != null) {
                    arrayList2.add(directory);
                }
            }
            return (File[]) arrayList2.toArray(new File[0]);
        }
        ArrayList arrayList3 = new ArrayList();
        Iterator it2 = arrayList.iterator();
        while (it2.hasNext()) {
            File T = T(b8.a(it2.next()));
            if (T != null) {
                arrayList3.add(T);
            }
        }
        if (!arrayList3.isEmpty()) {
            return (File[]) arrayList3.toArray(new File[0]);
        }
        File[] a3 = yd.a0.a(context, "external");
        yj.p.f(a3);
        return a3;
    }

    public static final boolean r0(String str) {
        yj.p.i(str, "<this>");
        return hk.o.I(str, "content://", false, 2, null);
    }

    @TargetApi(30)
    public static final StorageVolume[] s(Context context) {
        String state;
        yj.p.i(context, "<this>");
        k.a aVar = k.a;
        if (aVar.o()) {
            return new StorageVolume[0];
        }
        StorageManager S1 = ExtensionsContextKt.S1(context);
        if (S1 == null) {
            return new StorageVolume[0];
        }
        List storageVolumes = aVar.t() ? S1.getStorageVolumes() : S1.getRecentStorageVolumes();
        yj.p.f(storageVolumes);
        List a0 = kotlin.collections.r.a0(storageVolumes);
        ArrayList arrayList = new ArrayList();
        for (Object obj : a0) {
            state = b8.a(obj).getState();
            if (x2.e0(state, "mounted", "mounted_ro")) {
                arrayList.add(obj);
            }
        }
        return (StorageVolume[]) arrayList.toArray(new StorageVolume[0]);
    }

    public static final boolean s0(File file, Context context, boolean z) {
        yj.p.i(file, "<this>");
        yj.p.i(context, "context");
        return net.dinglisch.android.taskerm.h4.c0(context, file, z);
    }

    public static final String t(File file) {
        yj.p.i(file, "<this>");
        FileInputStream fileInputStream = new FileInputStream(file);
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 2);
                try {
                    vj.a.b(fileInputStream, base64OutputStream, 0, 2, null);
                    base64OutputStream.flush();
                    base64OutputStream.close();
                    byteArrayOutputStream.flush();
                    String byteArrayOutputStream2 = byteArrayOutputStream.toString();
                    vj.b.a(base64OutputStream, null);
                    vj.b.a(byteArrayOutputStream, null);
                    vj.b.a(fileInputStream, null);
                    yj.p.h(byteArrayOutputStream2, "use(...)");
                    return byteArrayOutputStream2;
                } finally {
                }
            } finally {
            }
        } finally {
        }
    }

    public static final boolean t0(Uri uri) {
        yj.p.i(uri, "<this>");
        return yj.p.d("com.android.providers.downloads.documents", uri.getAuthority());
    }

    public static final File u(Context context, String str) {
        yj.p.i(context, "<this>");
        yj.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
        return w(context, str, null, 2, null);
    }

    public static final boolean u0(Uri uri) {
        yj.p.i(uri, "<this>");
        return yj.p.d("com.android.externalstorage.documents", uri.getAuthority());
    }

    public static final File v(Context context, String str, String str2) {
        yj.p.i(context, "<this>");
        yj.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
        if (str2 == null) {
            return new File(context.getCacheDir(), str);
        }
        return new File(context.getCacheDir() + "/" + str2, str);
    }

    public static final boolean v0(String str) {
        String D;
        if (str == null || (D = D(str)) == null) {
            return false;
        }
        return hk.o.I(D, "file://", false, 2, null);
    }

    public static File w(Context context, String str, String str2, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str2 = null;
        }
        return v(context, str, str2);
    }

    public static final boolean w0(Uri uri) {
        yj.p.i(uri, "<this>");
        return yj.p.d("com.android.providers.media.documents", uri.getAuthority());
    }

    public static final boolean x(String str) {
        File B = B(str);
        if (B != null) {
            return B.canRead();
        }
        return false;
    }

    public static final boolean x0(String str) {
        yj.p.i(str, "<this>");
        if (str.length() % 4 != 0) {
            return false;
        }
        String str2 = hk.o.f1(str, 10) + hk.o.g1(str, 10);
        for (int i2 = 0; i2 < str2.length(); i2++) {
            char charAt = str2.charAt(i2);
            if (!hk.o.M("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", charAt, false, 2, null) && charAt != '=') {
                return false;
            }
        }
        return true;
    }

    public static final java.lang.String y(android.content.Context r8, android.net.Uri r9, java.lang.String r10, java.lang.String[] r11) {
        throw new UnsupportedOperationException("Method not decompiled: com.joaomgcd.taskerm.util.g8.y(android.content.Context, android.net.Uri, java.lang.String, java.lang.String[]):java.lang.String");
    }

    public static final boolean y0(File file) {
        return z0(file != null ? file.getAbsolutePath() : null);
    }

    public static final File z(Uri uri, Context context) {
        yj.p.i(uri, "<this>");
        yj.p.i(context, "context");
        String str = (String) x2.U4(null, new c(uri, context), 1, null);
        if (str == null) {
            return null;
        }
        File file = new File(str);
        if (file.exists()) {
            return file;
        }
        return null;
    }

    public static final boolean z0(String str) {
        if (str == null || k.a.o()) {
            return false;
        }
        return hk.o.I(str, "/mnt/media_rw", false, 2, null) || o0(str);
    }
}