what-the-bank/sources/com/huawei/hms/common/util/AGCUtils.java

209 lines
10 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.common.util;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AndroidException;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.HMSPackageManager;
import o.AbstractC12322evy;
import o.BRk;
import o.C16967sno;
import o.Sal;
/* loaded from: classes2.dex */
public class AGCUtils {
private static String b(Context context) {
Bundle bundle;
Object obj;
PackageManager packageManager = context.getPackageManager();
if (packageManager == null) {
HMSLog.e("AGCUtils", "In getMetaDataCpId, Failed to get 'PackageManager' instance.");
return "";
}
try {
ApplicationInfo applicationInfo = packageManager.getPackageInfo(context.getPackageName(), 128).applicationInfo;
if (applicationInfo != null && (bundle = (Bundle) PackageItemInfo.class.getField("metaData").get(applicationInfo)) != null && (obj = bundle.get("com.huawei.hms.client.cpid")) != null) {
String valueOf = String.valueOf(obj);
return valueOf.startsWith("cpid=") ? valueOf.substring(5) : valueOf;
}
HMSLog.i("AGCUtils", "In getMetaDataCpId, Failed to read meta data for the CpId.");
return "";
} catch (AndroidException unused) {
HMSLog.e("AGCUtils", "In getMetaDataCpId, Failed to read meta data for the CpId.");
return "";
} catch (RuntimeException e) {
HMSLog.e("AGCUtils", "In getMetaDataCpId, Failed to read meta data for the CpId.", e);
return "";
}
}
private static boolean c(Context context) {
return context.getPackageName().equals(HMSPackageManager.getInstance(context).getHMSPackageNameForMultiService());
}
public static String getAppId(Context context) {
String str;
if (context == null) {
HMSLog.w("AGCUtils", "getAppId context is null");
return "";
}
if (c(context)) {
str = a(context, "client/app_id");
if (!TextUtils.isEmpty(str)) {
return str;
}
} else {
str = null;
}
try {
AbstractC12322evy c = C16967sno.c();
if (c.d() != context) {
BRk bRk = new BRk();
c = C16967sno.a(new Sal(context, bRk.e, bRk.c, bRk.a, bRk.b, bRk.d));
}
str = c.b().d("client/app_id");
} catch (NullPointerException unused) {
HMSLog.e("AGCUtils", "Get appId with AGConnectServicesConfig failed");
}
if (!TextUtils.isEmpty(str)) {
return str;
}
String a = a(context);
return !TextUtils.isEmpty(a) ? a : a(context, "client/app_id");
}
public static String getCpId(Context context) {
String str;
if (context == null) {
HMSLog.w("AGCUtils", "getCpId context is null");
return "";
}
if (c(context)) {
return a(context, "client/cp_id");
}
try {
AbstractC12322evy c = C16967sno.c();
if (c.d() != context) {
BRk bRk = new BRk();
c = C16967sno.a(new Sal(context, bRk.e, bRk.c, bRk.a, bRk.b, bRk.d));
}
str = c.b().d("client/cp_id");
} catch (NullPointerException unused) {
HMSLog.e("AGCUtils", "Get cpid with AGConnectServicesConfig failed");
str = null;
}
if (!TextUtils.isEmpty(str)) {
return str;
}
String b = b(context);
return !TextUtils.isEmpty(b) ? b : a(context, "client/cp_id");
}
/* JADX WARN: Removed duplicated region for block: B:6:0x006f A[RETURN] */
/* JADX WARN: Removed duplicated region for block: B:8:0x0070 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static java.lang.String a(android.content.Context r13, java.lang.String r14) {
/*
java.lang.String r0 = ""
java.lang.String r1 = "Get "
java.lang.String r2 = "AGCUtils"
r3 = 0
o.BRk r4 = new o.BRk // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
r4.<init>() // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
android.content.res.Resources r5 = r13.getResources() // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
android.content.res.AssetManager r5 = r5.getAssets() // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.lang.String r6 = "agconnect-services.json"
java.io.InputStream r3 = r5.open(r6) // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
r4.a = r3 // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
o.Sal r12 = new o.Sal // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.lang.String r7 = r4.e // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
o.PoK r8 = r4.c // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.io.InputStream r9 = r4.a // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.util.Map<java.lang.String, java.lang.String> r10 = r4.b // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.util.List<o.kLX> r11 = r4.d // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
r5 = r12
r6 = r13
r5.<init>(r6, r7, r8, r9, r10, r11) // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
java.lang.String r13 = r12.d(r14) // Catch: java.lang.Throwable -> L32 java.lang.NullPointerException -> L34 java.io.IOException -> L4d
goto L66
L32:
r13 = move-exception
goto L87
L34:
r13 = move-exception
java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L32
r4.<init>(r1) // Catch: java.lang.Throwable -> L32
r4.append(r14) // Catch: java.lang.Throwable -> L32
java.lang.String r1 = " with AGConnectServicesConfig failed: "
r4.append(r1) // Catch: java.lang.Throwable -> L32
r4.append(r13) // Catch: java.lang.Throwable -> L32
java.lang.String r13 = r4.toString() // Catch: java.lang.Throwable -> L32
com.huawei.hms.support.log.HMSLog.e(r2, r13) // Catch: java.lang.Throwable -> L32
goto L65
L4d:
r13 = move-exception
java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L32
r4.<init>(r1) // Catch: java.lang.Throwable -> L32
r4.append(r14) // Catch: java.lang.Throwable -> L32
java.lang.String r1 = " failed: "
r4.append(r1) // Catch: java.lang.Throwable -> L32
r4.append(r13) // Catch: java.lang.Throwable -> L32
java.lang.String r13 = r4.toString() // Catch: java.lang.Throwable -> L32
com.huawei.hms.support.log.HMSLog.e(r2, r13) // Catch: java.lang.Throwable -> L32
L65:
r13 = r0
L66:
com.huawei.hms.utils.IOUtils.closeQuietly(r3)
boolean r1 = android.text.TextUtils.isEmpty(r13)
if (r1 != 0) goto L70
return r13
L70:
java.lang.StringBuilder r13 = new java.lang.StringBuilder
java.lang.String r1 = "The "
r13.<init>(r1)
r13.append(r14)
java.lang.String r14 = " is null."
r13.append(r14)
java.lang.String r13 = r13.toString()
com.huawei.hms.support.log.HMSLog.e(r2, r13)
return r0
L87:
com.huawei.hms.utils.IOUtils.closeQuietly(r3)
throw r13
*/
throw new UnsupportedOperationException("Method not decompiled: com.huawei.hms.common.util.AGCUtils.a(android.content.Context, java.lang.String):java.lang.String");
}
private static String a(Context context) {
Bundle bundle;
Object obj;
PackageManager packageManager = context.getPackageManager();
if (packageManager == null) {
HMSLog.e("AGCUtils", "In getMetaDataAppId, Failed to get 'PackageManager' instance.");
return "";
}
try {
ApplicationInfo applicationInfo = packageManager.getPackageInfo(context.getPackageName(), 128).applicationInfo;
if (applicationInfo != null && (bundle = (Bundle) PackageItemInfo.class.getField("metaData").get(applicationInfo)) != null && (obj = bundle.get("com.huawei.hms.client.appid")) != null) {
String valueOf = String.valueOf(obj);
return valueOf.startsWith("appid=") ? valueOf.substring(6) : valueOf;
}
HMSLog.e("AGCUtils", "In getMetaDataAppId, Failed to read meta data for the AppID.");
return "";
} catch (AndroidException unused) {
HMSLog.e("AGCUtils", "In getMetaDataAppId, Failed to read meta data for the AppID.");
return "";
} catch (RuntimeException e) {
HMSLog.e("AGCUtils", "In getMetaDataAppId, Failed to read meta data for the AppID.", e);
return "";
}
}
}