what-the-bank/sources/com/huawei/hms/utils/HMSBIInitializer.java

166 lines
6.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.utils;
import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;
import com.huawei.hianalytics.process.HiAnalyticsConfig;
import com.huawei.hianalytics.process.HiAnalyticsInstance;
import com.huawei.hianalytics.process.HiAnalyticsManager;
import com.huawei.hms.framework.network.grs.GrsApp;
import com.huawei.hms.framework.network.grs.GrsBaseInfo;
import com.huawei.hms.framework.network.grs.GrsClient;
import com.huawei.hms.framework.network.grs.IQueryUrlCallBack;
import com.huawei.hms.hatool.HmsHiAnalyticsUtils;
import com.huawei.hms.stats.HianalyticsExist;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hms.support.log.HMSLog;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
/* loaded from: classes2.dex */
public class HMSBIInitializer {
private static final Object d = new Object();
private static HMSBIInitializer e;
private static HiAnalyticsInstance f;
private final Context a;
private AtomicBoolean b = new AtomicBoolean(false);
private boolean c = HianalyticsExist.isHianalyticsExist();
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class a implements IQueryUrlCallBack {
final HMSBIInitializer a;
a(HMSBIInitializer hMSBIInitializer) {
this.a = hMSBIInitializer;
}
@Override // com.huawei.hms.framework.network.grs.IQueryUrlCallBack
public void onCallBackFail(int i) {
HMSLog.e("HMSBIInitializer", "get grs failed, the errorcode is ".concat(String.valueOf(i)));
this.a.b.set(false);
com.huawei.hms.stats.a.c().a();
}
@Override // com.huawei.hms.framework.network.grs.IQueryUrlCallBack
public void onCallBackSuccess(String str) {
if (!TextUtils.isEmpty(str)) {
if (!this.a.c) {
HmsHiAnalyticsUtils.init(this.a.a, false, false, false, str, "com.huawei.hwid");
} else {
this.a.a(str);
}
HMSLog.i("HMSBIInitializer", "BI URL acquired successfully");
}
this.a.b.set(false);
com.huawei.hms.stats.a.c().b();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class b extends AsyncTask<String, Integer, Void> {
final HMSBIInitializer a;
private b(HMSBIInitializer hMSBIInitializer) {
this.a = hMSBIInitializer;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // android.os.AsyncTask
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public Void doInBackground(String... strArr) {
this.a.b(strArr[0]);
return null;
}
/* synthetic */ b(HMSBIInitializer hMSBIInitializer, a aVar) {
this(hMSBIInitializer);
}
}
private HMSBIInitializer(Context context) {
this.a = context;
}
public static HMSBIInitializer getInstance(Context context) {
synchronized (d) {
if (e == null && context != null) {
Context applicationContext = context.getApplicationContext();
if (applicationContext != null) {
e = new HMSBIInitializer(applicationContext);
} else {
e = new HMSBIInitializer(context);
}
}
}
return e;
}
/* JADX INFO: Access modifiers changed from: protected */
public void initHaSDK() {
if (this.b.compareAndSet(false, true)) {
String issueCountryCode = GrsApp.getInstance().getIssueCountryCode(this.a);
if (!TextUtils.isEmpty(issueCountryCode)) {
issueCountryCode = issueCountryCode.toUpperCase(Locale.ENGLISH);
}
if (!GrsBaseInfo.CountryCodeSource.UNKNOWN.equalsIgnoreCase(issueCountryCode) && !TextUtils.isEmpty(issueCountryCode)) {
new b(this, null).execute(issueCountryCode);
} else {
HMSLog.e("HMSBIInitializer", "Failed to get device issue country");
this.b.set(false);
}
}
}
public void initBI() {
boolean initFlag;
if (!this.c) {
initFlag = HmsHiAnalyticsUtils.getInitFlag();
} else {
initFlag = HiAnalyticsManager.getInitFlag(HiAnalyticsConstant.HA_SERVICE_TAG);
}
HMSLog.i("HMSBIInitializer", "Builder->biInitFlag :".concat(String.valueOf(initFlag)));
if (initFlag || AnalyticsSwitchHolder.isAnalyticsDisabled(this.a)) {
return;
}
HMSLog.i("HMSBIInitializer", "Builder->biInitFlag : start initHaSDK");
initHaSDK();
}
public boolean isInit() {
if (!this.c) {
return HmsHiAnalyticsUtils.getInitFlag();
}
return HiAnalyticsManager.getInitFlag(HiAnalyticsConstant.HA_SERVICE_TAG);
}
/* JADX INFO: Access modifiers changed from: private */
public void a(String str) {
HiAnalyticsInstance instanceByTag = HiAnalyticsManager.getInstanceByTag(HiAnalyticsConstant.HA_SERVICE_TAG);
f = instanceByTag;
if (instanceByTag != null) {
instanceByTag.setAppid("com.huawei.hwid");
return;
}
HiAnalyticsConfig build = new HiAnalyticsConfig.Builder().setEnableImei(false).setEnableUDID(false).setEnableSN(false).setCollectURL(str).build();
HiAnalyticsInstance create = new HiAnalyticsInstance.Builder(this.a).setOperConf(build).setMaintConf(new HiAnalyticsConfig.Builder().setEnableImei(false).setEnableUDID(false).setEnableSN(false).setCollectURL(str).build()).create(HiAnalyticsConstant.HA_SERVICE_TAG);
f = create;
if (create != null) {
create.setAppid("com.huawei.hwid");
}
}
/* JADX INFO: Access modifiers changed from: private */
public void b(String str) {
HMSLog.i("HMSBIInitializer", "Start to query GRS");
GrsBaseInfo grsBaseInfo = new GrsBaseInfo();
grsBaseInfo.setIssueCountry(str);
new GrsClient(this.a, grsBaseInfo).ayncGetGrsUrl("com.huawei.cloud.opensdkhianalytics", "ROOTV2", new a(this));
}
public HiAnalyticsInstance getAnalyticsInstance() {
return f;
}
}