正在查看: Tasker v6.6.3 应用的 ph.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.6.3 应用的 ph.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.joaomgcd.taskerm.util;
import android.annotation.TargetApi;
import android.content.ClipData;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64InputStream;
import android.util.Base64OutputStream;
import android.webkit.MimeTypeMap;
import androidx.core.content.FileProvider;
import bg.h;
import com.joaomgcd.taskerm.util.r;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import cyanogenmod.app.ProfileManager;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import net.dinglisch.android.taskerm.pp;
import net.dinglisch.android.taskerm.ud;
public final class ph {
private static final vj.j a = vj.k.a(new ik.a() {
@Override
public final Object e() {
String l;
l = ph.l();
return l;
}
});
public static List A(Collection collection, Context context, boolean z, boolean z2, boolean z3, boolean z4, int i, Object obj) {
return z(collection, context, (i & 2) != 0 ? true : z, (i & 4) != 0 ? false : z2, (i & 8) != 0 ? false : z3, (i & 16) != 0 ? true : z4);
}
public static final Uri A0(File file, Context context, String[] strArr, Intent intent, boolean z) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
if (c0.p(context)) {
Uri fromFile = Uri.fromFile(file);
jk.p.f(fromFile);
return fromFile;
}
Uri h = FileProvider.h(context, context.getPackageName() + ".fileprovider", file);
int i = z ? 67 : 65;
if (intent != null) {
intent.addFlags(i);
}
if (strArr != null) {
for (String str : strArr) {
context.grantUriPermission(str, h, i);
}
}
jk.p.f(h);
return h;
}
public static final String B(final String str) {
File file;
jk.p.i(str, "<this>");
if (S0(str) || G0(str) || I0(str) || H0(str) || (file = (File) b7.n6(null, new ik.a() {
@Override
public final Object e() {
File j;
j = ph.j(str);
return j;
}
}, 1, null)) == null || !file.exists()) {
return null;
}
return file.getAbsolutePath();
}
public static final Uri B0(String str, Context context, String[] strArr, Intent intent, boolean z) {
jk.p.i(str, "<this>");
jk.p.i(context, "context");
File file = new File(sk.q.I(str, "file://", "", false, 4, null));
if (file.exists()) {
return A0(file, context, strArr, intent, z);
}
return null;
}
@TargetApi(30)
public static final File[] C(Context context) {
File directory;
jk.p.i(context, "<this>");
if (r.a.o()) {
File[] a2 = ud.a0.a(context, "external pre nougat");
jk.p.h(a2, "getExternalFilesDirs(...)");
return (File[]) kotlin.collections.n.M(a2, 1).toArray(new File[0]);
}
StorageVolume[] D = D(context);
ArrayList arrayList = new ArrayList();
for (StorageVolume storageVolume : D) {
if (!storageVolume.isPrimary()) {
arrayList.add(storageVolume);
}
}
if (!r.a.t()) {
ArrayList arrayList2 = new ArrayList();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
directory = ((StorageVolume) it.next()).getDirectory();
if (directory != null) {
arrayList2.add(directory);
}
}
return (File[]) arrayList2.toArray(new File[0]);
}
ArrayList arrayList3 = new ArrayList();
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
File g0 = g0((StorageVolume) it2.next());
if (g0 != null) {
arrayList3.add(g0);
}
}
if (!arrayList3.isEmpty()) {
return (File[]) arrayList3.toArray(new File[0]);
}
File[] a3 = ud.a0.a(context, "external");
jk.p.f(a3);
return a3;
}
public static Uri C0(File file, Context context, String[] strArr, Intent intent, boolean z, int i, Object obj) {
if ((i & 2) != 0) {
strArr = null;
}
if ((i & 4) != 0) {
intent = null;
}
if ((i & 8) != 0) {
z = true;
}
return A0(file, context, strArr, intent, z);
}
@TargetApi(30)
public static final StorageVolume[] D(Context context) {
jk.p.i(context, "<this>");
r.a aVar = r.a;
if (aVar.o()) {
return new StorageVolume[0];
}
StorageManager O2 = ExtensionsContextKt.O2(context);
if (O2 == null) {
return new StorageVolume[0];
}
List<StorageVolume> storageVolumes = aVar.t() ? O2.getStorageVolumes() : O2.getRecentStorageVolumes();
jk.p.f(storageVolumes);
List b0 = kotlin.collections.t.b0(storageVolumes);
ArrayList arrayList = new ArrayList();
for (Object obj : b0) {
if (b7.b1(((StorageVolume) obj).getState(), "mounted", "mounted_ro")) {
arrayList.add(obj);
}
}
return (StorageVolume[]) arrayList.toArray(new StorageVolume[0]);
}
public static Uri D0(String str, Context context, String[] strArr, Intent intent, boolean z, int i, Object obj) {
if ((i & 2) != 0) {
strArr = null;
}
if ((i & 4) != 0) {
intent = null;
}
if ((i & 8) != 0) {
z = true;
}
return B0(str, context, strArr, intent, z);
}
public static final String E(File file) {
jk.p.i(file, "<this>");
FileInputStream fileInputStream = new FileInputStream(file);
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 2);
try {
gk.a.b(fileInputStream, base64OutputStream, 0, 2, null);
base64OutputStream.flush();
base64OutputStream.close();
byteArrayOutputStream.flush();
String byteArrayOutputStream2 = byteArrayOutputStream.toString();
gk.b.a(base64OutputStream, null);
gk.b.a(byteArrayOutputStream, null);
gk.b.a(fileInputStream, null);
jk.p.h(byteArrayOutputStream2, "use(...)");
return byteArrayOutputStream2;
} finally {
}
} finally {
}
} finally {
}
}
public static final String E0(File file, Context context, String str) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
jk.p.i(str, "destinationPacakge");
String uri = C0(file, context, new String[]{str}, null, false, 12, null).toString();
jk.p.h(uri, "toString(...)");
return uri;
}
public static final File F(Context context, String str) {
jk.p.i(context, "<this>");
jk.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
return H(context, str, null, 2, null);
}
public static final boolean F0(String str) {
jk.p.i(str, "<this>");
return false;
}
public static final File G(Context context, String str, String str2) {
jk.p.i(context, "<this>");
jk.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
if (str2 == null) {
return new File(context.getCacheDir(), str);
}
return new File(context.getCacheDir() + "/" + str2, str);
}
public static final boolean G0(String str) {
jk.p.i(str, "<this>");
return sk.q.O(str, "android.resource", false, 2, null);
}
public static File H(Context context, String str, String str2, int i, Object obj) {
if ((i & 2) != 0) {
str2 = null;
}
return G(context, str, str2);
}
public static final boolean H0(String str) {
jk.p.i(str, "<this>");
return sk.q.O(str, bg.l.z(), false, 2, null) || sk.q.O(str, bg.l.y(), false, 2, null);
}
public static final boolean I(String str) {
File N = N(str);
if (N != null) {
return N.canRead();
}
return false;
}
public static final boolean I0(String str) {
jk.p.i(str, "<this>");
return sk.q.O(str, "content://", false, 2, null);
}
public static final java.lang.String J(android.content.Context r8, android.net.Uri r9, java.lang.String r10, java.lang.String[] r11) {
throw new UnsupportedOperationException("Method not decompiled: com.joaomgcd.taskerm.util.ph.J(android.content.Context, android.net.Uri, java.lang.String, java.lang.String[]):java.lang.String");
}
public static final boolean J0(File file, Context context, boolean z) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
return net.dinglisch.android.taskerm.d4.c0(context, file, z);
}
public static final File K(final Uri uri, final Context context) {
jk.p.i(uri, "<this>");
jk.p.i(context, "context");
String str = (String) b7.n6(null, new ik.a() {
@Override
public final Object e() {
String L;
L = ph.L(uri, context);
return L;
}
}, 1, null);
if (str == null) {
return null;
}
File file = new File(str);
if (file.exists()) {
return file;
}
return null;
}
public static final boolean K0(Uri uri) {
jk.p.i(uri, "<this>");
return jk.p.d("com.android.providers.downloads.documents", uri.getAuthority());
}
public static final String L(Uri uri, Context context) {
return j0(uri, context);
}
public static final boolean L0(Uri uri) {
jk.p.i(uri, "<this>");
return jk.p.d("com.android.externalstorage.documents", uri.getAuthority());
}
@TargetApi(30)
public static final List<String> M(Context context) {
jk.p.i(context, "<this>");
ArrayList<String> t = net.dinglisch.android.taskerm.d4.t(context);
jk.p.h(t, "getExtSdCardPaths(...)");
return t;
}
public static final boolean M0(String str) {
String P;
if (str == null || (P = P(str)) == null) {
return false;
}
return sk.q.O(P, "file://", false, 2, null);
}
public static final File N(String str) {
File c1;
if (str == null || str.length() == 0 || (c1 = pp.c1()) == null) {
return null;
}
String str2 = File.separator;
jk.p.h(str2, "separator");
return sk.q.O(str, str2, false, 2, null) ? new File(str) : new File(c1, str);
}
public static final boolean N0(Uri uri) {
jk.p.i(uri, "<this>");
return jk.p.d("com.android.providers.media.documents", uri.getAuthority());
}
public static final String O(Uri uri, Context context) {
int columnIndex;
String str;
jk.p.i(uri, "<this>");
jk.p.i(context, "context");
String str2 = null;
if (jk.p.d(uri.getScheme(), "content")) {
try {
Cursor query = context.getContentResolver().query(uri, null, null, null, null);
if (query != null) {
try {
String string = (!query.moveToFirst() || (columnIndex = query.getColumnIndex("_display_name")) == -1) ? null : query.getString(columnIndex);
try {
vj.e0 e0Var = vj.e0.a;
try {
gk.b.a(query, null);
} catch (Exception unused) {
}
str2 = string;
} catch (Throwable th2) {
String str3 = string;
th = th2;
str2 = str3;
try {
throw th;
} finally {
}
}
} catch (Throwable th3) {
th = th3;
}
}
} catch (Exception unused2) {
}
}
if (str2 == null) {
str2 = uri.getLastPathSegment();
}
if (str2 == null || str2.length() == 0) {
String type = context.getContentResolver().getType(uri);
String extensionFromMimeType = type != null ? MimeTypeMap.getSingleton().getExtensionFromMimeType(type) : "bin";
long currentTimeMillis = System.currentTimeMillis();
if (extensionFromMimeType != null) {
str = "." + extensionFromMimeType;
} else {
str = "";
}
str2 = "shared_file_" + currentTimeMillis + str;
}
return new sk.n("[^a-zA-Z0-9._-]").k(str2, "_");
}
public static final boolean O0(String str) {
jk.p.i(str, "<this>");
if (str.length() % 4 != 0) {
return false;
}
String str2 = sk.q.n1(str, 10) + sk.q.o1(str, 10);
for (int i = 0; i < str2.length(); i++) {
char charAt = str2.charAt(i);
if (!sk.q.T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", charAt, false, 2, null) && charAt != '=') {
return false;
}
}
return true;
}
public static final String P(String str) {
jk.p.i(str, "<this>");
if (!sk.q.O(str, "/", false, 2, null)) {
return str;
}
return "file://" + str;
}
public static final boolean P0(File file) {
return Q0(file != null ? file.getAbsolutePath() : null);
}
public static final String Q(String str) {
jk.p.i(str, "<this>");
return sk.q.O(str, "file://", false, 2, null) ? sk.q.z0(str, "file://") : str;
}
public static final boolean Q0(String str) {
if (str == null || r.a.o()) {
return false;
}
return sk.q.O(str, "/mnt/media_rw", false, 2, null) || F0(str);
}
public static final List<String> R(Intent intent, Context context, boolean z, boolean z2, boolean z3) {
ArrayList arrayList;
String uri;
String string;
jk.p.i(context, "context");
if (intent == null) {
throw new RuntimeException("Couldn't get result");
}
if (z) {
Bundle extras = intent.getExtras();
if (extras == null || (string = extras.getString("path")) == null) {
throw new RuntimeException("Couldn't get result");
}
if (z2) {
string = pp.B2(string);
}
return kotlin.collections.t.d(string);
}
ClipData clipData = intent.getClipData();
if (intent.getDataString() != null) {
arrayList = kotlin.collections.t.f(intent.getDataString());
} else {
if (clipData == null) {
throw new RuntimeException("Couldn't get result");
}
arrayList = new ArrayList();
int itemCount = clipData.getItemCount();
for (int i = 0; i < itemCount; i++) {
Uri uri2 = clipData.getItemAt(i).getUri();
if (uri2 != null && (uri = uri2.toString()) != null) {
arrayList.add(uri);
}
}
}
return A(arrayList, context, z2, false, false, z3, 12, null);
}
public static final boolean R0(File file, Context context) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
String absolutePath = file.getAbsolutePath();
jk.p.f(absolutePath);
if (F0(absolutePath)) {
return true;
}
List<String> M = M(context);
if (M == null || !M.isEmpty()) {
Iterator<T> it = M.iterator();
while (it.hasNext()) {
if (sk.q.O(absolutePath, (String) it.next(), false, 2, null)) {
return true;
}
}
}
return false;
}
@TargetApi(26)
public static final InputStream S(final String str, Context context) throws l3 {
InputStream openInputStream;
byte[] p;
jk.p.i(str, "<this>");
jk.p.i(context, "context");
File file = (File) b7.n6(null, new ik.a() {
@Override
public final Object e() {
File T;
T = ph.T(str);
return T;
}
}, 1, null);
if (file != null && file.exists()) {
return U(file, context);
}
if (S0(str)) {
return lg.n1.D(str);
}
if (M0(str)) {
return U(new File(Q(str)), context);
}
if (G0(str)) {
h.a aVar = bg.h.a;
PackageManager packageManager = context.getPackageManager();
jk.p.h(packageManager, "getPackageManager(...)");
Bitmap l = h.a.l(aVar, packageManager, str, null, null, 12, null);
if (l == null || (p = bg.l.p(l)) == null || (openInputStream = b7.k2(p)) == null) {
throw new RuntimeException("Could not get android resource image " + str);
}
} else {
if (!I0(str)) {
return O0(str) ? v(str) : U(U0(str, true), context);
}
openInputStream = context.getContentResolver().openInputStream(Uri.parse(str));
if (openInputStream == null) {
throw new RuntimeException("Could not get content resource " + str);
}
}
return openInputStream;
}
public static final boolean S0(String str) {
jk.p.i(str, "<this>");
return sk.q.O(str, "http", false, 2, null);
}
public static final File T(String str) {
return U0(str, true);
}
public static final boolean T0(File file) {
rf.d bVar;
jk.p.i(file, "<this>");
Context c = ng.c("mkParentDirs");
if (c == null || (bVar = rf.a.b(c, file, true)) == null) {
bVar = new rf.b(file);
}
if (!bVar.F() && (bVar = bVar.w()) == null) {
return false;
}
if (bVar.Y()) {
return true;
}
return c != null ? bVar.q(c) : bVar.A().mkdirs();
}
private static final InputStream U(File file, Context context) {
rf.d l = rf.a.l(file, context, false, 2, (Object) null);
if (!l.Y()) {
throw new RuntimeException("File doesn't exist: " + file);
}
InputStream U = l.U();
if (U != null) {
return U;
}
throw new RuntimeException("Could not open: " + file);
}
public static final File U0(String str, boolean z) throws l3 {
jk.p.i(str, "<this>");
File c1 = pp.c1();
if (c1 == null) {
V0(z, 2131887981);
}
if (str.length() == 0) {
V0(z, 2131887974);
}
String str2 = File.separator;
jk.p.h(str2, "separator");
return sk.q.O(str, str2, false, 2, null) ? new File(str) : new File(c1, str);
}
@TargetApi(24)
public static final String V(StorageVolume storageVolume, Context context, String str) {
jk.p.i(context, "context");
jk.p.i(str, "path");
if (storageVolume == null) {
return str;
}
if (r.a.o()) {
return b7.j6(2131887762, context, new Object[0]);
}
return kotlin.collections.t.n0(kotlin.collections.n.N(new String[]{v0(storageVolume), storageVolume.getDescription(context), str}), " - ", null, null, 0, null, null, 62, null);
}
private static final void V0(boolean z, int i) {
if (z) {
throw new l3(i);
}
}
public static final String W(File file) {
jk.p.i(file, "<this>");
return u8.a(file);
}
public static final boolean W0(File file, Context context, boolean z, String str) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
jk.p.i(str, "chooserTitle");
return Y0(file, context, z, str, null, null, 24, null);
}
public static final String X(File file) {
jk.p.i(file, "<this>");
return pp.H0(file);
}
public static final boolean X0(File file, Context context, boolean z, String str, String str2, ik.l<? super String, vj.e0> lVar) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
jk.p.i(str, "chooserTitle");
return pp.l3(context, t0(file, context, str2, null, lVar, z, str, 4, null));
}
public static final String Y(String str) {
jk.p.i(str, "<this>");
return pp.H0(new File(Q(str)));
}
public static boolean Y0(File file, Context context, boolean z, String str, String str2, ik.l lVar, int i, Object obj) {
if ((i & 2) != 0) {
z = true;
}
boolean z2 = z;
if ((i & 4) != 0) {
str = "";
}
return X0(file, context, z2, str, (i & 8) != 0 ? null : str2, (i & 16) != 0 ? null : lVar);
}
public static final FileDescriptor Z(File file, Context context) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
return b0(file, context, null, null, 6, null);
}
public static final void Z0(File file) {
jk.p.i(file, "<this>");
file.setExecutable(true, false);
file.setReadable(true, false);
file.setWritable(true, false);
}
public static final FileDescriptor a0(File file, Context context, String str, String str2) {
Uri parse;
jk.p.i(file, "<this>");
jk.p.i(context, "context");
if (J0(file, context, true)) {
parse = net.dinglisch.android.taskerm.d4.q(context, file, false, str, str2).n();
} else {
String absolutePath = file.getAbsolutePath();
jk.p.h(absolutePath, "getAbsolutePath(...)");
parse = Uri.parse(P(absolutePath));
}
ParcelFileDescriptor openFileDescriptor = context.getContentResolver().openFileDescriptor(parse, "w");
if (openFileDescriptor != null) {
return openFileDescriptor.getFileDescriptor();
}
return null;
}
public static final void a1(File file, Context context) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
c1(file, context, null, 2, null);
}
public static FileDescriptor b0(File file, Context context, String str, String str2, int i, Object obj) {
if ((i & 2) != 0) {
str = null;
}
if ((i & 4) != 0) {
str2 = null;
}
return a0(file, context, str, str2);
}
public static final void b1(File file, Context context, String str) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
jk.p.i(str, "mimeType");
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.setDataAndType(C0(file, context, null, intent, false, 10, null), str);
if (pp.l3(context, intent)) {
return;
}
pp.b0(context, "no viewer activity found", new Object[0]);
}
public static final File c0(String str, Context context, String str2, String str3) {
File N;
jk.p.i(str, "<this>");
jk.p.i(context, "context");
File U0 = U0(str, true);
if (!U0.isDirectory()) {
return U0;
}
Uri D = l7.D(str);
String j0 = D != null ? j0(D, context) : null;
net.dinglisch.android.taskerm.o7.f("UtilFile", "getOutputStreamFromPath real path for output: " + j0);
if (str3 == null) {
str3 = (j0 == null || (N = N(j0)) == null) ? null : N.getName();
if (str3 == null) {
if (str2 == null) {
throw new RuntimeException("Output file is a directory. Must provide fromPathDirectory");
}
str3 = new File(str2).getName();
}
}
return new File(U0, str3);
}
public static void c1(File file, Context context, String str, int i, Object obj) {
if ((i & 2) != 0) {
str = "text/plain";
}
b1(file, context, str);
}
public static File d0(String str, Context context, String str2, String str3, int i, Object obj) {
if ((i & 2) != 0) {
str2 = str;
}
if ((i & 4) != 0) {
str3 = null;
}
return c0(str, context, str2, str3);
}
public static final void d1(File file, String str) {
jk.p.i(file, "<this>");
jk.p.i(str, "content");
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
try {
bufferedWriter.write(str);
vj.e0 e0Var = vj.e0.a;
gk.b.a(bufferedWriter, null);
} finally {
}
}
public static final OutputStream e0(File file, Context context, String str, String str2) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
if (!J0(file, context, true)) {
return new FileOutputStream(file);
}
OutputStream Q = net.dinglisch.android.taskerm.d4.Q(context.getContentResolver(), net.dinglisch.android.taskerm.d4.q(context, file, false, str, str2));
return Q == null ? new FileOutputStream(file) : Q;
}
public static final OutputStream f0(String str, Context context, String str2, String str3, String str4) {
jk.p.i(str, "<this>");
jk.p.i(context, "context");
return e0(d0(str, context, str3, null, 4, null), context, str2, str4);
}
@TargetApi(30)
public static final File g0(final StorageVolume storageVolume) {
File directory;
jk.p.i(storageVolume, "<this>");
if (r.a.t()) {
return (File) b7.n6(null, new ik.a() {
@Override
public final Object e() {
File k;
k = ph.k(storageVolume);
return k;
}
}, 1, null);
}
directory = storageVolume.getDirectory();
return directory;
}
public static final String h0(StorageVolume storageVolume) {
jk.p.i(storageVolume, "<this>");
File g0 = g0(storageVolume);
if (g0 != null) {
return g0.toString();
}
return null;
}
public static final File i0(File file, String str) {
jk.p.i(file, "<this>");
if (file.exists()) {
return (file.isFile() || str == null) ? file : new File(file, str);
}
String name = file.getName();
jk.p.h(name, "getName(...)");
return sk.q.U(name, ".", false, 2, null) ? file : str != null ? new File(file, str) : file;
}
public static final File j(String str) {
return U0(str, true);
}
public static final String j0(final Uri uri, final Context context) {
jk.p.i(uri, "<this>");
jk.p.i(context, "context");
String str = (String) r0(null, new ik.a() {
@Override
public final Object e() {
String m0;
m0 = ph.m0(uri, context);
return m0;
}
}, 1, null);
if (str != null) {
return str;
}
String str2 = (String) r0(null, new ik.a() {
@Override
public final Object e() {
String n0;
n0 = ph.n0(uri, context);
return n0;
}
}, 1, null);
if (str2 != null) {
return str2;
}
String str3 = (String) r0(null, new ik.a() {
@Override
public final Object e() {
String o0;
o0 = ph.o0(uri, context);
return o0;
}
}, 1, null);
return str3 != null ? str3 : (String) r0(null, new ik.a() {
@Override
public final Object e() {
String p0;
p0 = ph.p0(uri, context);
return p0;
}
}, 1, null);
}
public static final File k(StorageVolume storageVolume) {
if (storageVolume != null) {
return (File) mi.v(storageVolume.getClass(), "mPath", null, true).get(storageVolume);
}
throw new m3("reflection instance is null", null, 2, null);
}
public static final String k0(String str, Context context) {
jk.p.i(str, "<this>");
jk.p.i(context, "context");
Uri parse = Uri.parse(str);
jk.p.h(parse, "parse(...)");
return j0(parse, context);
}
public static final String l() {
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data";
}
private static final String l0(Uri uri, Context context) {
List m;
List m2;
Uri uri2 = null;
if (DocumentsContract.isDocumentUri(context, uri)) {
String documentId = DocumentsContract.getDocumentId(uri);
jk.p.f(documentId);
if (sk.q.O(documentId, "raw:", false, 2, null)) {
return sk.q.z0(documentId, "raw:");
}
if (L0(uri)) {
List<String> l = new sk.n(ConstantsCommonTaskerServer.ID_SEPARATOR).l(documentId, 0);
if (!l.isEmpty()) {
ListIterator<String> listIterator = l.listIterator(l.size());
while (listIterator.hasPrevious()) {
if (listIterator.previous().length() != 0) {
m2 = kotlin.collections.t.I0(l, listIterator.nextIndex() + 1);
break;
}
}
}
m2 = kotlin.collections.t.m();
String[] strArr = (String[]) m2.toArray(new String[0]);
String str = strArr[0];
if (sk.q.B("primary", str, true)) {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
String str2 = (String) kotlin.collections.n.a0(strArr, 1);
if (str2 == null) {
str2 = "";
}
return externalStorageDirectory + "/" + str2;
}
String str3 = (String) kotlin.collections.n.a0(strArr, 1);
if (str3 == null) {
return null;
}
return net.dinglisch.android.taskerm.d4.A(str, context) + "/" + str3;
}
if (K0(uri)) {
Long v = sk.q.v(documentId);
if (v == null) {
throw new k3(uri);
}
Uri withAppendedId = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), v.longValue());
jk.p.h(withAppendedId, "withAppendedId(...)");
String J = J(context, withAppendedId, null, null);
if (J != null) {
return J;
}
throw new k3(uri);
}
if (N0(uri)) {
List<String> l2 = new sk.n(ConstantsCommonTaskerServer.ID_SEPARATOR).l(documentId, 0);
if (!l2.isEmpty()) {
ListIterator<String> listIterator2 = l2.listIterator(l2.size());
while (listIterator2.hasPrevious()) {
if (listIterator2.previous().length() != 0) {
m = kotlin.collections.t.I0(l2, listIterator2.nextIndex() + 1);
break;
}
}
}
m = kotlin.collections.t.m();
String[] strArr2 = (String[]) m.toArray(new String[0]);
String str4 = strArr2[0];
if (jk.p.d("image", str4)) {
uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if (jk.p.d("video", str4)) {
uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if (jk.p.d("audio", str4)) {
uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
return J(context, uri2, "_id=?", new String[]{strArr2[1]});
}
} else {
String scheme = uri.getScheme();
jk.p.f(scheme);
if (sk.q.B("content", scheme, true)) {
return J(context, uri, null, null);
}
String scheme2 = uri.getScheme();
jk.p.f(scheme2);
if (sk.q.B("file", scheme2, true)) {
return uri.getPath();
}
}
return null;
}
@TargetApi(26)
public static final void m(Context context, String str, File file) {
jk.p.i(context, "<this>");
jk.p.i(str, "base64String");
jk.p.i(file, "to");
o(context, str, file, null, 4, null);
}
public static final String m0(Uri uri, Context context) {
return l0(uri, context);
}
@TargetApi(26)
public static final void n(Context context, String str, File file, String str2) {
jk.p.i(context, "<this>");
jk.p.i(str, "base64String");
jk.p.i(file, "to");
rf.d k = rf.a.k(file, context, true);
if (str2 == null) {
str2 = "application/octet-stream";
}
OutputStream g0 = k.g0(str2, false);
if (g0 == null) {
throw new RuntimeException("Couldn't get output file");
}
gk.a.b(v(str), g0, 0, 2, null);
}
public static final String n0(Uri uri, Context context) {
Uri buildDocumentUri = DocumentsContract.buildDocumentUri(uri.getAuthority(), DocumentsContract.getDocumentId(uri));
jk.p.h(buildDocumentUri, "buildDocumentUri(...)");
return l0(buildDocumentUri, context);
}
public static void o(Context context, String str, File file, String str2, int i, Object obj) {
if ((i & 4) != 0) {
str2 = null;
}
n(context, str, file, str2);
}
public static final String o0(Uri uri, Context context) {
Uri buildDocumentUriUsingTree = DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri));
jk.p.h(buildDocumentUriUsingTree, "buildDocumentUriUsingTree(...)");
return l0(buildDocumentUriUsingTree, context);
}
public static final void p(Context context, File file, File file2) {
jk.p.i(context, "<this>");
jk.p.i(file, "from");
jk.p.i(file2, "to");
if (!jk.p.d(file, file2)) {
gk.a.b(U(file, context), e0(file2, context, X(file), "copyFile"), 0, 2, null);
return;
}
net.dinglisch.android.taskerm.o7.f("E", "Copy file: source same as dest: " + file2);
}
public static final String p0(Uri uri, Context context) {
return net.dinglisch.android.taskerm.d4.u(uri, context);
}
public static final void q(Context context, InputStream inputStream, File file, String str) throws l3 {
jk.p.i(context, "<this>");
jk.p.i(inputStream, "inputStreamFrom");
jk.p.i(file, "to");
gk.a.b(inputStream, e0(file, context, str, "copyFile"), 0, 2, null);
}
private static final <T> T q0(ik.l<? super Throwable, ? extends T> lVar, ik.a<? extends T> aVar) {
try {
return aVar.e();
} catch (Throwable th2) {
if (th2 instanceof k3) {
throw th2;
}
net.dinglisch.android.taskerm.o7.g("TRYORNULL", "Error", th2);
if (lVar != null) {
return lVar.invoke(th2);
}
return null;
}
}
public static final void r(Context context, InputStream inputStream, String str, String str2, String str3) throws l3 {
jk.p.i(context, "<this>");
jk.p.i(inputStream, "inputStreamFrom");
jk.p.i(str, "to");
gk.a.b(inputStream, f0(str, context, str2, str3, "copyFile"), 0, 2, null);
}
static Object r0(ik.l lVar, ik.a aVar, int i, Object obj) {
if ((i & 1) != 0) {
lVar = null;
}
return q0(lVar, aVar);
}
public static final void s(Context context, String str, String str2) throws l3 {
jk.p.i(context, "<this>");
jk.p.i(str, "from");
jk.p.i(str2, "to");
if (!jk.p.d(str, str2)) {
r(context, S(str, context), str2, Y(str), str);
return;
}
net.dinglisch.android.taskerm.o7.f("E", "Copy file: source same as dest: " + str2);
}
public static final Intent s0(File file, Context context, String str, String str2, ik.l<? super String, vj.e0> lVar, boolean z, String str3) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
jk.p.i(str2, "action");
if (TextUtils.isEmpty(str)) {
str = pp.H0(file);
}
Intent intent = new Intent(str2);
if (!TextUtils.isEmpty(str)) {
Uri C0 = C0(file, context, null, intent, false, 10, null);
intent.putExtra("android.intent.extra.STREAM", C0);
intent.setDataAndType(C0, str);
} else if (lVar != null) {
lVar.invoke("couldn't determine MIME type of " + file);
}
if (!z) {
return intent;
}
if (str3 == null) {
str3 = "Select App";
}
Intent createChooser = Intent.createChooser(intent, str3);
jk.p.h(createChooser, "createChooser(...)");
return createChooser;
}
public static void t(Context context, InputStream inputStream, File file, String str, int i, Object obj) throws l3 {
if ((i & 4) != 0) {
str = null;
}
q(context, inputStream, file, str);
}
public static Intent t0(File file, Context context, String str, String str2, ik.l lVar, boolean z, String str3, int i, Object obj) {
return s0(file, context, (i & 2) != 0 ? null : str, (i & 4) != 0 ? "android.intent.action.SEND" : str2, (i & 8) != 0 ? null : lVar, (i & 16) != 0 ? false : z, (i & 32) == 0 ? str3 : null);
}
public static final boolean u(File file) {
jk.p.i(file, "<this>");
return T0(file);
}
public static final StorageVolume u0(Context context, String str) {
StorageVolume[] D;
jk.p.i(str, "path");
if (context == null || (D = D(context)) == null) {
return null;
}
for (StorageVolume storageVolume : D) {
File g0 = g0(storageVolume);
if (jk.p.d(g0 != null ? g0.getAbsolutePath() : null, str)) {
return storageVolume;
}
}
return null;
}
@TargetApi(26)
public static final InputStream v(String str) {
jk.p.i(str, "<this>");
byte[] bytes = str.getBytes(sk.d.b);
jk.p.h(bytes, "getBytes(...)");
return new Base64InputStream(new ByteArrayInputStream(bytes), 0);
}
@TargetApi(24)
public static final String v0(StorageVolume storageVolume) {
Field field;
String obj;
if (storageVolume == null || r.a.o()) {
return null;
}
Field[] s = mi.s(storageVolume.getClass());
int length = s.length;
int i = 0;
while (true) {
if (i >= length) {
field = null;
break;
}
field = s[i];
String name = field.getName();
jk.p.h(name, "getName(...)");
if (sk.q.U(name, "SubSystem", false, 2, null)) {
break;
}
i++;
}
if (field == null) {
return null;
}
field.setAccessible(true);
Object obj2 = field.get(storageVolume);
if (obj2 == null || (obj = obj2.toString()) == null) {
return null;
}
String upperCase = obj.toUpperCase(Locale.ROOT);
jk.p.h(upperCase, "toUpperCase(...)");
return upperCase;
}
public static final boolean w(Context context, String str) {
jk.p.i(context, "<this>");
jk.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
return y(context, str, null, 2, null);
}
public static final String w0(File file) {
jk.p.i(file, "<this>");
if (!file.exists()) {
return null;
}
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
try {
String x0 = x0(bufferedInputStream);
gk.b.a(bufferedInputStream, null);
return x0;
} finally {
}
}
public static final boolean x(Context context, String str, String str2) {
jk.p.i(context, "<this>");
jk.p.i(str, ProfileManager.EXTRA_PROFILE_NAME);
File G = G(context, str, str2);
if (G.exists()) {
return G.delete();
}
return false;
}
public static final String x0(InputStream inputStream) {
if (inputStream == null) {
return null;
}
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, sk.d.b), 8192);
try {
String h = gk.j.h(bufferedReader);
gk.b.a(bufferedReader, null);
return h;
} finally {
}
}
public static boolean y(Context context, String str, String str2, int i, Object obj) {
if ((i & 2) != 0) {
str2 = null;
}
return x(context, str, str2);
}
public static final Uri y0(File file, Context context, String[] strArr) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
return C0(file, context, strArr, null, false, 12, null);
}
public static final List<String> z(Collection<String> collection, Context context, boolean z, boolean z2, boolean z3, boolean z4) {
Uri D0;
String uri;
jk.p.i(collection, "<this>");
jk.p.i(context, "context");
if (!z) {
return kotlin.collections.t.O0(collection);
}
Collection<String> collection2 = collection;
ArrayList<String> arrayList = new ArrayList(kotlin.collections.t.w(collection2, 10));
for (String str : collection2) {
String k0 = k0(str, context);
if (k0 != null) {
str = k0;
}
arrayList.add(str);
}
ArrayList<String> arrayList2 = new ArrayList(kotlin.collections.t.w(arrayList, 10));
for (String str2 : arrayList) {
if (z3) {
str2 = P(str2);
}
arrayList2.add(str2);
}
ArrayList<String> arrayList3 = new ArrayList(kotlin.collections.t.w(arrayList2, 10));
for (String str3 : arrayList2) {
if (z2 && (D0 = D0(str3, context, null, null, false, 14, null)) != null && (uri = D0.toString()) != null) {
str3 = uri;
}
arrayList3.add(str3);
}
ArrayList arrayList4 = new ArrayList(kotlin.collections.t.w(arrayList3, 10));
for (String str4 : arrayList3) {
if (z4) {
str4 = pp.B2(str4);
}
arrayList4.add(str4);
}
return arrayList4;
}
public static final Uri z0(File file, Context context, String[] strArr, Intent intent) {
jk.p.i(file, "<this>");
jk.p.i(context, "context");
return C0(file, context, strArr, intent, false, 8, null);
}
}