Picsart v24.6版本的 MD5 值为:21a61631d94e54da68d2ad9268b8b9d9
以下内容为反编译后的 WebContentUtils.java 源代码,内容仅作参考
package com.braze.support;
import android.content.Context;
import com.braze.support.BrazeLogger;
import io.jsonwebtoken.JwtParser;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Locale;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.Ref$ObjectRef;
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010$\n\u0002\b\b\bÇ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0015\u0010\u0016J\u001a\u0010\u0006\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0007J\u0018\u0010\n\u001a\u00020\t2\u0006\u0010\u0007\u001a\u00020\u00042\u0006\u0010\b\u001a\u00020\u0002H\u0007J\u0010\u0010\r\u001a\u00020\u00022\u0006\u0010\f\u001a\u00020\u000bH\u0007J$\u0010\u0011\u001a\u00020\u00042\u0006\u0010\u000e\u001a\u00020\u00042\u0012\u0010\u0010\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00040\u000fH\u0007J\u0018\u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0012\u001a\u00020\u00042\u0006\u0010\u0013\u001a\u00020\u0004H\u0007¨\u0006\u0017"}, d2 = {"Lcom/braze/support/WebContentUtils;", "", "Ljava/io/File;", "localDirectory", "", "remoteZipUrl", "getLocalHtmlUrlFromRemoteUrl", "unpackDirectory", "zipFile", "", "unpackZipIntoDirectory", "Landroid/content/Context;", "context", "getHtmlInAppMessageAssetCacheDirectory", "originalString", "", "remoteToLocalAssetMap", "replacePrefetchedUrlsWithLocalAssets", "intendedParentDirectory", "childFilePath", "validateChildFileExistsUnderParent", "<init>", "()V", "android-sdk-base_release"}, k = 1, mv = {1, 8, 0})
public final class WebContentUtils {
public static final WebContentUtils INSTANCE = new WebContentUtils();
public static final class a extends Lambda implements Function0 {
public static final a b = new a();
public a() {
super(0);
}
@Override
public final String invoke() {
return "Remote zip url is empty. No local URL will be created.";
}
}
public static final class b extends Lambda implements Function0 {
final String b;
final String c;
public b(String str, String str2) {
super(0);
this.b = str;
this.c = str2;
}
@Override
public final String invoke() {
return "Starting download of url: " + this.b + " to " + this.c;
}
}
public static final class c extends Lambda implements Function0 {
final String b;
public c(String str) {
super(0);
this.b = str;
}
@Override
public final String invoke() {
return "Could not download zip file to local storage. " + this.b;
}
}
public static final class d extends Lambda implements Function0 {
final String b;
final String c;
public d(String str, String str2) {
super(0);
this.b = str;
this.c = str2;
}
@Override
public final String invoke() {
return "Html content zip downloaded. " + this.b + " to " + this.c;
}
}
public static final class e extends Lambda implements Function0 {
public static final e b = new e();
public e() {
super(0);
}
@Override
public final String invoke() {
return "Error during the zip unpack.";
}
}
public static final class f extends Lambda implements Function0 {
final String b;
public f(String str) {
super(0);
this.b = str;
}
@Override
public final String invoke() {
return defpackage.a.l(new StringBuilder("Html content zip unpacked to to "), this.b, JwtParser.SEPARATOR_CHAR);
}
}
public static final class g extends Lambda implements Function0 {
final String b;
public g(String str) {
super(0);
this.b = str;
}
@Override
public final String invoke() {
return "Cannot find local asset file at path: " + this.b;
}
}
public static final class h extends Lambda implements Function0 {
final String b;
final String c;
public h(String str, String str2) {
super(0);
this.b = str;
this.c = str2;
}
@Override
public final String invoke() {
StringBuilder sb = new StringBuilder("Replacing remote url \"");
sb.append(this.b);
sb.append("\" with local uri \"");
return defpackage.a.l(sb, this.c, '\"');
}
}
public static final class i extends Lambda implements Function0 {
public static final i b = new i();
public i() {
super(0);
}
@Override
public final String invoke() {
return "Unpack directory is blank. Zip file not unpacked.";
}
}
public static final class j extends Lambda implements Function0 {
final Ref$ObjectRef b;
public j(Ref$ObjectRef ref$ObjectRef) {
super(0);
this.b = ref$ObjectRef;
}
@Override
public final String invoke() {
return "Error creating parent directory " + ((String) this.b.element);
}
}
public static final class k extends Lambda implements Function0 {
final Ref$ObjectRef b;
public k(Ref$ObjectRef ref$ObjectRef) {
super(0);
this.b = ref$ObjectRef;
}
@Override
public final String invoke() {
return "Error unpacking zipEntry " + ((String) this.b.element);
}
}
public static final class l extends Lambda implements Function0 {
final File b;
final String c;
public l(File file, String str) {
super(0);
this.b = file;
this.c = str;
}
@Override
public final String invoke() {
StringBuilder sb = new StringBuilder("Error during unpack of zip file ");
sb.append(this.b.getAbsolutePath());
sb.append(" to ");
return defpackage.a.l(sb, this.c, JwtParser.SEPARATOR_CHAR);
}
}
private WebContentUtils() {
}
public static final File getHtmlInAppMessageAssetCacheDirectory(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
return new File(context.getCacheDir().getPath() + "/braze-html-inapp-messages");
}
public static final String getLocalHtmlUrlFromRemoteUrl(File localDirectory, String remoteZipUrl) {
Intrinsics.checkNotNullParameter(localDirectory, "localDirectory");
Intrinsics.checkNotNullParameter(remoteZipUrl, "remoteZipUrl");
if (myobfuscated.mn2.k.o(remoteZipUrl)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, a.b, 2, (Object) null);
return null;
}
String absolutePath = localDirectory.getAbsolutePath();
String valueOf = String.valueOf(IntentUtils.getRequestCode());
String a2 = myobfuscated.xc0.b.a(absolutePath, '/', valueOf);
BrazeLogger brazeLogger = BrazeLogger.INSTANCE;
WebContentUtils webContentUtils = INSTANCE;
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new b(remoteZipUrl, a2), 3, (Object) null);
try {
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new d(remoteZipUrl, a2), 3, (Object) null);
if (unpackZipIntoDirectory(a2, BrazeFileUtils.downloadFileToPath(a2, remoteZipUrl, valueOf, ".zip").component1())) {
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new f(a2), 3, (Object) null);
return a2;
}
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, BrazeLogger.Priority.W, (Throwable) null, e.b, 2, (Object) null);
BrazeFileUtils.deleteFileOrDirectory(new File(a2));
return null;
} catch (Exception e2) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e2, new c(remoteZipUrl));
BrazeFileUtils.deleteFileOrDirectory(new File(a2));
return null;
}
}
public static final String replacePrefetchedUrlsWithLocalAssets(String originalString, Map<String, String> remoteToLocalAssetMap) {
Intrinsics.checkNotNullParameter(originalString, "originalString");
Intrinsics.checkNotNullParameter(remoteToLocalAssetMap, "remoteToLocalAssetMap");
for (Map.Entry<String, String> entry : remoteToLocalAssetMap.entrySet()) {
String value = entry.getValue();
if (defpackage.j.B(value)) {
String key = entry.getKey();
if (kotlin.text.d.w(value, "ab_triggers", false)) {
String p = com.appsflyer.internal.h.p("https://iamcache.braze/ab_triggers", (String) kotlin.text.d.V(value, new String[]{"ab_triggers"}, 0, 6).get(1));
if (kotlin.text.d.w(originalString, key, false)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new h(key, p), 3, (Object) null);
originalString = myobfuscated.mn2.k.r(originalString, key, p, false);
}
}
} else {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, new g(value), 2, (Object) null);
}
}
return originalString;
}
public static final boolean unpackZipIntoDirectory(String unpackDirectory, File zipFile) {
Intrinsics.checkNotNullParameter(unpackDirectory, "unpackDirectory");
Intrinsics.checkNotNullParameter(zipFile, "zipFile");
if (myobfuscated.mn2.k.o(unpackDirectory)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.I, (Throwable) null, i.b, 2, (Object) null);
return false;
}
new File(unpackDirectory).mkdirs();
try {
Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef();
ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
?? name = nextEntry.getName();
Intrinsics.checkNotNullExpressionValue(name, "zipEntry.name");
ref$ObjectRef.element = name;
Locale US = Locale.US;
Intrinsics.checkNotNullExpressionValue(US, "US");
String lowerCase = name.toLowerCase(US);
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(locale)");
if (!myobfuscated.mn2.k.v(lowerCase, "__macosx", false)) {
try {
String validateChildFileExistsUnderParent = validateChildFileExistsUnderParent(unpackDirectory, unpackDirectory + '/' + ((String) ref$ObjectRef.element));
if (!nextEntry.isDirectory()) {
try {
File parentFile = new File(validateChildFileExistsUnderParent).getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
} catch (Exception e2) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e2, new j(ref$ObjectRef));
}
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(validateChildFileExistsUnderParent));
try {
myobfuscated.tk2.a.a(zipInputStream, bufferedOutputStream, 8192);
myobfuscated.sr.e.s(bufferedOutputStream, null);
} catch (Throwable th) {
try {
throw th;
break;
} catch (Throwable th2) {
myobfuscated.sr.e.s(bufferedOutputStream, th);
throw th2;
break;
}
}
} else {
new File(validateChildFileExistsUnderParent).mkdirs();
}
} catch (Exception e3) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e3, new k(ref$ObjectRef));
}
}
zipInputStream.closeEntry();
}
Unit unit = Unit.a;
myobfuscated.sr.e.s(zipInputStream, null);
return true;
} catch (Throwable th3) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, th3, new l(zipFile, unpackDirectory));
return false;
}
}
public static final String validateChildFileExistsUnderParent(String intendedParentDirectory, String childFilePath) {
Intrinsics.checkNotNullParameter(intendedParentDirectory, "intendedParentDirectory");
Intrinsics.checkNotNullParameter(childFilePath, "childFilePath");
String parentCanonicalPath = new File(intendedParentDirectory).getCanonicalPath();
String childFileCanonicalPath = new File(childFilePath).getCanonicalPath();
Intrinsics.checkNotNullExpressionValue(childFileCanonicalPath, "childFileCanonicalPath");
Intrinsics.checkNotNullExpressionValue(parentCanonicalPath, "parentCanonicalPath");
if (myobfuscated.mn2.k.v(childFileCanonicalPath, parentCanonicalPath, false)) {
return childFileCanonicalPath;
}
throw new IllegalStateException(defpackage.d.r(com.appsflyer.internal.c.s("Invalid file with original path: ", childFilePath, " with canonical path: ", childFileCanonicalPath, " does not exist under intended parent with path: "), intendedParentDirectory, " and canonical path: ", parentCanonicalPath));
}
}