导航菜单

页面标题

页面副标题

Tasker v6.5.11 - dq.java 源代码

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

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


package net.dinglisch.android.taskerm;

import android.R;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Looper;
import android.os.Process;
import android.os.Vibrator;
import android.provider.Settings;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.webkit.MimeTypeMap;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.joaomgcd.taskerm.structuredoutput.StructureType;
import com.joaomgcd.taskerm.util.ExtensionsContextKt;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
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.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.Thread;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.dinglisch.android.taskerm.yd;
import org.json.JSONObject;

public class dq {
    private static final Set<String> a;
    static Pattern b;
    static Pattern c;
    private static float d;
    private static float e;
    private static float f;
    private static float g;
    private static float h;
    private static float[] i;
    private static int[] j;
    private static Pattern k;
    private static String l;
    private static Pattern m;

    class a implements Comparator<Long> {
        final boolean i;

        a(boolean z) {
            this.i = z;
        }

        @Override
        public int compare(Long l, Long l2) {
            return this.i ? l2.compareTo(l) : l.compareTo(l2);
        }
    }

    class b implements Runnable {
        final boolean i;
        final InputMethodManager q;
        final EditText r;
        final int s;

        b(boolean z, InputMethodManager inputMethodManager, EditText editText, int i) {
            this.i = z;
            this.q = inputMethodManager;
            this.r = editText;
            this.s = i;
        }

        @Override
        public void run() {
            if (this.i) {
                this.q.showSoftInput(this.r, this.s);
            } else {
                this.q.hideSoftInputFromWindow(this.r.getWindowToken(), this.s);
            }
        }
    }

    class c implements InputFilter {
        c() {
        }

        @Override
        public CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
            return charSequence.length() < 1 ? spanned.subSequence(i3, i4) : "";
        }
    }

    class d implements DialogInterface.OnClickListener {
        final Context i;

        d(Context context) {
            this.i = context;
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            this.i.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://zoom.dinglisch.net/")));
        }
    }

    class e implements DialogInterface.OnClickListener {
        final Context i;

        e(Context context) {
            this.i = context;
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            this.i.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=net.dinglisch.android.zoom")));
        }
    }

    class f implements Comparator<String> {
        f() {
        }

        @Override
        public int compare(String str, String str2) {
            return str.compareToIgnoreCase(str2);
        }
    }

    class g implements Runnable {
        final View i;

        class a implements Runnable {
            final int i;

            a(int i) {
                this.i = i;
            }

            @Override
            public void run() {
                g.this.i.setVisibility(this.i % 2 == 0 ? 4 : 0);
            }
        }

        g(View view) {
            this.i = view;
        }

        @Override
        public void run() {
            for (int i = 0; i < 8; i++) {
                this.i.postDelayed(new a(i), i * 200);
            }
        }
    }

    static {
        HashSet hashSet = new HashSet();
        a = hashSet;
        b = null;
        c = null;
        d = -1.0f;
        e = -1.0f;
        f = -1.0f;
        g = -1.0f;
        h = -1.0f;
        i = new float[]{3657.5f, 3660.0f, 3662.5f, 3665.0f, 3667.5f, 3670.0f, 3672.5f, 3675.0f, 3677.5f, 3680.0f, 3682.5f, 3685.0f, 3687.5f, 3690.0f, 3692.5f, 4915.0f, 4920.0f, 4925.0f, 4935.0f, 4940.0f, 4945.0f, 4960.0f, 4980.0f, 5035.0f, 5040.0f, 5045.0f, 5055.0f, 5060.0f, 5080.0f, 5170.0f, 5180.0f, 5190.0f, 5200.0f, 5210.0f, 5220.0f, 5230.0f, 5240.0f, 5260.0f, 5280.0f, 5300.0f, 5320.0f, 5500.0f, 5520.0f, 5540.0f, 5560.0f, 5580.0f, 5600.0f, 5620.0f, 5640.0f, 5660.0f, 5680.0f, 5700.0f, 5745.0f, 5765.0f, 5785.0f, 5805.0f, 5825.0f};
        j = new int[]{131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165};
        k = null;
        l = "<[^>]+>";
        m = null;
        hashSet.add("mp3");
        hashSet.add("wma");
        hashSet.add("au");
        hashSet.add("mid");
        hashSet.add("midi");
        hashSet.add("mp2");
        hashSet.add("ogg");
        hashSet.add("wav");
        hashSet.add("3gp");
        hashSet.add("amr");
        hashSet.add("m4a");
    }

    public static Set<String> A(Context context, Set<String> set) {
        HashSet hashSet = null;
        if (set != null) {
            for (String str : set) {
                if (!y1(context, str)) {
                    if (hashSet == null) {
                        hashSet = new HashSet();
                    }
                    hashSet.add(str);
                }
            }
        }
        return hashSet;
    }

    public static float A0() {
        return f;
    }

    public static boolean A1(Context context, int i2) {
        SensorManager sensorManager = (SensorManager) oi.d(context, "sensor", "Utils", "haveSensor");
        return (sensorManager == null || sensorManager.getDefaultSensor(i2) == null) ? false : true;
    }

    public static File A2(File file) {
        return new File(B2(file.toString()));
    }

    public static boolean A3(Context context, String str, String str2, int i2) {
        try {
            FileOutputStream openFileOutput = context.openFileOutput(str2, i2);
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(openFileOutput);
            outputStreamWriter.write(str);
            q0(outputStreamWriter);
            D(openFileOutput);
            return true;
        } catch (Exception e2) {
            String message = e2.getMessage();
            StringBuilder sb = new StringBuilder();
            sb.append("stringToDeviceFile: ");
            if (message == null) {
                message = e2.toString();
            }
            sb.append(message);
            Log.e("Utils", sb.toString());
            return false;
        }
    }

    public static boolean[] B(boolean[] zArr) {
        boolean[] zArr2 = new boolean[zArr.length];
        for (int i2 = 0; i2 < zArr.length; i2++) {
            zArr2[i2] = zArr[i2];
        }
        return zArr2;
    }

    public static int B0(Context context, int i2) {
        return C0(context, true, i2);
    }

    public static boolean B1(Context context) {
        Vibrator vibrator = (Vibrator) oi.d(context, "vibrator", "Utils", "haveVib");
        return vibrator.hasVibrator() & (vibrator != null);
    }

    public static String B2(String str) {
        return C2(str, false);
    }

    public static Double B3(String str) {
        try {
            return new Double(str);
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    public static boolean C(InputStream inputStream) {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e2) {
                r7.l("Utils", "failed to close input stream", e2);
                return false;
            }
        }
        return true;
    }

    private static int C0(Context context, boolean z, int i2) {
        int i3;
        WindowManager windowManager = (WindowManager) oi.d(context, "window", "Utils", "sdwh");
        if (windowManager != null) {
            Point point = new Point();
            windowManager.getDefaultDisplay().getSize(point);
            i3 = z ? point.x : point.y;
        } else {
            i3 = 0;
        }
        return i3 == 0 ? i2 : i3;
    }

    public static boolean C1(Context context) {
        WifiManager wifiManager = (WifiManager) oi.d(context, "wifi", "Utils", "haveWifiTether");
        if (wifiManager == null) {
            return false;
        }
        int a2 = yd.d1.a(wifiManager);
        r7.f("Utils", "current state: " + a2);
        return a2 == 3;
    }

    public static String C2(String str, boolean z) {
        String str2 = "^" + Environment.getExternalStorageDirectory().toString() + File.separator;
        if (!z) {
            str2 = str2 + "?";
        }
        return str.replaceFirst(str2, "");
    }

    public static boolean C3(String str, File file, boolean z) {
        try {
            return G3(str, new FileWriter(file, z));
        } catch (IOException unused) {
            return false;
        }
    }

    public static boolean D(OutputStream outputStream) {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e2) {
                r7.l("Utils", "failed to close output stream", e2);
                return false;
            }
        }
        return true;
    }

    public static float D0() {
        return e;
    }

    public static Integer D1(String str) {
        if (str == null) {
            return null;
        }
        try {
            return Integer.valueOf(Integer.parseInt(str, 16));
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    public static void D2(ViewGroup viewGroup, int i2) {
        viewGroup.removeViewInLayout(viewGroup.findViewById(i2));
    }

    public static Float D3(String str) {
        try {
            return Float.valueOf(Float.parseFloat(str));
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    public static boolean E(Reader reader) {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e2) {
                r7.l("Utils", "failed to close reader", e2);
                return false;
            }
        }
        return true;
    }

    public static float E0() {
        return g;
    }

    public static void E1(EditText editText, int i2) {
        String obj = editText.getText().toString();
        int i3 = 1;
        int i4 = -1;
        int i5 = -1;
        while (true) {
            if (i3 > i2) {
                break;
            }
            int indexOf = obj.indexOf(10, i4 + 1);
            if (indexOf == -1) {
                i5 = i4;
                i4 = indexOf;
                break;
            } else {
                i3++;
                i5 = i4;
                i4 = indexOf;
            }
        }
        if (i4 == -1) {
            i4 = obj.length();
        }
        editText.setSelection(i5 + 1, i4);
    }

    public static String E2(String str) {
        File externalStorageDirectory;
        return (str.startsWith(File.separator) || (externalStorageDirectory = Environment.getExternalStorageDirectory()) == null) ? str : new File(externalStorageDirectory, str).toString();
    }

    public static Integer E3(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Integer(str);
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    public static boolean F(Collection<?> collection) {
        return collection == null || collection.size() == 0;
    }

    public static float F0() {
        return h;
    }

    public static byte[] F1(InputStream inputStream) {
        try {
            byte[] bArr = new byte[8192];
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            while (true) {
                int read = inputStream.read(bArr);
                if (read == -1) {
                    byte[] byteArray = byteArrayOutputStream.toByteArray();
                    C(inputStream);
                    return byteArray;
                }
                byteArrayOutputStream.write(bArr, 0, read);
            }
        } catch (FileNotFoundException e2) {
            r7.H("Utils", "bytesToFile", e2);
            return null;
        } catch (IOException e3) {
            r7.H("Utils", "bytesToFile", e3);
            return null;
        }
    }

    public static boolean F2(Object obj, Object obj2) {
        return obj == null ? obj2 == null : obj.equals(obj2);
    }

    public static Long F3(String str) {
        try {
            return Long.valueOf(Long.parseLong(str));
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    public static Charset G(String str) {
        Charset defaultCharset = Charset.defaultCharset();
        if (str == null) {
            r7.f("Utils", "contentTypeToCharset: null");
            return defaultCharset;
        }
        String[] split = str.split(";");
        if (split == null) {
            r7.f("Utils", "contentTypeToCharset: no spec in " + str);
            return defaultCharset;
        }
        for (String str2 : split) {
            if (str2 == null) {
                r7.f("Utils", "contentTypeToCharset: null in spec " + str);
            } else {
                String trim = str2.trim();
                if (trim.toLowerCase().startsWith("charset=")) {
                    String substring = trim.substring(8);
                    Charset v0 = v0(substring);
                    if (v0 != null) {
                        r7.f("Utils", "contentTypeToCharset: parsed charset: " + substring + " from " + str);
                        return v0;
                    }
                    r7.f("Utils", "contentTypeToCharset: unavailable charset: " + substring + " in " + str);
                    return defaultCharset;
                }
            }
        }
        return defaultCharset;
    }

    public static String G0(String str, boolean z) {
        int length = str.length();
        int lastIndexOf = str.lastIndexOf(".");
        return (lastIndexOf > 0 && lastIndexOf != str.length() + (-1) && (length - lastIndexOf) + (-1) <= 4) ? str.substring(lastIndexOf + (!z ? 1 : 0)) : "";
    }

    public static void G1(Context context, EditText editText, String str) {
        int selectionStart = editText.getSelectionStart();
        int selectionEnd = editText.getSelectionEnd();
        try {
            editText.getText().replace(Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd), str, 0, str.length());
        } catch (Throwable th2) {
            pg.w0.X0(context, th2);
        }
    }

    public static String G2(Object obj) {
        return obj == null ? "<null>" : obj.toString();
    }

    public static boolean G3(String str, Writer writer) {
        BufferedWriter bufferedWriter;
        BufferedWriter bufferedWriter2 = null;
        try {
            try {
                bufferedWriter = new BufferedWriter(writer, 8192);
            } catch (IOException e2) {
                e = e2;
            }
        } catch (Throwable th2) {
            th = th2;
        }
        try {
            bufferedWriter.write(str);
            q0(bufferedWriter);
            return true;
        } catch (IOException e3) {
            e = e3;
            bufferedWriter2 = bufferedWriter;
            Log.w("Utils", e.toString());
            q0(bufferedWriter2);
            return false;
        } catch (Throwable th3) {
            th = th3;
            bufferedWriter2 = bufferedWriter;
            q0(bufferedWriter2);
            throw th;
        }
    }

    public static boolean H(InputStream inputStream, OutputStream outputStream) {
        try {
            byte[] bArr = new byte[8192];
            while (true) {
                int read = inputStream.read(bArr);
                if (read <= 0) {
                    C(inputStream);
                    D(outputStream);
                    return true;
                }
                outputStream.write(bArr, 0, read);
            }
        } catch (Exception e2) {
            r7.H("Utils", "copyStreams", e2);
            return false;
        }
    }

    public static String H0(File file) {
        String str = "file://" + file.toString();
        String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
        if (TextUtils.isEmpty(fileExtensionFromUrl)) {
            fileExtensionFromUrl = G0(str, false);
        }
        if (fileExtensionFromUrl.equals("html")) {
            return "text/html";
        }
        if (fileExtensionFromUrl.equals("csv")) {
            return "text/csv";
        }
        if (fileExtensionFromUrl.equals("txt")) {
            return "text/*";
        }
        MimeTypeMap singleton = MimeTypeMap.getSingleton();
        String mimeTypeFromExtension = singleton.getMimeTypeFromExtension(fileExtensionFromUrl);
        return TextUtils.isEmpty(mimeTypeFromExtension) ? singleton.getMimeTypeFromExtension(fileExtensionFromUrl.toLowerCase()) : mimeTypeFromExtension;
    }

    public static float H1(int i2) {
        if (i2 < 0) {
            return 0.0f;
        }
        if (i2 > 255) {
            return 1.0f;
        }
        return i2 / 255.0f;
    }

    public static int H2(int i2) {
        return (int) (i2 / d);
    }

    public static String H3(String str) {
        StringBuilder sb = new StringBuilder(str.length());
        for (int i2 = 0; i2 < str.length(); i2++) {
            char charAt = str.charAt(i2);
            if (Character.isLetterOrDigit(charAt) || charAt == '.') {
                sb.append(charAt);
            } else {
                sb.append("_");
            }
        }
        return sb.toString();
    }

    public static final Bundle I(Bundle bundle, String str) {
        int i2;
        Bundle bundle2 = new Bundle();
        int i3 = c6.ACTION_EDIT_ID;
        for (int i4 = c6.SCENE_JSI_ID_START; i4 >= 100000; i4 = i2) {
            i2 = 0;
            for (String str2 : bundle.keySet()) {
                if (str2 == null || !lq.l(str2)) {
                    String string = bundle.getString(str2);
                    if (string != null) {
                        int length = string.length();
                        if (length <= i3) {
                            if (!bundle2.containsKey(str2)) {
                                bundle2.putString(str2, string);
                            }
                            i2 += string.length();
                        } else {
                            r7.G("Utils", str + ": dropping var " + str2 + " length " + length + " cutoff " + i3);
                            if (bundle2.containsKey(str2)) {
                                bundle2.remove(str2);
                            }
                        }
                    }
                } else {
                    bundle2.putInt(str2, bundle.getInt(str2, StructureType.None.ordinal()));
                }
            }
            i3 /= 2;
        }
        return bundle2;
    }

    public static String I0(jf.d dVar) {
        return H0(dVar.z());
    }

    public static int[] I1(List<Integer> list) {
        int size = list.size();
        int[] iArr = new int[size];
        for (int i2 = 0; i2 < size; i2++) {
            iArr[i2] = list.get(i2).intValue();
        }
        return iArr;
    }

    public static int I2(int i2) {
        float f2 = d;
        if (f2 != -1.0f) {
            return (int) (i2 * f2);
        }
        r7.k("Utils", "scaleToDensity: density not initialized");
        return i2;
    }

    public static String I3(int i2) {
        if (i2 > 9) {
            return Integer.toString(i2);
        }
        return "0" + Integer.toString(i2);
    }

    public static int J(File file) {
        IOException e2;
        FileNotFoundException e3;
        int i2;
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file));
                try {
                    try {
                        byte[] bArr = new byte[1024];
                        boolean z = false;
                        i2 = 0;
                        while (true) {
                            try {
                                int read = bufferedInputStream2.read(bArr);
                                if (read == -1) {
                                    break;
                                }
                                for (int i3 = 0; i3 < read; i3++) {
                                    if (bArr[i3] == 10) {
                                        i2++;
                                    }
                                }
                                z = bArr[read + (-1)] != 10;
                            } catch (FileNotFoundException e4) {
                                e3 = e4;
                                bufferedInputStream = bufferedInputStream2;
                                r7.g("Utils", "countFileLines " + file, e3);
                                C(bufferedInputStream);
                                return i2;
                            } catch (IOException e5) {
                                e2 = e5;
                                bufferedInputStream = bufferedInputStream2;
                                r7.H("Utils", "countFileLines " + file, e2);
                                C(bufferedInputStream);
                                return i2;
                            }
                        }
                        if (z) {
                            i2++;
                        }
                        C(bufferedInputStream2);
                    } catch (Throwable th2) {
                        th = th2;
                        bufferedInputStream = bufferedInputStream2;
                        C(bufferedInputStream);
                        throw th;
                    }
                } catch (FileNotFoundException e6) {
                    e3 = e6;
                    bufferedInputStream = bufferedInputStream2;
                    i2 = 0;
                    r7.g("Utils", "countFileLines " + file, e3);
                    C(bufferedInputStream);
                    return i2;
                } catch (IOException e7) {
                    e2 = e7;
                    bufferedInputStream = bufferedInputStream2;
                    i2 = 0;
                    r7.H("Utils", "countFileLines " + file, e2);
                    C(bufferedInputStream);
                    return i2;
                }
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (FileNotFoundException e8) {
            e3 = e8;
        } catch (IOException e9) {
            e2 = e9;
        }
        return i2;
    }

    public static String J0(String str, String str2) {
        String encodedPath;
        File[] listFiles;
        Uri parse = Uri.parse(str);
        if (parse != null && (encodedPath = parse.getEncodedPath()) != null && (listFiles = new File(encodedPath).listFiles()) != null) {
            for (File file : listFiles) {
                String name = file.getName();
                if (name.endsWith(str2)) {
                    return name.substring(0, name.length() - str2.length());
                }
            }
        }
        return "";
    }

    public static int J1(int i2, int[] iArr) {
        if (iArr != null) {
            for (int i3 = 0; i3 < iArr.length; i3++) {
                if (i2 == iArr[i3]) {
                    return i3;
                }
            }
        }
        return -1;
    }

    public static boolean J2(Uri uri, String str) {
        String scheme;
        return (uri == null || (scheme = uri.getScheme()) == null || !scheme.equals(str)) ? false : true;
    }

    public static String J3(String str) {
        if (str.length() == 0) {
            return str;
        }
        if (str.length() == 1) {
            return str.toUpperCase();
        }
        return str.substring(0, 1).toUpperCase() + str.substring(1);
    }

    public static boolean K(File file) {
        try {
            return file.createNewFile();
        } catch (IOException unused) {
            r7.G("Utils", "failed to create " + file.toString());
            return false;
        }
    }

    public static Object K0(ContentResolver contentResolver, Uri uri, String str, Class<?> cls) {
        Object obj = null;
        try {
            Cursor query = contentResolver.query(uri, null, null, null, null);
            if (query != null) {
                if (query.moveToFirst()) {
                    int columnIndex = query.getColumnIndex(str);
                    if (columnIndex == -1) {
                        r7.G("Utils", "gffc: " + uri + ": `no column index for " + str);
                    } else if (cls.equals(String.class)) {
                        obj = query.getString(columnIndex);
                    } else if (cls.equals(Long.class)) {
                        obj = Long.valueOf(query.getLong(columnIndex));
                    }
                }
                query.close();
            }
        } catch (IllegalStateException e2) {
            r7.H("Utils", "getFirstCursorColumn: " + uri, e2);
        } catch (NullPointerException e3) {
            r7.H("Utils", "getFirstCursorColumn: " + uri, e3);
        }
        return obj;
    }

    public static String K1(int i2) {
        return (i2 & 255) + "." + ((i2 >> 8) & 255) + "." + ((i2 >> 16) & 255) + "." + ((i2 >> 24) & 255);
    }

    public static void K2(Context context, int i2) {
        Intent intent = new Intent("org.openintents.audio.action_volume_update");
        intent.putExtra("org.openintents.audio.extra_stream_type", i2);
        context.sendBroadcast(intent);
    }

    public static void K3(Context context, BroadcastReceiver broadcastReceiver) {
        try {
            context.unregisterReceiver(broadcastReceiver);
        } catch (IllegalArgumentException unused) {
        }
    }

    public static void L(EditText editText) {
        if (editText.length() > 0) {
            try {
                editText.setSelection(editText.length());
            } catch (IndexOutOfBoundsException unused) {
            }
        }
    }

    public static String L0(ContentResolver contentResolver, Uri uri, String str) {
        return (String) K0(contentResolver, uri, str, String.class);
    }

    public static int L1(int i2, List<Integer> list) {
        if (list != null) {
            for (int i3 = 0; i3 < list.size(); i3++) {
                if (i2 == list.get(i3).intValue()) {
                    return i3;
                }
            }
        }
        return -1;
    }

    public static boolean L2(Context context, String str) {
        if (context == null) {
            return false;
        }
        ActivityManager activityManager = (ActivityManager) oi.d(context, "activity", "Utils", "sr");
        String packageName = context.getPackageName();
        if (activityManager == null) {
            r7.G("Utils", vh.g(context, 2131887704, new Object[0]));
        } else {
            try {
                List<ActivityManager.RunningServiceInfo> runningServices = activityManager.getRunningServices(9999);
                for (int i2 = 0; i2 < runningServices.size(); i2++) {
                    ActivityManager.RunningServiceInfo runningServiceInfo = runningServices.get(i2);
                    if (runningServiceInfo.service.getClassName().equals(str) && runningServiceInfo.service.getPackageName().equals(packageName)) {
                        if (runningServiceInfo.pid == Process.myPid()) {
                            return true;
                        }
                        r7.f("Utils", "found service " + str + " in another process!");
                    }
                }
            } catch (Exception e2) {
                r7.l("Utils", "Could not get running services", e2);
                return false;
            }
        }
        return false;
    }

    public static void L3(Context context, long j2) {
        M3(context, j2, false);
    }

    public static boolean M(byte[] bArr, File file) {
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file, false);
            fileOutputStream.write(bArr);
            fileOutputStream.flush();
            fileOutputStream.close();
            return true;
        } catch (Exception e2) {
            r7.l("Utils", e2.getMessage(), e2);
            return false;
        }
    }

    private static String M0(int i2, int i3, char c2) {
        StringBuilder sb = new StringBuilder();
        sb.append(i2);
        sb.append(c2);
        sb.append(i3);
        return sb.toString();
    }

    public static boolean M1(ContentResolver contentResolver, String str) {
        try {
            Settings.System.getInt(contentResolver, str);
            return true;
        } catch (Settings.SettingNotFoundException unused) {
            return false;
        }
    }

    public static void M2(Activity activity, int i2, int i3) {
        TextView textView = (TextView) activity.findViewById(i2);
        if (textView != null) {
            textView.setText(vh.k(activity, i3, new Object[0]));
        }
    }

    public static void M3(Context context, long j2, boolean z) {
        Vibrator vibrator;
        if ((!z || N3(context)) && (vibrator = (Vibrator) oi.d(context, "vibrator", "Utils", "vib")) != null) {
            vibrator.cancel();
            vibrator.vibrate(new long[]{0, j2, 0, 0}, -1);
        }
    }

    public static String N(String str) {
        try {
            return URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e2) {
            r7.l("Utils", "decodingWrapper", e2);
            return str;
        }
    }

    public static int N0(ContentResolver contentResolver, int i2) {
        return O0(contentResolver, a1.d(i2));
    }

    public static boolean N1() {
        return "6.5.11".charAt(0) == 'X';
    }

    public static void N2(Context context) {
        DisplayMetrics displayMetrics;
        Display defaultDisplay;
        WindowManager windowManager = (WindowManager) oi.d(context, "window", "Utils", "sbdm");
        if (windowManager == null || (defaultDisplay = windowManager.getDefaultDisplay()) == null) {
            displayMetrics = null;
        } else {
            displayMetrics = new DisplayMetrics();
            defaultDisplay.getMetrics(displayMetrics);
        }
        if (displayMetrics == null) {
            r7.f("Utils", "use resource metrics");
            displayMetrics = context.getResources().getDisplayMetrics();
        } else {
            r7.f("Utils", "use display wm metrics");
        }
        if (displayMetrics != null) {
            e = displayMetrics.widthPixels;
            f = displayMetrics.heightPixels;
            r7.f("Utils", "record: " + e + "/" + f);
            g = displayMetrics.xdpi;
            h = displayMetrics.ydpi;
        }
    }

    public static boolean N3(Context context) {
        return R0(context).getBoolean("sHapt", true);
    }

    public static boolean O(Context context, String str) {
        try {
            if (v3(str, context.fileList()) == -1) {
                r0 = false;
            }
        } catch (Exception unused) {
            try {
                FileInputStream openFileInput = context.openFileInput(str);
                r0 = openFileInput != null;
                C(openFileInput);
            } catch (Exception unused2) {
                C(null);
                return false;
            } catch (Throwable th2) {
                C(null);
                throw th2;
            }
        }
        return r0;
    }

    public static int O0(android.content.ContentResolver r4, java.lang.String r5) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.dq.O0(android.content.ContentResolver, java.lang.String):int");
    }

    public static boolean O1() {
        return g() < 16;
    }

    public static void O2(View view, int i2) {
        P2(view, vh.g(view.getContext(), i2, new Object[0]));
    }

    public static int O3(float f2) {
        if (f2 >= 2484.0f) {
            int i2 = 0;
            while (true) {
                float[] fArr = i;
                if (i2 >= fArr.length) {
                    break;
                }
                if (fArr[i2] == f2) {
                    return j[i2];
                }
                i2++;
            }
        } else if (f2 >= 2412.0f) {
            return ((((int) f2) - 2412) / 5) + 1;
        }
        return 0;
    }

    public static String P(double d2, int i2) {
        DecimalFormat decimalFormat = new DecimalFormat("0.#");
        decimalFormat.setMaximumFractionDigits(i2);
        return decimalFormat.format(d2).replace(",", ".");
    }

    public static Intent P0() {
        File file;
        Intent intent = new Intent("android.intent.action.MEDIA_MOUNTED");
        try {
            file = Environment.getExternalStorageDirectory();
        } catch (NullPointerException e2) {
            e2.printStackTrace();
            file = null;
        }
        if (file != null) {
            intent.setData(Uri.parse("file://" + file));
        }
        return intent;
    }

    public static boolean P1() {
        return g() >= 21;
    }

    public static void P2(View view, String str) {
        view.setContentDescription(str);
    }

    public static void Q(Context context, String str, Uri uri, File file, String str2, String str3) {
        Random random = new Random();
        File p1 = p1();
        if (p1 == null) {
            c0(context, 2131887846, new Object[0]);
            return;
        }
        if (uri.toString().contains("%20")) {
            c0(context, 2131887918, new Object[0]);
            return;
        }
        if (str3 != null) {
            f0(context, str, uri.getLastPathSegment(), 0);
        }
        uri.getHost();
        File file2 = new File(p1, Integer.toString(random.nextInt()));
        net.dinglisch.android.taskerm.c cVar = new net.dinglisch.android.taskerm.c(118);
        cVar.k0(0, uri.toString());
        cVar.k0(2, "");
        cVar.k0(3, "");
        cVar.s1(5, 30);
        cVar.k0(6, str2);
        cVar.k0(7, A2(file2).toString());
        net.dinglisch.android.taskerm.c cVar2 = new net.dinglisch.android.taskerm.c(400);
        cVar2.k0(0, A2(file2).toString());
        cVar2.k0(1, A2(file).toString());
        cVar2.m1(2, false);
        tn X1 = to.X1();
        X1.G(str);
        X1.D2(51);
        X1.a0(cVar);
        X1.a0(cVar2);
        if (str2.endsWith(c6.ZIP_LABEL)) {
            net.dinglisch.android.taskerm.c cVar3 = new net.dinglisch.android.taskerm.c(422);
            cVar3.k0(0, A2(file).toString());
            cVar3.m1(1, true);
            X1.a0(cVar3);
        }
        if (str3 != null) {
            net.dinglisch.android.taskerm.c cVar4 = new net.dinglisch.android.taskerm.c(548);
            cVar4.k0(0, str3);
            cVar4.m1(1, true);
            X1.a0(cVar4);
        }
        ExecuteService.e6(context, X1, null, null, true);
    }

    public static String Q0(ContentResolver contentResolver, Uri uri, String str, String str2, String str3) {
        String str4;
        Cursor cursor = null;
        r6 = null;
        r6 = null;
        String str5 = null;
        Cursor cursor2 = null;
        try {
            Cursor query = contentResolver.query(uri, null, null, null, null);
            if (query != null) {
                try {
                    int columnIndex = query.getColumnIndex(str3);
                    int columnIndex2 = query.getColumnIndex(str);
                    while (true) {
                        if (!query.moveToNext()) {
                            break;
                        }
                        if (str2.equals(query.getString(columnIndex2))) {
                            str5 = query.getString(columnIndex);
                            break;
                        }
                    }
                    query.close();
                } catch (IllegalStateException unused) {
                    String str6 = str5;
                    cursor2 = query;
                    str4 = str6;
                    if (cursor2 != null) {
                        cursor2.close();
                    }
                    return str4;
                } catch (Throwable th2) {
                    th = th2;
                    cursor = query;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            }
            if (query == null) {
                return str5;
            }
            query.close();
            return str5;
        } catch (IllegalStateException unused2) {
            str4 = null;
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static boolean Q1(Context context) {
        return R1(context.getResources());
    }

    public static int Q2(Context context, EditText editText, int i2) {
        int selectionStart = editText.getSelectionStart();
        int selectionEnd = editText.getSelectionEnd();
        int inputType = editText.getInputType();
        oi.o(editText, i2);
        try {
            editText.setSelection(selectionStart, selectionEnd);
        } catch (Throwable th2) {
            pg.w0.X0(context, th2);
        }
        return inputType;
    }

    public static void R(Context context, boolean z) {
        if (O1()) {
            Class[] clsArr = {ReceiverStaticInternal.class, ReceiverStaticNotification.class, ReceiverStaticPhoneState.class, ReceiverStaticMediaButton.class, ReceiverStaticCallRewriter.class, ReceiverStaticCallBlocker.class};
            for (int i2 = 0; i2 < 6; i2++) {
                th.R(context, clsArr[i2].getName(), true);
            }
        }
    }

    public static SharedPreferences R0(Context context) {
        return context.getSharedPreferences(g6.g, 0);
    }

    public static boolean R1(Resources resources) {
        if (resources != null) {
            return resources.getConfiguration().orientation == 2;
        }
        r7.G("Utils", "isLandscape: no resources");
        return false;
    }

    private static void R2(ListView listView, int i2) {
        ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
        int count = listView.getAdapter().getCount();
        layoutParams.height = listView.getPaddingBottom() + listView.getPaddingTop() + (i2 * count) + I2(listView.getDividerHeight() * (count - 1));
        listView.setLayoutParams(layoutParams);
        listView.requestLayout();
    }

    public static String S(String str) {
        try {
            return URLEncoder.encode(str, "UTF-8");
        } catch (UnsupportedEncodingException e2) {
            r7.l("Utils", "encodingWrapper", e2);
            return str;
        }
    }

    public static SharedPreferences S0(Context context) {
        return context.getSharedPreferences(g6.j, 0);
    }

    public static boolean S1() {
        return g() >= 23;
    }

    public static void S2(ListView listView, int i2) {
        if (listView.getAdapter() == null) {
            r7.G("Utils", "setListHeightBasedOnChildHeight: no adapter");
        } else {
            R2(listView, i2);
        }
    }

    public static Double T(String str) {
        if (b == null) {
            b = Pattern.compile("(-?\\d+(?:\\.\\d+)?)");
        }
        Matcher matcher = b.matcher(str);
        if (matcher.find()) {
            return B3(matcher.group());
        }
        return null;
    }

    public static int T0(Context context) {
        int U0;
        boolean hasPermanentMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
        boolean deviceHasKey = KeyCharacterMap.deviceHasKey(4);
        if (!hasPermanentMenuKey && !deviceHasKey) {
            Resources resources = context.getResources();
            int i2 = resources.getConfiguration().orientation;
            if (V1(context)) {
                U0 = V0(resources, i2);
                if (U0 == 0) {
                    U0 = U0(resources, i2);
                }
            } else {
                U0 = U0(resources, i2);
            }
            if (U0 > 0) {
                return resources.getDimensionPixelSize(U0);
            }
        }
        return b1(context).y - Math.round(A0());
    }

    public static boolean T1() {
        return g() >= 24;
    }

    public static void T2(View view, int i2, boolean z) {
        U2(view, vh.g(view.getContext(), i2, new Object[0]), z);
    }

    public static Long U(String str) {
        if (c == null) {
            c = Pattern.compile("(-?\\d+)");
        }
        Matcher matcher = c.matcher(str);
        if (matcher.find()) {
            return F3(matcher.group());
        }
        return null;
    }

    private static int U0(Resources resources, int i2) {
        return resources.getIdentifier(i2 == 1 ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
    }

    public static boolean U1() {
        return g() >= 26;
    }

    public static void U2(View view, final String str, boolean z) {
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public final boolean onLongClick(View view2) {
                boolean d2;
                d2 = dq.d2(str, view2);
                return d2;
            }
        });
        if (z) {
            view.setContentDescription(str);
        }
    }

    public static boolean V(File file, String[] strArr) {
        return W(file, strArr) != null;
    }

    private static int V0(Resources resources, int i2) {
        return resources.getIdentifier(i2 == 1 ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
    }

    private static boolean V1(Context context) {
        return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
    }

    public static void V2(Context context, boolean z, String str) {
        int i2;
        SharedPreferences sharedPreferences = context.getSharedPreferences(g6.p, 0);
        int i3 = 2;
        if (z) {
            i2 = 2;
        } else {
            Iterator<Map.Entry<String, ?>> it = sharedPreferences.getAll().entrySet().iterator();
            int i4 = 2;
            while (it.hasNext()) {
                if (it.next().getValue().equals("block")) {
                    i3 = 1;
                } else {
                    i4 = 1;
                }
            }
            i2 = i3;
            i3 = i4;
        }
        if (O1()) {
            ReceiverStaticCallRewriter.c(i3 == 1);
            ReceiverStaticCallBlocker.e(i2 == 1);
        } else {
            th.Q(context, ReceiverStaticCallRewriter.class.getName(), i3);
            th.Q(context, ReceiverStaticCallBlocker.class.getName(), i2);
        }
    }

    public static String W(File file, String[] strArr) {
        String str;
        BufferedReader bufferedReader = null;
        String str2 = null;
        BufferedReader bufferedReader2 = null;
        bufferedReader = null;
        try {
            try {
                BufferedReader bufferedReader3 = new BufferedReader(new FileReader(file));
                do {
                    try {
                        String readLine = bufferedReader3.readLine();
                        if (readLine == null) {
                            break;
                        }
                        int length = strArr.length;
                        int i2 = 0;
                        while (true) {
                            if (i2 >= length) {
                                break;
                            }
                            if (readLine.contains(strArr[i2])) {
                                str2 = readLine;
                                break;
                            }
                            i2++;
                        }
                    } catch (FileNotFoundException e2) {
                        e = e2;
                        str = str2;
                        bufferedReader = bufferedReader3;
                        r7.g("Utils", "fileContainsString: " + file, e);
                        E(bufferedReader);
                        return str;
                    } catch (IOException e3) {
                        e = e3;
                        str = str2;
                        bufferedReader = bufferedReader3;
                        r7.H("Utils", "fileContainsString: " + file, e);
                        E(bufferedReader);
                        return str;
                    } catch (Throwable th2) {
                        th = th2;
                        bufferedReader2 = bufferedReader3;
                        E(bufferedReader2);
                        throw th;
                    }
                } while (str2 == null);
                E(bufferedReader3);
                return str2;
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (FileNotFoundException e4) {
            e = e4;
            str = null;
        } catch (IOException e5) {
            e = e5;
            str = null;
        }
    }

    public static int W0(Context context, boolean z) {
        Point b1 = b1(context);
        float T0 = T0(context);
        return Math.round((context.getResources().getConfiguration().orientation == 1 ? b1.y : b1.x) - ((j1(context) + T0) - (z ? T0 / 2.0f : 0.0f)));
    }

    public static boolean W1() {
        Looper mainLooper = Looper.getMainLooper();
        return mainLooper != null && mainLooper.equals(Looper.myLooper());
    }

    public static void W2(EditText editText, String str) {
        editText.setText("");
        editText.append(str);
    }

    public static String X(File file) {
        return Y(file, true);
    }

    public static NetworkInfo X0(Context context, int i2) {
        ConnectivityManager connectivityManager = (ConnectivityManager) oi.d(context, "connectivity", "Utils", "haveNet");
        if (connectivityManager == null) {
            r7.G("Utils", "no connectivity manager");
            return null;
        }
        NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
        if (allNetworkInfo == null) {
            r7.f("Utils", "haveNetwork: no network info");
            return null;
        }
        for (NetworkInfo networkInfo : allNetworkInfo) {
            int type = networkInfo.getType();
            if ((i2 == -1 || i2 == type) && networkInfo.isConnected()) {
                return networkInfo;
            }
        }
        return null;
    }

    public static String X1(String str, List<String> list) {
        StringBuilder sb = new StringBuilder();
        for (String str2 : list) {
            if (sb.length() > 0) {
                sb.append(str);
            }
            sb.append(str2);
        }
        return sb.toString();
    }

    public static void X2(EditText editText, boolean z) {
        if (z) {
            editText.setFilters(new InputFilter[0]);
        } else {
            editText.setFilters(new InputFilter[]{new c()});
        }
    }

    public static String Y(File file, boolean z) {
        try {
            return f(new InputStreamReader(new FileInputStream(file)));
        } catch (FileNotFoundException unused) {
            r7.N("Utils", z, file.toString() + " doesn't exist");
            return null;
        } catch (OutOfMemoryError unused2) {
            r7.N("Utils", z, file.toString() + " too big");
            return null;
        }
    }

    public static int Y0(Context context) {
        Resources resources = context.getResources();
        if (resources == null) {
            r7.G("Utils", "getOrientation: no resources");
        } else {
            Configuration configuration = resources.getConfiguration();
            if (configuration != null) {
                return configuration.orientation;
            }
        }
        return 0;
    }

    public static String Y1(String str, String[] strArr) {
        StringBuilder sb = new StringBuilder();
        for (String str2 : strArr) {
            if (sb.length() > 0) {
                sb.append(str);
            }
            sb.append(str2);
        }
        return sb.toString();
    }

    public static void Y2(View view, boolean z) {
        view.setVisibility(z ? 0 : 8);
    }

    private static void Z(final Context context, final String str, final int i2, final Object... objArr) {
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                dq.b2(context, str, objArr, i2);
            }
        });
    }

    public static String Z0(int i2, int i3) {
        return M0(i2, i3, ',');
    }

    public static String Z1(String[] strArr) {
        return Y1(" AND ", strArr);
    }

    public static void Z2(Context context) {
        d = context.getResources().getDisplayMetrics().density;
    }

    public static boolean a0(Context context, int i2, Object... objArr) {
        return b0(context, vh.g(context, i2, new Object[0]), objArr);
    }

    public static Intent a1() {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"));
        intent.addCategory("android.intent.category.ALTERNATIVE");
        return intent;
    }

    public static String a2(int i2) {
        return i2 == 0 ? "down" : i2 == 1 ? "up" : i2 == 2 ? "mult" : "?";
    }

    public static void a3(Context context) {
        new AlertDialog.Builder(context).setMessage(vh.g(context, 2131887365, new Object[0])).setTitle(vh.g(context, 2131887569, new Object[0])).setPositiveButton(vh.g(context, 2131886879, new Object[0]), new e(context)).setNeutralButton(vh.g(context, 2131886801, new Object[0]), new d(context)).setNegativeButton(vh.g(context, 2131886891, new Object[0]), (DialogInterface.OnClickListener) null).show();
    }

    public static boolean b0(Context context, String str, Object... objArr) {
        Z(context, vh.g(context, 2131891164, new Object[0]) + ": " + str, 1, objArr);
        return false;
    }

    public static Point b1(Context context) {
        Display defaultDisplay = ((WindowManager) oi.d(context, "window", "Utils", "gDSWN")).getDefaultDisplay();
        Point point = new Point();
        defaultDisplay.getRealSize(point);
        return point;
    }

    public static void b2(Context context, String str, Object[] objArr, int i2) {
        com.joaomgcd.taskerm.toast.d.e(context.getApplicationContext(), s0(str + ".", objArr), i2).show();
    }

    public static void b3(final Context context, View view, final String str) {
        Rect rect = new Rect();
        if (view.getGlobalVisibleRect(rect)) {
            int right = view.getRootView().getRight() / 2;
            int i2 = rect.right;
            int i3 = rect.left;
            int i4 = ((i2 - i3) / 2) + i3;
            r2 = i4 < right ? -(right - i4) : 0;
            if (i4 >= right) {
                r2 = i4 - right;
            }
        }
        final int Y = tp.Y(40);
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                dq.e2(context, str, r3, Y);
            }
        });
    }

    public static void c0(Context context, int i2, Object... objArr) {
        d0(context, vh.g(context, i2, new Object[0]), objArr);
    }

    public static File c1() {
        if (q3()) {
            return Environment.getExternalStorageDirectory();
        }
        return null;
    }

    public static void c2(Context context, String str) {
        com.joaomgcd.taskerm.toast.d.e(context.getApplicationContext(), str, 0).show();
    }

    public static void c3(Context context, EditText editText, boolean z, int i2, long j2) {
        InputMethodManager inputMethodManager = (InputMethodManager) oi.d(context, "input_method", "Utils", "shsf");
        if (i2 < 0) {
            i2 = 1;
        }
        if (inputMethodManager != null) {
            if (j2 < 0) {
                if (z) {
                    inputMethodManager.showSoftInput(editText, i2);
                    return;
                } else {
                    inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), i2);
                    return;
                }
            }
            b bVar = new b(z, inputMethodManager, editText, i2);
            if (j2 == 0) {
                editText.post(bVar);
            } else {
                editText.postDelayed(bVar, j2);
            }
        }
    }

    public static void d0(Context context, String str, Object... objArr) {
        f0(context, vh.g(context, 2131891164, new Object[0]), s0(str, objArr), 1);
    }

    public static int d1(ContentResolver contentResolver, String str) {
        try {
            return Settings.Secure.getInt(contentResolver, str);
        } catch (Settings.SettingNotFoundException unused) {
            r7.G("Utils", "getSecureIntSetting: setting not found: " + str);
            return -1;
        }
    }

    public static boolean d2(String str, View view) {
        b3(view.getContext(), view, str);
        return true;
    }

    public static boolean d3(Context context) {
        if (s1(context)) {
            return true;
        }
        InputMethodManager inputMethodManager = (InputMethodManager) oi.d(context, "input_method", "Utils", "ssk");
        if (inputMethodManager == null) {
            return false;
        }
        inputMethodManager.toggleSoftInput(2, 1);
        return true;
    }

    public static void e0(Context context, int i2, int i3, int i4) {
        f0(context, vh.g(context, i2, new Object[0]), vh.g(context, i3, new Object[0]), i4);
    }

    public static String e1(ContentResolver contentResolver, String str) {
        return Settings.Secure.getString(contentResolver, str);
    }

    public static void e2(Context context, String str, int i2, int i3) {
        com.joaomgcd.taskerm.toast.d e2 = com.joaomgcd.taskerm.toast.d.e(context.getApplicationContext(), str, 0);
        e2.setGravity(81, i2, i3);
        e2.show();
    }

    public static boolean e3(File file, int i2) {
        boolean z;
        long length = file.length();
        SecureRandom secureRandom = new SecureRandom();
        int i3 = 0;
        while (i3 < i2) {
            try {
                byte[] bArr = new byte[8192];
                RandomAccessFile randomAccessFile = null;
                try {
                    RandomAccessFile randomAccessFile2 = new RandomAccessFile(file, "rw");
                    long j2 = 0;
                    while (j2 < length) {
                        long j3 = length - j2;
                        int i4 = i3;
                        if (j3 < 8192) {
                            try {
                                bArr = new byte[(int) j3];
                            } catch (Throwable th2) {
                                th = th2;
                                randomAccessFile = randomAccessFile2;
                                if (randomAccessFile != null) {
                                    randomAccessFile.close();
                                }
                                throw th;
                            }
                        }
                        secureRandom.nextBytes(bArr);
                        randomAccessFile2.write(bArr);
                        j2 += bArr.length;
                        i3 = i4;
                    }
                    int i5 = i3;
                    randomAccessFile2.close();
                    i3 = i5 + 1;
                } catch (Throwable th3) {
                    th = th3;
                }
            } catch (Exception e2) {
                r7.l("Utils", "wipe", e2);
                z = false;
            }
        }
        z = true;
        r7.f("Utils", "shred2: " + file + "/" + i2 + " times: " + z);
        return z;
    }

    public static String f(InputStreamReader inputStreamReader) {
        String str;
        StringBuffer stringBuffer;
        BufferedReader bufferedReader;
        int read;
        Reader reader = null;
        BufferedReader bufferedReader2 = null;
        try {
            try {
                stringBuffer = new StringBuffer(8193);
                bufferedReader = new BufferedReader(inputStreamReader, 8192);
            } catch (Throwable th2) {
                th = th2;
            }
        } catch (IOException e2) {
            e = e2;
        }
        try {
            char[] cArr = new char[8192];
            while (true) {
                read = bufferedReader.read(cArr);
                if (read == -1) {
                    break;
                }
                stringBuffer.append(cArr, 0, read);
            }
            str = stringBuffer.toString();
            E(bufferedReader);
            reader = read;
        } catch (IOException e3) {
            e = e3;
            bufferedReader2 = bufferedReader;
            r7.k("Utils", e.getMessage());
            E(bufferedReader2);
            str = "";
            reader = bufferedReader2;
            return str;
        } catch (Throwable th3) {
            th = th3;
            reader = bufferedReader;
            E(reader);
            throw th;
        }
        return str;
    }

    public static void f0(Context context, String str, String str2, int i2) {
        g0(context, str, str2, null, i2);
    }

    public static ArrayAdapter<String> f1(Context context, int i2) {
        return h1(context, vh.i(context, i2));
    }

    public static int f2(String str, String str2, CharSequence charSequence, CharSequence charSequence2) {
        if (charSequence == null || charSequence2 == null) {
            return 0;
        }
        String charSequence3 = charSequence.toString();
        String charSequence4 = charSequence2.toString();
        if (str != null) {
            if (str.equals(charSequence3)) {
                return -1;
            }
            if (str.equals(charSequence4)) {
                return 1;
            }
        }
        if (str2 != null) {
            if (str2.equals(charSequence3)) {
                return 1;
            }
            if (str2.equals(charSequence4)) {
                return -1;
            }
        }
        return charSequence3.compareToIgnoreCase(charSequence4);
    }

    public static List<String> f3(List<String> list) {
        Collections.sort(list, new f());
        return list;
    }

    public static int g() {
        return Build.VERSION.SDK_INT;
    }

    public static void g0(Context context, String str, String str2, net.dinglisch.android.taskerm.g gVar, int i2) {
        final com.joaomgcd.taskerm.toast.d dVar = new com.joaomgcd.taskerm.toast.d(context, new Toast(context));
        Drawable drawable = null;
        View inflate = ((LayoutInflater) oi.d(context, "layout_inflater", "Utils", "flashIT")).inflate(2131494256, (ViewGroup) null);
        TextView textView = (TextView) inflate.findViewById(2131297590);
        if (textView == null) {
            r7.k("Utils", "Can't show flashImageToast. TextView is null");
            return;
        }
        textView.setText(str2);
        ImageView imageView = (ImageView) inflate.findViewById(2131296972);
        if (gVar != null) {
            try {
                drawable = gVar.E(context);
            } catch (Exception unused) {
            }
        }
        if (drawable == null) {
            imageView.setImageResource(ExtensionsContextKt.G0(context));
        } else {
            imageView.setImageDrawable(drawable);
        }
        ((TextView) inflate.findViewById(2131297638)).setText(str);
        dVar.setView(inflate);
        dVar.f(2131297638, 2131297590, 2131296972);
        dVar.setDuration(i2);
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                com.joaomgcd.taskerm.toast.d.this.show();
            }
        });
    }

    public static ArrayAdapter<String> g1(Context context, List<String> list) {
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, R.layout.simple_list_item_1, list);
        arrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
        return arrayAdapter;
    }

    public static List<File> g2(File file, boolean z, boolean z2, int i2, int i3) {
        ArrayList arrayList = new ArrayList();
        ArrayList<File> arrayList2 = new ArrayList();
        if (file != null) {
            try {
                File[] listFiles = file.listFiles();
                if (listFiles != null) {
                    for (File file2 : listFiles) {
                        if (file2.isDirectory()) {
                            if (z) {
                                arrayList2.add(file2);
                            }
                        } else if (!z2 || a.contains(G0(file2.getName(), false))) {
                            arrayList.add(file2);
                            if (arrayList.size() + i3 >= i2) {
                                break;
                            }
                        }
                    }
                }
            } catch (NullPointerException e2) {
                r7.g("Utils", "listMusicFilesRec: " + file, e2);
            }
        }
        Collections.sort(arrayList);
        for (File file3 : arrayList2) {
            if (arrayList.size() >= i2) {
                break;
            }
            arrayList.addAll(g2(file3, true, z2, i2, arrayList.size()));
        }
        return arrayList;
    }

    public static CharSequence[] g3(CharSequence[] charSequenceArr, final String str, final String str2) {
        Arrays.sort(charSequenceArr, new Comparator() {
            @Override
            public final int compare(Object obj, Object obj2) {
                int f2;
                f2 = dq.f2(str, str2, (CharSequence) obj, (CharSequence) obj2);
                return f2;
            }
        });
        return charSequenceArr;
    }

    public static boolean h(Context context) {
        return S0(context).getBoolean("dscl", false);
    }

    public static void h0(Context context, int i2, Object... objArr) {
        i0(context, vh.g(context, i2, new Object[0]), objArr);
    }

    public static ArrayAdapter<String> h1(Context context, String[] strArr) {
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, R.layout.simple_spinner_item, strArr);
        arrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
        return arrayAdapter;
    }

    public static String h2(List<?> list, char c2) {
        if (list == null) {
            return "null";
        }
        StringBuilder sb = new StringBuilder();
        Iterator<?> it = list.iterator();
        while (it.hasNext()) {
            Object next = it.next();
            if (sb.length() != 0) {
                sb.append(c2);
            }
            sb.append(next == null ? "null" : next.toString());
        }
        return sb.toString();
    }

    public static Integer[] h3(Set<Integer> set) {
        Integer[] numArr = new Integer[set.size()];
        set.toArray(numArr);
        Arrays.sort(numArr);
        return numArr;
    }

    public static File i(File file, String str) {
        return new File(file.toString() + str);
    }

    public static void i0(Context context, String str, Object... objArr) {
        Z(context, J3(str), 1, objArr);
    }

    public static String i1(int i2, int i3) {
        return M0(i2, i3, 'x');
    }

    public static String[] i2(List<?> list) {
        int size = list.size();
        String[] strArr = new String[size];
        for (int i2 = 0; i2 < size; i2++) {
            strArr[i2] = list.get(i2).toString();
        }
        return strArr;
    }

    public static Long[] i3(Set<Long> set, boolean z) {
        Long[] lArr = new Long[set.size()];
        set.toArray(lArr);
        Arrays.sort(lArr, new a(z));
        return lArr;
    }

    public static File j(File file, String str) {
        return file.getName().endsWith(str) ? file : i(file, str);
    }

    public static void j0(Context context, int i2, Object... objArr) {
        l0(context, vh.g(context, i2, new Object[0]), objArr);
    }

    public static float j1(Context context) {
        return context.getResources().getIdentifier("status_bar_height", "dimen", "android") > 0 ? context.getResources().getDimensionPixelSize(r0) : y0() * 25.0f;
    }

    public static int j2(Object obj, List<?> list) {
        if (list != null) {
            for (int i2 = 0; i2 < list.size(); i2++) {
                if (obj.equals(list.get(i2))) {
                    return i2;
                }
            }
        }
        return -1;
    }

    public static boolean j3(List<String> list, Comparator<String> comparator, String str, String str2) {
        try {
            Collections.sort(list, comparator);
            return true;
        } catch (Exception e2) {
            r7.k(str, str2 + ": " + e2.toString());
            r7.k(str, h2(list, ','));
            return false;
        }
    }

    public static void k(Intent intent, boolean z) {
        intent.addFlags(268435456);
        intent.addFlags(4);
        intent.addFlags(8388608);
        intent.addFlags(262144);
        if (z) {
            return;
        }
        intent.addFlags(1073741824);
    }

    public static void k0(final Context context, final String str) {
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                dq.c2(context, str);
            }
        });
    }

    public static File k1() {
        return new File(Environment.getExternalStorageDirectory(), g6.c);
    }

    public static boolean k2(List<String> list, List<String> list2) {
        if (list == null) {
            return list2 == null;
        }
        if (list2 == null || list.size() != list2.size()) {
            return false;
        }
        List<String> subList = list.subList(0, list.size());
        Collections.sort(subList);
        List<String> subList2 = list2.subList(0, list2.size());
        Collections.sort(subList2);
        for (int i2 = 0; i2 < subList.size(); i2++) {
            if (!subList.get(i2).equals(subList2.get(i2))) {
                return false;
            }
        }
        return true;
    }

    public static String k3(String str) {
        return str != null ? (str.equals("net.dinglisch.android.tasker") || str.equals("net.dinglisch.android.taskercupcake") || str.equals("net.dinglisch.android.taskerm")) ? th.B() : str : str;
    }

    public static void l(Context context, Menu menu, int i2, int i3) {
        menu.add(0, i2, 0, vh.g(context, 2131888880, new Object[0]));
        menu.add(0, i3, 0, vh.g(context, 2131889085, new Object[0]));
    }

    public static void l0(Context context, String str, Object... objArr) {
        Z(context, J3(str), 0, objArr);
    }

    public static File l1(String str, boolean z) {
        if (c1() == null) {
            return null;
        }
        File k1 = k1();
        if (z) {
            o2(k1);
        }
        File file = new File(k1, str);
        if (z) {
            p2(file, true);
        }
        if (file.exists()) {
            return file;
        }
        return null;
    }

    public static void l2(String str, Bundle bundle) {
        m2(str, bundle, "\t");
    }

    public static boolean l3(Context context, Intent intent) {
        return m3(context, intent, false);
    }

    public static void m(HashMap<String, List<String>> hashMap, String str, String str2) {
        List<String> list;
        if (hashMap.containsKey(str)) {
            list = hashMap.get(str);
        } else {
            LinkedList linkedList = new LinkedList();
            hashMap.put(str, linkedList);
            list = linkedList;
        }
        list.add(str2);
    }

    public static void m0(View view, long j2) {
        view.postDelayed(new g(view), j2);
    }

    public static String m1(TextView textView) {
        CharSequence text;
        return (textView == null || (text = textView.getText()) == null) ? "" : text.toString().trim();
    }

    private static void m2(String str, Bundle bundle, String str2) {
        if (r7.K()) {
            if (bundle == null) {
                if (str != null) {
                    r7.f("Utils", str + ": null");
                    return;
                }
                return;
            }
            if (bundle.size() <= 0) {
                if (str != null) {
                    r7.f("Utils", str + ": empty");
                    return;
                }
                return;
            }
            if (str != null) {
                r7.f("Utils", str);
            }
            for (String str3 : bundle.keySet()) {
                try {
                    Object obj = bundle.get(str3);
                    String str4 = str2 + str3 + " / ";
                    if (obj == null) {
                        r7.f("Utils", str4 + "null");
                    } else {
                        String str5 = str4 + obj.getClass().getSimpleName();
                        if (obj.getClass().equals(Bundle.class)) {
                            r7.f("Utils", str5 + ConstantsCommonTaskerServer.ID_SEPARATOR);
                            m2(null, (Bundle) obj, str2 + "\t");
                        } else {
                            r7.f("Utils", str5 + " / " + G2(obj));
                        }
                    }
                } catch (Exception e2) {
                    r7.f("Utils", e2.toString());
                }
            }
        }
    }

    public static boolean m3(Context context, Intent intent, boolean z) {
        try {
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException unused) {
            if (z) {
                r7.k("Utils", "startActivityWrapper: activity not found");
            } else {
                r7.f("Utils", "startActivityWrapper: activity not found");
            }
            r7.y("startActivityWrapper", intent, false);
            return false;
        } catch (Exception e2) {
            String str = "startActivityWrapper: unexpected exception: " + e2.getMessage();
            if (z) {
                r7.k("Utils", str);
                return false;
            }
            r7.H("Utils", str, e2);
            return false;
        }
    }

    public static void n(HashMap<String, HashSet<String>> hashMap, String str, String str2) {
        HashSet<String> hashSet;
        if (hashMap.containsKey(str)) {
            hashSet = hashMap.get(str);
        } else {
            HashSet<String> hashSet2 = new HashSet<>();
            hashMap.put(str, hashSet2);
            hashSet = hashSet2;
        }
        hashSet.add(str2);
    }

    public static boolean n0(Context context, int i2, Object... objArr) {
        return o0(context, vh.g(context, i2, new Object[0]), objArr);
    }

    public static int n1(String str, Paint paint) {
        int length = str.length();
        float[] fArr = new float[length];
        paint.getTextWidths(str, fArr);
        int i2 = 0;
        for (int i3 = 0; i3 < length; i3++) {
            i2 = (int) (i2 + fArr[i3]);
        }
        return i2;
    }

    public static boolean n2(String str) {
        if (str == null) {
            return false;
        }
        if (m == null) {
            m = Pattern.compile(l, 0);
        }
        return m.matcher(str).find();
    }

    public static void n3(Context context, boolean z) {
        if (z) {
            MonitorService.j8(context, false);
        }
        yi.k();
    }

    public static void o(EditText editText, String str, String str2) {
        if (editText.length() > 0) {
            if (!editText.getText().toString().matches(Pattern.quote(str2) + "\\s*$")) {
                editText.append(str2);
            }
        }
        editText.append(str);
    }

    public static boolean o0(Context context, String str, Object... objArr) {
        Z(context, vh.g(context, 2131891282, new Object[0]) + ": " + str, 1, objArr);
        return false;
    }

    public static Thread.State o1(Thread thread) {
        Thread.State state = null;
        int i2 = 0;
        while (state == null && i2 < 4) {
            try {
                state = thread.getState();
            } catch (ArrayIndexOutOfBoundsException e2) {
                r7.g("Utils", "failed to get thread state", e2);
                try {
                    Thread.sleep(100L);
                } catch (InterruptedException unused) {
                }
            }
            i2++;
        }
        if (state == null) {
            r7.f("Utils", "getThreadState: bail out after " + i2 + " tries");
        } else if (i2 > 1) {
            r7.f("Utils", "getThreadState: succeeded on try " + i2);
        }
        return state;
    }

    public static boolean o2(File file) {
        return p2(file, false);
    }

    public static void o3(Context context, Class<?> cls) {
        boolean L2 = L2(context, cls.getName());
        if (context.stopService(new Intent(context, cls)) || !L2) {
            return;
        }
        r7.k("Utils", "failed to stop service when running");
        o0(context, vh.g(context, 2131891072, new Object[0]) + cls.getSimpleName(), new Object[0]);
    }

    public static void p(EditText editText, String str) {
        o(editText, str, "/");
    }

    public static String p0(float f2, int i2) {
        String f3 = Float.toString(f2);
        int indexOf = f3.indexOf(".") + i2 + 1;
        return indexOf >= f3.length() ? f3 : f3.substring(0, indexOf);
    }

    public static File p1() {
        return l1("cache/tmp", true);
    }

    public static boolean p2(File file, boolean z) {
        if (file == null) {
            r7.G("Utils", "mkdirIfNeeded: null file");
            return false;
        }
        if (file.exists()) {
            return true;
        }
        if (file.mkdirs()) {
            if (z) {
                K(new File(file, ".nomedia"));
            }
            return true;
        }
        r7.G("Utils", "mkdirIfNeeded: failed to create dir: " + file);
        return false;
    }

    public static void p3(Context context) {
        ExecuteService.f8(context);
        MonitorService.z8(context, true);
        o3(context, ExecuteService.class);
        wl.r(context);
        if (S1()) {
            ph.c();
        }
        ExecuteService.o8(context);
        kp.U0((AlarmManager) oi.d(context, "alarm", "Utils", "stopTasker"));
        r7.n();
        yi.k();
    }

    public static void q(StringBuilder sb, String str, char c2) {
        if (sb.length() != 0) {
            sb.append(c2);
        }
        sb.append(str);
    }

    public static boolean q0(Writer writer) {
        if (writer != null) {
            try {
                writer.flush();
                writer.close();
            } catch (IOException e2) {
                Log.e("Utils", "failed to close output stream" + e2.toString());
                return false;
            }
        }
        return true;
    }

    public static String q1(boolean z) {
        StringBuilder sb = new StringBuilder();
        sb.append("Tasker/");
        sb.append("6.5.11");
        if (z) {
            sb.append(" (Android/");
            sb.append(Build.VERSION.RELEASE);
            sb.append(')');
        }
        return sb.toString();
    }

    public static final File q2(File file, File file2) {
        File file3 = new File(file2, file.getName());
        if (file.renameTo(file3)) {
            return file3;
        }
        return null;
    }

    public static boolean q3() {
        try {
            return Environment.getExternalStorageState().equals("mounted");
        } catch (Exception e2) {
            r7.k("Utils", "storageMounted: " + e2);
            return false;
        }
    }

    public static boolean r(Object[] objArr) {
        return objArr == null || objArr.length == 0;
    }

    public static String r0(Context context, int i2, Object... objArr) {
        return s0(vh.g(context, i2, new Object[0]), objArr);
    }

    public static void r1(Context context, boolean z, boolean z2) {
        try {
            r7.f("Utils", "grabReleaseMediaButton: " + z + " newAPI: " + z2);
            String name = ReceiverStaticMediaButton.class.getName();
            if (z2 && !S1()) {
                r7.G("Utils", "refusing to use new API < marshmallow");
                z2 = false;
            }
            if (z2) {
                if (z) {
                    ph.a(context);
                    return;
                } else {
                    ph.c();
                    return;
                }
            }
            ComponentName componentName = new ComponentName(context.getPackageName(), name);
            AudioManager audioManager = (AudioManager) oi.d(context, "audio", "Utils", "grmb");
            yd.e.g(audioManager, componentName);
            if (z) {
                yd.e.e(audioManager, componentName);
            }
            if (O1()) {
                ReceiverStaticMediaButton.b(z);
            } else {
                th.R(context, name, z);
            }
        } catch (Exception e2) {
            r7.l("Utils", "grabReleaseMediaButton", e2);
        }
    }

    public static String r2(Context context, String str) {
        try {
            return f(new InputStreamReader(context.openFileInput(str)));
        } catch (FileNotFoundException unused) {
            r7.f("Utils", "fisToString, fnf " + str);
            return null;
        } catch (Exception unused2) {
            return null;
        }
    }

    public static List<String> r3(String[] strArr, String str) {
        LinkedList linkedList = new LinkedList();
        if (strArr != null) {
            String lowerCase = str.toLowerCase();
            for (String str2 : strArr) {
                if (str2.toLowerCase().contains(lowerCase)) {
                    linkedList.add(str2);
                }
            }
        }
        return linkedList;
    }

    public static int s(Bundle bundle) {
        if (bundle == null) {
            return -1;
        }
        int i2 = bundle.getInt("level", -1);
        int i3 = bundle.getInt("scale", -1);
        if (i2 < 0 || i3 <= 0) {
            return -1;
        }
        return (i2 * 100) / i3;
    }

    public static String s0(String str, Object... objArr) {
        try {
            return String.format(str, objArr);
        } catch (Exception unused) {
            return str;
        }
    }

    public static boolean s1(Context context) {
        Resources resources = context.getResources();
        if (resources != null) {
            return resources.getConfiguration().hardKeyboardHidden == 1;
        }
        r7.G("Utils", "hardKeyboardShowing: no resources");
        return false;
    }

    public static void s2() {
        if (Looper.myLooper() == null) {
            Looper.prepare();
        }
    }

    public static boolean s3(String str, String[] strArr) {
        return v3(str, strArr) != -1;
    }

    public static boolean t(byte[] bArr, OutputStream outputStream) {
        try {
            if (!H(new ByteArrayInputStream(bArr), outputStream)) {
                r7.G("Utils", "bytesToOutputStream: copy stream failed");
                return false;
            }
            outputStream.flush();
            D(outputStream);
            return true;
        } catch (FileNotFoundException e2) {
            r7.H("Utils", "bytesToOutputStream", e2);
            return false;
        } catch (IOException e3) {
            r7.H("Utils", "bytesToOutputStream", e3);
            return false;
        }
    }

    public static String t0() {
        return String.valueOf(e) + "," + String.valueOf(f);
    }

    public static boolean t1(Context context) {
        return x1(context, -1);
    }

    public static String[] t2(String str, String[] strArr) {
        String[] strArr2 = new String[strArr.length + 1];
        int i2 = 0;
        while (i2 < strArr.length) {
            int i3 = i2 + 1;
            strArr2[i3] = strArr[i2];
            i2 = i3;
        }
        strArr2[0] = str;
        return strArr2;
    }

    public static String t3(String[] strArr) {
        return u3(strArr, ",");
    }

    public static int u(String str) {
        int i2 = 0;
        for (int i3 = 0; i3 < str.length(); i3++) {
            i2 += str.charAt(i3) * i3;
        }
        return i2;
    }

    public static String u0(Rect rect) {
        return Z0(rect.left, rect.top) + ' ' + i1(rect.width(), rect.height());
    }

    public static boolean u1(Context context, String str) {
        return yd.d.c(context) && yd.d.a(yd.d.b(context), str, Process.myUid(), context.getPackageName()) == 0;
    }

    public static String u2(String str) {
        return "'" + str.replaceAll("'", "\\\\'") + "'";
    }

    public static String u3(String[] strArr, String str) {
        StringBuilder sb = new StringBuilder();
        if (strArr == null) {
            sb.append("<null>");
        } else {
            for (String str2 : strArr) {
                if (sb.length() > 0) {
                    sb.append(str);
                }
                sb.append(str2);
            }
        }
        return sb.toString();
    }

    public static int v(String str) {
        int i2 = 0;
        for (int i3 = 0; i3 < str.length(); i3++) {
            i2 = str.charAt(i3) + ((i2 << 5) - i2);
        }
        return i2;
    }

    public static Charset v0(String str) {
        try {
            return Charset.forName(str);
        } catch (IllegalCharsetNameException | UnsupportedCharsetException unused) {
            return null;
        }
    }

    public static boolean v1() {
        return (e == -1.0f && f == -1.0f) ? false : true;
    }

    public static String v2(String str, boolean z) {
        String quote = JSONObject.quote(str);
        if (quote != null) {
            return (z || quote.length() < 2 || !quote.startsWith("\"") || !quote.endsWith("\"")) ? quote : quote.substring(1, quote.length() - 1);
        }
        r7.G("Utils", "null result from JSON replacement of " + str);
        return str;
    }

    public static int v3(String str, String[] strArr) {
        if (strArr != null && str != null) {
            for (int i2 = 0; i2 < strArr.length; i2++) {
                if (str.equals(strArr[i2])) {
                    return i2;
                }
            }
        }
        return -1;
    }

    public static boolean w(PackageManager packageManager) {
        boolean z;
        if (w1(packageManager, "sms")) {
            z = true;
        } else {
            r7.f("Utils", "no SMS provider");
            z = false;
        }
        if (!w1(packageManager, "mms")) {
            r7.f("Utils", "no MMS provider");
            z = false;
        }
        if (w1(packageManager, "mms-sms")) {
            return z;
        }
        r7.f("Utils", "no MMS-SMS provider");
        return false;
    }

    public static Object w0(String str, Bundle bundle, String str2, Class<?> cls, boolean z) {
        if (!bundle.containsKey(str2)) {
            if (!z) {
                return null;
            }
            r7.G(str, "extra " + str2 + ": absent and required");
            return null;
        }
        Object obj = bundle.get(str2);
        if (obj == null) {
            r7.G(str, "extra " + str2 + ": null");
        } else if (!obj.getClass().equals(cls)) {
            r7.G(str, "extra " + str2 + ": class mismatch, exected " + cls.getName() + " got " + obj.getClass().getName());
            return null;
        }
        return obj;
    }

    public static final boolean w1(PackageManager packageManager, String str) {
        return packageManager.resolveContentProvider(str, 0) != null;
    }

    public static boolean w2(File file) {
        File[] listFiles = file.listFiles();
        boolean z = true;
        if (listFiles == null) {
            return true;
        }
        for (File file2 : listFiles) {
            if (file2.isDirectory()) {
                z = w2(file2);
            } else if (!file2.delete()) {
                z = false;
            }
            if (!z) {
                break;
            }
        }
        if (!z || file.delete()) {
            return z;
        }
        return false;
    }

    public static String[] w3(List<String> list) {
        if (list == null) {
            return null;
        }
        int size = list.size();
        String[] strArr = new String[size];
        for (int i2 = 0; i2 < size; i2++) {
            strArr[i2] = list.get(i2);
        }
        return strArr;
    }

    public static void x(ListView listView, int i2) {
        if (listView != null && listView.getChildCount() > 0) {
            listView.setSelectionFromTop(i2, (listView.getHeight() / 2) - listView.getChildAt(0).getHeight());
        }
    }

    public static InputMethodInfo x0(Context context) {
        try {
            InputMethodManager inputMethodManager = (InputMethodManager) oi.d(context, "input_method", "Utils", "gcim");
            InputMethodSubtype currentInputMethodSubtype = inputMethodManager.getCurrentInputMethodSubtype();
            if (currentInputMethodSubtype == null) {
                r7.f("Utils", "getCurInputMethod: null subtype");
                return null;
            }
            for (InputMethodInfo inputMethodInfo : inputMethodManager.getEnabledInputMethodList()) {
                for (int i2 = 0; i2 < inputMethodInfo.getSubtypeCount(); i2++) {
                    if (inputMethodInfo.getSubtypeAt(i2).equals(currentInputMethodSubtype)) {
                        return inputMethodInfo;
                    }
                }
            }
            return null;
        } catch (Throwable th2) {
            r7.l("Utils", "getCurInputMethod: error getting", th2);
            return null;
        }
    }

    public static boolean x1(Context context, int i2) {
        return X0(context, i2) != null;
    }

    public static File x2(File file) {
        int lastIndexOf;
        String name = file.getName();
        return (name.length() < 3 || (lastIndexOf = name.lastIndexOf(".")) <= 0) ? file : new File(file.getParent(), name.substring(0, lastIndexOf));
    }

    public static String x3(List<String> list) {
        return h2(list, ' ');
    }

    public static String y(CharSequence charSequence) {
        return charSequence == null ? "" : charSequence.toString();
    }

    public static float y0() {
        return d;
    }

    public static boolean y1(Context context, String str) {
        boolean z1 = z1(context, str);
        if (z1 || !str.equals(sd.c)) {
            return z1;
        }
        if (g() >= 19 && !z1(context, sd.b)) {
            return z1;
        }
        return true;
    }

    public static File y2(File file, String str) {
        return new File(file.toString().replaceFirst(str + "$", ""));
    }

    public static ArrayList<String> y3(Set<String> set) {
        ArrayList<String> arrayList = new ArrayList<>();
        if (set != null) {
            Iterator<String> it = set.iterator();
            while (it.hasNext()) {
                arrayList.add(it.next());
            }
        }
        return arrayList;
    }

    public static boolean z(Context context, String str, String str2) {
        if (y1(context, str)) {
            return true;
        }
        r7.G("Utils", str2 + ": missing permission: " + str);
        return false;
    }

    public static int z0(Context context, int i2) {
        return C0(context, false, i2);
    }

    private static boolean z1(Context context, String str) {
        return context.checkPermission(str, Process.myPid(), Process.myUid()) == 0;
    }

    public static String z2(String str, String str2) {
        return str2.replaceFirst(Pattern.quote(str + "."), "");
    }

    public static Boolean z3(String str) {
        if (str == null) {
            return null;
        }
        try {
            return Boolean.valueOf(Boolean.parseBoolean(str));
        } catch (NumberFormatException unused) {
            return null;
        }
    }
}