正在查看: Zepto v25.1.4 应用的 PhoenixUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Zepto v25.1.4 应用的 PhoenixUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.phoenix;
import android.content.Context;
import android.content.SharedPreferences;
import com.phoenix.FileUtil;
import com.phoenix.Phoenix;
import com.phoenix.PhoenixAnalyticsLogger;
import com.phoenix.PhoenixLogger;
import com.phoenix.PhoenixSharedPreference;
import com.phoenix.PhoenixUpdateManager;
import com.smart.library.util.bspatch.BSPatchUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.io.FilesKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import org.json.JSONObject;
import org.npci.upi.security.pinactivitycomponent.CLConstants;
@Metadata
public final class PhoenixUtils {
@Metadata
@SourceDebugExtension
public static final class Companion {
public static void a(JSONObject jsonObject, Pair... params) {
Intrinsics.checkNotNullParameter(jsonObject, "jsonObject");
Intrinsics.checkNotNullParameter(params, "params");
for (Pair pair : params) {
jsonObject.put((String) pair.a, pair.b);
}
}
public static CacheManifest b(JSONObject jSONObject) {
if (jSONObject == null) {
return null;
}
Object d2 = Phoenix.f2374d.d(CacheManifest.class, jSONObject.toString());
Intrinsics.checkNotNullExpressionValue(d2, "gson.fromJson(jsonObject…acheManifest::class.java)");
return (CacheManifest) d2;
}
public static void c(int i2, int i3) {
try {
e(i2, i3, "unzip");
PhoenixLogger.Companion.a(" Delete bundle related directories success for jsVersion -> " + i2 + " bundleVersion -> " + i3);
} catch (Exception e2) {
StringBuilder v = android.support.v4.media.a.v(" Delete bundle related directories failed for jsVersion -> ", i2, " bundleVersion -> ", i3, " with exception ");
v.append(e2);
PhoenixLogger.Companion.a(v.toString());
}
}
public static boolean d(int i2, int i3, BundleStates bundleStates, String reason, String cacheManifestAppVersion) {
Intrinsics.checkNotNullParameter(reason, "reason");
Intrinsics.checkNotNullParameter(cacheManifestAppVersion, "cacheManifestAppVersion");
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("app_version", cacheManifestAppVersion), new Pair("js_version", Integer.valueOf(i2)), new Pair("bundle_version", Integer.valueOf(i3)), new Pair(CLConstants.OTP_STATUS, bundleStates), new Pair("reason", reason), new Pair("js_bundle_version", i2 + "-" + i3));
try {
a(jSONObject, new Pair("delete_status", Boolean.TRUE));
e(i2, i3, null);
PhoenixAnalyticsLogger.Companion.a("DELETE_BUNDLE_STATUS", jSONObject);
PhoenixLogger.Companion.a("Deleting current bundle success for jsVersion-> " + i2 + " bundleVersion -> " + i3 + " appVersion " + cacheManifestAppVersion);
return true;
} catch (Exception e2) {
StringBuilder v = android.support.v4.media.a.v("Deleting current bundle failed for jsVersion-> ", i2, " bundleVersion -> ", i3, " appVersion ");
v.append(cacheManifestAppVersion);
v.append(" with exception ");
v.append(e2);
PhoenixLogger.Companion.a(v.toString());
a(jSONObject, new Pair("delete_status", Boolean.FALSE));
PhoenixAnalyticsLogger.Companion.a("DELETE_BUNDLE_STATUS", jSONObject);
return false;
}
}
public static void e(int i2, int i3, String str) {
if (str != null) {
String path = FileUtil.Companion.b(i2, i3, str);
Intrinsics.checkNotNullParameter(path, "path");
File file = new File(path);
if (file.exists()) {
FilesKt.a(file);
return;
}
return;
}
String path2 = FileUtil.Companion.b(i2, i3, null);
Intrinsics.checkNotNullParameter(path2, "path");
File file2 = new File(path2);
if (file2.exists()) {
FilesKt.a(file2);
}
}
public static void f(int i2, int i3) {
try {
e(i2, i3, "temp/index.android.bundle");
e(i2, i3, "unzip");
PhoenixLogger.Companion.a("Delete patch related directories success for jsVersion -> " + i2 + " bundleVersion -> " + i3);
} catch (Exception e2) {
StringBuilder v = android.support.v4.media.a.v("Delete patch related directories failed for jsVersion -> ", i2, " bundleVersion -> ", i3, " with exception ");
v.append(e2);
PhoenixLogger.Companion.a(v.toString());
}
}
public static String g() {
String str = Phoenix.a;
Context a = Phoenix.Companion.a();
String str2 = a.getPackageManager().getPackageInfo(a.getPackageName(), 0).versionName;
Intrinsics.checkNotNullExpressionValue(str2, "packageInfo.versionName");
return str2;
}
public static int h(java.lang.Integer r7, java.lang.Integer r8) {
throw new UnsupportedOperationException("Method not decompiled: com.phoenix.PhoenixUtils.Companion.h(java.lang.Integer, java.lang.Integer):int");
}
public static String i(int i2, int i3, int i4) {
String str = Intrinsics.c(Phoenix.b, "PROD") ? "https://phoenix.zepto.co.in/Prod" : "https://phoenix.zeptonow.dev/Prod";
String str2 = Phoenix.a;
if (str2 == null) {
Intrinsics.n(CLConstants.SALT_FIELD_APP_ID);
throw null;
}
Context context = Phoenix.Companion.a();
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter("is_internal_user", "key");
SharedPreferences sharedPreferences = context.getSharedPreferences("phoenix_shared_preference", 0);
Intrinsics.checkNotNullExpressionValue(sharedPreferences, "context.getSharedPrefere…ME, Context.MODE_PRIVATE)");
return str + "/api/v1/check_update?appId=" + str2 + "&jsVersion=" + i2 + "&bundleVersion=" + i3 + "&bucket=" + i4 + "&iu=" + sharedPreferences.getBoolean("is_internal_user", false);
}
public static void j(String reason) {
Intrinsics.checkNotNullParameter(reason, "reason");
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("reason", reason));
PhoenixAnalyticsLogger.Companion.a("SHARED_DEFAULT_BUNDLE", jSONObject);
}
public static JSONObject k() {
try {
String str = Phoenix.a;
InputStream inputStream = Phoenix.Companion.a().getAssets().open("manifest.json");
Intrinsics.checkNotNullExpressionValue(inputStream, "context.assets.open(Phoe…ts.DEFAULT_MANIFEST_PATH)");
Intrinsics.checkNotNullParameter(inputStream, "inputStream");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
bufferedReader.close();
inputStream.close();
return new JSONObject(sb.toString());
}
sb.append(readLine);
sb.append("\n");
}
} catch (IOException e2) {
e2.printStackTrace();
Unit.a.getClass();
Intrinsics.checkNotNullParameter("kotlin.Unit", "data");
return null;
}
}
public static boolean l(String str, Integer num, String hash, Integer num2, BundleStates bundleStates, String source) {
Intrinsics.checkNotNullParameter(hash, "hash");
Intrinsics.checkNotNullParameter(source, "source");
String g2 = g();
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("app_version", g2), new Pair("js_version", num), new Pair("bundle_version", num2), new Pair("js_bundle_version", num + "-" + num2));
try {
JSONObject jSONObject2 = new JSONObject();
a(jSONObject2, new Pair("appVersion", g2), new Pair("jsVersion", num), new Pair("hash", hash), new Pair("bundleVersion", num2));
if (str != null) {
a(jSONObject2, new Pair("bundleUrl", str));
}
a(jSONObject2, new Pair(CLConstants.OTP_STATUS, bundleStates));
a(jSONObject, new Pair(CLConstants.OTP_STATUS, bundleStates));
a(jSONObject, new Pair("update_status", "success"));
PhoenixSharedPreference.Companion.b(source, jSONObject2);
PhoenixAnalyticsLogger.Companion.a("UPDATE_CACHE_DATA", jSONObject);
return true;
} catch (Exception e2) {
a(jSONObject, new Pair("update_status", "failed"));
a(jSONObject, new Pair(CLConstants.OTP_STATUS, bundleStates));
PhoenixAnalyticsLogger.Companion.a("UPDATE_CACHE_DATA", jSONObject);
PhoenixLogger.Companion.a("failed to update user data with exception " + e2);
return false;
}
}
public static void m(String finalPatchFile, Integer num, String hash, String bundleUrl, Integer num2) {
Intrinsics.checkNotNullParameter(finalPatchFile, "finalPatchFile");
Intrinsics.checkNotNullParameter(hash, "hash");
Intrinsics.checkNotNullParameter(bundleUrl, "bundleUrl");
String c = FileUtil.Companion.c(new FileInputStream(new File(finalPatchFile)));
String g2 = g();
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("app_version", g2), new Pair("js_version", num), new Pair("bundle_version", num2), new Pair("md5", c), new Pair("hash", hash), new Pair("js_bundle_version", num + "-" + num2));
PhoenixLogger.Companion.a("md5 for patch is " + c + " and for the bundle is " + hash);
if (!Intrinsics.c(c, hash)) {
a(jSONObject, new Pair(CLConstants.OTP_STATUS, "md5_not_matched"));
PhoenixAnalyticsLogger.Companion.a("PATCH_MD5_STATUS", jSONObject);
Intrinsics.checkNotNullParameter("Md5 mismatched for patch", "data");
l(bundleUrl, num, hash, num2, BundleStates.f2367d, "cache_temp_manifest_data");
Intrinsics.f(num, "null cannot be cast to non-null type kotlin.Int");
int intValue = num.intValue();
Intrinsics.f(num2, "null cannot be cast to non-null type kotlin.Int");
f(intValue, num2.intValue());
PhoenixUpdateManager.Companion.b(bundleUrl, num, hash, num2);
return;
}
a(jSONObject, new Pair(CLConstants.OTP_STATUS, "md5_matched"));
Intrinsics.checkNotNullParameter("Md5 matched for patch", "data");
PhoenixAnalyticsLogger.Companion.a("PATCH_MD5_STATUS", jSONObject);
Intrinsics.f(num, "null cannot be cast to non-null type kotlin.Int");
int intValue2 = num.intValue();
Intrinsics.f(num2, "null cannot be cast to non-null type kotlin.Int");
if (!FileUtil.Companion.d(new File(FileUtil.Companion.b(intValue2, num2.intValue(), "unzip")), new File(FileUtil.Companion.b(num.intValue(), num2.intValue(), null)))) {
a(jSONObject, new Pair("is_copied", Boolean.FALSE));
PhoenixAnalyticsLogger.Companion.a("PATCH_COPY_STATUS", jSONObject);
Intrinsics.checkNotNullParameter("Patch copy failed", "data");
return;
}
a(jSONObject, new Pair("is_copied", Boolean.TRUE));
Intrinsics.checkNotNullParameter("Patch copying success", "data");
PhoenixAnalyticsLogger.Companion.a("PATCH_COPY_STATUS", jSONObject);
if (l(null, num, hash, num2, BundleStates.f2370g, "cache_manifest_data")) {
f(num.intValue(), num2.intValue());
PhoenixSharedPreference.Companion.b("cache_temp_manifest_data", null);
}
}
public static void n(File unzipBundleFile, Integer num, String hash, Integer num2) {
Intrinsics.checkNotNullParameter(unzipBundleFile, "unzipBundleFile");
Intrinsics.checkNotNullParameter(hash, "hash");
String c = FileUtil.Companion.c(new FileInputStream(unzipBundleFile));
String g2 = g();
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("app_version", g2), new Pair("js_version", num), new Pair("bundle_version", num2), new Pair("md5", c), new Pair("hash", hash));
if (!Intrinsics.c(c, hash)) {
a(jSONObject, new Pair(CLConstants.OTP_STATUS, "md5_not_matched"));
PhoenixAnalyticsLogger.Companion.a("BUNDLE_MD5_STATUS", jSONObject);
Intrinsics.f(num, "null cannot be cast to non-null type kotlin.Int");
int intValue = num.intValue();
Intrinsics.f(num2, "null cannot be cast to non-null type kotlin.Int");
c(intValue, num2.intValue());
Intrinsics.checkNotNullParameter("Md5 hash doesn't matches for bundle applying", "data");
return;
}
a(jSONObject, new Pair(CLConstants.OTP_STATUS, "md5_matched"));
PhoenixAnalyticsLogger.Companion.a("BUNDLE_MD5_STATUS", jSONObject);
Intrinsics.f(num, "null cannot be cast to non-null type kotlin.Int");
int intValue2 = num.intValue();
Intrinsics.f(num2, "null cannot be cast to non-null type kotlin.Int");
if (!FileUtil.Companion.d(new File(FileUtil.Companion.b(intValue2, num2.intValue(), "unzip")), new File(FileUtil.Companion.b(num.intValue(), num2.intValue(), null)))) {
a(jSONObject, new Pair("is_copied", Boolean.FALSE));
PhoenixAnalyticsLogger.Companion.a("BUNDLE_COPY_STATUS", jSONObject);
return;
}
a(jSONObject, new Pair("is_copied", Boolean.TRUE));
PhoenixAnalyticsLogger.Companion.a("BUNDLE_COPY_STATUS", jSONObject);
if (l(null, num, hash, num2, BundleStates.f2370g, "cache_manifest_data")) {
c(num.intValue(), num2.intValue());
PhoenixSharedPreference.Companion.b("cache_temp_manifest_data", null);
}
}
public static void o(String unzipPatchFilePath, Integer num, BundleStates statusParam, String hash, String bundleUrl, Integer num2, Integer num3) {
String str;
Intrinsics.checkNotNullParameter(unzipPatchFilePath, "unzipPatchFilePath");
Intrinsics.checkNotNullParameter(statusParam, "statusParam");
Intrinsics.checkNotNullParameter(hash, "hash");
Intrinsics.checkNotNullParameter(bundleUrl, "bundleUrl");
long currentTimeMillis = System.currentTimeMillis();
Intrinsics.f(num, "null cannot be cast to non-null type kotlin.Int");
int intValue = num.intValue();
Intrinsics.f(num2, "null cannot be cast to non-null type kotlin.Int");
int intValue2 = num2.intValue();
Intrinsics.f(num3, "null cannot be cast to non-null type kotlin.Int");
try {
String b = FileUtil.Companion.b(intValue, num3.intValue(), "index.android.bundle");
String b2 = FileUtil.Companion.b(intValue, intValue2, "temp/index.android.bundle");
if (FileUtil.Companion.e(b)) {
FileUtil.Companion.i(b2, FileUtil.Companion.g(new FileInputStream(new File(b))));
PhoenixAnalyticsLogger.Companion.a("COPY_BUNDLE_INTO_TEMP_SUCCESS", new JSONObject());
str = "phoenix_bundle";
} else {
String str2 = Phoenix.a;
InputStream open = Phoenix.Companion.a().getAssets().open("index.android.bundle");
Intrinsics.checkNotNullExpressionValue(open, "context.assets.open(Phoe…ants.DEFAULT_BUNDLE_PATH)");
FileUtil.Companion.i(b2, FileUtil.Companion.g(open));
PhoenixAnalyticsLogger.Companion.a("COPY_BUNDLE_INTO_TEMP_SUCCESS", new JSONObject());
str = "default_bundle";
}
} catch (Exception e2) {
PhoenixAnalyticsLogger.Companion.a("COPY_BUNDLE_INTO_TEMP_FAILED", new JSONObject());
PhoenixLogger.Companion.a("failed to copy to temp folder with exception " + e2);
str = "failed";
}
long currentTimeMillis2 = System.currentTimeMillis() - currentTimeMillis;
String b3 = FileUtil.Companion.b(num.intValue(), num2.intValue(), "temp/index.android.bundle");
String a = FileUtil.Companion.a(FileUtil.Companion.b(num.intValue(), num2.intValue(), "unzip"), "index.android.bundle");
long currentTimeMillis3 = System.currentTimeMillis();
int bspatch = BSPatchUtil.bspatch(b3, a, unzipPatchFilePath);
long currentTimeMillis4 = System.currentTimeMillis() - currentTimeMillis3;
PhoenixLogger.Companion.a("Result is " + bspatch);
String g2 = g();
JSONObject jSONObject = new JSONObject();
a(jSONObject, new Pair("app_version", g2), new Pair("js_version", num), new Pair("bundle_version", num2), new Pair("bundle_into_temp_copy_duration", Long.valueOf(currentTimeMillis2)), new Pair("copy_from_source_into_temp", str), new Pair("patch_apply_duration", Long.valueOf(currentTimeMillis4)), new Pair(CLConstants.OTP_STATUS, statusParam), new Pair("js_bundle_version", num + "-" + num2));
if (bspatch != -1) {
BundleStates bundleStates = BundleStates.c;
a(jSONObject, new Pair(CLConstants.OTP_STATUS, bundleStates));
PhoenixAnalyticsLogger.Companion.a("PATCH_APPLICATION_STATUS", jSONObject);
l(bundleUrl, num, hash, num2, bundleStates, "cache_temp_manifest_data");
m(a, num, hash, bundleUrl, num2);
return;
}
BundleStates bundleStates2 = BundleStates.f2367d;
a(jSONObject, new Pair(CLConstants.OTP_STATUS, bundleStates2));
PhoenixAnalyticsLogger.Companion.a("PATCH_APPLICATION_STATUS", jSONObject);
l(bundleUrl, num, hash, num2, bundleStates2, "cache_temp_manifest_data");
f(num.intValue(), num2.intValue());
PhoenixUpdateManager.Companion.b(bundleUrl, num, hash, num2);
}
}
}