正在查看: 新暖心缘 v8.1.1 应用的 i.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 新暖心缘 v8.1.1 应用的 i.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package d7;
import android.content.Context;
import android.content.res.AssetManager;
import android.net.http.HttpResponseCache;
import android.os.Handler;
import android.os.Looper;
import com.tencent.open.SocialConstants;
import com.tencent.qcloud.core.http.HttpConstants;
import h8.o;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
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.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.Inflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.json.JSONObject;
import q8.p;
public final class i {
private Context f11361a;
private volatile int f11362b;
private volatile int f11363c;
private c f11364d;
public static final b f11360h = new b(null);
private static final AtomicInteger f11357e = new AtomicInteger(0);
private static i f11358f = new i(null);
private static ExecutorService f11359g = Executors.newCachedThreadPool(a.f11365a);
static final class a implements ThreadFactory {
public static final a f11365a = new a();
a() {
}
@Override
public final Thread newThread(Runnable runnable) {
return new Thread(runnable, "SVGAParser-Thread-" + i.f11357e.getAndIncrement());
}
}
public static final class b {
private b() {
}
public b(q8.g gVar) {
this();
}
public final ExecutorService a() {
return i.f11359g;
}
}
public static class c {
private boolean f11366a;
static final class a implements Runnable {
final URL f11368b;
final p f11369c;
final p8.l f11370d;
final p8.l f11371e;
a(URL url, p pVar, p8.l lVar, p8.l lVar2) {
this.f11368b = url;
this.f11369c = pVar;
this.f11370d = lVar;
this.f11371e = lVar2;
}
@Override
public final void run() {
try {
j7.c cVar = j7.c.f13909a;
cVar.e("SVGAParser", "================ svga file download start ================");
if (HttpResponseCache.getInstalled() == null && !c.this.a()) {
cVar.b("SVGAParser", "SVGAParser can not handle cache before install HttpResponseCache. see https://github.com/yyued/SVGAPlayer-Android#cache");
cVar.b("SVGAParser", "在配置 HttpResponseCache 前 SVGAParser 无法缓存. 查看 https://github.com/yyued/SVGAPlayer-Android#cache ");
}
URLConnection openConnection = this.f11368b.openConnection();
if (!(openConnection instanceof HttpURLConnection)) {
openConnection = null;
}
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
if (httpURLConnection == null) {
return;
}
httpURLConnection.setConnectTimeout(20000);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty(HttpConstants.Header.CONNECTION, "close");
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[4096];
while (true) {
if (this.f11369c.a) {
j7.c.f13909a.f("SVGAParser", "================ svga file download canceled ================");
break;
}
int read = inputStream.read(bArr, 0, 4096);
if (read == -1) {
break;
} else {
byteArrayOutputStream.write(bArr, 0, read);
}
}
if (this.f11369c.a) {
j7.c.f13909a.f("SVGAParser", "================ svga file download canceled ================");
n8.a.a(byteArrayOutputStream, (Throwable) null);
n8.a.a(inputStream, (Throwable) null);
return;
}
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
try {
j7.c.f13909a.e("SVGAParser", "================ svga file download complete ================");
this.f11370d.invoke(byteArrayInputStream);
o oVar = o.a;
n8.a.a(byteArrayInputStream, (Throwable) null);
n8.a.a(byteArrayOutputStream, (Throwable) null);
n8.a.a(inputStream, (Throwable) null);
} finally {
}
} finally {
}
} finally {
}
} catch (Exception e8) {
j7.c cVar2 = j7.c.f13909a;
cVar2.b("SVGAParser", "================ svga file download fail ================");
cVar2.b("SVGAParser", "error: " + e8.getMessage());
e8.printStackTrace();
this.f11371e.invoke(e8);
}
}
}
static final class b extends q8.j implements p8.a<o> {
final p f11372a;
b(p pVar) {
super(0);
this.f11372a = pVar;
}
public Object invoke() {
m181invoke();
return o.a;
}
public final void m181invoke() {
this.f11372a.a = true;
}
}
public final boolean a() {
return this.f11366a;
}
public p8.a<o> b(URL url, p8.l<? super InputStream, o> lVar, p8.l<? super Exception, o> lVar2) {
q8.i.g(url, SocialConstants.PARAM_URL);
q8.i.g(lVar, "complete");
q8.i.g(lVar2, "failure");
p pVar = new p();
pVar.a = false;
b bVar = new b(pVar);
i.f11360h.a().execute(new a(url, pVar, lVar, lVar2));
return bVar;
}
}
public interface d {
void a(d7.l lVar);
void onError();
}
public interface e {
void a(List<? extends File> list);
}
static final class f implements Runnable {
final String f11374b;
final d f11375c;
final e f11376d;
f(String str, d dVar, e eVar) {
this.f11374b = str;
this.f11375c = dVar;
this.f11376d = eVar;
}
@Override
public final void run() {
AssetManager assets;
InputStream open;
try {
Context context = i.this.f11361a;
if (context == null || (assets = context.getAssets()) == null || (open = assets.open(this.f11374b)) == null) {
return;
}
i.this.p(open, d7.c.f11335c.c("file:///assets/" + this.f11374b), this.f11375c, true, this.f11376d, this.f11374b);
} catch (Exception e8) {
i.this.w(e8, this.f11375c, this.f11374b);
}
}
}
static final class g implements Runnable {
final InputStream f11378b;
final String f11379c;
final d f11380d;
final String f11381e;
final e f11382f;
final boolean f11383g;
static final class a implements Runnable {
final byte[] f11384a;
final g f11385b;
a(byte[] bArr, g gVar) {
this.f11384a = bArr;
this.f11385b = gVar;
}
@Override
public final void run() {
File e8 = d7.c.f11335c.e(this.f11385b.f11379c);
try {
File file = e8.exists() ^ true ? e8 : null;
if (file != null) {
file.createNewFile();
}
new FileOutputStream(e8).write(this.f11384a);
o oVar = o.a;
} catch (Exception e9) {
j7.c.f13909a.c("SVGAParser", "create cache file fail.", e9);
e8.delete();
}
}
}
static final class b extends q8.j implements p8.a<o> {
final d7.l f11386a;
final g f11387b;
b(d7.l lVar, g gVar) {
super(0);
this.f11386a = lVar;
this.f11387b = gVar;
}
public Object invoke() {
m182invoke();
return o.a;
}
public final void m182invoke() {
j7.c.f13909a.e("SVGAParser", "SVGAVideoEntity prepare success");
g gVar = this.f11387b;
i.this.v(this.f11386a, gVar.f11380d, gVar.f11381e);
}
}
g(InputStream inputStream, String str, d dVar, String str2, e eVar, boolean z7) {
this.f11378b = inputStream;
this.f11379c = str;
this.f11380d = dVar;
this.f11381e = str2;
this.f11382f = eVar;
this.f11383g = z7;
}
@Override
public final void run() {
throw new UnsupportedOperationException("Method not decompiled: d7.i.g.run():void");
}
}
static final class h implements Runnable {
final String f11389b;
final String f11390c;
final d f11391d;
final e f11392e;
static final class a extends q8.j implements p8.a<o> {
final d7.l f11393a;
final h f11394b;
a(d7.l lVar, h hVar) {
super(0);
this.f11393a = lVar;
this.f11394b = hVar;
}
public Object invoke() {
m183invoke();
return o.a;
}
public final void m183invoke() {
j7.c.f13909a.e("SVGAParser", "SVGAVideoEntity prepare success");
h hVar = this.f11394b;
i.this.v(this.f11393a, hVar.f11391d, hVar.f11389b);
}
}
h(String str, String str2, d dVar, e eVar) {
this.f11389b = str;
this.f11390c = str2;
this.f11391d = dVar;
this.f11392e = eVar;
}
@Override
public final void run() {
j7.c cVar;
StringBuilder sb;
FileInputStream fileInputStream;
try {
try {
cVar = j7.c.f13909a;
cVar.e("SVGAParser", "================ decode " + this.f11389b + " from svga cachel file to entity ================");
fileInputStream = new FileInputStream(d7.c.f11335c.e(this.f11390c));
} catch (Exception e8) {
i.this.w(e8, this.f11391d, this.f11389b);
cVar = j7.c.f13909a;
sb = new StringBuilder();
}
try {
byte[] z7 = i.this.z(fileInputStream);
if (z7 == null) {
i.this.w(new Exception("readAsBytes(inputStream) cause exception"), this.f11391d, this.f11389b);
} else if (i.this.x(z7)) {
i.this.o(this.f11390c, this.f11391d, this.f11389b);
} else {
cVar.e("SVGAParser", "inflate start");
byte[] u8 = i.this.u(z7);
if (u8 != null) {
cVar.e("SVGAParser", "inflate complete");
h7.d f8 = h7.d.f12392j.f(u8);
q8.i.b(f8, "MovieEntity.ADAPTER.decode(it)");
d7.l lVar = new d7.l(f8, new File(this.f11390c), i.this.f11362b, i.this.f11363c);
cVar.e("SVGAParser", "SVGAVideoEntity prepare start");
lVar.u(new a(lVar, this), this.f11392e);
} else {
i.this.w(new Exception("inflate(bytes) cause exception"), this.f11391d, this.f11389b);
}
}
o oVar = o.a;
n8.a.a(fileInputStream, (Throwable) null);
sb = new StringBuilder();
sb.append("================ decode ");
sb.append(this.f11389b);
sb.append(" from svga cachel file to entity end ================");
cVar.e("SVGAParser", sb.toString());
} finally {
}
} catch (Throwable th) {
j7.c.f13909a.e("SVGAParser", "================ decode " + this.f11389b + " from svga cachel file to entity end ================");
throw th;
}
}
}
static final class RunnableC0150i implements Runnable {
final String f11396b;
final d f11397c;
final String f11398d;
final e f11399e;
RunnableC0150i(String str, d dVar, String str2, e eVar) {
this.f11396b = str;
this.f11397c = dVar;
this.f11398d = str2;
this.f11399e = eVar;
}
@Override
public final void run() {
if (d7.c.f11335c.i()) {
i.this.o(this.f11396b, this.f11397c, this.f11398d);
} else {
i.this.q(this.f11396b, this.f11397c, this.f11399e, this.f11398d);
}
}
}
static final class j extends q8.j implements p8.l<InputStream, o> {
final String f11401b;
final d f11402c;
final e f11403d;
final String f11404e;
j(String str, d dVar, e eVar, String str2) {
super(1);
this.f11401b = str;
this.f11402c = dVar;
this.f11403d = eVar;
this.f11404e = str2;
}
public final void c(InputStream inputStream) {
q8.i.g(inputStream, "it");
i.this.p(inputStream, this.f11401b, this.f11402c, false, this.f11403d, this.f11404e);
}
public Object invoke(Object obj) {
c((InputStream) obj);
return o.a;
}
}
static final class k extends q8.j implements p8.l<Exception, o> {
final URL f11406b;
final d f11407c;
final String f11408d;
k(URL url, d dVar, String str) {
super(1);
this.f11406b = url;
this.f11407c = dVar;
this.f11408d = str;
}
public final void c(Exception exc) {
q8.i.g(exc, "it");
j7.c.f13909a.b("SVGAParser", "================ svga file: " + this.f11406b + " download fail ================");
i.this.w(exc, this.f11407c, this.f11408d);
}
public Object invoke(Object obj) {
c((Exception) obj);
return o.a;
}
}
static final class l implements Runnable {
final String f11409a;
final d f11410b;
final d7.l f11411c;
l(String str, d dVar, d7.l lVar) {
this.f11409a = str;
this.f11410b = dVar;
this.f11411c = lVar;
}
@Override
public final void run() {
j7.c.f13909a.e("SVGAParser", "================ " + this.f11409a + " parser complete ================");
d dVar = this.f11410b;
if (dVar != null) {
dVar.a(this.f11411c);
}
}
}
static final class m implements Runnable {
final d f11412a;
m(d dVar) {
this.f11412a = dVar;
}
@Override
public final void run() {
d dVar = this.f11412a;
if (dVar != null) {
dVar.onError();
}
}
}
public i(Context context) {
this.f11361a = context != null ? context.getApplicationContext() : null;
d7.c.f11335c.k(context);
this.f11364d = new c();
}
public final void A(InputStream inputStream, String str) {
j7.c.f13909a.e("SVGAParser", "================ unzip prepare ================");
File b8 = d7.c.f11335c.b(str);
b8.mkdirs();
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
try {
ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream);
while (true) {
try {
ZipEntry nextEntry = zipInputStream.getNextEntry();
if (nextEntry == null) {
o oVar = o.a;
n8.a.a(zipInputStream, (Throwable) null);
n8.a.a(bufferedInputStream, (Throwable) null);
return;
}
String name = nextEntry.getName();
q8.i.b(name, "zipItem.name");
if (!w8.g.D(name, "../", false, 2, (Object) null)) {
String name2 = nextEntry.getName();
q8.i.b(name2, "zipItem.name");
if (!w8.g.D(name2, "/", false, 2, (Object) null)) {
File file = new File(b8, nextEntry.getName());
String absolutePath = b8.getAbsolutePath();
q8.i.b(absolutePath, "cacheDir.absolutePath");
t(file, absolutePath);
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
byte[] bArr = new byte[2048];
while (true) {
int read = zipInputStream.read(bArr);
if (read <= 0) {
break;
} else {
fileOutputStream.write(bArr, 0, read);
}
}
o oVar2 = o.a;
n8.a.a(fileOutputStream, (Throwable) null);
j7.c.f13909a.b("SVGAParser", "================ unzip complete ================");
zipInputStream.closeEntry();
} finally {
}
}
}
} finally {
}
}
} finally {
}
} catch (Exception e8) {
j7.c cVar = j7.c.f13909a;
cVar.b("SVGAParser", "================ unzip error ================");
cVar.c("SVGAParser", "error", e8);
d7.c cVar2 = d7.c.f11335c;
String absolutePath2 = b8.getAbsolutePath();
q8.i.b(absolutePath2, "cacheDir.absolutePath");
cVar2.f(absolutePath2);
b8.delete();
throw e8;
}
}
public static void n(i iVar, String str, d dVar, e eVar, int i8, Object obj) {
if ((i8 & 4) != 0) {
eVar = null;
}
iVar.m(str, dVar, eVar);
}
public final void o(String str, d dVar, String str2) {
FileInputStream fileInputStream;
j7.c cVar = j7.c.f13909a;
cVar.e("SVGAParser", "================ decode " + str2 + " from cache ================");
StringBuilder sb = new StringBuilder();
sb.append("decodeFromCacheKey called with cacheKey : ");
sb.append(str);
cVar.a("SVGAParser", sb.toString());
if (this.f11361a == null) {
cVar.b("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
return;
}
try {
File b8 = d7.c.f11335c.b(str);
File file = new File(b8, "movie.binary");
if (!file.isFile()) {
file = null;
}
if (file != null) {
try {
cVar.e("SVGAParser", "binary change to entity");
fileInputStream = new FileInputStream(file);
try {
cVar.e("SVGAParser", "binary change to entity success");
h7.d c8 = h7.d.f12392j.c(fileInputStream);
q8.i.b(c8, "MovieEntity.ADAPTER.decode(it)");
v(new d7.l(c8, b8, this.f11362b, this.f11363c), dVar, str2);
o oVar = o.a;
n8.a.a(fileInputStream, (Throwable) null);
} finally {
}
} catch (Exception e8) {
j7.c.f13909a.c("SVGAParser", "binary change to entity fail", e8);
b8.delete();
file.delete();
throw e8;
}
}
File file2 = new File(b8, "movie.spec");
if (!file2.isFile()) {
file2 = null;
}
if (file2 == null) {
return;
}
try {
cVar.e("SVGAParser", "spec change to entity");
fileInputStream = new FileInputStream(file2);
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[2048];
while (true) {
int read = fileInputStream.read(bArr, 0, 2048);
if (read == -1) {
JSONObject jSONObject = new JSONObject(byteArrayOutputStream.toString());
j7.c.f13909a.e("SVGAParser", "spec change to entity success");
v(new d7.l(jSONObject, b8, this.f11362b, this.f11363c), dVar, str2);
o oVar2 = o.a;
n8.a.a(byteArrayOutputStream, (Throwable) null);
n8.a.a(fileInputStream, (Throwable) null);
return;
}
byteArrayOutputStream.write(bArr, 0, read);
}
} finally {
}
} finally {
try {
throw th;
} finally {
}
}
} catch (Exception e9) {
j7.c.f13909a.c("SVGAParser", str2 + " movie.spec change to entity fail", e9);
b8.delete();
file2.delete();
throw e9;
}
} catch (Exception e10) {
w(e10, dVar, str2);
}
}
public static p8.a s(i iVar, URL url, d dVar, e eVar, int i8, Object obj) {
if ((i8 & 4) != 0) {
eVar = null;
}
return iVar.r(url, dVar, eVar);
}
private final void t(File file, String str) {
String canonicalPath = new File(str).getCanonicalPath();
String canonicalPath2 = file.getCanonicalPath();
q8.i.b(canonicalPath2, "outputFileCanonicalPath");
q8.i.b(canonicalPath, "dstDirCanonicalPath");
if (w8.g.y(canonicalPath2, canonicalPath, false, 2, (Object) null)) {
return;
}
throw new IOException("Found Zip Path Traversal Vulnerability with " + canonicalPath);
}
public final byte[] u(byte[] bArr) {
Inflater inflater = new Inflater();
inflater.setInput(bArr, 0, bArr.length);
byte[] bArr2 = new byte[2048];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
try {
int inflate = inflater.inflate(bArr2, 0, 2048);
if (inflate <= 0) {
inflater.end();
byte[] byteArray = byteArrayOutputStream.toByteArray();
n8.a.a(byteArrayOutputStream, (Throwable) null);
return byteArray;
}
byteArrayOutputStream.write(bArr2, 0, inflate);
} finally {
}
}
}
public final void v(d7.l lVar, d dVar, String str) {
new Handler(Looper.getMainLooper()).post(new l(str, dVar, lVar));
}
public final void w(Exception exc, d dVar, String str) {
exc.printStackTrace();
j7.c cVar = j7.c.f13909a;
cVar.b("SVGAParser", "================ " + str + " parser error ================");
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" parse error");
cVar.c("SVGAParser", sb.toString(), exc);
new Handler(Looper.getMainLooper()).post(new m(dVar));
}
public final boolean x(byte[] bArr) {
return bArr.length > 4 && bArr[0] == 80 && bArr[1] == 75 && bArr[2] == 3 && bArr[3] == 4;
}
public final byte[] z(InputStream inputStream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[2048];
while (true) {
int read = inputStream.read(bArr, 0, 2048);
if (read <= 0) {
byte[] byteArray = byteArrayOutputStream.toByteArray();
n8.a.a(byteArrayOutputStream, (Throwable) null);
return byteArray;
}
byteArrayOutputStream.write(bArr, 0, read);
}
} finally {
}
}
public final void m(String str, d dVar, e eVar) {
q8.i.g(str, "name");
if (this.f11361a == null) {
j7.c.f13909a.b("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
return;
}
j7.c.f13909a.e("SVGAParser", "================ decode " + str + " from assets ================");
f11359g.execute(new f(str, dVar, eVar));
}
public final void p(InputStream inputStream, String str, d dVar, boolean z7, e eVar, String str2) {
q8.i.g(inputStream, "inputStream");
q8.i.g(str, "cacheKey");
if (this.f11361a == null) {
j7.c.f13909a.b("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
return;
}
j7.c.f13909a.e("SVGAParser", "================ decode " + str2 + " from input stream ================");
f11359g.execute(new g(inputStream, str, dVar, str2, eVar, z7));
}
public final void q(String str, d dVar, e eVar, String str2) {
q8.i.g(str, "cacheKey");
f11359g.execute(new h(str2, str, dVar, eVar));
}
public final p8.a<o> r(URL url, d dVar, e eVar) {
q8.i.g(url, SocialConstants.PARAM_URL);
if (this.f11361a == null) {
j7.c.f13909a.b("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
return null;
}
String url2 = url.toString();
q8.i.b(url2, "url.toString()");
j7.c cVar = j7.c.f13909a;
cVar.e("SVGAParser", "================ decode from url: " + url2 + " ================");
d7.c cVar2 = d7.c.f11335c;
String d8 = cVar2.d(url);
if (!cVar2.h(d8)) {
cVar.e("SVGAParser", "no cached, prepare to download");
return this.f11364d.b(url, new j(d8, dVar, eVar, url2), new k(url, dVar, url2));
}
cVar.e("SVGAParser", "this url cached");
f11359g.execute(new RunnableC0150i(d8, dVar, url2, eVar));
return null;
}
public final void y(URL url, d dVar) {
q8.i.g(url, SocialConstants.PARAM_URL);
r(url, dVar, null);
}
}