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

195 lines
7.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.huawei.hms.activity.BridgeActivity;
import com.huawei.hms.adapter.internal.CommonCode;
import com.huawei.hms.adapter.sysobs.SystemManager;
import com.huawei.hms.adapter.sysobs.SystemObserver;
import com.huawei.hms.adapter.ui.NotInstalledHmsAdapter;
import com.huawei.hms.adapter.ui.UpdateAdapter;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.update.note.AppSpoofResolution;
import com.huawei.hms.utils.Checker;
import com.huawei.hms.utils.HMSBIInitializer;
import com.huawei.hms.utils.HMSPackageManager;
import com.huawei.hms.utils.PackageManagerHelper;
import com.huawei.hms.utils.UIUtil;
/* loaded from: classes2.dex */
public class AvailableAdapter {
private final int a;
private AvailableCallBack b;
private SystemObserver d = new a(this);
private boolean c = false;
/* loaded from: classes2.dex */
public interface AvailableCallBack {
void onComplete(int i);
}
/* loaded from: classes2.dex */
class a implements SystemObserver {
final AvailableAdapter a;
a(AvailableAdapter availableAdapter) {
this.a = availableAdapter;
}
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
public boolean onNoticeResult(int i) {
AvailableCallBack a = this.a.a();
if (a == null) {
HMSLog.e("AvailableAdapter", "onNoticeResult baseCallBack null");
return true;
}
a.onComplete(i);
return true;
}
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
public boolean onSolutionResult(Intent intent, String str) {
return false;
}
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
public boolean onUpdateResult(int i) {
AvailableCallBack a = this.a.a();
if (a == null) {
HMSLog.e("AvailableAdapter", "onUpdateResult baseCallBack null");
return true;
}
a.onComplete(i);
return true;
}
}
public AvailableAdapter(int i) {
this.a = i;
}
private void b(Context context) {
HMSBIInitializer.getInstance(context).initBI();
}
public int checkHuaweiMobileServicesForUpdate(Context context) {
Checker.checkNonNull(context, "context must not be null.");
int a2 = a(context);
if (a2 != 0 || !HMSPackageManager.getInstance(context).isApkNeedUpdate(this.a)) {
return a2;
}
HMSLog.i("AvailableAdapter", "The current version does not meet the target version requirements");
return 2;
}
public int isHuaweiMobileServicesAvailable(Context context) {
Checker.checkNonNull(context, "context must not be null.");
int a2 = a(context);
if (a2 != 0 || !HMSPackageManager.getInstance(context).isApkUpdateNecessary(this.a)) {
return a2;
}
HMSLog.i("AvailableAdapter", "The current version does not meet the minimum version requirements");
return 2;
}
public boolean isUserNoticeError(int i) {
return i == 29;
}
public boolean isUserResolvableError(int i) {
return i == 1 || i == 2;
}
public void startNotice(Activity activity, AvailableCallBack availableCallBack) {
if (activity == null || availableCallBack == null) {
return;
}
if (UIUtil.isBackground(activity)) {
HMSLog.i("AvailableAdapter", "current app is in Background");
availableCallBack.onComplete(28);
} else {
HMSLog.i("AvailableAdapter", "startNotice");
this.b = availableCallBack;
SystemManager.getSystemNotifier().registerObserver(this.d);
activity.startActivity(BridgeActivity.getIntentStartBridgeActivity(activity, AppSpoofResolution.class.getName()));
}
}
public void startResolution(Activity activity, AvailableCallBack availableCallBack) {
if (activity == null || availableCallBack == null) {
return;
}
b(activity);
if (UIUtil.isBackground(activity)) {
HMSLog.i("AvailableAdapter", "current app is in Background");
availableCallBack.onComplete(28);
return;
}
boolean a2 = a(activity);
if (!AvailableUtil.isInstallerLibExist(activity) && !a2) {
a(activity, availableCallBack);
return;
}
HMSLog.i("AvailableAdapter", "startResolution");
this.b = availableCallBack;
SystemManager.getSystemNotifier().registerObserver(this.d);
Intent intentStartBridgeActivity = BridgeActivity.getIntentStartBridgeActivity(activity, UpdateAdapter.class.getName());
intentStartBridgeActivity.putExtra(CommonCode.MapKey.UPDATE_VERSION, this.a);
if (this.c) {
intentStartBridgeActivity.putExtra("installHMS", "installHMS");
}
intentStartBridgeActivity.putExtra(CommonCode.MapKey.NEW_UPDATE, a2);
activity.startActivity(intentStartBridgeActivity);
}
private int a(Context context) {
if (HMSPackageManager.getInstance(context).isUseOldCertificate()) {
HMSLog.e("AvailableAdapter", "The CP uses the old certificate to terminate the connection.");
return 13;
}
PackageManagerHelper.PackageStates hMSPackageStatesForMultiService = HMSPackageManager.getInstance(context).getHMSPackageStatesForMultiService();
if (PackageManagerHelper.PackageStates.NOT_INSTALLED.equals(hMSPackageStatesForMultiService)) {
HMSLog.i("AvailableAdapter", "HMS is not installed");
return 1;
}
if (PackageManagerHelper.PackageStates.SPOOF.equals(hMSPackageStatesForMultiService)) {
HMSLog.i("AvailableAdapter", "HMS is spoofed");
return 29;
}
if (!PackageManagerHelper.PackageStates.DISABLED.equals(hMSPackageStatesForMultiService)) {
return 0;
}
HMSLog.i("AvailableAdapter", "HMS is disabled");
return 3;
}
private void a(Activity activity, AvailableCallBack availableCallBack) {
HMSLog.i("AvailableAdapter", "<showHmsApkNotInstalledDialog> startResolution");
if (NotInstalledHmsAdapter.getShowLock()) {
this.b = availableCallBack;
SystemManager.getSystemNotifier().registerObserver(this.d);
activity.startActivity(BridgeActivity.getIntentStartBridgeActivity(activity, NotInstalledHmsAdapter.class.getName()));
return;
}
availableCallBack.onComplete(31);
}
private boolean a(Activity activity) {
if (HMSPackageManager.getInstance(activity).isUpdateHmsForThirdPartyDevice() || HMSPackageManager.getInstance(activity).getHmsVersionCode() < 40000000) {
return false;
}
HMSLog.i("AvailableAdapter", "enter 4.0 HmsCore upgrade process");
return true;
}
public void setCalledBySolutionInstallHms(boolean z) {
this.c = z;
}
/* JADX INFO: Access modifiers changed from: private */
public AvailableCallBack a() {
return this.b;
}
}