web移动端项目 v2.0版本的 MD5 值为:d6e917484f74532fa46bea60e2f4f1ad
以下内容为反编译后的 FileFeatureImpl.java 源代码,内容仅作参考
package io.dcloud.js.file;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.MimeTypeMap;
import androidx.webkit.ProxyConfig;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.AbsMgr;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IFeature;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.io.DHFile;
import io.dcloud.common.adapter.io.UnicodeInputStream;
import io.dcloud.common.adapter.util.AsyncTaskHandler;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.PermissionUtil;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.DOMException;
import io.dcloud.common.util.AppRuntime;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.Deprecated_JSUtil;
import io.dcloud.common.util.FileUtil;
import io.dcloud.common.util.IOUtil;
import io.dcloud.common.util.JSONUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.Md5Utils;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.common.util.ThreadPool;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.Map;
import net.lingala.zip4j.util.InternalZipConstants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class FileFeatureImpl implements IFeature {
private static String a;
private static String b;
private static String c;
private static String d;
private static String e;
class a implements AsyncTaskHandler.IAsyncTaskListener {
final String a;
final int b;
final int c;
final String d;
final IWebview e;
final String f;
a(String str, int i, int i2, String str2, IWebview iWebview, String str3) {
this.a = str;
this.b = i;
this.c = i2;
this.d = str2;
this.e = iWebview;
this.f = str3;
}
@Override
public void onCancel() {
}
@Override
public void onExecuteBegin() {
}
@Override
public void onExecuteEnd(Object obj) {
if (obj != null) {
Deprecated_JSUtil.execCallback(this.e, this.f, String.valueOf(obj), JSUtil.OK, true, false);
} else {
FileFeatureImpl.this.a(10, this.e, this.f);
}
}
@Override
public Object onExecuting() {
InputStream inputStream;
Exception e;
Exception exc;
InputStream inputStream2;
Object obj;
ByteArrayOutputStream byteArrayOutputStream;
Throwable th;
int available;
ByteArrayOutputStream byteArrayOutputStream2 = null;
try {
inputStream = DHFile.getInputStream(DHFile.createFileHandler(this.a));
try {
try {
available = inputStream.available();
try {
inputStream = new UnicodeInputStream(inputStream, Charset.defaultCharset().name());
} catch (Exception e2) {
e2.printStackTrace();
}
byteArrayOutputStream = new ByteArrayOutputStream();
} catch (Exception e3) {
e = e3;
exc = e;
inputStream2 = inputStream;
obj = null;
try {
exc.printStackTrace();
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e4) {
e4.printStackTrace();
return obj;
}
}
if (byteArrayOutputStream2 != null) {
byteArrayOutputStream2.close();
}
return obj;
} catch (Throwable th2) {
byteArrayOutputStream = byteArrayOutputStream2;
th = th2;
inputStream = inputStream2;
th = th;
byteArrayOutputStream2 = byteArrayOutputStream;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
throw th;
}
}
if (byteArrayOutputStream2 != null) {
byteArrayOutputStream2.close();
}
throw th;
}
}
} catch (Throwable th3) {
th = th3;
if (inputStream != null) {
}
if (byteArrayOutputStream2 != null) {
}
throw th;
}
} catch (Exception e6) {
e = e6;
inputStream = null;
} catch (Throwable th4) {
th = th4;
inputStream = null;
}
try {
int i = this.b;
if (i > 0) {
if (i >= available) {
i = available - 1;
}
int i2 = this.c;
int i3 = (i - i2) + 1;
byte[] bArr = new byte[i3];
inputStream.skip(i2);
inputStream.read(bArr, 0, i3);
byteArrayOutputStream.write(bArr, 0, i3);
} else {
while (true) {
byte[] bArr2 = new byte[DHFile.BUF_SIZE];
int read = inputStream.read(bArr2);
if (read == -1) {
break;
}
byteArrayOutputStream.write(bArr2, 0, read);
}
}
String jSONableString = JSONUtil.toJSONableString(PdrUtil.isEmpty(this.d) ? byteArrayOutputStream.toString() : byteArrayOutputStream.toString(this.d));
try {
inputStream.close();
byteArrayOutputStream.close();
return jSONableString;
} catch (IOException e7) {
e7.printStackTrace();
return jSONableString;
}
} catch (Exception e8) {
InputStream inputStream3 = inputStream;
obj = null;
byteArrayOutputStream2 = byteArrayOutputStream;
exc = e8;
inputStream2 = inputStream3;
exc.printStackTrace();
if (inputStream2 != null) {
}
if (byteArrayOutputStream2 != null) {
}
return obj;
} catch (Throwable th5) {
th = th5;
th = th;
byteArrayOutputStream2 = byteArrayOutputStream;
if (inputStream != null) {
}
if (byteArrayOutputStream2 != null) {
}
throw th;
}
}
}
class b implements AsyncTaskHandler.IAsyncTaskListener {
final String a;
final int b;
final int c;
final IWebview d;
final String e;
b(String str, int i, int i2, IWebview iWebview, String str2) {
this.a = str;
this.b = i;
this.c = i2;
this.d = iWebview;
this.e = str2;
}
@Override
public void onCancel() {
}
@Override
public void onExecuteBegin() {
}
@Override
public void onExecuteEnd(Object obj) {
if (obj != null) {
Deprecated_JSUtil.execCallback(this.d, this.e, String.valueOf(obj), JSUtil.OK, true, false);
} else {
FileFeatureImpl.this.a(10, this.d, this.e);
}
}
@Override
public Object onExecuting() {
InputStream inputStream;
String str;
ByteArrayOutputStream byteArrayOutputStream;
String encodeToString;
String mimeType = PdrUtil.getMimeType(this.a);
ByteArrayOutputStream byteArrayOutputStream2 = null;
String str2 = null;
ByteArrayOutputStream byteArrayOutputStream3 = null;
byteArrayOutputStream2 = null;
try {
try {
inputStream = DHFile.getInputStream(DHFile.createFileHandler(this.a));
try {
int available = inputStream.available();
int i = this.b;
if (i > 0) {
if (i >= available) {
i = available - 1;
}
int i2 = this.c;
int i3 = (i - i2) + 1;
byte[] bArr = new byte[i3];
inputStream.skip(i2);
inputStream.read(bArr, 0, i3);
encodeToString = Base64.encodeToString(bArr, 2);
byteArrayOutputStream = null;
} else {
byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
try {
byte[] bArr2 = new byte[DHFile.BUF_SIZE];
int read = inputStream.read(bArr2);
if (read == -1) {
break;
}
byteArrayOutputStream.write(bArr2, 0, read);
} catch (Exception e) {
e = e;
ByteArrayOutputStream byteArrayOutputStream4 = byteArrayOutputStream;
str = str2;
byteArrayOutputStream3 = byteArrayOutputStream4;
e.printStackTrace();
if (inputStream != null) {
}
if (byteArrayOutputStream3 != null) {
}
return str;
} catch (Throwable th) {
th = th;
byteArrayOutputStream2 = byteArrayOutputStream;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
throw th;
}
}
if (byteArrayOutputStream2 != null) {
byteArrayOutputStream2.close();
}
throw th;
}
}
encodeToString = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 2);
}
str2 = StringUtil.format("data:%s;base64,%s", mimeType, encodeToString);
String jSONableString = JSONUtil.toJSONableString(str2);
try {
inputStream.close();
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
return jSONableString;
}
return jSONableString;
} catch (IOException e3) {
e3.printStackTrace();
return jSONableString;
}
} catch (Exception e4) {
e = e4;
str = null;
e.printStackTrace();
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
return str;
}
}
if (byteArrayOutputStream3 != null) {
byteArrayOutputStream3.close();
}
return str;
}
} catch (Throwable th2) {
th = th2;
}
} catch (Exception e6) {
e = e6;
inputStream = null;
} catch (Throwable th3) {
th = th3;
inputStream = null;
}
}
}
class c extends CustomTarget<File> {
final String a;
final IWebview b;
final String c;
c(String str, IWebview iWebview, String str2) {
this.a = str;
this.b = iWebview;
this.c = str2;
}
@Override
public void onResourceReady(File file, Transition<? super File> transition) {
if (PdrUtil.isEmpty(this.a)) {
FileFeatureImpl.this.a(file.getAbsolutePath(), this.b, this.c);
} else if (DHFile.copyFile(file.getPath(), this.a) == 1) {
FileFeatureImpl.this.a(this.a, this.b, this.c);
} else {
Deprecated_JSUtil.execCallback(this.b, this.c, DOMException.toJSON(13, "Failed to load resource"), JSUtil.ERROR, true, false);
}
}
@Override
public void onLoadCleared(Drawable drawable) {
}
@Override
public void onLoadFailed(Drawable drawable) {
Deprecated_JSUtil.execCallback(this.b, this.c, DOMException.toJSON(13, "Failed to load resource"), JSUtil.ERROR, true, false);
}
}
class d implements Runnable {
final File a;
final String b;
final IWebview c;
final String d;
d(File file, String str, IWebview iWebview, String str2) {
this.a = file;
this.b = str;
this.c = iWebview;
this.d = str2;
}
@Override
public void run() {
String md5 = Md5Utils.md5(this.a, this.b);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(AbsoluteConst.JSON_KEY_SIZE, this.a.length());
if (md5 != null) {
jSONObject.put("digest", md5.toUpperCase(Locale.US));
}
} catch (JSONException unused) {
}
Deprecated_JSUtil.execCallback(this.c, this.d, jSONObject.toString(), JSUtil.OK, true, false);
}
}
class e implements ISysEventListener {
final int a;
final IApp b;
final IWebview c;
final String d;
e(int i, IApp iApp, IWebview iWebview, String str) {
this.a = i;
this.b = iApp;
this.c = iWebview;
this.d = str;
}
@Override
public boolean onExecute(ISysEventListener.SysEventType sysEventType, Object obj) {
Object[] objArr = (Object[]) obj;
int intValue = ((Integer) objArr[0]).intValue();
Intent intent = (Intent) objArr[2];
ISysEventListener.SysEventType sysEventType2 = ISysEventListener.SysEventType.onActivityResult;
if (sysEventType == sysEventType2 && intValue == this.a) {
this.b.unregisterSysEventListener(this, sysEventType2);
if (intent != null && (intent.getData() != null || intent.getClipData() != null)) {
JSONArray jSONArray = new JSONArray();
ClipData clipData = intent.getClipData();
if (clipData != null) {
int itemCount = clipData.getItemCount();
for (int i = 0; i < itemCount; i++) {
jSONArray.put(FileUtil.getPathFromUri(this.b.getActivity(), clipData.getItemAt(i).getUri()));
}
} else {
Uri data = intent.getData();
String pathFromUri = FileUtil.getPathFromUri(this.b.getActivity(), data);
if (PdrUtil.isEmpty(pathFromUri)) {
pathFromUri = data.toString();
}
jSONArray.put(pathFromUri);
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("files", jSONArray);
} catch (JSONException e) {
e.printStackTrace();
}
Deprecated_JSUtil.execCallback(this.c, this.d, jSONObject.toString(), JSUtil.OK, true, false);
} else {
Deprecated_JSUtil.execCallback(this.c, this.d, StringUtil.format(DOMException.JSON_ERROR_INFO, -2, DOMException.MSG_USER_CANCEL), JSUtil.ERROR, true, false);
}
}
return false;
}
}
public class f implements AsyncTaskHandler.IAsyncTaskListener {
final String[] a;
final IWebview b;
final String c;
final int d;
final String e;
f(String[] strArr, IWebview iWebview, String str, int i, String str2) {
this.a = strArr;
this.b = iWebview;
this.c = str;
this.d = i;
this.e = str2;
}
@Override
public void onCancel() {
}
@Override
public void onExecuteBegin() {
}
@Override
public void onExecuteEnd(Object obj) {
}
@Override
public Object onExecuting() {
byte[] decode2bytes = io.dcloud.common.util.Base64.decode2bytes(this.a[1]);
if (decode2bytes == null) {
Deprecated_JSUtil.execCallback(this.b, this.c, StringUtil.format(DOMException.JSON_ERROR_INFO, 16, this.b.getContext().getString(R.string.dcloud_io_write_non_base64)).toString(), JSUtil.ERROR, true, false);
return null;
}
DHFile.writeFile(decode2bytes, this.d, this.e);
JSUtil.execCallback(this.b, this.c, decode2bytes.length, JSUtil.OK, false);
return null;
}
}
public class g implements AsyncTaskHandler.IAsyncTaskListener {
final String a;
final int b;
final int c;
final IWebview d;
final String e;
g(String str, int i, int i2, IWebview iWebview, String str2) {
this.a = str;
this.b = i;
this.c = i2;
this.d = iWebview;
this.e = str2;
}
@Override
public void onCancel() {
}
@Override
public void onExecuteBegin() {
}
@Override
public void onExecuteEnd(Object obj) {
if (obj != null) {
Deprecated_JSUtil.execCallback(this.d, this.e, String.valueOf(obj), JSUtil.OK, true, false);
} else {
FileFeatureImpl.this.a(10, this.d, this.e);
}
}
@Override
public Object onExecuting() {
ByteArrayOutputStream byteArrayOutputStream;
?? r4;
Exception e;
String encodeToString;
String str = null;
try {
r4 = DHFile.getInputStream(DHFile.createFileHandler(this.a));
try {
int available = r4.available();
int i = this.b;
if (i > 0) {
if (i >= available) {
i = available - 1;
}
int i2 = this.c;
int i3 = (i - i2) + 1;
byte[] bArr = new byte[i3];
r4.skip(i2);
r4.read(bArr, 0, i3);
encodeToString = Base64.encodeToString(bArr, 2);
byteArrayOutputStream = null;
} else {
byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
try {
byte[] bArr2 = new byte[DHFile.BUF_SIZE];
int read = r4.read(bArr2);
if (read == -1) {
break;
}
byteArrayOutputStream.write(bArr2, 0, read);
} catch (Exception e2) {
e = e2;
try {
Deprecated_JSUtil.execCallback(this.d, this.e, StringUtil.format(DOMException.JSON_ERROR_INFO, 13, e.getMessage()), JSUtil.ERROR, true, false);
if (r4 != 0) {
try {
r4.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
return str;
} catch (Throwable th) {
th = th;
str = r4;
r4 = str;
if (r4 != 0) {
try {
r4.close();
} catch (IOException e4) {
e4.printStackTrace();
throw th;
}
}
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
throw th;
}
} catch (Throwable th2) {
th = th2;
if (r4 != 0) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
}
encodeToString = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 2);
}
str = JSONUtil.toJSONableString(encodeToString);
try {
r4.close();
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
} catch (IOException e5) {
e5.printStackTrace();
}
} catch (Exception e6) {
e = e6;
e = e;
byteArrayOutputStream = null;
Deprecated_JSUtil.execCallback(this.d, this.e, StringUtil.format(DOMException.JSON_ERROR_INFO, 13, e.getMessage()), JSUtil.ERROR, true, false);
if (r4 != 0) {
}
if (byteArrayOutputStream != null) {
}
return str;
} catch (Throwable th3) {
th = th3;
byteArrayOutputStream = null;
str = r4;
r4 = str;
if (r4 != 0) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
} catch (Exception e7) {
e = e7;
r4 = 0;
} catch (Throwable th4) {
th = th4;
byteArrayOutputStream = null;
r4 = str;
if (r4 != 0) {
}
if (byteArrayOutputStream != null) {
}
throw th;
}
return str;
}
}
private void b(IWebview iWebview, String[] strArr, String str) {
try {
String str2 = strArr[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str2)) {
a(15, iWebview, str);
return;
}
boolean checkPrivateDir = iWebview.obtainApp().checkPrivateDir(str2);
int intValue = Integer.valueOf(strArr[2]).intValue();
if (strArr[1] != null && !checkPrivateDir) {
AsyncTaskHandler.executeThreadTask(new f(strArr, iWebview, str, intValue, str2));
return;
}
a(4, iWebview, str);
} catch (Exception unused) {
a(10, iWebview, str);
}
}
private String c(String str) {
if (str.startsWith(a)) {
return AbsoluteConst.MINI_SERVER_APP_WWW + str.substring(a.length(), str.length());
} else if (str.startsWith(c)) {
return AbsoluteConst.MINI_SERVER_APP_DOC + str.substring(c.length(), str.length());
} else if (str.startsWith(d)) {
return "_documents/" + str.substring(d.length(), str.length());
} else if (str.startsWith(e)) {
return "_downloads/" + str.substring(e.length(), str.length());
} else {
return null;
}
}
private String d(String str) {
boolean z;
String b2 = b(str);
if (PdrUtil.isEmpty(b2)) {
b2 = String.valueOf(-1);
z = true;
} else {
z = false;
}
if (z) {
if (str.startsWith(a)) {
return String.valueOf(1);
}
if (str.startsWith(c)) {
return String.valueOf(2);
}
if (str.startsWith(d)) {
return String.valueOf(3);
}
return str.startsWith(e) ? String.valueOf(4) : b2;
}
return b2;
}
private boolean e(String str) {
return str.endsWith(BaseInfo.REL_PRIVATE_WWW_DIR) || str.endsWith(BaseInfo.REL_PUBLIC_DOCUMENTS_DIR) || str.endsWith(BaseInfo.REL_PUBLIC_DOWNLOADS_DIR) || str.endsWith(BaseInfo.REL_PRIVATE_DOC_DIR) || str.endsWith(AbsoluteConst.MINI_SERVER_APP_WWW) || str.endsWith("_documents/") || str.endsWith("_downloads/") || str.endsWith(AbsoluteConst.MINI_SERVER_APP_DOC);
}
@Override
public void dispose(String str) {
}
@Override
public String execute(IWebview iWebview, String str, String[] strArr) {
char c2;
String str2;
byte[] bytes;
String str3;
boolean z;
JSONObject a2;
boolean z2;
String str4;
JSONObject a3;
boolean z3;
String name;
boolean z4;
String str5;
boolean z5;
JSONObject a4;
boolean z6;
FileOutputStream fileOutputStream;
InputStream inputStream;
String str6;
JSONArray b2;
boolean z7;
boolean z8;
String str7 = Md5Utils.ALGORITHM;
String str8 = strArr[0];
?? obtainApp = iWebview.obtainFrameView().obtainApp();
AppRuntime.checkPrivacyComplianceAndPrompt(iWebview.getContext(), "Io-" + str);
boolean isOnAppRunningMode = obtainApp.isOnAppRunningMode();
a = obtainApp.getPathByType((byte) 0);
b = obtainApp.getPathByType((byte) -1);
c = obtainApp.getPathByType((byte) 1);
d = obtainApp.getPathByType((byte) 2);
e = obtainApp.getPathByType((byte) 3);
str.hashCode();
switch (str.hashCode()) {
case -1354714928:
if (str.equals("copyTo")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case -1224446278:
if (str.equals("requestFileSystem")) {
c2 = 1;
break;
}
c2 = 65535;
break;
case -1068263892:
if (str.equals("moveTo")) {
c2 = 2;
break;
}
c2 = 65535;
break;
case -1017341515:
if (str.equals("readAsText")) {
c2 = 3;
break;
}
c2 = 65535;
break;
case -972189769:
if (str.equals("getDirectory")) {
c2 = 4;
break;
}
c2 = 65535;
break;
case -941263860:
if (str.equals("convertLocalFileSystemURL")) {
c2 = 5;
break;
}
c2 = 65535;
break;
case -934610812:
if (str.equals(AbsoluteConst.XML_REMOVE)) {
c2 = 6;
break;
}
c2 = 65535;
break;
case -888091149:
if (str.equals("getImageInfo")) {
c2 = 7;
break;
}
c2 = 65535;
break;
case -91542719:
if (str.equals("getFileMetadata")) {
c2 = '\b';
break;
}
c2 = 65535;
break;
case -75538958:
if (str.equals("getFile")) {
c2 = '\t';
break;
}
c2 = 65535;
break;
case 113399775:
if (str.equals("write")) {
c2 = '\n';
break;
}
c2 = 65535;
break;
case 178260718:
if (str.equals("getAudioInfo")) {
c2 = 11;
break;
}
c2 = 65535;
break;
case 324074165:
if (str.equals("convertAbsoluteFileSystem")) {
c2 = '\f';
break;
}
c2 = 65535;
break;
case 529285085:
if (str.equals("readAsDataURL")) {
c2 = '\r';
break;
}
c2 = 65535;
break;
case 676070354:
if (str.equals("writeAsBinary")) {
c2 = 14;
break;
}
c2 = 65535;
break;
case 700591008:
if (str.equals("getParent")) {
c2 = 15;
break;
}
c2 = 65535;
break;
case 1068167127:
if (str.equals("readAsBase64")) {
c2 = 16;
break;
}
c2 = 65535;
break;
case 1323018515:
if (str.equals("getVideoInfo")) {
c2 = 17;
break;
}
c2 = 65535;
break;
case 1342041536:
if (str.equals("getFileInfo")) {
c2 = 18;
break;
}
c2 = 65535;
break;
case 1352737307:
if (str.equals("removeRecursively")) {
c2 = 19;
break;
}
c2 = 65535;
break;
case 1572117509:
if (str.equals("resolveLocalFileSystemURL")) {
c2 = 20;
break;
}
c2 = 65535;
break;
case 1627895973:
if (str.equals("getMetadata")) {
c2 = 21;
break;
}
c2 = 65535;
break;
case 1852984678:
if (str.equals("truncate")) {
c2 = 22;
break;
}
c2 = 65535;
break;
case 1963978266:
if (str.equals("readEntries")) {
c2 = 23;
break;
}
c2 = 65535;
break;
case 2023226419:
if (str.equals("chooseFile")) {
c2 = 24;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
str2 = "";
OutputStream outputStream = null;
switch (c2) {
case 0:
String[] a5 = a(iWebview, strArr, str8);
if (a5 != null) {
if (a5[1] != null) {
StringBuilder sb = new StringBuilder();
sb.append(a5[1]);
String str9 = a5[1];
String str10 = File.separator;
sb.append(str9.endsWith(str10) ? "" : str10);
str3 = sb.toString();
} else {
str3 = a5[1];
}
String str11 = str3 + a5[2];
String str12 = a5[0];
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str11, str12) || FileUtil.isFilePathForPublic(iWebview.getContext(), str12))) {
a(15, iWebview, str8);
break;
} else {
if (!obtainApp.checkPrivateDir(str11)) {
try {
} catch (IOException e2) {
e2.printStackTrace();
}
if (!DHFile.isExist(str11)) {
if (!DHFile.isExist(str12)) {
break;
} else if (DHFile.copyFile(str12, str11) == 1) {
z = true;
if (!z) {
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(a5[2], str11, obtainApp.convert2RelPath(str11), new File(str11).isDirectory()), JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
}
}
z = false;
if (!z) {
}
}
}
break;
case 1:
try {
String[] a6 = a(iWebview, strArr, str8);
if (a6 != null) {
int parseInt = Integer.parseInt(a6[0]);
if (parseInt == 1) {
a2 = io.dcloud.js.file.a.a("PRIVATE_WWW", 1, BaseInfo.REAL_PRIVATE_WWW_DIR, a, BaseInfo.REL_PRIVATE_WWW_DIR);
} else if (parseInt == 2) {
a2 = io.dcloud.js.file.a.a("PRIVATE_DOCUMENTS", 2, BaseInfo.REAL_PRIVATE_DOC_DIR, c, BaseInfo.REL_PRIVATE_DOC_DIR);
} else if (parseInt == 3) {
a2 = io.dcloud.js.file.a.a("PUBLIC_DOCUMENTS", 3, BaseInfo.REAL_PUBLIC_DOCUMENTS_DIR, d, BaseInfo.REL_PUBLIC_DOCUMENTS_DIR);
} else if (parseInt != 4) {
String str13 = DeviceInfo.sDeviceRootDir;
a2 = io.dcloud.js.file.a.a("PUBLIC_DEVICE_ROOT", 5, str13, str13, str13);
} else {
a2 = io.dcloud.js.file.a.a("PUBLIC_DOWNLOADS", 4, BaseInfo.REAL_PUBLIC_DOWNLOADS_DIR, e, BaseInfo.REL_PUBLIC_DOWNLOADS_DIR);
}
JSUtil.execCallback(iWebview, str8, a2, JSUtil.OK, false);
break;
} else {
break;
}
} catch (Exception e3) {
e3.printStackTrace();
a(10, iWebview, str8);
break;
}
case 2:
String[] a7 = a(iWebview, strArr, str8);
if (a7 != null) {
String convert2AbsFullPath = obtainApp.convert2AbsFullPath(iWebview.obtainFullUrl(), a7[1] + a7[2]);
if (obtainApp.checkPrivateDir(a7[0]) || obtainApp.checkPrivateDir(convert2AbsFullPath)) {
a(10, iWebview, str8);
break;
} else {
String convert2AbsFullPath2 = obtainApp.convert2AbsFullPath(iWebview.obtainFullUrl(), a7[0]);
if (!FileUtil.checkPathAccord(iWebview.getContext(), convert2AbsFullPath, convert2AbsFullPath2)) {
a(15, iWebview, str8);
break;
} else {
File file = new File(convert2AbsFullPath2);
boolean isDirectory = file.isDirectory();
File file2 = new File(convert2AbsFullPath);
if (file2.exists()) {
z2 = false;
} else {
File parentFile = file2.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
z2 = file.renameTo(file2);
}
if (z2) {
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(a7[2], convert2AbsFullPath, obtainApp.convert2RelPath(convert2AbsFullPath), isDirectory), JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
}
}
break;
case 3:
String[] a8 = a(iWebview, strArr, str8);
if (a8 != null) {
String str14 = a8[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str14)) {
a(15, iWebview, str8);
break;
} else {
boolean checkPrivateDir = obtainApp.checkPrivateDir(str14);
String str15 = a8[1];
int parseInt2 = PdrUtil.parseInt(a8[2], 0);
int parseInt3 = PdrUtil.parseInt(a8[3], -1);
if (checkPrivateDir && isOnAppRunningMode) {
a(10, iWebview, str8);
break;
} else {
AsyncTaskHandler.executeThreadTask(new a(str14, parseInt3, parseInt2, str15, iWebview, str8));
break;
}
}
}
break;
case 4:
String[] a9 = a(iWebview, strArr, str8);
if (a9 != null) {
if (a9[0] != null && !a9[0].endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
a9[0] = a9[0] + InternalZipConstants.ZIP_FILE_SEPARATOR;
}
String convert2AbsFullPath3 = obtainApp.convert2AbsFullPath(a9[0], a9[1]);
if (!FileUtil.checkPathAccord(iWebview.getContext(), convert2AbsFullPath3)) {
a(15, iWebview, str8);
break;
} else if (a9[0] != null && a9[1] != null && a9[1].indexOf("../") != -1 && e(a9[0])) {
a(4, iWebview, str8);
return null;
} else {
if (!convert2AbsFullPath3.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
convert2AbsFullPath3 = convert2AbsFullPath3 + InternalZipConstants.ZIP_FILE_SEPARATOR;
}
File file3 = new File(convert2AbsFullPath3);
try {
JSONObject jSONObject = new JSONObject(a9[2]);
boolean optBoolean = jSONObject.optBoolean("create");
boolean optBoolean2 = jSONObject.optBoolean("exclusive");
if (file3.exists()) {
if (optBoolean2 && optBoolean2) {
a(12, iWebview, str8);
}
} else if (optBoolean) {
byte createNewFile = DHFile.createNewFile(convert2AbsFullPath3);
if (createNewFile == -1 || (createNewFile == -2 && optBoolean2)) {
throw new RuntimeException();
}
} else {
a(14, iWebview, str8);
return null;
}
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(a9[1], convert2AbsFullPath3, obtainApp.convert2RelPath(convert2AbsFullPath3), true), JSUtil.OK, false);
} catch (Exception unused) {
Logger.d("Not Found " + convert2AbsFullPath3);
a(10, iWebview, str8);
break;
}
}
}
break;
case 5:
return Deprecated_JSUtil.wrapJsVar(obtainApp.convert2AbsFullPath(iWebview.obtainFullUrl(), strArr[0]), true);
case 6:
String[] a10 = a(iWebview, strArr, str8);
if (a10 != null) {
String str16 = a10[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str16)) {
a(15, iWebview, str8);
break;
} else if (obtainApp.checkPrivateDir(str16)) {
a(4, iWebview, str8);
return null;
} else if (new File(str16).delete()) {
JSUtil.execCallback(iWebview, str8, "", JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
break;
case 7:
String str17 = strArr[0];
String str18 = strArr[1];
if (!PdrUtil.isEmpty(str18)) {
if (PdrUtil.isNetPath(str18)) {
try {
if (strArr.length <= 2 || PdrUtil.isEmpty(strArr[2])) {
str4 = null;
} else {
String str19 = strArr[2];
if (!str19.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
str19 = str19 + InternalZipConstants.ZIP_FILE_SEPARATOR;
}
String downloadFilename = PdrUtil.getDownloadFilename(str18, "image/*", str18);
if (TextUtils.isEmpty(downloadFilename)) {
downloadFilename = System.currentTimeMillis() + "_" + Math.abs(str18.hashCode());
}
str4 = iWebview.obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), str19) + downloadFilename;
}
Glide.with(iWebview.getContext()).asFile().load(str18).into((RequestBuilder<File>) new c(str4, iWebview, str17));
break;
} catch (Exception unused2) {
Deprecated_JSUtil.execCallback(iWebview, str17, DOMException.toJSON(13, "Failed to load resource"), JSUtil.ERROR, true, false);
break;
}
} else {
String convert2AbsFullPath4 = obtainApp.convert2AbsFullPath(iWebview.obtainFullUrl(), str18);
if (!(FileUtil.checkPathAccord(iWebview.getContext(), convert2AbsFullPath4) || FileUtil.isFilePathForPublic(iWebview.getContext(), convert2AbsFullPath4))) {
a(15, iWebview, str8);
break;
} else {
if (convert2AbsFullPath4.startsWith("apps/")) {
convert2AbsFullPath4 = InternalZipConstants.ZIP_FILE_SEPARATOR + convert2AbsFullPath4;
}
if (convert2AbsFullPath4.startsWith("/android_asset/")) {
convert2AbsFullPath4 = convert2AbsFullPath4.replace("/android_asset", "");
} else if (convert2AbsFullPath4.startsWith("android_asset/")) {
convert2AbsFullPath4 = convert2AbsFullPath4.replace("android_asset", "");
}
String checkPrivateDirAndCopy2Temp = obtainApp.checkPrivateDirAndCopy2Temp(convert2AbsFullPath4);
if (!new File(checkPrivateDirAndCopy2Temp).exists()) {
a(14, iWebview, str8);
break;
} else {
a(checkPrivateDirAndCopy2Temp, iWebview, str17);
break;
}
}
}
}
break;
case '\b':
String[] a11 = a(iWebview, strArr, str8);
if (a11 != null) {
String str20 = a11[0];
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str20) || FileUtil.isFilePathForPublic(iWebview.getContext(), str20))) {
a(15, iWebview, str8);
break;
} else {
if (!obtainApp.checkPrivateDir(str20) || !isOnAppRunningMode) {
try {
a3 = io.dcloud.js.file.a.a(str20, d(str20));
z3 = true;
} catch (Exception e4) {
e4.printStackTrace();
}
if (!z3) {
JSUtil.execCallback(iWebview, str8, a3, JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
a3 = null;
z3 = false;
if (!z3) {
}
}
}
break;
case '\t':
String[] a12 = a(iWebview, strArr, str8);
if (a12 != null) {
String convert2AbsFullPath5 = obtainApp.convert2AbsFullPath(a12[0], a12[1]);
if (!FileUtil.checkPathAccord(iWebview.getContext(), convert2AbsFullPath5)) {
a(15, iWebview, str8);
break;
} else {
File file4 = new File(convert2AbsFullPath5);
try {
JSONObject jSONObject2 = new JSONObject(a12[2]);
String str21 = a12[1];
boolean optBoolean3 = jSONObject2.optBoolean("create");
boolean optBoolean4 = jSONObject2.optBoolean("exclusive");
if (file4.exists()) {
if (optBoolean3 && optBoolean4) {
a(12, iWebview, str8);
return null;
}
name = file4.getName();
} else if (optBoolean3) {
byte createNewFile2 = DHFile.createNewFile(file4);
name = file4.getName();
if (createNewFile2 == -1 || (createNewFile2 == -2 && optBoolean4)) {
throw new RuntimeException();
}
} else {
a(14, iWebview, str8);
return null;
}
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(name, convert2AbsFullPath5, obtainApp.convert2RelPath(convert2AbsFullPath5), false), JSUtil.OK, false);
} catch (Exception unused3) {
a(10, iWebview, str8);
break;
}
}
}
break;
case '\n':
try {
String[] a13 = a(iWebview, strArr, str8);
if (a13 == null) {
break;
} else {
String str22 = a13[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str22)) {
a(15, iWebview, str8);
break;
} else {
boolean checkPrivateDir2 = obtainApp.checkPrivateDir(str22);
int intValue = Integer.valueOf(a13[2]).intValue();
if (a13[1] != null && !checkPrivateDir2) {
DHFile.writeFile(a13[1].getBytes(), intValue, str22);
JSUtil.execCallback(iWebview, str8, bytes.length, JSUtil.OK, false);
break;
}
a(4, iWebview, str8);
return null;
}
}
} catch (Exception unused4) {
a(10, iWebview, str8);
break;
}
case 11:
case 17:
String str23 = strArr[0];
try {
str2 = new JSONObject(strArr[1]).optString("filePath");
} catch (JSONException unused5) {
}
a(str2, str23, iWebview, str);
break;
case '\f':
return Deprecated_JSUtil.wrapJsVar(obtainApp.convert2RelPath(strArr[0]), true);
case '\r':
String[] a14 = a(iWebview, strArr, str8);
if (a14 != null) {
String str24 = a14[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str24)) {
a(15, iWebview, str8);
break;
} else {
boolean checkPrivateDir3 = obtainApp.checkPrivateDir(str24);
int parseInt4 = PdrUtil.parseInt(a14[1], 0);
int parseInt5 = PdrUtil.parseInt(a14[2], -1);
if (checkPrivateDir3 && isOnAppRunningMode) {
a(10, iWebview, str8);
break;
} else {
AsyncTaskHandler.executeThreadTask(new b(str24, parseInt5, parseInt4, iWebview, str8));
break;
}
}
}
break;
case 14:
String[] a15 = a(iWebview, strArr, str8);
if (a15 != null) {
b(iWebview, a15, str8);
break;
}
break;
case 15:
String[] a16 = a(iWebview, strArr, str8);
if (a16 != null) {
String str25 = a16[0];
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str25) || FileUtil.isFilePathForPublic(iWebview.getContext(), str25))) {
a(15, iWebview, str8);
break;
} else if (str25 != null && e(str25)) {
a(4, iWebview, str8);
return null;
} else {
File file5 = new File(str25);
if (file5.exists()) {
String parent = file5.getParent();
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(file5.getParentFile().getName(), parent, obtainApp.convert2RelPath(parent), true), JSUtil.OK, false);
z4 = true;
} else {
z4 = false;
}
if (!z4) {
a(10, iWebview, str8);
break;
}
}
}
break;
case 16:
String[] a17 = a(iWebview, strArr, str8);
if (a17 != null) {
a(iWebview, obtainApp, a17, str8);
break;
}
break;
case 18:
String str26 = strArr[0];
try {
JSONObject jSONObject3 = new JSONObject(strArr[1]);
str5 = jSONObject3.optString("filePath");
try {
str7 = jSONObject3.optString("digestAlgorithm", Md5Utils.ALGORITHM);
} catch (JSONException unused6) {
}
} catch (JSONException unused7) {
str5 = "";
}
String str27 = str7;
if (!PdrUtil.isEmpty(str5) && !PdrUtil.isNetPath(str5)) {
String convert2AbsFullPath6 = iWebview.obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), str5);
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str5) || FileUtil.isFilePathForPublic(iWebview.getContext(), str5))) {
a(15, iWebview, str8);
break;
} else {
if (convert2AbsFullPath6.startsWith("apps/")) {
convert2AbsFullPath6 = InternalZipConstants.ZIP_FILE_SEPARATOR + convert2AbsFullPath6;
}
if (convert2AbsFullPath6.startsWith("/android_asset/")) {
convert2AbsFullPath6 = convert2AbsFullPath6.replace("/android_asset", "");
} else if (convert2AbsFullPath6.startsWith("android_asset/")) {
convert2AbsFullPath6 = convert2AbsFullPath6.replace("android_asset", "");
}
File file6 = new File(obtainApp.checkPrivateDirAndCopy2Temp(convert2AbsFullPath6));
if (!file6.exists()) {
Deprecated_JSUtil.execCallback(iWebview, str26, StringUtil.format(DOMException.JSON_ERROR_INFO, -4, DOMException.MSG_FILE_NOT_EXIST), JSUtil.ERROR, true, false);
break;
} else {
ThreadPool.self().addThreadTask(new d(file6, str27, iWebview, str26));
break;
}
}
}
break;
case 19:
String[] a18 = a(iWebview, strArr, str8);
if (a18 != null && !JSUtil.checkOperateDirErrorAndCallback(iWebview, str8, a18[0])) {
String str28 = a18[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str28)) {
a(15, iWebview, str8);
break;
} else {
File file7 = new File(str28);
if (file7.isDirectory()) {
try {
String valueOf = String.valueOf(System.currentTimeMillis());
DHFile.rename(file7.getAbsolutePath() + InternalZipConstants.ZIP_FILE_SEPARATOR, valueOf);
file7 = new File(file7.getParent() + InternalZipConstants.ZIP_FILE_SEPARATOR + valueOf);
} catch (IOException e5) {
e5.printStackTrace();
}
}
if (DHFile.delete(file7)) {
JSUtil.execCallback(iWebview, str8, "", JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
} else {
return null;
}
case 20:
try {
String[] a19 = a(iWebview, strArr, str8);
if (a19 == null) {
break;
} else {
boolean e6 = e(a19[0]);
boolean z9 = e6 && obtainApp.isOnAppRunningMode() && obtainApp.checkPrivateDir(a19[0]);
String convert2AbsFullPath7 = obtainApp.convert2AbsFullPath(iWebview.obtainFullUrl(), a19[0]);
if (z9) {
JSONObject a20 = a(convert2AbsFullPath7);
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(BaseInfo.REL_PRIVATE_WWW_DIR, convert2AbsFullPath7, true, BaseInfo.REL_PRIVATE_WWW_DIR, a20.optString("fsName"), a20.optInt("type"), a20.optJSONObject("fsRoot")), JSUtil.OK, false);
break;
} else {
File file8 = new File(convert2AbsFullPath7);
boolean exists = file8.exists();
if (!exists && e6) {
try {
File parentFile2 = file8.getParentFile();
if (!parentFile2.exists()) {
parentFile2.mkdirs();
}
z5 = 1 == DHFile.createNewFile(DHFile.createFileHandler(convert2AbsFullPath7));
} catch (Exception e7) {
e7.printStackTrace();
}
if (!z5) {
JSONObject a21 = a(convert2AbsFullPath7);
JSUtil.execCallback(iWebview, str8, io.dcloud.js.file.a.a(file8.getName(), convert2AbsFullPath7, file8.isDirectory(), a19[0], a21.optString("fsName"), a21.optInt("type"), a21.optJSONObject("fsRoot")), JSUtil.OK, false);
break;
} else {
a(14, iWebview, str8);
break;
}
}
z5 = exists;
if (!z5) {
}
}
}
} catch (JSONException unused8) {
a(10, iWebview, str8);
break;
}
break;
case 21:
String[] a22 = a(iWebview, strArr, str8);
if (a22 != null) {
String str29 = a22[0];
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str29) || FileUtil.isFilePathForPublic(iWebview.getContext(), str29))) {
a(15, iWebview, str8);
break;
} else {
if (!obtainApp.checkPrivateDir(str29) || !isOnAppRunningMode) {
try {
a4 = io.dcloud.js.file.a.a(str29, (a22.length == 2 && a22[1] != null && a22[1].equalsIgnoreCase(AbsoluteConst.TRUE)) ? Boolean.parseBoolean(a22[1]) : false);
z6 = true;
} catch (Exception e8) {
e8.printStackTrace();
}
if (!z6) {
JSUtil.execCallback(iWebview, str8, a4, JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
a4 = null;
z6 = false;
if (!z6) {
}
}
}
break;
case 22:
String[] a23 = a(iWebview, strArr, str8);
try {
if (a23 != null) {
try {
str6 = a23[0];
} catch (Exception e9) {
e = e9;
fileOutputStream = null;
obtainApp = 0;
} catch (Throwable th) {
th = th;
obtainApp = 0;
}
if (!FileUtil.checkPathAccord(iWebview.getContext(), str6)) {
a(15, iWebview, str8);
IOUtil.close((InputStream) null);
IOUtil.close((OutputStream) null);
} else {
File file9 = new File(str6);
obtainApp = new FileInputStream(file9);
try {
File file10 = new File(file9.getParent() + InternalZipConstants.ZIP_FILE_SEPARATOR + (System.currentTimeMillis() + file9.getName()));
fileOutputStream = new FileOutputStream(file10);
try {
int parseInt6 = Integer.parseInt(a23[1]);
int parseInt7 = Integer.parseInt(a23[2]);
byte[] bArr = new byte[Math.min(parseInt7 + parseInt6, 10240)];
int i = parseInt7;
int i2 = 0;
while (true) {
int read = obtainApp.read(bArr);
if (read != -1) {
int min = Math.min(parseInt6 - i2, read - i);
if (min > 0) {
fileOutputStream.write(bArr, i, min);
i2 += min;
}
if (i2 < parseInt6) {
i = i > 0 ? i - read : 0;
}
}
}
file9.delete();
file10.renameTo(file9);
Deprecated_JSUtil.execCallback(iWebview, str8, a23[1], JSUtil.OK, true, false);
inputStream = obtainApp;
} catch (Exception e10) {
e = e10;
e.printStackTrace();
a(10, iWebview, str8);
inputStream = obtainApp;
IOUtil.close(inputStream);
IOUtil.close(fileOutputStream);
return null;
}
} catch (Exception e11) {
e = e11;
fileOutputStream = null;
} catch (Throwable th2) {
th = th2;
IOUtil.close((InputStream) obtainApp);
IOUtil.close(outputStream);
throw th;
}
IOUtil.close(inputStream);
IOUtil.close(fileOutputStream);
}
}
} catch (Throwable th3) {
th = th3;
outputStream = InternalZipConstants.ZIP_FILE_SEPARATOR;
}
case 23:
String[] a24 = a(iWebview, strArr, str8);
if (a24 != null) {
String str30 = a24[0];
if (!(FileUtil.checkPathAccord(iWebview.getContext(), str30) || FileUtil.getPathForPublicType(str30) != null)) {
a(15, iWebview, str8);
break;
} else {
if (!obtainApp.checkPrivateDir(str30) || !isOnAppRunningMode) {
try {
b2 = io.dcloud.js.file.a.b(str30, obtainApp.convert2RelPath(str30));
z7 = true;
} catch (Exception e12) {
e12.printStackTrace();
}
if (!z7) {
JSUtil.execCallback(iWebview, str8, b2, JSUtil.OK, false);
break;
} else {
a(10, iWebview, str8);
break;
}
}
b2 = null;
z7 = false;
if (!z7) {
}
}
}
break;
case 24:
String str31 = strArr[0];
if (strArr.length > 1 && PdrUtil.isEmpty(strArr[1])) {
try {
z8 = new JSONObject(strArr[1]).optBoolean("multiple", false);
} catch (Exception e13) {
e13.printStackTrace();
}
int requestCode = PermissionUtil.getRequestCode();
obtainApp.registerSysEventListener(new e(requestCode, obtainApp, iWebview, str31), ISysEventListener.SysEventType.onActivityResult);
Intent intent = new Intent("android.intent.action.GET_CONTENT");
if (z8) {
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", false);
} else {
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
}
intent.setType("*/*");
intent.addCategory("android.intent.category.OPENABLE");
iWebview.getActivity().startActivityForResult(intent, requestCode);
break;
}
z8 = false;
int requestCode2 = PermissionUtil.getRequestCode();
obtainApp.registerSysEventListener(new e(requestCode2, obtainApp, iWebview, str31), ISysEventListener.SysEventType.onActivityResult);
Intent intent2 = new Intent("android.intent.action.GET_CONTENT");
if (z8) {
}
intent2.setType("*/*");
intent2.addCategory("android.intent.category.OPENABLE");
iWebview.getActivity().startActivityForResult(intent2, requestCode2);
break;
}
return null;
}
@Override
public void init(AbsMgr absMgr, String str) {
}
private void a(IWebview iWebview, IApp iApp, String[] strArr, String str) {
String str2 = strArr[0];
if (!FileUtil.checkPathAccord(iWebview.getContext(), str2)) {
a(15, iWebview, str);
return;
}
boolean checkPrivateDir = iApp.checkPrivateDir(str2);
int parseInt = PdrUtil.parseInt(strArr[1], 0);
int parseInt2 = PdrUtil.parseInt(strArr[2], -1);
if (checkPrivateDir && iApp.isOnAppRunningMode()) {
a(10, iWebview, str);
} else {
AsyncTaskHandler.executeThreadTask(new g(str2, parseInt2, parseInt, iWebview, str));
}
}
private void a(String str, String str2, IWebview iWebview, String str3) {
String extractMetadata;
char c2;
String extractMetadata2;
String extractMetadata3;
if (PdrUtil.isEmpty(str) || PdrUtil.isNetPath(str)) {
return;
}
String convert2AbsFullPath = iWebview.obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), str);
if (convert2AbsFullPath.startsWith("apps/")) {
convert2AbsFullPath = InternalZipConstants.ZIP_FILE_SEPARATOR + convert2AbsFullPath;
}
if (convert2AbsFullPath.startsWith("/android_asset/")) {
convert2AbsFullPath = convert2AbsFullPath.replace("/android_asset", "");
} else if (convert2AbsFullPath.startsWith("android_asset/")) {
convert2AbsFullPath = convert2AbsFullPath.replace("android_asset", "");
}
String checkPrivateDirAndCopy2Temp = iWebview.obtainApp().checkPrivateDirAndCopy2Temp(convert2AbsFullPath);
if (!(FileUtil.checkPathAccord(iWebview.getContext(), checkPrivateDirAndCopy2Temp) || FileUtil.isFilePathForPublic(iWebview.getContext(), checkPrivateDirAndCopy2Temp))) {
a(15, iWebview, str2);
} else if (!new File(checkPrivateDirAndCopy2Temp).exists()) {
Deprecated_JSUtil.execCallback(iWebview, str2, StringUtil.format(DOMException.JSON_ERROR_INFO, -4, DOMException.MSG_FILE_NOT_EXIST), JSUtil.ERROR, true, false);
} else {
try {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
if (FileUtil.checkPrivatePath(iWebview.getContext(), checkPrivateDirAndCopy2Temp)) {
mediaMetadataRetriever.setDataSource(checkPrivateDirAndCopy2Temp);
} else {
Uri videoFileUri = FileUtil.getVideoFileUri(iWebview.getContext(), checkPrivateDirAndCopy2Temp);
if (videoFileUri != null) {
mediaMetadataRetriever.setDataSource(iWebview.getContext(), videoFileUri);
}
}
String extractMetadata4 = mediaMetadataRetriever.extractMetadata(9);
String extractMetadata5 = mediaMetadataRetriever.extractMetadata(18);
String extractMetadata6 = mediaMetadataRetriever.extractMetadata(19);
String extractMetadata7 = mediaMetadataRetriever.extractMetadata(24);
JSONObject jSONObject = new JSONObject();
if (str3.equals("getVideoInfo")) {
if ("90".equals(extractMetadata7) || "270".equals(extractMetadata7)) {
extractMetadata6 = extractMetadata5;
extractMetadata5 = extractMetadata6;
}
if (extractMetadata5 != null && extractMetadata6 != null) {
jSONObject.put("resolution", extractMetadata5 + ProxyConfig.MATCH_ALL_SCHEMES + extractMetadata6);
}
if (extractMetadata5 != null) {
try {
jSONObject.put(AbsoluteConst.JSON_KEY_WIDTH, Float.parseFloat(extractMetadata5));
} catch (Exception unused) {
}
}
if (extractMetadata6 != null) {
jSONObject.put("height", Float.parseFloat(extractMetadata6));
}
jSONObject.put(AbsoluteConst.JSON_KEY_SIZE, new File(checkPrivateDirAndCopy2Temp).length());
if (TextUtils.isEmpty(mediaMetadataRetriever.extractMetadata(32))) {
MediaExtractor mediaExtractor = new MediaExtractor();
if (FileUtil.checkPrivatePath(iWebview.getContext(), checkPrivateDirAndCopy2Temp)) {
mediaExtractor.setDataSource(checkPrivateDirAndCopy2Temp);
} else {
Uri videoFileUri2 = FileUtil.getVideoFileUri(iWebview.getContext(), checkPrivateDirAndCopy2Temp);
if (videoFileUri2 != null) {
mediaExtractor.setDataSource(iWebview.getContext(), videoFileUri2, (Map<String, String>) null);
}
}
int trackCount = mediaExtractor.getTrackCount();
for (int i = 0; i < trackCount; i++) {
MediaFormat trackFormat = mediaExtractor.getTrackFormat(i);
try {
String string = trackFormat.getString("mime");
if (!TextUtils.isEmpty(string) && string.startsWith("video/")) {
jSONObject.put("fps", trackFormat.getInteger("frame-rate"));
}
} catch (Exception unused2) {
}
}
} else {
try {
jSONObject.put("fps", Math.ceil((Float.parseFloat(extractMetadata) / Float.parseFloat(extractMetadata4)) * 1000.0f));
} catch (Exception unused3) {
}
}
int hashCode = extractMetadata7.hashCode();
if (hashCode == 1815) {
if (extractMetadata7.equals("90")) {
c2 = 0;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
}
}
c2 = 65535;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
}
} else if (hashCode != 48873) {
if (hashCode == 49803 && extractMetadata7.equals("270")) {
c2 = 1;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
jSONObject.put("type", extractMetadata2);
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
try {
jSONObject.put("bitrate", Integer.valueOf(Integer.parseInt(extractMetadata3) / 1000));
} catch (Exception unused4) {
}
}
}
c2 = 65535;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
}
} else {
if (extractMetadata7.equals("180")) {
c2 = 2;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
}
}
c2 = 65535;
jSONObject.put("orientation", c2 == 0 ? c2 != 1 ? c2 != 2 ? "up" : "down" : "left" : "right");
extractMetadata2 = mediaMetadataRetriever.extractMetadata(12);
if (!TextUtils.isEmpty(extractMetadata2)) {
}
extractMetadata3 = mediaMetadataRetriever.extractMetadata(20);
if (!TextUtils.isEmpty(extractMetadata3)) {
}
}
}
try {
jSONObject.put(AbsoluteConst.TRANS_DURATION, BigDecimal.valueOf(Float.parseFloat(extractMetadata4) / 1000.0f).setScale(2, 4));
} catch (Exception unused5) {
}
Deprecated_JSUtil.execCallback(iWebview, str2, jSONObject.toString(), JSUtil.OK, true, false);
} catch (Exception e2) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("code", 13);
jSONObject2.put(DOMException.MESSAGE, e2.getMessage());
} catch (JSONException unused6) {
}
Deprecated_JSUtil.execCallback(iWebview, str2, jSONObject2.toString(), JSUtil.ERROR, true, false);
}
}
}
public static String b(String str) {
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
if (fileExtensionFromUrl != null) {
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtensionFromUrl);
}
return null;
}
private JSONObject a(String str) throws JSONException {
JSONObject jSONObject = new JSONObject();
if (str.startsWith(a)) {
jSONObject.put("type", 1);
jSONObject.put("fsName", "PRIVATE_WWW");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PRIVATE_WWW", a, c(str), true));
} else if (str.startsWith(c)) {
jSONObject.put("type", 2);
jSONObject.put("fsName", "PRIVATE_DOCUMENTS");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PRIVATE_DOCUMENTS", c, c(str), true));
} else if (str.startsWith(d)) {
jSONObject.put("type", 3);
jSONObject.put("fsName", "PUBLIC_DOCUMENTS");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PUBLIC_DOCUMENTS", d, c(str), true));
} else if (str.startsWith(e)) {
jSONObject.put("type", 4);
jSONObject.put("fsName", "PUBLIC_DOWNLOADS");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PUBLIC_DOWNLOADS", e, c(str), true));
} else if (str.startsWith(b)) {
jSONObject.put("type", 1);
jSONObject.put("fsName", "PRIVATE_WWW");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PRIVATE_WWW", b, c(str), true));
} else if (PdrUtil.isDeviceRootDir(str)) {
jSONObject.put("type", 5);
jSONObject.put("fsName", "PUBLIC_DEVICE_ROOT");
jSONObject.put("fsRoot", io.dcloud.js.file.a.a("PUBLIC_DEVICE_ROOT", DeviceInfo.sDeviceRootDir, c(str), true));
}
return jSONObject;
}
public void a(int i, IWebview iWebview, String str) {
Deprecated_JSUtil.execCallback(iWebview, str, a(iWebview.getContext(), i), JSUtil.ERROR, true, false);
}
private String a(Context context, int i) {
switch (i) {
case 1:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_file_not_found));
case 2:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_without_authorization));
case 3:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_common_cancel));
case 4:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_file_not_read));
case 5:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_coding_error));
case 6:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_no_modification_allowed));
case 7:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_invalid_state));
case 8:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_grammar_mistakes));
case 9:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_invalid_modification));
case 10:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_perform_error));
case 11:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_type_mismatch));
case 12:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_path_exists));
case 13:
default:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_unknown_error));
case 14:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), context.getString(R.string.dcloud_io_path_not_exist));
case 15:
return StringUtil.format(DOMException.JSON_ERROR_INFO, Integer.valueOf(i), DOMException.MSG_PATH_NOT_PRIVATE_ERROR);
}
}
public void a(String str, IWebview iWebview, String str2) {
String attribute;
JSONObject jSONObject;
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
String str3 = null;
if (!FileUtil.checkPrivatePath(iWebview.getContext(), str) && Build.VERSION.SDK_INT >= 24) {
InputStream fileInputStream = FileUtil.getFileInputStream(iWebview.getContext(), str);
if (fileInputStream != null) {
BitmapFactory.decodeStream(fileInputStream, null, options);
attribute = new ExifInterface(fileInputStream).getAttribute("Orientation");
fileInputStream.close();
} else {
attribute = null;
}
} else {
attribute = new ExifInterface(str).getAttribute("Orientation");
BitmapFactory.decodeFile(str, options);
}
int i = options.outWidth;
int i2 = options.outHeight;
String str4 = options.outMimeType;
if (!PdrUtil.isEmpty(str4) && str4.contains(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
String[] split = str4.split(InternalZipConstants.ZIP_FILE_SEPARATOR);
str4 = split[split.length - 1];
}
if (!TextUtils.isEmpty(attribute)) {
char c2 = 65535;
switch (attribute.hashCode()) {
case 48:
if (attribute.equals("0")) {
c2 = 1;
break;
}
break;
case 49:
if (attribute.equals("1")) {
c2 = 2;
break;
}
break;
case 50:
if (attribute.equals(io.dcloud.common.util.ExifInterface.GPS_MEASUREMENT_2D)) {
c2 = 3;
break;
}
break;
case 51:
if (attribute.equals(io.dcloud.common.util.ExifInterface.GPS_MEASUREMENT_3D)) {
c2 = 4;
break;
}
break;
case 52:
if (attribute.equals("4")) {
c2 = 5;
break;
}
break;
case 53:
if (attribute.equals("5")) {
c2 = 6;
break;
}
break;
case 54:
if (attribute.equals("6")) {
c2 = 7;
break;
}
break;
case 55:
if (attribute.equals("7")) {
c2 = '\b';
break;
}
break;
case 56:
if (attribute.equals("8")) {
c2 = '\t';
break;
}
break;
}
switch (c2) {
case 3:
str3 = "up-mirrored";
break;
case 4:
str3 = "down";
break;
case 5:
str3 = "down-mirrored";
break;
case 6:
str3 = "left-mirrored";
break;
case 7:
str3 = "right";
break;
case '\b':
str3 = "right-mirrored";
break;
case '\t':
str3 = "left";
break;
default:
str3 = "up";
break;
}
}
jSONObject = new JSONObject();
jSONObject.put(AbsoluteConst.XML_PATH, DeviceInfo.FILE_PROTOCOL + str);
jSONObject.put(AbsoluteConst.JSON_KEY_WIDTH, i);
jSONObject.put("height", i2);
jSONObject.put("orientation", str3);
if (!PdrUtil.isEmpty(str4)) {
str4 = str4.toLowerCase(Locale.ENGLISH);
}
jSONObject.put("type", str4);
} catch (IOException e2) {
e = e2;
} catch (JSONException e3) {
e = e3;
}
try {
JSUtil.execCallback(iWebview, str2, jSONObject, JSUtil.OK, false);
} catch (IOException e4) {
e = e4;
Deprecated_JSUtil.execCallback(iWebview, str2, StringUtil.format(DOMException.JSON_ERROR_INFO, 13, e.getMessage()), JSUtil.ERROR, true, false);
} catch (JSONException e5) {
e = e5;
Deprecated_JSUtil.execCallback(iWebview, str2, StringUtil.format(DOMException.JSON_ERROR_INFO, 13, e.getMessage()), JSUtil.ERROR, true, false);
}
}
private String[] a(IWebview iWebview, String[] strArr, String str) {
if (strArr.length > 1 && !PdrUtil.isEmpty(strArr[1])) {
try {
return JSUtil.jsonArrayToStringArr(new JSONArray(strArr[1]));
} catch (JSONException e2) {
e2.printStackTrace();
a(8, iWebview, str);
}
}
return null;
}
}