what-the-bank/sources/com/huawei/hms/adapter/AvailableUtil.java

95 lines
4.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.adapter;
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.util.AndroidException;
import com.huawei.hms.adapter.ui.UpdateAdapter;
import com.huawei.hms.common.HmsCheckedState;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.AgHmsUpdateState;
/* loaded from: classes2.dex */
public class AvailableUtil {
private static final Object a = new Object();
private static boolean b = false;
private static boolean c = false;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class a implements Runnable {
final Context a;
a(Context context) {
this.a = context;
}
@Override // java.lang.Runnable
public void run() {
HMSLog.i("AvailableUtil", "enter asyncCheckHmsV3UpdateInfo");
if (!AvailableUtil.isInstallerLibExist(this.a)) {
AgHmsUpdateState.getInstance().setCheckedState(HmsCheckedState.NOT_NEED_UPDATE);
HMSLog.e("AvailableUtil", "asyncCheckHmsV3UpdateInfo installer is not exist");
} else {
UpdateAdapter.invokeMethod("com.huawei.hms.adapter.ui.InstallerAdapter", "checkHmsUpdateInfo", new Object[]{this.a});
HMSLog.i("AvailableUtil", "quit asyncCheckHmsV3UpdateInfo");
}
}
}
public static void asyncCheckHmsUpdateInfo(Context context) {
if (HmsCheckedState.UNCHECKED != AgHmsUpdateState.getInstance().getCheckedState()) {
HMSLog.i("AvailableUtil", "asyncCheckHmsUpdateInfo, not need to check");
} else {
new Thread(new a(context), "Thread-asyncCheckHmsV3UpdateInfo").start();
}
}
public static boolean isInstallerLibExist(Context context) {
Bundle bundle;
Object obj;
boolean z;
if (b) {
StringBuilder sb = new StringBuilder("installerInit exist: ");
sb.append(c);
HMSLog.i("AvailableUtil", sb.toString());
return c;
}
synchronized (a) {
if (!b) {
PackageManager packageManager = context.getPackageManager();
if (packageManager == null) {
HMSLog.e("AvailableUtil", "In isAvailableLibExist, Failed to get 'PackageManager' instance.");
try {
Class.forName("com.huawei.hms.update.manager.UpdateManager");
z = true;
} catch (ClassNotFoundException unused) {
HMSLog.e("AvailableUtil", "In isInstallerLibExist, Failed to find class UpdateManager.");
}
} else {
try {
ApplicationInfo applicationInfo = packageManager.getPackageInfo(context.getPackageName(), 128).applicationInfo;
if (applicationInfo != null && (bundle = (Bundle) PackageItemInfo.class.getField("metaData").get(applicationInfo)) != null && (obj = bundle.get("availableHMSCoreInstaller")) != null && String.valueOf(obj).equalsIgnoreCase("yes")) {
HMSLog.i("AvailableUtil", "available exist: true");
z = true;
}
} catch (AndroidException unused2) {
HMSLog.e("AvailableUtil", "In isInstallerLibExist, Failed to read meta data for the availableHMSCoreInstaller.");
} catch (RuntimeException e) {
HMSLog.e("AvailableUtil", "In isInstallerLibExist, Failed to read meta data for the availableHMSCoreInstaller.", e);
}
z = false;
}
c = z;
b = true;
}
}
StringBuilder sb2 = new StringBuilder("available exist: ");
sb2.append(c);
HMSLog.i("AvailableUtil", sb2.toString());
return c;
}
}