正在查看: Tasker v6.5.11 应用的 h4.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.5.11 应用的 h4.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package net.dinglisch.android.taskerm;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.UriPermission;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import net.dinglisch.android.taskerm.yd;
@SuppressLint({"NewApi"})
public final class h4 {
public static String a = "FileUtil";
private static int[] b = {2131889022, 2131889027, 2131889030, 2131889031, 2131889032, 2131889033, 2131889034, 2131889035, 2131889038, 2131889039};
class a implements Comparator<String> {
final boolean i;
a(boolean z) {
this.i = z;
}
@Override
public int compare(String str, String str2) {
return this.i ? str2.compareToIgnoreCase(str) : str.compareToIgnoreCase(str2);
}
}
class b implements Comparator<String> {
final boolean i;
b(boolean z) {
this.i = z;
}
@Override
public int compare(String str, String str2) {
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
String fileExtensionFromUrl2 = MimeTypeMap.getFileExtensionFromUrl(str2);
int compareToIgnoreCase = this.i ? fileExtensionFromUrl2.compareToIgnoreCase(fileExtensionFromUrl) : fileExtensionFromUrl.compareToIgnoreCase(fileExtensionFromUrl2);
return compareToIgnoreCase == 0 ? fileExtensionFromUrl2.compareToIgnoreCase(fileExtensionFromUrl) : compareToIgnoreCase;
}
}
class c implements Comparator<e> {
final boolean i;
final boolean q;
final d r;
c(boolean z, boolean z2, d dVar) {
this.i = z;
this.q = z2;
this.r = dVar;
}
@Override
public int compare(e eVar, e eVar2) {
int compare = this.i ? this.q ? Long.compare(eVar2.b, eVar.b) : Long.compare(eVar.b, eVar2.b) : this.q ? Long.compare(eVar.b, eVar2.b) : Long.compare(eVar2.b, eVar.b);
if (compare != 0) {
return compare;
}
d dVar = this.r;
return (dVar == d.DirectoryFile || dVar == d.FileDirectory) ? eVar.a.compareToIgnoreCase(eVar2.a) : eVar2.a.compareToIgnoreCase(eVar.a);
}
}
public enum d {
Alpha,
AlphaReverse,
DirectoryFile,
Extension,
ExtensionReverse,
FileDirectory,
ModifyDate,
ModifyDateReverse,
Size,
SizeReverse
}
private static class e {
public String a;
public long b;
public e(String str, long j) {
this.a = str;
this.b = j;
}
}
public static String A(String str, Context context) {
try {
StorageManager storageManager = (StorageManager) context.getSystemService("storage");
Class<?> cls = Class.forName("android.os.storage.StorageVolume");
Method method = storageManager.getClass().getMethod("getVolumeList", null);
Method method2 = cls.getMethod("getUuid", null);
Method method3 = cls.getMethod("isPrimary", null);
Object invoke = com.joaomgcd.taskerm.util.k.g() ? method.invoke(storageManager, null) : com.joaomgcd.taskerm.util.g8.s(context);
int length = Array.getLength(invoke);
for (int i = 0; i < length; i++) {
Object obj = Array.get(invoke, i);
if (d4.a(obj)) {
StorageVolume a2 = com.joaomgcd.taskerm.util.b8.a(obj);
String str2 = (String) method2.invoke(a2, null);
Boolean bool = (Boolean) method3.invoke(a2, null);
if (bool != null && bool.booleanValue() && "primary".equals(str)) {
return com.joaomgcd.taskerm.util.g8.U(a2);
}
if (str2 != null && str2.equals(str)) {
return com.joaomgcd.taskerm.util.g8.U(a2);
}
}
}
} catch (Exception unused) {
}
return null;
}
public static boolean B(Context context, File file, File file2) {
OutputStream outputStream;
if (!c0(context, file, false) && !c0(context, file2, true)) {
return jr.a(file, file2);
}
y1 o = o(context, file, "gunzipFile src");
y1 q = q(context, file2, false, "*/*", "gunzipFile dst");
if (q != null && file2 != null) {
GZIPInputStream gZIPInputStream = null;
r8 = null;
OutputStream outputStream2 = null;
gZIPInputStream = null;
try {
GZIPInputStream gZIPInputStream2 = new GZIPInputStream(new BufferedInputStream(M(context.getContentResolver(), o)));
try {
outputStream2 = N(context.getContentResolver(), q);
dq.H(gZIPInputStream2, outputStream2);
dq.C(gZIPInputStream2);
dq.D(outputStream2);
return true;
} catch (Exception e2) {
e = e2;
outputStream = outputStream2;
gZIPInputStream = gZIPInputStream2;
try {
r7.H(a, "gunzipDocFile", e);
dq.C(gZIPInputStream);
dq.D(outputStream);
return false;
} catch (Throwable th2) {
th = th2;
dq.C(gZIPInputStream);
dq.D(outputStream);
throw th;
}
} catch (Throwable th3) {
th = th3;
outputStream = outputStream2;
gZIPInputStream = gZIPInputStream2;
dq.C(gZIPInputStream);
dq.D(outputStream);
throw th;
}
} catch (Exception e3) {
e = e3;
outputStream = null;
} catch (Throwable th4) {
th = th4;
outputStream = null;
}
}
return false;
}
public static boolean C(Context context, File file, File file2) {
GZIPOutputStream gZIPOutputStream;
InputStream M;
if (!c0(context, file, false) && !c0(context, file2, true)) {
return jr.c(file, file2);
}
InputStream inputStream = null;
try {
y1 o = o(context, file, "gzipFile src");
y1 q = q(context, file2, false, "application/gzip", "gzipFile dst");
M = M(context.getContentResolver(), o);
try {
gZIPOutputStream = new GZIPOutputStream(new BufferedOutputStream(N(context.getContentResolver(), q)));
} catch (Exception e2) {
e = e2;
gZIPOutputStream = null;
} catch (Throwable th2) {
th = th2;
gZIPOutputStream = null;
}
} catch (Exception e3) {
e = e3;
gZIPOutputStream = null;
} catch (Throwable th3) {
th = th3;
gZIPOutputStream = null;
}
try {
dq.H(M, gZIPOutputStream);
dq.C(M);
dq.D(gZIPOutputStream);
return true;
} catch (Exception e4) {
e = e4;
inputStream = M;
try {
r7.H(a, "gzipFile", e);
dq.C(inputStream);
dq.D(gZIPOutputStream);
return false;
} catch (Throwable th4) {
th = th4;
dq.C(inputStream);
dq.D(gZIPOutputStream);
throw th;
}
} catch (Throwable th5) {
th = th5;
inputStream = M;
dq.C(inputStream);
dq.D(gZIPOutputStream);
throw th;
}
}
public static void D(Context context, int i, Intent intent) {
if (i != -1) {
r7.G(a, "result code " + i + " from FS permission request");
return;
}
Uri data = intent.getData();
String u = u(data, context);
if (u == null) {
r7.G(a, "handleDocFilePermResult: null fullpath for " + data + ", can't persist uri");
return;
}
r7.f(a, "FS perm request: user selected uri: " + data + " path " + u);
R(context.getContentResolver(), data, intent.getFlags(), false);
}
public static boolean E(Context context, File file, boolean z, boolean z2) {
if (yd.z.b()) {
List<UriPermission> a2 = yd.z.a(context.getContentResolver());
if (!dq.F(a2)) {
for (UriPermission uriPermission : a2) {
boolean b2 = yd.u0.b(uriPermission);
boolean c2 = yd.u0.c(uriPermission);
Uri a3 = yd.u0.a(uriPermission);
r7.f(a, "haveAccess: test : " + a3 + " wr: " + z + " ww: " + z2 + " ir: " + b2 + " iw: " + c2);
if (z && !b2) {
r7.f(a, "haveAccess: " + a3 + " grants no read for " + file);
} else if (!z2 || c2) {
String u = u(a3, context);
if (u == null || File.separator.equals(u)) {
r7.f(a, "haveAccess: null fullpath for perm: " + uriPermission + " uri: " + a3);
} else {
r7.f(a, "haveAccess: fullPath: " + u);
if (file.toString().startsWith(u.toString())) {
return true;
}
}
} else {
r7.f(a, "haveAccess: " + a3 + " grants no write for " + file);
}
}
}
}
return false;
}
public static boolean F(Context context, File file) {
if (!c0(context, file, false)) {
return file.isDirectory();
}
y1 o = o(context, file, "isDirWrapper");
if (o != null) {
return o.o();
}
return false;
}
public static long G(Context context, File file) {
if (!c0(context, file, false)) {
return file.lastModified();
}
y1 o = o(context, file, "modifiedWrapper");
if (o == null) {
return 0L;
}
return o.q();
}
public static long H(Context context, File file) {
if (!c0(context, file, false)) {
return file.length();
}
y1 o = o(context, file, "lengthWrapper");
if (o == null) {
return 0L;
}
return o.r();
}
public static String[] I(Context context, File file, FilenameFilter filenameFilter) {
boolean c0 = c0(context, file, false);
r7.f(a, "listWrapper: " + file + " wantDocFile: " + c0);
if (!c0) {
return filenameFilter != null ? file.list(filenameFilter) : file.list();
}
LinkedList linkedList = new LinkedList();
y1 q = q(context, file, false, null, "listWrapper");
if (q == null) {
return null;
}
for (y1 y1Var : q.s()) {
String i = y1Var.i();
if (filenameFilter == null || filenameFilter.accept(file, i)) {
linkedList.add(i);
}
}
return dq.i2(linkedList);
}
public static boolean J(File file) {
if (!file.isDirectory()) {
file = file.getParentFile();
}
if (file.exists()) {
return true;
}
return file.mkdirs();
}
public static boolean K(Context context, File file, boolean z) {
jf.d a2 = jf.a.a(context, file);
if (a2.E()) {
return true;
}
if (a2.h0()) {
return false;
}
return c0(context, file, true) ? q(context, file, z, "vnd.android.document/directory", "mkdirWrapper") != null : z ? file.mkdirs() : file.mkdir();
}
public static boolean L(Context context, File file, boolean z, boolean z2, boolean z3) {
boolean z4;
if (!z && file != null && d0(context, file, z3, "needReqDocAccess") && !E(context, file, z2, z3)) {
if (com.joaomgcd.taskerm.util.g8.A0(file, context)) {
z4 = true;
r7.f(a, "nrda: need request: " + file + ": " + z4);
return z4;
}
r7.k(a, "nrda: External storage " + file + " doesn't exist");
}
z4 = false;
r7.f(a, "nrda: need request: " + file + ": " + z4);
return z4;
}
public static InputStream M(ContentResolver contentResolver, y1 y1Var) {
try {
return contentResolver.openInputStream(y1Var.n());
} catch (FileNotFoundException e2) {
r7.H(a, "ois: " + y1Var.i(), e2);
return null;
}
}
public static OutputStream N(ContentResolver contentResolver, y1 y1Var) {
return O(contentResolver, y1Var, "w");
}
public static OutputStream O(ContentResolver contentResolver, y1 y1Var, String str) {
if (y1Var == null) {
return null;
}
try {
return contentResolver.openOutputStream(y1Var.n(), str);
} catch (FileNotFoundException e2) {
r7.H(a, "oos: " + y1Var.n() + " mode: " + str, e2);
return null;
}
}
public static OutputStream P(ContentResolver contentResolver, y1 y1Var) {
return O(contentResolver, y1Var, "wa");
}
public static OutputStream Q(ContentResolver contentResolver, y1 y1Var) {
return O(contentResolver, y1Var, "rwt");
}
public static void R(ContentResolver contentResolver, Uri uri, int i, boolean z) {
r7.f(a, "persist " + uri + " existing: " + i + " ro: " + z);
if (yd.z.b()) {
yd.z.c(contentResolver, uri, z ? i & 1 : i & 3);
return;
}
r7.G(a, "persist " + uri + ": no API");
}
public static boolean S(Context context, File file) {
if (!c0(context, file, true)) {
return dq.w2(file);
}
y1 o = o(context, file, "recDirDelete");
if (o == null) {
return false;
}
return T(o);
}
private static boolean T(y1 y1Var) {
y1[] s = y1Var.s();
boolean z = true;
if (s == null) {
return true;
}
for (y1 y1Var2 : s) {
if (y1Var2.o()) {
z = T(y1Var2);
} else if (!y1Var2.c()) {
z = false;
}
if (!z) {
break;
}
}
if (!z || y1Var.c()) {
return z;
}
return false;
}
public static boolean U(Context context, File file, File file2) {
if (!c0(context, file, true)) {
return false;
}
String parent = file.getParent();
String parent2 = file2.getParent();
if (parent == null || !parent.equals(parent2)) {
return false;
}
r7.f(a, "rename with file wrapper: " + file + " -> " + file2);
return jf.a.a(context, file).T(file2.getName());
}
public static boolean V(Context context, File file, File file2) {
Path path;
Path path2;
StandardCopyOption standardCopyOption;
r7.f(a, "rename: " + file + " -> " + file2);
if (c0(context, file, true) || c0(context, file2, true)) {
if (e(context, file, file2, true)) {
return F(context, file) ? S(context, file) : f(context, file);
}
} else {
if (!J(file2)) {
return false;
}
if (file.renameTo(file2)) {
return true;
}
r7.f(a, "Direct rename failed. Trying move...");
path = file.toPath();
path2 = file2.toPath();
try {
standardCopyOption = StandardCopyOption.REPLACE_EXISTING;
Files.move(path, path2, standardCopyOption);
return true;
} catch (IOException e2) {
r7.f(a, "Failed to move " + file + " to " + file2 + " - " + e2.getMessage());
}
}
return false;
}
public static void W(Activity activity, Handler handler) {
oi.i(activity, 2131888876, 2131887263, handler);
}
public static java.lang.String[] X(android.content.Context r16, java.io.File r17, java.lang.String[] r18, net.dinglisch.android.taskerm.h4.d r19) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.h4.X(android.content.Context, java.io.File, java.lang.String[], net.dinglisch.android.taskerm.h4$d):java.lang.String[]");
}
public static boolean Y(Context context, String str, File file, boolean z, boolean z2) {
if (z2 && !K(context, file.getParentFile(), true)) {
return false;
}
if (!c0(context, file, true)) {
return dq.C3(str, file, z);
}
String H0 = dq.H0(file);
if (TextUtils.isEmpty(H0)) {
H0 = "text/*";
}
y1 q = q(context, file, false, H0, "stringToFile");
if (q != null) {
OutputStream O = O(context.getContentResolver(), q, z ? "wa" : "rwt");
if (O != null) {
return dq.G3(str, new OutputStreamWriter(O));
}
}
return false;
}
public static boolean Z() {
return dq.g() >= 23;
}
private static String a(File file, String str, boolean z) {
if (str != null && !str.equals("vnd.android.document/directory")) {
String extensionFromMimeType = MimeTypeMap.getSingleton().getExtensionFromMimeType(str);
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(file.getName());
r7.f(a, "extension from mime: " + extensionFromMimeType + " existing: " + fileExtensionFromUrl);
if (TextUtils.isEmpty(fileExtensionFromUrl)) {
fileExtensionFromUrl = "*";
}
if (extensionFromMimeType != null && !extensionFromMimeType.toLowerCase().equals(fileExtensionFromUrl.toLowerCase())) {
str = str.replaceFirst("/.*$", "/" + fileExtensionFromUrl);
r7.f(a, "new type: " + str);
}
}
return (z || !TextUtils.isEmpty(str)) ? str : "application/octet-stream";
}
public static boolean a0(Context context, File file) {
return c0(context, file, true) ? b0(context, file, file.getParentFile(), null) : jr.e(file);
}
public static boolean b(Context context, byte[] bArr, File file) {
if (c0(context, file, true)) {
y1 q = q(context, file, false, dq.H0(file), "bytesToFile");
if (q != null) {
return dq.t(bArr, N(context.getContentResolver(), q));
}
return false;
}
try {
return dq.t(bArr, new FileOutputStream(file));
} catch (FileNotFoundException e2) {
r7.H(a, "bytesToFile: " + file, e2);
return false;
}
}
private static boolean b0(android.content.Context r9, java.io.File r10, java.io.File r11, java.util.regex.Pattern r12) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.h4.b0(android.content.Context, java.io.File, java.io.File, java.util.regex.Pattern):boolean");
}
private static boolean c(Context context, File file, File file2, boolean z) {
r7.f(a, "copyDir: " + file + " -> " + file2);
String[] list = file.list();
for (int i = 0; i < list.length; i++) {
if (!e(context, new File(file, list[i]), new File(file2, list[i]), z)) {
return false;
}
}
return true;
}
public static boolean c0(Context context, File file, boolean z) {
return d0(context, file, z, "");
}
public static boolean d(android.content.Context r6, java.io.File r7, java.io.File r8, boolean r9) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.h4.d(android.content.Context, java.io.File, java.io.File, boolean):boolean");
}
public static boolean d0(Context context, File file, boolean z, String str) {
if (com.joaomgcd.taskerm.util.g8.y0(file)) {
return true;
}
if (file == null) {
r7.G(a, str + ": wudc: file null");
return false;
}
if (context == null) {
r7.f(a, str + ": wudf: null context");
return false;
}
if (!z) {
r7.f(a, str + ": wudf: no write needed");
return false;
}
if (!Z()) {
r7.f(a, str + ": wudf: no support");
return false;
}
if (j(context, file)) {
return true;
}
r7.f(a, str + ": wudf: not external: " + file);
return false;
}
public static boolean e(Context context, File file, File file2, boolean z) {
r7.f(a, "copyFiles: " + file + " -> " + file2);
if (c0(context, file, false) || c0(context, file2, true)) {
y1 o = o(context, file, "copyFiles");
if (o == null) {
return false;
}
if (!o.o()) {
return d(context, file, file2, z);
}
if (q(context, file2, true, "vnd.android.document/directory", "copyFilesDir") == null) {
return false;
}
return c(context, file, file2, z);
}
if (!file.isDirectory()) {
return d(context, file, file2, z);
}
if (file2.exists() || file2.mkdirs()) {
return c(context, file, file2, z);
}
r7.G(a, "copyFiles: " + file + " -> " + file2 + ": couldn't make dest");
return false;
}
public static boolean e0(Context context, File[] fileArr, File file, int i) {
if (!c0(context, file, true)) {
return jr.g(context, fileArr, file, i);
}
y1 q = q(context, file, false, "application/zip", "zipFilesAndDirs");
if (q != null) {
try {
ZipOutputStream zipOutputStream = new ZipOutputStream(N(context.getContentResolver(), q));
zipOutputStream.setLevel(i);
for (File file2 : fileArr) {
if (!f0(context, file2, new File("."), zipOutputStream)) {
r7.G(a, "failed to zip " + file2 + ", bailing");
zipOutputStream.close();
q.c();
return false;
}
}
dq.D(zipOutputStream);
return true;
} catch (Exception e2) {
r7.H(a, "zipFilesAndDirs", e2);
}
}
return false;
}
public static boolean f(Context context, File file) {
if (!c0(context, file, true)) {
return file.delete();
}
y1 o = o(context, file, "deleteWrapper");
if (o == null) {
return false;
}
return o.c();
}
public static boolean f0(Context context, File file, File file2, ZipOutputStream zipOutputStream) {
BufferedInputStream bufferedInputStream;
jf.d a2 = jf.a.a(context, file);
File file3 = file2.toString().equals(".") ? new File(file.getName()) : new File(file2, file.getName());
String file4 = file3.toString();
r7.f(a, "create entry " + file4);
try {
if (a2.E()) {
String str = file4 + File.separator;
str.replace('\\', '/');
zipOutputStream.putNextEntry(new ZipEntry(str));
zipOutputStream.closeEntry();
String[] I = I(context, file, null);
if (dq.r(I)) {
return true;
}
for (String str2 : I) {
r7.f(a, "zip: " + file3);
if (!f0(context, new File(file, str2), file3, zipOutputStream)) {
r7.G(a, "failed to zip: " + file + ", bailing");
return false;
}
}
return true;
}
ZipEntry zipEntry = new ZipEntry(file4);
if (c0(context, file, false)) {
y1 q = q(context, file, false, dq.H0(file), "zipFileToStream");
if (q == null) {
return false;
}
bufferedInputStream = new BufferedInputStream(M(context.getContentResolver(), q));
} else {
bufferedInputStream = new BufferedInputStream(new FileInputStream(file), 8192);
}
byte[] bArr = new byte[8192];
try {
zipOutputStream.putNextEntry(zipEntry);
while (true) {
int read = bufferedInputStream.read(bArr);
if (read == -1) {
dq.C(bufferedInputStream);
zipOutputStream.closeEntry();
return true;
}
zipOutputStream.write(bArr, 0, read);
}
} catch (Throwable th2) {
dq.C(bufferedInputStream);
throw th2;
}
} catch (Exception e2) {
r7.H(a, "zipToStream: " + file, e2);
return false;
}
}
public static boolean g(Context context, File file) {
return !dq.r(I(context, file, null));
}
private static y1 h(File file, boolean z) {
if (file == null) {
return null;
}
y1 n = n(file, "mkdir");
if (!n.d()) {
LinkedList<String> linkedList = new LinkedList();
while (!n.d()) {
linkedList.add(0, file.getName());
r7.f(a, "added name " + file.getName());
file = file.getParentFile();
n = n(file, "mkdir");
if (n == null || !z) {
break;
}
}
for (String str : linkedList) {
if (n == null || (n = n.a(str)) == null) {
break;
}
}
} else {
r7.f(a, "mkdir: " + n.n() + ": already exists");
}
return n;
}
public static boolean i(Context context, File file) {
return jf.a.a(context, file).V();
}
public static boolean j(Context context, File file) {
String file2 = file.toString();
Iterator<String> it = t(context).iterator();
while (it.hasNext()) {
if (file2.startsWith(it.next())) {
return true;
}
}
return false;
}
public static byte[] k(Context context, File file) {
if (c0(context, file, false)) {
y1 o = o(context, file, "fileToBytes");
if (o != null) {
return dq.F1(M(context.getContentResolver(), o));
}
return null;
}
try {
return dq.F1(new FileInputStream(file));
} catch (FileNotFoundException e2) {
r7.H(a, "fileToBytes: " + file, e2);
return null;
}
}
public static InputStreamReader l(Context context, File file) {
try {
return new InputStreamReader(jf.a.j(file, context).b0());
} catch (Exception e2) {
r7.H(a, "fileToISR", e2);
return null;
}
}
public static String m(Context context, File file) {
return dq.f(l(context, file));
}
private static y1 n(File file, String str) {
y1 f = y1.f(file);
if (f == null) {
r7.G(a, str + ": docFromFile: " + file + ": null");
} else {
r7.f(a, str + ": " + file + " -> " + f.n());
}
return f;
}
public static y1 o(Context context, File file, String str) {
return q(context, file, false, null, str);
}
public static y1 p(Context context, File file, String str, boolean z) {
return r(context, file, false, null, str, z);
}
public static y1 q(Context context, File file, boolean z, String str, String str2) {
return r(context, file, z, str, str2, false);
}
public static net.dinglisch.android.taskerm.y1 r(android.content.Context r16, java.io.File r17, boolean r18, java.lang.String r19, java.lang.String r20, boolean r21) {
throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.h4.r(android.content.Context, java.io.File, boolean, java.lang.String, java.lang.String, boolean):net.dinglisch.android.taskerm.y1");
}
private static String s(Uri uri, String str, boolean z) {
String str2;
String l = y1.l(uri, str + "/getDocFromTreeUri", z);
if (l == null) {
return null;
}
String[] split = l.split(ConstantsCommonTaskerServer.ID_SEPARATOR);
return (split.length < 2 || (str2 = split[1]) == null) ? File.separator : str2;
}
public static ArrayList<String> t(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
if (yd.a0.b() && Z()) {
for (File file : com.joaomgcd.taskerm.util.g8.r(context)) {
if (file != null && !file.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().getAbsolutePath())) {
int lastIndexOf = file.getAbsolutePath().lastIndexOf("/Android/data");
String absolutePath = file.getAbsolutePath();
if (lastIndexOf > 0) {
absolutePath = absolutePath.substring(0, lastIndexOf);
}
try {
absolutePath = new File(absolutePath).getCanonicalPath();
} catch (IOException unused) {
}
arrayList.add(absolutePath);
}
}
}
return arrayList;
}
public static String u(Uri uri, Context context) {
return v(uri, context, false);
}
public static String v(Uri uri, Context context, boolean z) {
String z2;
if (uri == null || (z2 = z(uri, "getFullPathFromTreeUriA")) == null) {
return null;
}
String A = A(z2, context);
if (A == null) {
return File.separator;
}
String str = File.separator;
if (A.endsWith(str)) {
A = A.substring(0, A.length() - 1);
}
String s = s(uri, "getFullPathFromTreeUriB", z);
if (s == null) {
return null;
}
if (s.endsWith(str)) {
s = s.substring(0, s.length() - 1);
}
if (s.length() <= 0) {
return A;
}
if (s.startsWith(str)) {
return A + s;
}
return A + str + s;
}
public static Intent w(boolean z) {
Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT_TREE");
if (z) {
intent.putExtra("android.intent.extra.LOCAL_ONLY", true);
}
return intent;
}
public static String[] x(Resources resources) {
return vh.s(resources, b);
}
public static Intent y(Context context, File file, String str, boolean z) {
String str2;
Uri uri;
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(1);
if (z) {
intent.addFlags(2);
}
y1 o = c0(context, file, false) ? o(context, file, "getViewFileIntent") : null;
if (o == null) {
str2 = TextUtils.isEmpty(str) ? dq.H0(file) : str;
uri = com.joaomgcd.taskerm.util.g8.i0(file, context, null, intent);
} else {
String m = TextUtils.isEmpty(str) ? o.m() : str;
Uri n = o.n();
str2 = m;
uri = n;
}
r7.f(a, "getViewFileIntent: file: " + file + " wantType: " + str + " uri: " + uri + " type " + str2);
intent.setDataAndType(uri, str2);
return intent;
}
private static String z(Uri uri, String str) {
String k = y1.k(uri, str + "/getVolumeIdFromTreeUri");
if (k != null) {
String[] split = k.split(ConstantsCommonTaskerServer.ID_SEPARATOR);
if (split.length > 0) {
return split[0];
}
}
return null;
}
}