正在查看: 万能钥匙 v1.1.23 应用的 FileDescriptorHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 FileDescriptorHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.api.file;
import ah0.q;
import android.content.Context;
import android.system.Os;
import android.system.StructStat;
import android.util.Base64;
import com.dx.mobile.risk.RiskSituationEventHandler;
import com.finogeeks.lib.applet.api.CallbackHandlerKt;
import com.finogeeks.lib.applet.interfaces.ICallback;
import com.finogeeks.lib.applet.main.host.Host;
import com.finogeeks.lib.applet.modules.subscaleview.ImageEditeActivity;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.b1;
import eh0.d;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.p;
import lg0.e0;
import lg0.s;
import mg0.x;
import org.json.JSONArray;
import org.json.JSONObject;
import tj0.t;
import tj0.u;
import yg0.l;
@Metadata(d1 = {"\u0000b\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0015\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u00002\u00020\u0001:\u0002HIB\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\t\u0010\nJ%\u0010\u0011\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b\u0011\u0010\u0012J\u001d\u0010\u0013\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u0013\u0010\u0014J\u000f\u0010\u0015\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\u0015\u0010\u0016J+\u0010\u0018\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u0018\u0010\u0019J+\u0010\u001a\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001a\u0010\u0019J+\u0010\u001b\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001b\u0010\u0019J+\u0010\u001c\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001c\u0010\u0019J+\u0010\u001d\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001d\u0010\u0019J+\u0010\u001e\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001e\u0010\u0019J+\u0010\u001f\u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b\u001f\u0010\u0019J+\u0010 \u001a\u000e\u0012\u0004\u0012\u00020\b\u0012\u0004\u0012\u00020\f0\u00172\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b \u0010\u0019J%\u0010!\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b!\u0010\u0012J\u001d\u0010\"\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b\"\u0010\u0014J%\u0010#\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b#\u0010\u0012J\u001d\u0010$\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b$\u0010\u0014J\u0019\u0010'\u001a\u0004\u0018\u00010&2\u0006\u0010%\u001a\u00020\u0006H\u0002¢\u0006\u0004\b'\u0010(J\u001f\u0010-\u001a\u00020,2\u0006\u0010*\u001a\u00020)2\u0006\u0010+\u001a\u00020\u0006H\u0002¢\u0006\u0004\b-\u0010.J\u0017\u00100\u001a\u00020\u00062\u0006\u0010/\u001a\u00020\u0006H\u0002¢\u0006\u0004\b0\u00101J\u0017\u00103\u001a\u00020\f2\u0006\u00102\u001a\u00020\u0006H\u0002¢\u0006\u0004\b3\u00104J)\u00106\u001a\u0004\u0018\u00010\f2\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u00102\u001a\u00020\u00062\u0006\u00105\u001a\u00020\bH\u0002¢\u0006\u0004\b6\u00107J%\u00108\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b8\u0010\u0012J\u001d\u00109\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b9\u0010\u0014J%\u0010:\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b:\u0010\u0012J\u001d\u0010;\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b;\u0010\u0014J%\u0010<\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b<\u0010\u0012J\u001d\u0010=\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b=\u0010\u0014J%\u0010>\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b>\u0010\u0012J\u001d\u0010?\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b?\u0010\u0014J%\u0010@\u001a\u00020\u00102\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b@\u0010\u0012J\u001d\u0010A\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\bA\u0010\u0014R8\u0010E\u001a&\u0012\u0004\u0012\u00020\u0006\u0012\b\u0012\u00060CR\u00020\u00000Bj\u0012\u0012\u0004\u0012\u00020\u0006\u0012\b\u0012\u00060CR\u00020\u0000`D8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bE\u0010FR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010G¨\u0006J"}, d2 = {"Lcom/finogeeks/lib/applet/api/file/FileDescriptorHandler;", "", "Lcom/finogeeks/lib/applet/main/host/Host;", "host", "<init>", "(Lcom/finogeeks/lib/applet/main/host/Host;)V", "", "flag", "", "checkFlagValid", "(Ljava/lang/String;)Z", FinFileResourceUtil.KEY_EVENT, "Lorg/json/JSONObject;", "param", "Lcom/finogeeks/lib/applet/interfaces/ICallback;", "callback", "Llg0/e0;", "close", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "closeSync", "(Ljava/lang/String;Lorg/json/JSONObject;)Ljava/lang/String;", "createFdId", "()Ljava/lang/String;", "Lkotlin/Pair;", "doClose", "(Ljava/lang/String;Lorg/json/JSONObject;)Lkotlin/Pair;", "doFStat", "doFTruncate", "doOpen", "doRead", "doStat", "doTruncate", "doWrite", "fstat", "fstatSync", "ftruncate", "ftruncateSync", "encoding", "Ljava/nio/charset/Charset;", "getCharset", "(Ljava/lang/String;)Ljava/nio/charset/Charset;", "Ljava/io/File;", "file", "targetDirPath", "Lorg/json/JSONArray;", "getChildFileStat", "(Ljava/io/File;Ljava/lang/String;)Lorg/json/JSONArray;", ImageEditeActivity.EXTRA_FILE_PATH, "getLocalFilePath", "(Ljava/lang/String;)Ljava/lang/String;", "path", "getSingleFileStat", "(Ljava/lang/String;)Lorg/json/JSONObject;", "recursive", "getStatFromStreamLoad", "(Ljava/lang/String;Ljava/lang/String;Z)Lorg/json/JSONObject;", "open", "openSync", "read", "readSync", "stat", "statSync", "truncate", "truncateSync", "write", "writeSync", "Ljava/util/HashMap;", "Lcom/finogeeks/lib/applet/api/file/FileDescriptorHandler$FileDescriptorBean;", "Lkotlin/collections/HashMap;", "fdMap", "Ljava/util/HashMap;", "Lcom/finogeeks/lib/applet/main/host/Host;", "Companion", "FileDescriptorBean", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class FileDescriptorHandler {
public static final a c = new a(null);
private final HashMap<String, b> a;
private final Host b;
public static final class a {
private a() {
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final boolean a(String str) {
n.j(str, "path");
return n.d(str, "finfile://store") || t.L(str, "finfile://store/", false, 2, (Object) null) || t.L(str, "finfile://store_", false, 2, (Object) null);
}
public final boolean b(String str) {
n.j(str, "path");
return n.d(str, "finfile://temp") || t.L(str, "finfile://temp/", false, 2, (Object) null) || t.L(str, "finfile://tmp_", false, 2, (Object) null);
}
public final boolean c(String str) {
n.j(str, "path");
return n.d(str, "finfile://usr") || t.L(str, "finfile://usr/", false, 2, (Object) null);
}
}
public final class b {
private final RandomAccessFile a;
private final String b;
private final String c;
private final String d;
public b(com.finogeeks.lib.applet.api.file.FileDescriptorHandler r1, java.lang.String r2, java.lang.String r3, java.lang.String r4) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.api.file.FileDescriptorHandler.b.<init>(com.finogeeks.lib.applet.api.m.a, java.lang.String, java.lang.String, java.lang.String):void");
}
public final String a() {
return this.d;
}
public final String b() {
return this.b;
}
public final String c() {
return this.c;
}
public final RandomAccessFile d() {
return this.a;
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0014\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H\n¢\u0006\u0002\b\u0006"}, d2 = {"flattenDir", "Lorg/json/JSONArray;", "jsonObject", "Lorg/json/JSONObject;", "amTime", "", "invoke"}, k = 3, mv = {1, 1, 16})
public static final class c extends p implements ah0.p<JSONObject, Long, JSONArray> {
public static final c a = new c();
public static final class a extends p implements q<String, JSONObject, JSONArray, e0> {
final long a;
public a(long j) {
super(3);
this.a = j;
}
public final void a(String str, JSONObject jSONObject, JSONArray jSONArray) {
n.j(str, "prefix");
n.j(jSONObject, "jsonObject");
n.j(jSONArray, "result");
if (!jSONObject.has("files")) {
jSONArray.put(new JSONObject().put("path", str).put("stats", new JSONObject().put("mode", 33060).put("size", jSONObject.getInt("size")).put("lastAccessedTime", this.a).put("lastModifiedTime", this.a).put("isFile", true).put("isDirectory", false)));
return;
}
jSONArray.put(new JSONObject().put("path", str).put("stats", new JSONObject().put("mode", 16676).put("size", 0).put("lastAccessedTime", this.a).put("lastModifiedTime", this.a).put("isFile", false).put("isDirectory", true)));
JSONObject jSONObject2 = jSONObject.getJSONObject("files");
Iterator<String> keys = jSONObject2.keys();
n.e(keys, "files.keys()");
while (keys.hasNext()) {
String next = keys.next();
String str2 = str + '/' + next;
JSONObject jSONObject3 = jSONObject2.getJSONObject(next);
n.e(jSONObject3, "files.getJSONObject(key)");
a(str2, jSONObject3, jSONArray);
}
}
public Object invoke(Object obj, Object obj2, Object obj3) {
a((String) obj, (JSONObject) obj2, (JSONArray) obj3);
return e0.a;
}
}
public c() {
super(2);
}
public final JSONArray a(JSONObject jSONObject, long j) {
n.j(jSONObject, "jsonObject");
a aVar = new a(j);
JSONArray jSONArray = new JSONArray();
JSONObject put = new JSONObject().put("path", "/");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("mode", 16676);
jSONObject2.put("size", 0);
jSONObject2.put("lastAccessedTime", j);
jSONObject2.put("lastModifiedTime", j);
jSONObject2.put("isFile", false);
jSONObject2.put("isDirectory", true);
jSONArray.put(put.put("stats", jSONObject2));
JSONObject jSONObject3 = jSONObject.getJSONObject("files");
Iterator<String> keys = jSONObject3.keys();
n.e(keys, "files.keys()");
while (keys.hasNext()) {
String next = keys.next();
String str = '/' + next;
JSONObject jSONObject4 = jSONObject3.getJSONObject(next);
n.e(jSONObject4, "files.getJSONObject(key)");
aVar.a(str, jSONObject4, jSONArray);
}
return jSONArray;
}
public Object invoke(Object obj, Object obj2) {
return a((JSONObject) obj, ((Number) obj2).longValue());
}
}
public FileDescriptorHandler(Host host) {
n.j(host, "host");
this.b = host;
this.a = new HashMap<>();
}
private final String a() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= 15; i++) {
sb.append("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(d.a.i(0, 61)));
}
String sb2 = sb.toString();
n.e(sb2, "randomDateSB.toString()");
return sb2;
}
private final JSONArray a(File file, String str) {
JSONArray jSONArray = new JSONArray();
if (!file.isDirectory()) {
JSONObject jSONObject = new JSONObject();
String absolutePath = file.getAbsolutePath();
n.e(absolutePath, "absolutePath");
int length = str.length() + 1;
if (absolutePath == null) {
throw new lg0.t("null cannot be cast to non-null type java.lang.String");
}
String substring = absolutePath.substring(length);
n.e(substring, "(this as java.lang.String).substring(startIndex)");
jSONObject.putOpt("path", substring);
jSONObject.putOpt("stats", d(absolutePath));
jSONArray.put(jSONObject);
return jSONArray;
}
File[] listFiles = file.listFiles();
if (listFiles != null) {
for (File file2 : listFiles) {
n.e(file2, "childFile");
JSONArray a2 = a(file2, str);
int length2 = a2.length();
for (int i = 0; i < length2; i++) {
jSONArray.put(a2.get(i));
}
}
}
return jSONArray;
}
private final JSONObject a(String str, String str2, boolean z10) {
String b2;
c cVar = c.a;
try {
String a2 = b1.a(this.b, str2);
String a3 = b1.a((Context) this.b.getK(), str2, this.b.getAppConfig());
if (a3 != null && (b2 = b1.b(this.b, a3)) != null) {
n.e(b2, "StreamLoadUtil.getFtPkgP…ativePath) ?: return null");
long lastModified = new File(b2).lastModified() / RiskSituationEventHandler.DA2_EVENT_MISC;
JSONObject apiOk = CallbackHandlerKt.apiOk(str);
JSONObject jSONObject = new JSONObject(a2);
if (!jSONObject.has("files")) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.putOpt("mode", 33060);
jSONObject2.putOpt("size", jSONObject.opt("size"));
jSONObject2.putOpt("lastAccessedTime", Long.valueOf(lastModified));
jSONObject2.putOpt("lastModifiedTime", Long.valueOf(lastModified));
jSONObject2.putOpt("isFile", Boolean.TRUE);
jSONObject2.putOpt("isDirectory", Boolean.FALSE);
apiOk.putOpt("stats", jSONObject2);
return apiOk;
}
if (z10) {
apiOk.putOpt("stats", cVar.a(jSONObject, lastModified));
return apiOk;
}
JSONObject jSONObject3 = new JSONObject();
jSONObject3.putOpt("mode", 16676);
jSONObject3.putOpt("size", 0);
jSONObject3.putOpt("lastAccessedTime", Long.valueOf(lastModified));
jSONObject3.putOpt("lastModifiedTime", Long.valueOf(lastModified));
jSONObject3.putOpt("isFile", Boolean.TRUE);
jSONObject3.putOpt("isDirectory", Boolean.FALSE);
apiOk.putOpt("stats", jSONObject3);
return apiOk;
}
} catch (Exception unused) {
}
return null;
}
private final boolean a(String str) {
switch (str.hashCode()) {
case 97:
return str.equals(ag.a.a);
case 114:
return str.equals("r");
case 119:
return str.equals("w");
case 3050:
return str.equals("a+");
case 3122:
return str.equals("as");
case 3127:
return str.equals("ax");
case 3577:
return str.equals("r+");
case 3732:
return str.equals("w+");
case 3809:
return str.equals("wx");
case 96825:
return str.equals("as+");
case 96980:
return str.equals("ax+");
case 118122:
return str.equals("wx+");
default:
return false;
}
}
private final Charset b(String str) {
switch (str.hashCode()) {
case -1109877331:
if (!str.equals("latin1")) {
return null;
}
break;
case -119555963:
if (!str.equals("utf16le")) {
return null;
}
return tj0.c.e;
case 3584301:
if (!str.equals("ucs2")) {
return null;
}
return tj0.c.e;
case 3600241:
if (!str.equals("utf8")) {
return null;
}
break;
case 93106001:
if (!str.equals("ascii")) {
return null;
}
break;
case 111113226:
if (!str.equals("ucs-2")) {
return null;
}
return tj0.c.e;
case 111607186:
if (!str.equals("utf-8")) {
return null;
}
break;
case 584837828:
if (!str.equals("utf-16le")) {
return null;
}
return tj0.c.e;
default:
return null;
}
return Charset.forName(str);
}
private final String c(String str) {
String localFileAbsolutePath = this.b.getAppConfig().getLocalFileAbsolutePath(this.b.getK(), str);
n.e(localFileAbsolutePath, "host.appConfig.getLocalF…(host.activity, filePath)");
return localFileAbsolutePath;
}
private final JSONObject d(String str) {
JSONObject jSONObject = new JSONObject();
try {
StructStat stat = Os.stat(str);
jSONObject.putOpt("mode", Integer.valueOf(stat.st_mode));
jSONObject.putOpt("size", Long.valueOf(stat.st_size));
jSONObject.putOpt("lastAccessedTime", Long.valueOf(stat.st_atime));
jSONObject.putOpt("lastModifiedTime", Long.valueOf(stat.st_mtime));
File file = new File(str);
jSONObject.putOpt("isFile", Boolean.valueOf(file.isFile()));
jSONObject.putOpt("isDirectory", Boolean.valueOf(file.isDirectory()));
return jSONObject;
} catch (Exception e) {
e.printStackTrace();
return jSONObject;
}
}
private final Pair<Boolean, JSONObject> i(String str, JSONObject jSONObject) {
b remove = this.a.remove(jSONObject.optString("fd"));
if (remove == null) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "bad file descriptor"));
}
try {
RandomAccessFile d = remove.d();
if (d != null) {
d.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return s.a(Boolean.TRUE, CallbackHandlerKt.apiOk(str));
}
private final Pair<Boolean, JSONObject> j(String str, JSONObject jSONObject) {
b bVar = this.a.get(jSONObject.optString("fd"));
if (bVar == null) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "bad file descriptor"));
}
n.e(bVar, "fdMap[fd] ?: return fals…t, \"bad file descriptor\")");
String a2 = bVar.a();
a aVar = c;
if (!aVar.c(a2) && !aVar.b(a2) && !aVar.a(a2)) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied"));
}
JSONObject apiOk = CallbackHandlerKt.apiOk(str);
apiOk.putOpt("stats", d(bVar.c()));
return s.a(Boolean.TRUE, apiOk);
}
private final Pair<Boolean, JSONObject> k(String str, JSONObject jSONObject) {
String message;
String optString = jSONObject.optString("fd");
long optLong = jSONObject.optLong("length");
b bVar = this.a.get(optString);
if (bVar == null) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "bad file descriptor"));
}
n.e(bVar, "fdMap[fd] ?: return fals…t, \"bad file descriptor\")");
if (optLong < 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "illegal length \"" + optLong + '\"'));
}
String a2 = bVar.a();
if (!c.c(a2)) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied, open " + a2));
}
String c2 = c(a2);
if (c2.length() == 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied, open " + a2));
}
File file = new File(c2);
File parentFile = file.getParentFile();
if (parentFile == null || !parentFile.exists()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "no such file or directory, open " + a2));
}
if (!file.exists()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "no such file or directory, open " + a2));
}
if (file.isDirectory()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "illegal operation on a directory, open \"" + a2 + '\"'));
}
try {
if (file.length() < optLong) {
l.d(file, new byte[(int) (optLong - file.length())]);
} else {
l.m(file, x.U0(mg0.l.r0(l.h(file), (int) optLong)));
}
return s.a(Boolean.TRUE, CallbackHandlerKt.apiOk(str));
} catch (Exception e) {
e.printStackTrace();
return ((e instanceof IOException) && (message = e.getMessage()) != null && u.Q(message, "No space left on device", false, 2, (Object) null)) ? s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "the maximum size of the file storage limit is exceeded")) : s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str));
}
}
private final kotlin.Pair<java.lang.Boolean, org.json.JSONObject> l(java.lang.String r8, org.json.JSONObject r9) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.api.file.FileDescriptorHandler.l(java.lang.String, org.json.JSONObject):kotlin.Pair");
}
private final Pair<Boolean, JSONObject> m(String str, JSONObject jSONObject) {
String optString = jSONObject.optString("fd");
int optInt = jSONObject.optInt("arrayBufferLength");
byte[] bArr = new byte[optInt];
int optInt2 = jSONObject.optInt("offset");
int optInt3 = jSONObject.optInt("length");
long optLong = jSONObject.optLong("position");
b bVar = this.a.get(optString);
if (bVar == null) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "bad file descriptor"));
}
n.e(bVar, "fdMap[fd] ?: return fals…t, \"bad file descriptor\")");
if (optInt2 < 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "The value of \"offset\" is out of range."));
}
if (optInt3 < 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "The value of \"length\" is out of range."));
}
if (optLong < 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "The value of \"position\" is out of range."));
}
String a2 = bVar.a();
if (!c.c(a2)) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied"));
}
String c2 = c(a2);
if (c2.length() == 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied"));
}
File file = new File(c2);
File parentFile = file.getParentFile();
if (parentFile == null || !parentFile.exists()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "no such file or directory, read " + a2));
}
if (file.isDirectory()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "illegal operation on a directory, read \"" + a2 + '\"'));
}
String b2 = bVar.b();
if (!n.d(b2, "a+") && !n.d(b2, "ax+") && !n.d(b2, "as+") && !n.d(b2, "r+") && !n.d(b2, "r") && !n.d(b2, "w+") && !n.d(b2, "wx+")) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "operation not permitted, read"));
}
if (optInt2 + optInt3 > optInt) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "The value of \"length\" or \"offset\" is out of range."));
}
try {
JSONObject apiOk = CallbackHandlerKt.apiOk(str);
RandomAccessFile d = bVar.d();
int i = 0;
if (optInt3 == 0) {
apiOk.putOpt("bytesRead", 0);
apiOk.putOpt("base64", Base64.encodeToString(bArr, 2));
} else {
if (jSONObject.has("position") && d != null) {
d.seek(optLong);
}
int read = d != null ? d.read(bArr, optInt2, optInt3) : -1;
if (read != -1) {
i = read;
}
apiOk.putOpt("bytesRead", Integer.valueOf(i));
apiOk.putOpt("base64", Base64.encodeToString(bArr, 2));
}
return s.a(Boolean.TRUE, apiOk);
} catch (Exception e) {
e.printStackTrace();
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str));
}
}
private final kotlin.Pair<java.lang.Boolean, org.json.JSONObject> n(java.lang.String r8, org.json.JSONObject r9) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.api.file.FileDescriptorHandler.n(java.lang.String, org.json.JSONObject):kotlin.Pair");
}
private final Pair<Boolean, JSONObject> o(String str, JSONObject jSONObject) {
String message;
String optString = jSONObject.optString(ImageEditeActivity.EXTRA_FILE_PATH);
long optLong = jSONObject.optLong("length");
if (optLong < 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "illegal length \"" + optLong + '\"'));
}
a aVar = c;
n.e(optString, ImageEditeActivity.EXTRA_FILE_PATH);
if (!aVar.c(optString)) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied, open " + optString));
}
String c2 = c(optString);
if (c2.length() == 0) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "permission denied, open " + optString));
}
File file = new File(c2);
File parentFile = file.getParentFile();
if (parentFile == null || !parentFile.exists()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "no such file or directory, open " + optString));
}
if (!file.exists()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "no such file or directory, open " + optString));
}
if (file.isDirectory()) {
return s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "illegal operation on a directory, open \"" + optString + '\"'));
}
try {
if (file.length() < optLong) {
l.d(file, new byte[(int) (optLong - file.length())]);
} else {
l.m(file, x.U0(mg0.l.r0(l.h(file), (int) optLong)));
}
return s.a(Boolean.TRUE, CallbackHandlerKt.apiOk(str));
} catch (Exception e) {
e.printStackTrace();
return ((e instanceof IOException) && (message = e.getMessage()) != null && u.Q(message, "No space left on device", false, 2, (Object) null)) ? s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str, "the maximum size of the file storage limit is exceeded")) : s.a(Boolean.FALSE, CallbackHandlerKt.apiFail(str));
}
}
private final kotlin.Pair<java.lang.Boolean, org.json.JSONObject> p(java.lang.String r21, org.json.JSONObject r22) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.api.file.FileDescriptorHandler.p(java.lang.String, org.json.JSONObject):kotlin.Pair");
}
public final String a(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
String jSONObject2 = ((JSONObject) i(str, jSONObject).d()).toString();
n.e(jSONObject2, "resultPair.second.toString()");
return jSONObject2;
}
public final void a(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> i = i(str, jSONObject);
if (((Boolean) i.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) i.d());
} else {
iCallback.onFail((JSONObject) i.d());
}
}
public final String b(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
Pair<Boolean, JSONObject> j = j(str, jSONObject);
JSONObject jSONObject2 = (JSONObject) j.d();
if (jSONObject2.has("stats")) {
jSONObject2.put("data", jSONObject2.opt("stats"));
jSONObject2.remove("stats");
}
String jSONObject3 = ((JSONObject) j.d()).toString();
n.e(jSONObject3, "resultPair.second.toString()");
return jSONObject3;
}
public final void b(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> j = j(str, jSONObject);
if (((Boolean) j.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) j.d());
} else {
iCallback.onFail((JSONObject) j.d());
}
}
public final String c(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
String jSONObject2 = ((JSONObject) k(str, jSONObject).d()).toString();
n.e(jSONObject2, "resultPair.second.toString()");
return jSONObject2;
}
public final void c(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> k = k(str, jSONObject);
if (((Boolean) k.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) k.d());
} else {
iCallback.onFail((JSONObject) k.d());
}
}
public final String d(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
Pair<Boolean, JSONObject> l = l(str, jSONObject);
JSONObject jSONObject2 = (JSONObject) l.d();
if (jSONObject2.has("fd")) {
jSONObject2.put("data", jSONObject2.optString("fd"));
jSONObject2.remove("fd");
}
String jSONObject3 = ((JSONObject) l.d()).toString();
n.e(jSONObject3, "resultPair.second.toString()");
return jSONObject3;
}
public final void d(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> l = l(str, jSONObject);
if (((Boolean) l.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) l.d());
} else {
iCallback.onFail((JSONObject) l.d());
}
}
public final String e(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
Pair<Boolean, JSONObject> m = m(str, jSONObject);
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("errMsg", ((JSONObject) m.d()).opt("errMsg"));
JSONObject jSONObject3 = new JSONObject();
if (((JSONObject) m.d()).has("bytesRead")) {
jSONObject3.put("bytesRead", ((JSONObject) m.d()).opt("bytesRead"));
}
if (((JSONObject) m.d()).has("bytesRead")) {
jSONObject3.put("base64", ((JSONObject) m.d()).opt("base64"));
}
if (!com.finogeeks.lib.applet.modules.ext.p.a(jSONObject3)) {
jSONObject2.put("data", jSONObject3);
}
String jSONObject4 = jSONObject2.toString();
n.e(jSONObject4, "jsonObject.toString()");
return jSONObject4;
}
public final void e(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> m = m(str, jSONObject);
if (((Boolean) m.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) m.d());
} else {
iCallback.onFail((JSONObject) m.d());
}
}
public final String f(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
Pair<Boolean, JSONObject> n = n(str, jSONObject);
JSONObject jSONObject2 = (JSONObject) n.d();
if (jSONObject2.has("stats")) {
jSONObject2.put("data", jSONObject2.opt("stats"));
jSONObject2.remove("stats");
}
String jSONObject3 = ((JSONObject) n.d()).toString();
n.e(jSONObject3, "resultPair.second.toString()");
return jSONObject3;
}
public final void f(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> n = n(str, jSONObject);
if (((Boolean) n.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) n.d());
} else {
iCallback.onFail((JSONObject) n.d());
}
}
public final String g(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
String jSONObject2 = ((JSONObject) o(str, jSONObject).d()).toString();
n.e(jSONObject2, "resultPair.second.toString()");
return jSONObject2;
}
public final void g(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> o = o(str, jSONObject);
if (((Boolean) o.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) o.d());
} else {
iCallback.onFail((JSONObject) o.d());
}
}
public final String h(String str, JSONObject jSONObject) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
JSONObject jSONObject2 = (JSONObject) p(str, jSONObject).d();
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("errMsg", jSONObject2.opt("errMsg"));
jSONObject2.remove("errMsg");
if (!com.finogeeks.lib.applet.modules.ext.p.a(jSONObject2)) {
jSONObject3.put("data", jSONObject2);
}
String jSONObject4 = jSONObject3.toString();
n.e(jSONObject4, "dataJsonObject.toString()");
return jSONObject4;
}
public final void h(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
Pair<Boolean, JSONObject> p = p(str, jSONObject);
if (((Boolean) p.c()).booleanValue()) {
iCallback.onSuccess((JSONObject) p.d());
} else {
iCallback.onFail((JSONObject) p.d());
}
}
}