ComeetChat v1.866866806590版本的 MD5 值为:4a7461802cd62adce19de75377dd7ca7
以下内容为反编译后的 gs.java 源代码,内容仅作参考
package net.dinglisch.android.taskerm;
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 androidx.core.app.NotificationCompat;
import com.joaomgcd.taskerm.structuredoutput.StructureType;
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.danlew.android.joda.R;
import net.dinglisch.android.taskerm.bw;
import org.json.JSONObject;
public class gs {
private static final Set<String> f13550c = new HashSet();
static Pattern f13548a = null;
static Pattern f13549b = null;
private static float f13551d = -1.0f;
private static float f13552e = -1.0f;
private static float f13553f = -1.0f;
private static float g = -1.0f;
private static float h = -1.0f;
private static float[] i = {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};
private static int[] j = {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};
private static Pattern k = null;
private static String l = "<[^>]+>";
private static Pattern m = null;
public static float e(int i2) {
if (i2 < 0) {
return 0.0f;
}
if (i2 > 255) {
return 1.0f;
}
return i2 / 255.0f;
}
public static String f(int i2) {
return i2 == 0 ? "down" : i2 == 1 ? "up" : i2 == 2 ? "mult" : "?";
}
static {
f13550c.add("mp3");
f13550c.add("wma");
f13550c.add("au");
f13550c.add("mid");
f13550c.add("midi");
f13550c.add("mp2");
f13550c.add("ogg");
f13550c.add("wav");
f13550c.add("3gp");
f13550c.add("amr");
f13550c.add("m4a");
}
public static void a(final Context context, final String str) {
com.joaomgcd.taskerm.rx.h.c(new Runnable() {
@Override
public final void run() {
gs.h(context, str);
}
});
}
public static void h(Context context, String str) {
com.joaomgcd.taskerm.toast.c.a(context.getApplicationContext(), str, 0).show();
}
public static Point a(Context context) {
Display defaultDisplay = ((WindowManager) df.a(context, "window", "Utils", "gDSWN")).getDefaultDisplay();
Point point = new Point();
defaultDisplay.getRealSize(point);
return point;
}
public static boolean a() {
return (f13552e == -1.0f && f13553f == -1.0f) ? false : true;
}
public static float b() {
return g;
}
public static float c() {
return h;
}
public static float d() {
return f13552e;
}
public static float e() {
return f13553f;
}
public static String f() {
return String.valueOf(f13552e) + "," + String.valueOf(f13553f);
}
public static void b(Context context) {
f13551d = context.getResources().getDisplayMetrics().density;
}
public static void c(Context context) {
DisplayMetrics displayMetrics;
Display defaultDisplay;
WindowManager windowManager = (WindowManager) df.a(context, "window", "Utils", "sbdm");
if (windowManager == null || (defaultDisplay = windowManager.getDefaultDisplay()) == null) {
displayMetrics = null;
} else {
displayMetrics = new DisplayMetrics();
defaultDisplay.getMetrics(displayMetrics);
}
if (displayMetrics == null) {
bo.b("Utils", "use resource metrics");
displayMetrics = context.getResources().getDisplayMetrics();
} else {
bo.b("Utils", "use display wm metrics");
}
if (displayMetrics != null) {
f13552e = displayMetrics.widthPixels;
f13553f = displayMetrics.heightPixels;
bo.b("Utils", "record: " + f13552e + "/" + f13553f);
g = displayMetrics.xdpi;
h = displayMetrics.ydpi;
}
}
public static int a(int i2) {
if (f13551d == -1.0f) {
bo.c("Utils", "scaleToDensity: density not initialized");
return i2;
}
return (int) (i2 * f13551d);
}
public static int b(int i2) {
return (int) (i2 / f13551d);
}
public static void a(Context context, int i2, Object... objArr) {
d(context, ct.a(context, i2, new Object[0]), objArr);
}
public static void b(Context context, int i2, Object... objArr) {
c(context, ct.a(context, i2, new Object[0]), objArr);
}
public static boolean c(Context context, int i2, Object... objArr) {
return b(context, ct.a(context, i2, new Object[0]), objArr);
}
public static boolean d(Context context, int i2, Object... objArr) {
return a(context, ct.a(context, i2, new Object[0]), objArr);
}
public static boolean a(Context context, String str, Object... objArr) {
a(context, ct.a(context, R.string.word_error, new Object[0]) + ": " + str, 1, objArr);
return false;
}
public static boolean b(Context context, String str, Object... objArr) {
a(context, ct.a(context, R.string.word_warning, new Object[0]) + ": " + str, 1, objArr);
return false;
}
public static void c(Context context, String str, Object... objArr) {
a(context, a(str), 1, objArr);
}
public static void d(Context context, String str, Object... objArr) {
a(context, a(str), 0, objArr);
}
public static String e(Context context, int i2, Object... objArr) {
return a(ct.a(context, i2, new Object[0]), objArr);
}
public static String a(String str, Object... objArr) {
try {
return String.format(str, objArr);
} catch (Exception unused) {
return str;
}
}
private static void a(final Context context, final String str, final int i2, final Object... objArr) {
com.joaomgcd.taskerm.rx.h.c(new Runnable() {
@Override
public final void run() {
gs.a(context, str, objArr, i2);
}
});
}
public static void a(Context context, String str, Object[] objArr, int i2) {
com.joaomgcd.taskerm.toast.c.a(context.getApplicationContext(), a(str + ".", objArr), i2).show();
}
public static String a(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 a(File file, String[] strArr) {
return b(file, strArr) != null;
}
public static String b(File file, String[] strArr) {
BufferedReader bufferedReader;
BufferedReader bufferedReader2;
String str;
BufferedReader bufferedReader3 = null;
try {
try {
BufferedReader bufferedReader4 = new BufferedReader(new FileReader(file));
do {
try {
String readLine = bufferedReader4.readLine();
if (readLine == null) {
break;
}
int length = strArr.length;
int i2 = 0;
while (true) {
if (i2 >= length) {
break;
}
if (readLine.contains(strArr[i2])) {
bufferedReader3 = readLine;
break;
}
i2++;
}
} catch (FileNotFoundException e2) {
e = e2;
bufferedReader2 = bufferedReader3;
bufferedReader3 = bufferedReader4;
bo.a("Utils", "fileContainsString: " + file, (Throwable) e);
str = bufferedReader2;
a((Reader) bufferedReader3);
return str;
} catch (IOException e3) {
e = e3;
bufferedReader = bufferedReader3;
bufferedReader3 = bufferedReader4;
bo.a("Utils", "fileContainsString: " + file, (Exception) e);
str = bufferedReader;
a((Reader) bufferedReader3);
return str;
} catch (Throwable th) {
th = th;
bufferedReader3 = bufferedReader4;
a((Reader) bufferedReader3);
throw th;
}
} while (bufferedReader3 == null);
a((Reader) bufferedReader4);
return bufferedReader3;
} catch (Throwable th2) {
th = th2;
}
} catch (FileNotFoundException e4) {
e = e4;
bufferedReader2 = null;
} catch (IOException e5) {
e = e5;
bufferedReader = null;
}
}
public static boolean a(Reader reader) {
if (reader != null) {
try {
reader.close();
} catch (IOException e2) {
bo.b("Utils", "failed to close reader", e2);
return false;
}
}
return true;
}
public static String a(File file) {
return a(file, true);
}
public static String a(File file, boolean z) {
try {
return a(new InputStreamReader(new FileInputStream(file)));
} catch (FileNotFoundException unused) {
bo.a("Utils", z, file.toString() + " doesn't exist");
return null;
} catch (OutOfMemoryError unused2) {
bo.a("Utils", z, file.toString() + " too big");
return null;
}
}
public static boolean b(Context context, String str) {
try {
return b(str, context.fileList()) != -1;
} catch (Exception unused) {
try {
FileInputStream openFileInput = context.openFileInput(str);
boolean z = openFileInput != null;
a((InputStream) openFileInput);
return z;
} catch (Exception unused2) {
a((InputStream) null);
return false;
} catch (Throwable th) {
a((InputStream) null);
throw th;
}
}
}
public static String c(Context context, String str) {
try {
return a(new InputStreamReader(context.openFileInput(str)));
} catch (FileNotFoundException unused) {
bo.b("Utils", "fisToString, fnf " + str);
return null;
} catch (Exception unused2) {
return null;
}
}
public static String a(InputStreamReader inputStreamReader) {
StringBuffer stringBuffer;
BufferedReader bufferedReader;
BufferedReader bufferedReader2 = null;
try {
try {
stringBuffer = new StringBuffer(8193);
bufferedReader = new BufferedReader(inputStreamReader, 8192);
} catch (IOException e2) {
e = e2;
}
} catch (Throwable th) {
th = th;
}
try {
char[] cArr = new char[8192];
while (true) {
int read = bufferedReader.read(cArr);
if (read != -1) {
stringBuffer.append(cArr, 0, read);
} else {
String stringBuffer2 = stringBuffer.toString();
a((Reader) bufferedReader);
return stringBuffer2;
}
}
} catch (IOException e3) {
e = e3;
bufferedReader2 = bufferedReader;
bo.c("Utils", e.getMessage());
a((Reader) bufferedReader2);
return "";
} catch (Throwable th2) {
th = th2;
bufferedReader2 = bufferedReader;
a((Reader) bufferedReader2);
throw th;
}
}
public static boolean a(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 boolean a(OutputStream outputStream) {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e2) {
bo.b("Utils", "failed to close output stream", e2);
return false;
}
}
return true;
}
public static boolean a(InputStream inputStream) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e2) {
bo.b("Utils", "failed to close input stream", e2);
return false;
}
}
return true;
}
public static String a(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 boolean a(InputStream inputStream, OutputStream outputStream) {
try {
byte[] bArr = new byte[8192];
while (true) {
int read = inputStream.read(bArr);
if (read > 0) {
outputStream.write(bArr, 0, read);
} else {
a(inputStream);
a(outputStream);
return true;
}
}
} catch (Exception e2) {
bo.a("Utils", "copyStreams", e2);
return false;
}
}
public static byte[] b(InputStream inputStream) {
try {
byte[] bArr = new byte[8192];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byte[] byteArray = byteArrayOutputStream.toByteArray();
a(inputStream);
return byteArray;
}
}
} catch (FileNotFoundException e2) {
bo.a("Utils", "bytesToFile", (Exception) e2);
return null;
} catch (IOException e3) {
bo.a("Utils", "bytesToFile", (Exception) e3);
return null;
}
}
public static boolean a(byte[] bArr, OutputStream outputStream) {
try {
if (a((InputStream) new ByteArrayInputStream(bArr), outputStream)) {
outputStream.flush();
a(outputStream);
return true;
}
bo.d("Utils", "bytesToOutputStream: copy stream failed");
return false;
} catch (FileNotFoundException e2) {
bo.a("Utils", "bytesToOutputStream", (Exception) e2);
return false;
} catch (IOException e3) {
bo.a("Utils", "bytesToOutputStream", (Exception) e3);
return false;
}
}
public static boolean a(String str, Writer writer) {
BufferedWriter bufferedWriter;
BufferedWriter bufferedWriter2 = null;
try {
try {
bufferedWriter = new BufferedWriter(writer, 8192);
} catch (IOException e2) {
e = e2;
}
} catch (Throwable th) {
th = th;
}
try {
bufferedWriter.write(str);
a((Writer) bufferedWriter);
return true;
} catch (IOException e3) {
e = e3;
bufferedWriter2 = bufferedWriter;
Log.w("Utils", e.toString());
a((Writer) bufferedWriter2);
return false;
} catch (Throwable th2) {
th = th2;
bufferedWriter2 = bufferedWriter;
a((Writer) bufferedWriter2);
throw th;
}
}
public static boolean a(String str, File file, boolean z) {
try {
return a(str, (Writer) new FileWriter(file, z));
} catch (IOException unused) {
return false;
}
}
public static Integer[] a(Set<Integer> set) {
Integer[] numArr = new Integer[set.size()];
set.toArray(numArr);
Arrays.sort(numArr);
return numArr;
}
public static Long[] a(Set<Long> set, final boolean z) {
Long[] lArr = new Long[set.size()];
set.toArray(lArr);
Arrays.sort(lArr, new Comparator<Long>() {
@Override
public int compare(Long l2, Long l3) {
return z ? l3.compareTo(l2) : l2.compareTo(l3);
}
});
return lArr;
}
public static boolean a(byte[] bArr, File file) {
try {
FileOutputStream fileOutputStream = new FileOutputStream(file, false);
fileOutputStream.write(bArr);
fileOutputStream.flush();
fileOutputStream.close();
return true;
} catch (Exception e2) {
bo.b("Utils", e2.getMessage(), e2);
return false;
}
}
public static boolean a(Context context, String str, String str2, int i2) {
try {
FileOutputStream openFileOutput = context.openFileOutput(str2, i2);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(openFileOutput);
outputStreamWriter.write(str);
a((Writer) outputStreamWriter);
a((OutputStream) 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 a(Context context, Intent intent) {
return a(context, intent, false);
}
public static boolean a(Context context, Intent intent, boolean z) {
try {
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException unused) {
if (z) {
bo.c("Utils", "startActivityWrapper: activity not found");
} else {
bo.b("Utils", "startActivityWrapper: activity not found");
}
bo.a("startActivityWrapper", intent, false);
return false;
} catch (Exception e2) {
if (z) {
bo.c("Utils", "startActivityWrapper: unexpected exception");
return false;
}
bo.a("Utils", "startActivityWrapper: unexpected exception", e2);
return false;
}
}
public static String a(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) {
return "";
}
for (File file : listFiles) {
String name = file.getName();
if (name.endsWith(str2)) {
return name.substring(0, name.length() - str2.length());
}
}
return "";
}
public static boolean g() {
try {
return Environment.getExternalStorageState().equals("mounted");
} catch (Exception e2) {
bo.c("Utils", "storageMounted: " + e2);
return false;
}
}
public static File h() {
if (g()) {
return Environment.getExternalStorageDirectory();
}
return null;
}
public static void a(Intent intent, boolean z) {
intent.addFlags(268435456);
intent.addFlags(4);
intent.addFlags(8388608);
intent.addFlags(262144);
if (z) {
return;
}
intent.addFlags(1073741824);
}
public static boolean d(Context context) {
return h(context).getBoolean("dscl", false);
}
public static File b(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 File a(File file, String str) {
return new File(file.toString().replaceFirst(str + "$", ""));
}
public static File b(File file, String str) {
return file.getName().endsWith(str) ? file : c(file, str);
}
public static File c(File file, String str) {
return new File(file.toString() + str);
}
public static float i() {
return f13551d;
}
public static float e(Context context) {
if (context.getResources().getIdentifier("status_bar_height", "dimen", "android") > 0) {
return context.getResources().getDimensionPixelSize(r0);
}
return i() * 25.0f;
}
public static int a(Context context, boolean z) {
Point a2 = a(context);
float f2 = f(context);
return Math.round((context.getResources().getConfiguration().orientation == 1 ? a2.y : a2.x) - ((e(context) + f2) - (z ? f2 / 2.0f : 0.0f)));
}
public static int f(Context context) {
int a2;
boolean hasPermanentMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
boolean deviceHasKey = KeyCharacterMap.deviceHasKey(4);
if (!hasPermanentMenuKey && !deviceHasKey) {
Resources resources = context.getResources();
int i2 = resources.getConfiguration().orientation;
if (t(context)) {
a2 = b(resources, i2);
if (a2 == 0) {
a2 = a(resources, i2);
}
} else {
a2 = a(resources, i2);
}
if (a2 > 0) {
return resources.getDimensionPixelSize(a2);
}
}
return a(context).y - Math.round(e());
}
private static int a(Resources resources, int i2) {
return resources.getIdentifier(i2 == 1 ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
}
private static int b(Resources resources, int i2) {
return resources.getIdentifier(i2 == 1 ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
}
private static boolean t(Context context) {
return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
}
public static Object a(ContentResolver contentResolver, Uri uri, String str, Class<?> cls) {
Object valueOf;
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) {
bo.d("Utils", "gffc: " + uri + ": `no column index for " + str);
} else {
if (cls.equals(String.class)) {
valueOf = query.getString(columnIndex);
} else if (cls.equals(Long.class)) {
valueOf = Long.valueOf(query.getLong(columnIndex));
}
obj = valueOf;
}
}
query.close();
}
} catch (IllegalStateException e2) {
bo.a("Utils", "getFirstCursorColumn: " + uri, (Exception) e2);
} catch (NullPointerException e3) {
bo.a("Utils", "getFirstCursorColumn: " + uri, (Exception) e3);
}
return obj;
}
public static String a(ContentResolver contentResolver, Uri uri, String str) {
return (String) a(contentResolver, uri, str, (Class<?>) String.class);
}
public static String a(com.joaomgcd.taskerm.j.d dVar) {
return c(dVar.g());
}
public static String c(File file) {
String str = "file://" + file.toString();
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
if (TextUtils.isEmpty(fileExtensionFromUrl)) {
fileExtensionFromUrl = a(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 String a(String str, boolean z) {
int length = str.length();
int lastIndexOf = str.lastIndexOf(".");
if (lastIndexOf > 0 && lastIndexOf != str.length() - 1 && (length - lastIndexOf) - 1 <= 4) {
return str.substring(lastIndexOf + (!z ? 1 : 0));
}
return "";
}
public static SharedPreferences g(Context context) {
return context.getSharedPreferences(bh.g, 0);
}
public static SharedPreferences h(Context context) {
return context.getSharedPreferences(bh.j, 0);
}
public static void a(Context context, long j2) {
a(context, j2, false);
}
public static void a(Context context, long j2, boolean z) {
Vibrator vibrator;
if ((!z || s(context)) && (vibrator = (Vibrator) df.a(context, "vibrator", "Utils", "vib")) != null) {
vibrator.cancel();
vibrator.vibrate(new long[]{0, j2, 0, 0}, -1);
}
}
public static boolean i(Context context) {
Vibrator vibrator = (Vibrator) df.a(context, "vibrator", "Utils", "haveVib");
return vibrator.hasVibrator() & (vibrator != null);
}
public static String c(int i2) {
if (i2 > 9) {
return Integer.toString(i2);
}
return "0" + Integer.toString(i2);
}
public static void a(Context context, boolean z, String str) {
int i2;
SharedPreferences sharedPreferences = context.getSharedPreferences(bh.p, 0);
int i3 = 2;
if (z) {
i2 = 2;
} else {
Iterator<Map.Entry<String, ?>> it = sharedPreferences.getAll().entrySet().iterator();
i2 = 2;
while (it.hasNext()) {
if (it.next().getValue().equals("block")) {
i2 = 1;
} else {
i3 = 1;
}
}
}
if (p()) {
ReceiverStaticCallRewriter.b(i3 == 1);
ReceiverStaticCallBlocker.a(i2 == 1);
} else {
cr.a(context, ReceiverStaticCallRewriter.class.getName(), i3);
cr.a(context, ReceiverStaticCallBlocker.class.getName(), i2);
}
}
public static void e(Context context, String str, Object... objArr) {
b(context, ct.a(context, R.string.word_error, new Object[0]), a(str, objArr), 1);
}
public static void f(Context context, int i2, Object... objArr) {
e(context, ct.a(context, i2, new Object[0]), objArr);
}
public static void a(Context context, int i2, int i3, int i4) {
b(context, ct.a(context, i2, new Object[0]), ct.a(context, i3, new Object[0]), i4);
}
public static void b(Context context, String str, String str2, int i2) {
a(context, str, str2, (g) null, i2);
}
public static void a(Context context, String str, String str2, g gVar, int i2) {
Drawable a2;
final com.joaomgcd.taskerm.toast.c cVar = new com.joaomgcd.taskerm.toast.c(context, new Toast(context));
View inflate = ((LayoutInflater) df.a(context, "layout_inflater", "Utils", "flashIT")).inflate(R.layout.toastwithimage, (ViewGroup) null);
TextView textView = (TextView) inflate.findViewById(R.id.text);
if (textView == null) {
bo.c("Utils", "Can't show flashImageToast. TextView is null");
return;
}
textView.setText(str2);
ImageView imageView = (ImageView) inflate.findViewById(R.id.icon);
if (gVar != null) {
try {
a2 = gVar.a(context);
} catch (Exception unused) {
}
if (a2 != null) {
imageView.setImageResource(com.joaomgcd.taskerm.util.al.M(context));
} else {
imageView.setImageDrawable(a2);
}
((TextView) inflate.findViewById(R.id.title)).setText(str);
cVar.setView(inflate);
cVar.a(Integer.valueOf(R.id.title), Integer.valueOf(R.id.text), Integer.valueOf(R.id.icon));
cVar.setDuration(i2);
cVar.getClass();
com.joaomgcd.taskerm.rx.h.c(new Runnable() {
@Override
public final void run() {
com.joaomgcd.taskerm.toast.c.this.show();
}
});
}
a2 = null;
if (a2 != null) {
}
((TextView) inflate.findViewById(R.id.title)).setText(str);
cVar.setView(inflate);
cVar.a(Integer.valueOf(R.id.title), Integer.valueOf(R.id.text), Integer.valueOf(R.id.icon));
cVar.setDuration(i2);
cVar.getClass();
com.joaomgcd.taskerm.rx.h.c(new Runnable() {
@Override
public final void run() {
com.joaomgcd.taskerm.toast.c.this.show();
}
});
}
public static boolean a(String str, String[] strArr) {
return b(str, strArr) != -1;
}
public static int b(String str, String[] strArr) {
if (strArr != null) {
for (int i2 = 0; i2 < strArr.length; i2++) {
if (str.equals(strArr[i2])) {
return i2;
}
}
}
return -1;
}
public static int a(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 int a(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 int a(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 final File a(File file, File file2) {
File file3 = new File(file2, file.getName());
if (file.renameTo(file3)) {
return file3;
}
return null;
}
public static String b(String str) {
return b(str, false);
}
public static String b(String str, boolean z) {
String str2 = "^" + Environment.getExternalStorageDirectory().toString() + File.separator;
if (!z) {
str2 = str2 + "?";
}
return str.replaceFirst(str2, "");
}
public static File d(File file) {
return new File(b(file.toString()));
}
public static Integer c(String str) {
if (str == null) {
return null;
}
try {
return new Integer(str);
} catch (NumberFormatException unused) {
return null;
}
}
public static Integer d(String str) {
if (str == null) {
return null;
}
try {
return Integer.valueOf(Integer.parseInt(str, 16));
} catch (NumberFormatException unused) {
return null;
}
}
public static Long e(String str) {
try {
return Long.valueOf(Long.parseLong(str));
} catch (NumberFormatException unused) {
return null;
}
}
public static String a(double d2, int i2) {
DecimalFormat decimalFormat = new DecimalFormat("0.#");
decimalFormat.setMaximumFractionDigits(i2);
return decimalFormat.format(d2).replace(",", ".");
}
public static Float f(String str) {
try {
return Float.valueOf(Float.parseFloat(str));
} catch (NumberFormatException unused) {
return (Float) null;
}
}
public static Double g(String str) {
try {
return new Double(str);
} catch (NumberFormatException unused) {
return null;
}
}
public static void a(Context context, Class<?> cls) {
boolean d2 = d(context, cls.getName());
if (context.stopService(new Intent(context, cls)) || !d2) {
return;
}
bo.c("Utils", "failed to stop service when running");
b(context, ct.a(context, R.string.warn_fail_stop_service, new Object[0]) + cls.getSimpleName(), new Object[0]);
}
public static boolean d(Context context, String str) {
if (context == null) {
return false;
}
ActivityManager activityManager = (ActivityManager) df.a(context, "activity", "Utils", "sr");
String packageName = context.getPackageName();
if (activityManager == null) {
bo.d("Utils", ct.a(context, R.string.err_no_activity_manager, 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;
}
bo.b("Utils", "found service " + str + " in another process!");
}
}
} catch (Exception e2) {
bo.b("Utils", "Could not get running services", e2);
return false;
}
}
return false;
}
public static String a(String[] strArr) {
return a(strArr, ",");
}
public static String a(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 String[] a(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 String[] b(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 int[] c(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 boolean j(Context context) {
return a(context, -1);
}
public static boolean a(Context context, int i2) {
ConnectivityManager connectivityManager = (ConnectivityManager) df.a(context, "connectivity", "Utils", "haveNet");
if (connectivityManager == null) {
bo.d("Utils", "no connectivity manager");
} else {
NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
if (allNetworkInfo == null) {
bo.b("Utils", "haveNetwork: no network info");
} else {
for (NetworkInfo networkInfo : allNetworkInfo) {
int type = networkInfo.getType();
if ((i2 == -1 || i2 == type) && networkInfo.isConnected()) {
return true;
}
}
}
}
return false;
}
public static int a(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 d(int i2) {
return ((i2 >> 0) & 255) + "." + ((i2 >> 8) & 255) + "." + ((i2 >> 16) & 255) + "." + ((i2 >> 24) & 255);
}
public static void a(Context context, final EditText editText, final boolean z, int i2, long j2) {
final InputMethodManager inputMethodManager = (InputMethodManager) df.a(context, "input_method", "Utils", "shsf");
final int i3 = i2 >= 0 ? i2 : 1;
if (inputMethodManager != null) {
if (j2 < 0) {
if (z) {
inputMethodManager.showSoftInput(editText, i3);
return;
} else {
inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), i3);
return;
}
}
Runnable runnable = new Runnable() {
@Override
public void run() {
if (z) {
inputMethodManager.showSoftInput(editText, i3);
} else {
inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), i3);
}
}
};
if (j2 == 0) {
editText.post(runnable);
} else {
editText.postDelayed(runnable, j2);
}
}
}
public static boolean k(Context context) {
Resources resources = context.getResources();
if (resources != null) {
return resources.getConfiguration().hardKeyboardHidden == 1;
}
bo.d("Utils", "hardKeyboardShowing: no resources");
return false;
}
public static boolean l(Context context) {
if (k(context)) {
return true;
}
InputMethodManager inputMethodManager = (InputMethodManager) df.a(context, "input_method", "Utils", "ssk");
if (inputMethodManager == null) {
return false;
}
inputMethodManager.toggleSoftInput(2, 1);
return true;
}
public static void a(EditText editText) {
if (editText.length() > 0) {
try {
editText.setSelection(editText.length());
} catch (IndexOutOfBoundsException unused) {
}
}
}
public static String a(TextView textView) {
CharSequence text;
return (textView == null || (text = textView.getText()) == null) ? "" : text.toString().trim();
}
public static List<File> a(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 || f13550c.contains(a(file2.getName(), false))) {
arrayList.add(file2);
if (arrayList.size() + i3 >= i2) {
break;
}
}
}
}
} catch (NullPointerException e2) {
bo.a("Utils", "listMusicFilesRec: " + file, (Throwable) e2);
}
}
Collections.sort(arrayList);
for (File file3 : arrayList2) {
if (arrayList.size() >= i2) {
break;
}
arrayList.addAll(a(file3, true, z2, i2, arrayList.size()));
}
return arrayList;
}
public static boolean[] a(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 a(float f2) {
if (f2 >= 2484.0f) {
for (int i2 = 0; i2 < i.length; i2++) {
if (i[i2] == f2) {
return j[i2];
}
}
} else if (f2 >= 2412.0f) {
return ((((int) f2) - 2412) / 5) + 1;
}
return 0;
}
public static File c(String str, boolean z) {
if (h() == null) {
return null;
}
File k2 = k();
if (z) {
e(k2);
}
File file = new File(k2, str);
if (z) {
b(file, true);
}
if (file.exists()) {
return file;
}
return null;
}
public static File j() {
return c("cache/tmp", true);
}
public static boolean e(File file) {
return b(file, false);
}
public static boolean b(File file, boolean z) {
if (file == null) {
bo.d("Utils", "mkdirIfNeeded: null file");
return false;
}
if (file.exists()) {
return true;
}
if (file.mkdirs()) {
if (z) {
f(new File(file, ".nomedia"));
}
return true;
}
bo.d("Utils", "mkdirIfNeeded: failed to create dir: " + file);
return false;
}
public static File k() {
return new File(Environment.getExternalStorageDirectory(), bh.f12206c);
}
public static int a(ContentResolver contentResolver, int i2) {
return b(contentResolver, n.l(i2));
}
public static boolean a(ContentResolver contentResolver, String str) {
try {
Settings.System.getInt(contentResolver, str);
return true;
} catch (Settings.SettingNotFoundException unused) {
return false;
}
}
public static int b(ContentResolver contentResolver, String str) {
int i2;
if (str == null) {
return -1;
}
try {
if (str.equals("airplane_mode_on") && bw.ab.b()) {
i2 = bw.ab.a(contentResolver, str).intValue();
} else {
i2 = Settings.System.getInt(contentResolver, str);
}
} catch (Settings.SettingNotFoundException unused) {
bo.d("Utils", "getIntSetting: setting not found: " + str);
i2 = -1;
if (i2 == -1) {
}
} catch (Exception unused2) {
bo.d("Utils", "getIntSetting: global setting not found: " + str);
i2 = -1;
if (i2 == -1) {
}
}
return (i2 == -1 || !str.equals("screen_brightness_mode")) ? i2 : b(contentResolver, "screen_auto");
}
public static int c(ContentResolver contentResolver, String str) {
try {
return Settings.Secure.getInt(contentResolver, str);
} catch (Settings.SettingNotFoundException unused) {
bo.d("Utils", "getSecureIntSetting: setting not found: " + str);
return -1;
}
}
public static String d(ContentResolver contentResolver, String str) {
return Settings.Secure.getString(contentResolver, str);
}
public static String h(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 int i(String str) {
int i2 = 0;
for (int i3 = 0; i3 < str.length(); i3++) {
i2 = str.charAt(i3) + ((i2 << 5) - i2);
}
return i2;
}
public static int j(String str) {
int i2 = 0;
for (int i3 = 0; i3 < str.length(); i3++) {
i2 += str.charAt(i3) * i3;
}
return i2;
}
public static int l() {
return Build.VERSION.SDK_INT;
}
public static void b(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 boolean m() {
return "6.1.32".charAt(0) == 'X';
}
public static String a(boolean z) {
StringBuilder sb = new StringBuilder();
sb.append("Tasker/");
sb.append("6.1.32");
if (z) {
sb.append(" (Android/");
sb.append(Build.VERSION.RELEASE);
sb.append(')');
}
return sb.toString();
}
public static void a(EditText editText, boolean z) {
if (z) {
editText.setFilters(new InputFilter[0]);
} else {
editText.setFilters(new InputFilter[]{new InputFilter() {
@Override
public CharSequence filter(CharSequence charSequence, int i2, int i3, Spanned spanned, int i4, int i5) {
return charSequence.length() < 1 ? spanned.subSequence(i4, i5) : "";
}
}});
}
}
public static String k(String str) {
try {
return URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e2) {
bo.b("Utils", "encodingWrapper", e2);
return str;
}
}
public static String l(String str) {
try {
return URLDecoder.decode(str, "UTF-8");
} catch (UnsupportedEncodingException e2) {
bo.b("Utils", "decodingWrapper", e2);
return str;
}
}
public static void a(View view, boolean z) {
view.setVisibility(z ? 0 : 8);
}
public static String a(ContentResolver contentResolver, Uri uri, String str, String str2, String str3) {
Cursor cursor;
String str4 = null;
try {
cursor = contentResolver.query(uri, null, null, null, null);
if (cursor != null) {
try {
int columnIndex = cursor.getColumnIndex(str3);
int columnIndex2 = cursor.getColumnIndex(str);
while (true) {
if (!cursor.moveToNext()) {
break;
}
if (str2.equals(cursor.getString(columnIndex2))) {
str4 = cursor.getString(columnIndex);
break;
}
}
cursor.close();
} catch (IllegalStateException unused) {
} catch (Throwable th) {
th = th;
if (cursor != null) {
cursor.close();
}
throw th;
}
}
} catch (IllegalStateException unused2) {
cursor = null;
} catch (Throwable th2) {
th = th2;
cursor = null;
}
}
public static boolean a(Collection<?> collection) {
return collection == null || collection.size() == 0;
}
public static boolean a(Object[] objArr) {
return objArr == null || objArr.length == 0;
}
public static Intent n() {
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 d(List<String> list) {
return a((List<?>) list, ' ');
}
public static String a(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 ArrayList<String> b(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 int c(Context context, int i2) {
return a(context, true, i2);
}
public static int d(Context context, int i2) {
return a(context, false, i2);
}
private static int a(Context context, boolean z, int i2) {
int i3;
WindowManager windowManager = (WindowManager) df.a(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 final boolean a(PackageManager packageManager, String str) {
return packageManager.resolveContentProvider(str, 0) != null;
}
public static boolean e(Context context, int i2) {
SensorManager sensorManager = (SensorManager) df.a(context, "sensor", "Utils", "haveSensor");
return (sensorManager == null || sensorManager.getDefaultSensor(i2) == null) ? false : true;
}
public static String a(Object obj) {
return obj == null ? "<null>" : obj.toString();
}
public static void a(String str, Bundle bundle) {
a(str, bundle, "\t");
}
private static void a(String str, Bundle bundle, String str2) {
if (bo.j()) {
if (bundle == null) {
if (str != null) {
bo.b("Utils", str + ": null");
return;
}
return;
}
if (bundle.size() <= 0) {
if (str != null) {
bo.b("Utils", str + ": empty");
return;
}
return;
}
if (str != null) {
bo.b("Utils", str);
}
for (String str3 : bundle.keySet()) {
try {
Object obj = bundle.get(str3);
String str4 = str2 + str3 + " / ";
if (obj == null) {
bo.b("Utils", str4 + "null");
} else {
String str5 = str4 + obj.getClass().getSimpleName();
if (obj.getClass().equals(Bundle.class)) {
bo.b("Utils", str5 + ConstantsCommonTaskerServer.ID_SEPARATOR);
a((String) null, (Bundle) obj, str2 + "\t");
} else {
bo.b("Utils", str5 + " / " + a(obj));
}
}
} catch (Exception e2) {
bo.b("Utils", e2.toString());
}
}
}
}
public static String m(String str) {
return str != null ? (str.equals("net.dinglisch.android.tasker") || str.equals("net.dinglisch.android.taskercupcake") || str.equals("net.dinglisch.android.taskerm")) ? cr.b() : str : str;
}
public static void a(ListView listView, int i2) {
if (listView != null && listView.getChildCount() > 0) {
listView.setSelectionFromTop(i2, (listView.getHeight() / 2) - listView.getChildAt(0).getHeight());
}
}
public static boolean a(PackageManager packageManager) {
boolean z;
if (a(packageManager, "sms")) {
z = true;
} else {
bo.b("Utils", "no SMS provider");
z = false;
}
if (!a(packageManager, "mms")) {
bo.b("Utils", "no MMS provider");
z = false;
}
if (a(packageManager, "mms-sms")) {
return z;
}
bo.b("Utils", "no MMS-SMS provider");
return false;
}
public static String b(String[] strArr) {
return c(" AND ", strArr);
}
public static Intent o() {
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 void a(EditText editText, String str) {
a(editText, str, "/");
}
public static void a(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 void b(EditText editText, String str) {
editText.setText("");
editText.append(str);
}
public static String c(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 String a(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 a(Context context, String str, Uri uri, File file, String str2, String str3) {
Random random = new Random();
File j2 = j();
if (j2 == null) {
f(context, R.string.f_no_local_storage, new Object[0]);
return;
}
if (uri.toString().contains("%20")) {
f(context, R.string.f_uris_no_spaces, new Object[0]);
return;
}
if (str3 != null) {
b(context, str, uri.getLastPathSegment(), 0);
}
uri.getHost();
File file2 = new File(j2, Integer.toString(random.nextInt()));
c cVar = new c(118);
cVar.b(0, uri.toString());
cVar.b(2, "");
cVar.b(3, "");
cVar.a(5, 30);
cVar.b(6, str2);
cVar.b(7, d(file2).toString());
c cVar2 = new c(400);
cVar2.b(0, d(file2).toString());
cVar2.b(1, d(file).toString());
cVar2.a(2, false);
ft d2 = fy.d();
d2.a(str);
d2.g(51);
d2.a(cVar);
d2.a(cVar2);
if (str2.endsWith(bf.ZIP_LABEL)) {
c cVar3 = new c(422);
cVar3.b(0, d(file).toString());
cVar3.a(1, true);
d2.a(cVar3);
}
if (str3 != null) {
c cVar4 = new c(548);
cVar4.b(0, str3);
cVar4.a(1, true);
d2.a(cVar4);
}
ExecuteService.a(context, d2, (List<String>) null, (String) null, true);
}
public static void a(Activity activity, int i2, int i3) {
TextView textView = (TextView) activity.findViewById(i2);
if (textView != null) {
textView.setText(ct.b(activity, i3, new Object[0]));
}
}
public static ArrayAdapter<String> f(Context context, int i2) {
return a(context, ct.a(context, i2));
}
public static ArrayAdapter<String> a(Context context, List<String> list) {
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, list);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
return arrayAdapter;
}
public static ArrayAdapter<String> a(Context context, String[] strArr) {
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, strArr);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
return arrayAdapter;
}
public static void a(Context context, boolean z, boolean z2) {
try {
bo.b("Utils", "grabReleaseMediaButton: " + z + " newAPI: " + z2);
String name = ReceiverStaticMediaButton.class.getName();
if (z2 && !t()) {
bo.d("Utils", "refusing to use new API < marshmallow");
z2 = false;
}
if (z2) {
if (z) {
cn.a(context);
return;
} else {
cn.b();
return;
}
}
ComponentName componentName = new ComponentName(context.getPackageName(), name);
AudioManager audioManager = (AudioManager) df.a(context, "audio", "Utils", "grmb");
bw.e.b(audioManager, componentName);
if (z) {
bw.e.a(audioManager, componentName);
}
if (p()) {
ReceiverStaticMediaButton.a(z);
} else {
cr.a(context, name, z);
}
} catch (Exception e2) {
bo.b("Utils", "grabReleaseMediaButton", e2);
}
}
public static void m(final Context context) {
new AlertDialog.Builder(context).setMessage(ct.a(context, R.string.dc_zoom_not_installed, new Object[0])).setTitle(ct.a(context, R.string.dt_zoom_not_installed, new Object[0])).setPositiveButton(ct.a(context, R.string.button_label_get_new_version, new Object[0]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=net.dinglisch.android.zoom")));
}
}).setNeutralButton(ct.a(context, R.string.bl_info, new Object[0]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://zoom.dinglisch.net/")));
}
}).setNegativeButton(ct.a(context, R.string.button_label_ok, new Object[0]), (DialogInterface.OnClickListener) null).show();
}
public static Thread.State a(Thread thread) {
Thread.State state = null;
int i2 = 0;
while (state == null && i2 < 4) {
try {
state = thread.getState();
} catch (ArrayIndexOutOfBoundsException e2) {
bo.a("Utils", "failed to get thread state", (Throwable) e2);
try {
Thread.sleep(100L);
} catch (InterruptedException unused) {
}
}
i2++;
}
if (state == null) {
bo.b("Utils", "getThreadState: bail out after " + i2 + " tries");
} else if (i2 > 1) {
bo.b("Utils", "getThreadState: succeeded on try " + i2);
}
return state;
}
public static boolean a(File file, int i2) {
boolean z;
RandomAccessFile randomAccessFile;
long length = file.length();
SecureRandom secureRandom = new SecureRandom();
int i3 = 0;
while (i3 < i2) {
try {
byte[] bArr = new byte[8192];
long j2 = 0;
try {
randomAccessFile = new RandomAccessFile(file, "rw");
while (j2 < length) {
long j3 = length - j2;
int i4 = i3;
if (j3 < 8192) {
try {
bArr = new byte[(int) j3];
} catch (Throwable th) {
th = th;
if (randomAccessFile != null) {
randomAccessFile.close();
}
throw th;
}
}
secureRandom.nextBytes(bArr);
randomAccessFile.write(bArr);
j2 += bArr.length;
i3 = i4;
}
int i5 = i3;
randomAccessFile.close();
i3 = i5 + 1;
} catch (Throwable th2) {
th = th2;
randomAccessFile = null;
}
} catch (Exception e2) {
bo.b("Utils", "wipe", e2);
z = false;
}
}
z = true;
bo.b("Utils", "shred2: " + file + "/" + i2 + " times: " + z);
return z;
}
public static void b(Context context, boolean z) {
if (z) {
MonitorService.a(context, false);
}
dn.c();
}
public static void n(Context context) {
MonitorService.b(context, true);
a(context, (Class<?>) ExecuteService.class);
ew.a(context);
if (t()) {
cn.b();
}
ExecuteService.b(context);
gh.a((AlarmManager) df.a(context, NotificationCompat.CATEGORY_ALARM, "Utils", "stopTasker"));
bo.e();
dn.c();
}
public static void a(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 th) {
com.joaomgcd.taskerm.rx.h.a(context, th);
}
}
public static int a(Context context, EditText editText, int i2) {
int selectionStart = editText.getSelectionStart();
int selectionEnd = editText.getSelectionEnd();
int inputType = editText.getInputType();
df.a((TextView) editText, i2);
try {
editText.setSelection(selectionStart, selectionEnd);
} catch (Throwable th) {
com.joaomgcd.taskerm.rx.h.a(context, th);
}
return inputType;
}
public static int o(Context context) {
Resources resources = context.getResources();
if (resources == null) {
bo.d("Utils", "getOrientation: no resources");
} else {
Configuration configuration = resources.getConfiguration();
if (configuration != null) {
return configuration.orientation;
}
}
return 0;
}
public static boolean p(Context context) {
return a(context.getResources());
}
public static boolean a(Resources resources) {
if (resources != null) {
return resources.getConfiguration().orientation == 2;
}
bo.d("Utils", "isLandscape: no resources");
return false;
}
public static Object a(String str, Bundle bundle, String str2, Class<?> cls, boolean z) {
if (!bundle.containsKey(str2)) {
if (!z) {
return null;
}
bo.d(str, "extra " + str2 + ": absent and required");
return null;
}
Object obj = bundle.get(str2);
if (obj == null) {
bo.d(str, "extra " + str2 + ": null");
} else if (!obj.getClass().equals(cls)) {
bo.d(str, "extra " + str2 + ": class mismatch, exected " + cls.getName() + " got " + obj.getClass().getName());
return null;
}
return obj;
}
public static boolean a(Uri uri, String str) {
String scheme;
return (uri == null || (scheme = uri.getScheme()) == null || !scheme.equals(str)) ? false : true;
}
public static boolean f(File file) {
try {
return file.createNewFile();
} catch (IOException unused) {
bo.d("Utils", "failed to create " + file.toString());
return false;
}
}
private static String a(int i2, int i3, char c2) {
StringBuilder sb = new StringBuilder();
sb.append(i2);
sb.append(c2);
sb.append(i3);
return sb.toString();
}
public static String a(int i2, int i3) {
return a(i2, i3, 'x');
}
public static String b(int i2, int i3) {
return a(i2, i3, ',');
}
public static String a(Rect rect) {
return b(rect.left, rect.top) + ' ' + a(rect.width(), rect.height());
}
public static int a(String str, Paint paint) {
float[] fArr = new float[str.length()];
paint.getTextWidths(str, fArr);
int i2 = 0;
for (float f2 : fArr) {
i2 = (int) (i2 + f2);
}
return i2;
}
public static List<String> e(List<String> list) {
Collections.sort(list, new Comparator<String>() {
@Override
public int compare(String str, String str2) {
return str.compareToIgnoreCase(str2);
}
});
return list;
}
public static CharSequence[] a(CharSequence[] charSequenceArr, final String str, final String str2) {
Arrays.sort(charSequenceArr, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int a2;
a2 = gs.a(str, str2, (CharSequence) obj, (CharSequence) obj2);
return a2;
}
});
return charSequenceArr;
}
public static int a(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 void a(ViewGroup viewGroup, int i2) {
viewGroup.removeViewInLayout(viewGroup.findViewById(i2));
}
public static void b(ListView listView, int i2) {
if (listView.getAdapter() == null) {
bo.d("Utils", "setListHeightBasedOnChildHeight: no adapter");
} else {
c(listView, i2);
}
}
private static void c(ListView listView, int i2) {
ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
int count = listView.getAdapter().getCount();
layoutParams.height = listView.getPaddingBottom() + listView.getPaddingTop() + (i2 * count) + a(listView.getDividerHeight() * (count - 1));
listView.setLayoutParams(layoutParams);
listView.requestLayout();
}
public static void a(Context context, Menu menu, int i2, int i3) {
menu.add(0, i2, 0, ct.a(context, R.string.ml_help_this_screen, new Object[0]));
menu.add(0, i3, 0, ct.a(context, R.string.ml_userguide, new Object[0]));
}
public static void a(final View view, long j2) {
view.postDelayed(new Runnable() {
@Override
public void run() {
for (final int i2 = 0; i2 < 8; i2++) {
view.postDelayed(new Runnable() {
@Override
public void run() {
view.setVisibility(i2 % 2 == 0 ? 4 : 0);
}
}, i2 * 200);
}
}
}, j2);
}
public static boolean a(Object obj, Object obj2) {
if (obj == null) {
return obj2 == null;
}
return obj.equals(obj2);
}
public static String[] d(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 boolean p() {
return l() < 16;
}
public static boolean q() {
return l() >= 21;
}
public static boolean r() {
return l() >= 24;
}
public static boolean s() {
return l() >= 26;
}
public static boolean t() {
return l() >= 23;
}
public static void u() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
}
public static int g(File file) {
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 e2) {
bufferedInputStream = bufferedInputStream2;
e = e2;
bo.a("Utils", "countFileLines " + file, (Throwable) e);
a((InputStream) bufferedInputStream);
return i2;
} catch (IOException e3) {
bufferedInputStream = bufferedInputStream2;
e = e3;
bo.a("Utils", "countFileLines " + file, (Exception) e);
a((InputStream) bufferedInputStream);
return i2;
}
}
if (z) {
i2++;
}
a((InputStream) bufferedInputStream2);
} catch (Throwable th) {
th = th;
bufferedInputStream = bufferedInputStream2;
a((InputStream) bufferedInputStream);
throw th;
}
} catch (FileNotFoundException e4) {
i2 = 0;
e = e4;
bufferedInputStream = bufferedInputStream2;
} catch (IOException e5) {
i2 = 0;
e = e5;
bufferedInputStream = bufferedInputStream2;
}
} catch (Throwable th2) {
th = th2;
}
} catch (FileNotFoundException e6) {
e = e6;
i2 = 0;
} catch (IOException e7) {
e = e7;
i2 = 0;
}
return i2;
}
public static InputMethodInfo q(Context context) {
try {
InputMethodManager inputMethodManager = (InputMethodManager) df.a(context, "input_method", "Utils", "gcim");
InputMethodSubtype currentInputMethodSubtype = inputMethodManager.getCurrentInputMethodSubtype();
if (currentInputMethodSubtype == null) {
bo.b("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 th) {
bo.b("Utils", "getCurInputMethod: error getting", th);
return null;
}
}
public static String n(String str) {
File externalStorageDirectory;
return (str.startsWith(File.separator) || (externalStorageDirectory = Environment.getExternalStorageDirectory()) == null) ? str : new File(externalStorageDirectory, str).toString();
}
private static boolean g(Context context, String str) {
return context.checkPermission(str, Process.myPid(), Process.myUid()) == 0;
}
public static boolean e(Context context, String str) {
boolean g2 = g(context, str);
if (g2 || !str.equals("android.permission.READ_EXTERNAL_STORAGE") || (l() >= 19 && !g(context, "android.permission.WRITE_EXTERNAL_STORAGE"))) {
return g2;
}
return true;
}
public static boolean a(Context context, String str, String str2) {
if (e(context, str)) {
return true;
}
bo.d("Utils", str2 + ": missing permission: " + str);
return false;
}
public static Set<String> a(Context context, Set<String> set) {
HashSet hashSet = null;
if (set != null) {
for (String str : set) {
if (!e(context, str)) {
if (hashSet == null) {
hashSet = new HashSet();
}
hashSet.add(str);
}
}
}
return hashSet;
}
public static boolean f(Context context, String str) {
return bw.d.a(context) && bw.d.a(bw.d.b(context), str, Process.myUid(), context.getPackageName()) == 0;
}
public static void c(Context context, boolean z) {
if (p()) {
for (Class cls : new Class[]{ReceiverStaticInternal.class, ReceiverStaticNotification.class, ReceiverStaticPhoneState.class, ReceiverStaticMediaButton.class, ReceiverStaticCallRewriter.class, ReceiverStaticCallBlocker.class}) {
cr.a(context, cls.getName(), true);
}
}
}
public static void a(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 void a(Context context, BroadcastReceiver broadcastReceiver) {
try {
context.unregisterReceiver(broadcastReceiver);
} catch (IllegalArgumentException unused) {
}
}
public static List<String> b(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 void a(View view, String str) {
view.setContentDescription(str);
}
public static void a(View view, int i2) {
a(view, ct.a(view.getContext(), i2, new Object[0]));
}
public static void a(View view, final String str, boolean z) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public final boolean onLongClick(View view2) {
boolean a2;
a2 = gs.a(str, view2);
return a2;
}
});
if (z) {
view.setContentDescription(str);
}
}
public static boolean a(String str, View view) {
a(view.getContext(), view, str);
return true;
}
public static void a(View view, int i2, boolean z) {
a(view, ct.a(view.getContext(), i2, new Object[0]), z);
}
public static void a(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 - rect.left) / 2) + rect.left;
r2 = i2 < right ? -(right - i2) : 0;
if (i2 >= right) {
r2 = i2 - right;
}
}
final int a2 = go.a(40);
com.joaomgcd.taskerm.rx.h.c(new Runnable() {
@Override
public final void run() {
gs.a(context, str, r3, a2);
}
});
}
public static void a(Context context, String str, int i2, int i3) {
com.joaomgcd.taskerm.toast.c a2 = com.joaomgcd.taskerm.toast.c.a(context.getApplicationContext(), str, 0);
a2.setGravity(81, i2, i3);
a2.show();
}
public static boolean v() {
Looper mainLooper = Looper.getMainLooper();
return mainLooper != null && mainLooper.equals(Looper.myLooper());
}
public static String o(String str) {
return "'" + str.replaceAll("'", "\\\\'") + "'";
}
public static final Bundle a(Bundle bundle, String str) {
Bundle bundle2 = new Bundle();
int i2 = bf.SCENE_JSI_ID_START;
int i3 = bf.ACTION_EDIT_ID;
while (i2 >= 100000) {
i2 = 0;
for (String str2 : bundle.keySet()) {
if (str2 != null && gy.c(str2)) {
bundle2.putInt(str2, bundle.getInt(str2, StructureType.None.ordinal()));
} else {
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 {
bo.d("Utils", str + ": dropping var " + str2 + " length " + length + " cutoff " + i3);
if (bundle2.containsKey(str2)) {
bundle2.remove(str2);
}
}
}
}
}
i3 /= 2;
}
return bundle2;
}
public static String b(String str, String str2) {
return str2.replaceFirst(Pattern.quote(str + "."), "");
}
public static String a(CharSequence charSequence) {
return charSequence == null ? "" : charSequence.toString();
}
public static boolean a(List<String> list, Comparator<String> comparator, String str, String str2) {
try {
Collections.sort(list, comparator);
return true;
} catch (Exception e2) {
bo.c(str, str2 + ": " + e2.toString());
bo.c(str, a((List<?>) list, ','));
return false;
}
}
public static Charset p(String str) {
Charset defaultCharset = Charset.defaultCharset();
if (str == null) {
bo.b("Utils", "contentTypeToCharset: null");
return defaultCharset;
}
String[] split = str.split(";");
if (split == null) {
bo.b("Utils", "contentTypeToCharset: no spec in " + str);
return defaultCharset;
}
for (String str2 : split) {
if (str2 == null) {
bo.b("Utils", "contentTypeToCharset: null in spec " + str);
} else {
String trim = str2.trim();
if (trim.toLowerCase().startsWith("charset=")) {
String substring = trim.substring("charset=".length());
Charset q = q(substring);
if (q != null) {
bo.b("Utils", "contentTypeToCharset: parsed charset: " + substring + " from " + str);
return q;
}
bo.b("Utils", "contentTypeToCharset: unavailable charset: " + substring + " in " + str);
return defaultCharset;
}
}
}
return defaultCharset;
}
public static Charset q(String str) {
try {
return Charset.forName(str);
} catch (IllegalCharsetNameException unused) {
return null;
} catch (UnsupportedCharsetException unused2) {
return null;
}
}
public static Double r(String str) {
if (f13548a == null) {
f13548a = Pattern.compile("(-?\\d+(?:\\.\\d+)?)");
}
Matcher matcher = f13548a.matcher(str);
if (matcher.find()) {
return g(matcher.group());
}
return null;
}
public static Long s(String str) {
if (f13549b == null) {
f13549b = Pattern.compile("(-?\\d+)");
}
Matcher matcher = f13549b.matcher(str);
if (matcher.find()) {
return e(matcher.group());
}
return null;
}
public static boolean r(Context context) {
WifiManager wifiManager = (WifiManager) df.a(context, "wifi", "Utils", "haveWifiTether");
if (wifiManager == null) {
return false;
}
int b2 = bw.bd.b(wifiManager);
bo.b("Utils", "current state: " + b2);
return b2 == 3;
}
public static boolean a(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 boolean h(File file) {
File[] listFiles = file.listFiles();
if (listFiles == null) {
return true;
}
boolean z = true;
for (File file2 : listFiles) {
if (file2.isDirectory()) {
z = h(file2);
} else if (!file2.delete()) {
z = false;
}
if (!z) {
break;
}
}
boolean z2 = z;
if (!z2 || file.delete()) {
return z2;
}
return false;
}
public static void a(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 b(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 void a(StringBuilder sb, String str, char c2) {
if (sb.length() != 0) {
sb.append(c2);
}
sb.append(str);
}
public static String d(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);
}
bo.d("Utils", "null result from JSON replacement of " + str);
return str;
}
public static boolean s(Context context) {
return g(context).getBoolean("sHapt", true);
}
public static boolean t(String str) {
if (str == null) {
return false;
}
if (m == null) {
m = Pattern.compile(l, 0);
}
return m.matcher(str).find();
}
}