663 lines
28 KiB
Java
663 lines
28 KiB
Java
|
package com.huawei.hms.adapter;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.app.PendingIntent;
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.os.Build;
|
||
|
import android.os.Bundle;
|
||
|
import android.os.Parcelable;
|
||
|
import android.text.TextUtils;
|
||
|
import com.huawei.hms.activity.BridgeActivity;
|
||
|
import com.huawei.hms.adapter.AvailableAdapter;
|
||
|
import com.huawei.hms.adapter.internal.CommonCode;
|
||
|
import com.huawei.hms.adapter.sysobs.ApkResolutionFailedManager;
|
||
|
import com.huawei.hms.adapter.sysobs.SystemManager;
|
||
|
import com.huawei.hms.adapter.sysobs.SystemObserver;
|
||
|
import com.huawei.hms.adapter.ui.BaseResolutionAdapter;
|
||
|
import com.huawei.hms.adapter.ui.UpdateAdapter;
|
||
|
import com.huawei.hms.common.internal.RequestHeader;
|
||
|
import com.huawei.hms.common.internal.ResponseHeader;
|
||
|
import com.huawei.hms.common.internal.ResponseWrap;
|
||
|
import com.huawei.hms.core.aidl.IMessageEntity;
|
||
|
import com.huawei.hms.framework.common.ExceptionCode;
|
||
|
import com.huawei.hms.support.api.PendingResultImpl;
|
||
|
import com.huawei.hms.support.api.ResolveResult;
|
||
|
import com.huawei.hms.support.api.client.ApiClient;
|
||
|
import com.huawei.hms.support.api.client.PendingResult;
|
||
|
import com.huawei.hms.support.api.client.ResultCallback;
|
||
|
import com.huawei.hms.support.api.client.Status;
|
||
|
import com.huawei.hms.support.api.entity.core.CommonCode;
|
||
|
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
|
||
|
import com.huawei.hms.support.hianalytics.HiAnalyticsUtil;
|
||
|
import com.huawei.hms.support.log.HMSLog;
|
||
|
import com.huawei.hms.update.kpms.KpmsConstant;
|
||
|
import com.huawei.hms.utils.HMSPackageManager;
|
||
|
import com.huawei.hms.utils.IntentUtil;
|
||
|
import com.huawei.hms.utils.JsonUtil;
|
||
|
import com.huawei.hms.utils.ResolutionFlagUtil;
|
||
|
import com.huawei.hms.utils.Util;
|
||
|
import java.lang.ref.WeakReference;
|
||
|
import java.sql.Timestamp;
|
||
|
import java.util.Map;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
import org.json.JSONException;
|
||
|
import org.json.JSONObject;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class BaseAdapter {
|
||
|
private WeakReference<ApiClient> a;
|
||
|
private WeakReference<Activity> b;
|
||
|
private BaseCallBack c;
|
||
|
private String d;
|
||
|
private String e;
|
||
|
private Parcelable f;
|
||
|
private BaseCallBack g;
|
||
|
private String h;
|
||
|
private Context i;
|
||
|
private RequestHeader j = new RequestHeader();
|
||
|
private ResponseHeader k = new ResponseHeader();
|
||
|
private SystemObserver l;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public interface BaseCallBack {
|
||
|
void onComplete(String str, String str2, Parcelable parcelable);
|
||
|
|
||
|
void onError(String str);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class BaseRequestResultCallback implements ResultCallback<ResolveResult<CoreBaseResponse>> {
|
||
|
private AtomicBoolean a = new AtomicBoolean(true);
|
||
|
final BaseAdapter b;
|
||
|
|
||
|
public BaseRequestResultCallback(BaseAdapter baseAdapter) {
|
||
|
this.b = baseAdapter;
|
||
|
}
|
||
|
|
||
|
private void a(String str, BaseCallBack baseCallBack, CoreBaseResponse coreBaseResponse, int i) {
|
||
|
if (CommonCode.Resolution.HAS_RESOLUTION_FROM_APK.equals(str)) {
|
||
|
Activity c = this.b.c();
|
||
|
HMSLog.i("BaseAdapter", "activity is: ".concat(String.valueOf(c)));
|
||
|
if (c != null && !c.isFinishing()) {
|
||
|
PendingIntent pendingIntent = coreBaseResponse.getPendingIntent();
|
||
|
if (pendingIntent != null) {
|
||
|
if (!Util.isAvailableLibExist(this.b.i)) {
|
||
|
baseCallBack.onError(this.b.b(-9));
|
||
|
return;
|
||
|
} else {
|
||
|
this.b.a(c, pendingIntent, coreBaseResponse);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
Intent intent = coreBaseResponse.getIntent();
|
||
|
if (intent != null) {
|
||
|
if (!Util.isAvailableLibExist(this.b.i)) {
|
||
|
baseCallBack.onError(this.b.b(-9));
|
||
|
return;
|
||
|
} else {
|
||
|
this.b.a(c, intent, coreBaseResponse);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
BaseAdapter baseAdapter = this.b;
|
||
|
baseCallBack.onError(baseAdapter.b(baseAdapter.k.getErrorCode()));
|
||
|
return;
|
||
|
} else {
|
||
|
HMSLog.e("BaseAdapter", "hasResolution is true but NO_SOLUTION");
|
||
|
baseCallBack.onError(this.b.b(-4));
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "activity null");
|
||
|
this.b.a(baseCallBack, coreBaseResponse);
|
||
|
return;
|
||
|
}
|
||
|
if (!"installHMS".equals(str)) {
|
||
|
this.b.a(baseCallBack, coreBaseResponse);
|
||
|
} else {
|
||
|
HMSLog.i("BaseAdapter", "has resolutin: installHMS");
|
||
|
a(baseCallBack, coreBaseResponse);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.support.api.client.ResultCallback
|
||
|
public void onResult(ResolveResult<CoreBaseResponse> resolveResult) {
|
||
|
HMSLog.i("BaseAdapter", "BaseRequestResultCallback onResult");
|
||
|
BaseCallBack b = this.b.b();
|
||
|
if (b == null) {
|
||
|
HMSLog.e("BaseAdapter", "onResult baseCallBack null");
|
||
|
return;
|
||
|
}
|
||
|
if (resolveResult == null) {
|
||
|
HMSLog.e("BaseAdapter", "result null");
|
||
|
b.onError(this.b.b(-1));
|
||
|
return;
|
||
|
}
|
||
|
CoreBaseResponse value = resolveResult.getValue();
|
||
|
if (value == null) {
|
||
|
HMSLog.e("BaseAdapter", "response null");
|
||
|
b.onError(this.b.b(-1));
|
||
|
return;
|
||
|
}
|
||
|
if (!TextUtils.isEmpty(value.getJsonHeader())) {
|
||
|
JsonUtil.jsonToEntity(value.getJsonHeader(), this.b.k);
|
||
|
if (this.a.compareAndSet(true, false)) {
|
||
|
BaseAdapter baseAdapter = this.b;
|
||
|
baseAdapter.a(baseAdapter.i, this.b.k);
|
||
|
}
|
||
|
String resolution = this.b.k.getResolution();
|
||
|
int statusCode = this.b.k.getStatusCode();
|
||
|
StringBuilder sb = new StringBuilder("api is: ");
|
||
|
sb.append(this.b.k.getApiName());
|
||
|
sb.append(", resolution: ");
|
||
|
sb.append(resolution);
|
||
|
sb.append(", status_code: ");
|
||
|
sb.append(statusCode);
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
a(resolution, b, value, statusCode);
|
||
|
return;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "jsonHeader null");
|
||
|
b.onError(this.b.b(-1));
|
||
|
}
|
||
|
|
||
|
private void a(BaseCallBack baseCallBack, CoreBaseResponse coreBaseResponse) {
|
||
|
if (Util.isAvailableLibExist(this.b.i)) {
|
||
|
Activity c = this.b.c();
|
||
|
if (c != null && !c.isFinishing()) {
|
||
|
HMSLog.i("BaseAdapter", "start handleSolutionForHMS");
|
||
|
AvailableAdapter availableAdapter = new AvailableAdapter(ExceptionCode.CRASH_EXCEPTION);
|
||
|
availableAdapter.setCalledBySolutionInstallHms(true);
|
||
|
availableAdapter.startResolution(c, new AvailableAdapter.AvailableCallBack(this, baseCallBack) { // from class: com.huawei.hms.adapter.BaseAdapter.BaseRequestResultCallback.1
|
||
|
final BaseCallBack a;
|
||
|
final BaseRequestResultCallback b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
this.a = baseCallBack;
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.adapter.AvailableAdapter.AvailableCallBack
|
||
|
public void onComplete(int i) {
|
||
|
HMSLog.i("BaseAdapter", "complete handleSolutionForHMS, result: ".concat(String.valueOf(i)));
|
||
|
if (i == 0) {
|
||
|
HMSPackageManager.getInstance(this.b.b.i).resetMultiServiceState();
|
||
|
BaseAdapter baseAdapter = this.b.b;
|
||
|
this.a.onError(baseAdapter.a(11, baseAdapter.a(11)).toJson());
|
||
|
this.b.b.i();
|
||
|
return;
|
||
|
}
|
||
|
BaseAdapter baseAdapter2 = this.b.b;
|
||
|
this.a.onError(baseAdapter2.a(i, baseAdapter2.a(i)).toJson());
|
||
|
}
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "activity is null");
|
||
|
try {
|
||
|
if (this.b.i != null && AvailableUtil.isInstallerLibExist(this.b.i)) {
|
||
|
HMSLog.i("BaseAdapter", "pass installHMS intent");
|
||
|
Intent intentStartBridgeActivity = BridgeActivity.getIntentStartBridgeActivity(this.b.i, UpdateAdapter.class.getName());
|
||
|
intentStartBridgeActivity.putExtra(CommonCode.MapKey.UPDATE_VERSION, ExceptionCode.CRASH_EXCEPTION);
|
||
|
intentStartBridgeActivity.putExtra("installHMS", "installHMS");
|
||
|
coreBaseResponse.setIntent(intentStartBridgeActivity);
|
||
|
this.b.a(baseCallBack, coreBaseResponse);
|
||
|
return;
|
||
|
}
|
||
|
HMSLog.i("BaseAdapter", "pass ACTIVITY_NULL error");
|
||
|
BaseAdapter baseAdapter = this.b;
|
||
|
baseCallBack.onError(baseAdapter.a(-3, baseAdapter.a(-3)).toJson());
|
||
|
return;
|
||
|
} catch (RuntimeException unused) {
|
||
|
HMSLog.e("BaseAdapter", "handleSolutionForHms pass result failed");
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
HMSLog.i("BaseAdapter", "handleSolutionForHms: no Available lib exist");
|
||
|
baseCallBack.onError(this.b.b(-9));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class a extends PendingResultImpl<ResolveResult<CoreBaseResponse>, CoreBaseResponse> {
|
||
|
public a(ApiClient apiClient, String str, IMessageEntity iMessageEntity) {
|
||
|
super(apiClient, str, iMessageEntity);
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.support.api.PendingResultImpl
|
||
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||
|
public ResolveResult<CoreBaseResponse> onComplete(CoreBaseResponse coreBaseResponse) {
|
||
|
ResolveResult<CoreBaseResponse> resolveResult = new ResolveResult<>(coreBaseResponse);
|
||
|
resolveResult.setStatus(Status.SUCCESS);
|
||
|
return resolveResult;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BaseAdapter(ApiClient apiClient) {
|
||
|
this.a = new WeakReference<>(apiClient);
|
||
|
if (apiClient == null) {
|
||
|
HMSLog.w("BaseAdapter", "BaseAdapter constructor client is null");
|
||
|
return;
|
||
|
}
|
||
|
this.i = apiClient.getContext().getApplicationContext();
|
||
|
StringBuilder sb = new StringBuilder("In constructor, WeakReference is ");
|
||
|
sb.append(this.a);
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
}
|
||
|
|
||
|
public void baseRequest(String str, String str2, Parcelable parcelable, BaseCallBack baseCallBack) {
|
||
|
a(str, str2, parcelable, baseCallBack);
|
||
|
if (this.a == null) {
|
||
|
HMSLog.e("BaseAdapter", "client is null");
|
||
|
baseCallBack.onError(b(-2));
|
||
|
return;
|
||
|
}
|
||
|
this.c = baseCallBack;
|
||
|
JsonUtil.jsonToEntity(str, this.j);
|
||
|
CoreBaseRequest coreBaseRequest = new CoreBaseRequest();
|
||
|
coreBaseRequest.setJsonObject(str2);
|
||
|
coreBaseRequest.setJsonHeader(str);
|
||
|
coreBaseRequest.setParcelable(parcelable);
|
||
|
String apiName = this.j.getApiName();
|
||
|
if (TextUtils.isEmpty(apiName)) {
|
||
|
HMSLog.e("BaseAdapter", "get uri null");
|
||
|
baseCallBack.onError(b(-5));
|
||
|
return;
|
||
|
}
|
||
|
String transactionId = this.j.getTransactionId();
|
||
|
this.h = transactionId;
|
||
|
if (TextUtils.isEmpty(transactionId)) {
|
||
|
HMSLog.e("BaseAdapter", "get transactionId null");
|
||
|
baseCallBack.onError(b(-6));
|
||
|
return;
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder("in baseRequest + uri is :");
|
||
|
sb.append(apiName);
|
||
|
sb.append(", transactionId is : ");
|
||
|
sb.append(this.h);
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
a(this.i, this.j);
|
||
|
a(this.a.get(), apiName, coreBaseRequest).setResultCallback(new BaseRequestResultCallback(this));
|
||
|
}
|
||
|
|
||
|
private void g() {
|
||
|
this.l = new SystemObserver(this) { // from class: com.huawei.hms.adapter.BaseAdapter.2
|
||
|
final BaseAdapter a;
|
||
|
|
||
|
{
|
||
|
this.a = this;
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
|
||
|
public boolean onNoticeResult(int i) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
|
||
|
public boolean onSolutionResult(Intent intent, String str) {
|
||
|
if (!TextUtils.isEmpty(str)) {
|
||
|
if (!str.equals(this.a.h)) {
|
||
|
return false;
|
||
|
}
|
||
|
HMSLog.i("BaseAdapter", "onSolutionResult + id is :".concat(String.valueOf(str)));
|
||
|
BaseCallBack b = this.a.b();
|
||
|
if (b == null) {
|
||
|
HMSLog.e("BaseAdapter", "onResult baseCallBack null");
|
||
|
return true;
|
||
|
}
|
||
|
if (intent != null) {
|
||
|
if (this.a.b(intent, b) || this.a.a(intent, b)) {
|
||
|
return true;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "onComplete for on activity result");
|
||
|
this.a.c(intent, b);
|
||
|
return true;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "onSolutionResult but data is null");
|
||
|
String b2 = this.a.b(-7);
|
||
|
BaseAdapter baseAdapter = this.a;
|
||
|
baseAdapter.a(baseAdapter.i, this.a.k, 0L);
|
||
|
b.onError(b2);
|
||
|
return true;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "onSolutionResult but id is null");
|
||
|
BaseCallBack b3 = this.a.b();
|
||
|
if (b3 != null) {
|
||
|
b3.onError(this.a.b(-6));
|
||
|
return true;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "onSolutionResult baseCallBack null");
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // com.huawei.hms.adapter.sysobs.SystemObserver
|
||
|
public boolean onUpdateResult(int i) {
|
||
|
return false;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void i() {
|
||
|
if (this.i == null) {
|
||
|
HMSLog.e("BaseAdapter", "sendBroadcastAfterResolutionHms, context is null");
|
||
|
return;
|
||
|
}
|
||
|
Intent intent = new Intent("com.huawei.hms.core.action.SESSION_INVALID");
|
||
|
try {
|
||
|
intent.setPackage(this.i.getPackageName());
|
||
|
this.i.sendBroadcast(intent);
|
||
|
} catch (IllegalArgumentException unused) {
|
||
|
HMSLog.e("BaseAdapter", "IllegalArgumentException when sendBroadcastAfterResolutionHms intent.setPackage");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public Activity c() {
|
||
|
if (this.b == null) {
|
||
|
StringBuilder sb = new StringBuilder("activityWeakReference is ");
|
||
|
sb.append(this.b);
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
return null;
|
||
|
}
|
||
|
ApiClient apiClient = this.a.get();
|
||
|
if (apiClient == null) {
|
||
|
HMSLog.i("BaseAdapter", "tmpApi is null");
|
||
|
return null;
|
||
|
}
|
||
|
StringBuilder sb2 = new StringBuilder("activityWeakReference has ");
|
||
|
sb2.append(this.b.get());
|
||
|
HMSLog.i("BaseAdapter", sb2.toString());
|
||
|
return Util.getActiveActivity(this.b.get(), apiClient.getContext());
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public BaseCallBack b() {
|
||
|
BaseCallBack baseCallBack = this.c;
|
||
|
if (baseCallBack != null) {
|
||
|
return baseCallBack;
|
||
|
}
|
||
|
HMSLog.e("BaseAdapter", "callback null");
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private void h() {
|
||
|
if (this.d == null || this.g == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.k = null;
|
||
|
this.k = new ResponseHeader();
|
||
|
baseRequest(d(), e(), f(), a());
|
||
|
}
|
||
|
|
||
|
private void b(Context context, RequestHeader requestHeader) {
|
||
|
Map<String, String> mapFromRequestHeader = HiAnalyticsUtil.getInstance().getMapFromRequestHeader(requestHeader);
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_DIRECTION, HiAnalyticsConstant.Direction.REQUEST);
|
||
|
mapFromRequestHeader.put("version", HiAnalyticsUtil.versionCodeToName(String.valueOf(requestHeader.getKitSdkVersion())));
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_PHONETYPE, Util.getSystemProperties("ro.logsystem.usertype", ""));
|
||
|
HiAnalyticsUtil.getInstance().onNewEvent(context, HiAnalyticsConstant.HMS_SDK_BASE_START_RESOLUTION, mapFromRequestHeader);
|
||
|
}
|
||
|
|
||
|
private PendingResult<ResolveResult<CoreBaseResponse>> a(ApiClient apiClient, String str, CoreBaseRequest coreBaseRequest) {
|
||
|
return new a(apiClient, str, coreBaseRequest);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void a(BaseCallBack baseCallBack, CoreBaseResponse coreBaseResponse) {
|
||
|
HMSLog.i("BaseAdapter", "baseCallBack.onComplete");
|
||
|
PendingIntent pendingIntent = coreBaseResponse.getPendingIntent();
|
||
|
if (pendingIntent != null) {
|
||
|
baseCallBack.onComplete(coreBaseResponse.getJsonHeader(), coreBaseResponse.getJsonBody(), pendingIntent);
|
||
|
return;
|
||
|
}
|
||
|
Intent modifyIntentBehaviorsSafe = IntentUtil.modifyIntentBehaviorsSafe(coreBaseResponse.getIntent());
|
||
|
if (modifyIntentBehaviorsSafe != null) {
|
||
|
baseCallBack.onComplete(coreBaseResponse.getJsonHeader(), coreBaseResponse.getJsonBody(), modifyIntentBehaviorsSafe);
|
||
|
} else {
|
||
|
baseCallBack.onComplete(coreBaseResponse.getJsonHeader(), coreBaseResponse.getJsonBody(), null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public String b(int i) {
|
||
|
c(i);
|
||
|
return this.k.toJson();
|
||
|
}
|
||
|
|
||
|
private void c(int i) {
|
||
|
this.k.setTransactionId(this.j.getTransactionId());
|
||
|
this.k.setAppID(this.j.getAppID());
|
||
|
this.k.setApiName(this.j.getApiName());
|
||
|
this.k.setSrvName(this.j.getSrvName());
|
||
|
this.k.setPkgName(this.j.getPkgName());
|
||
|
this.k.setStatusCode(1);
|
||
|
this.k.setErrorCode(i);
|
||
|
this.k.setErrorReason("Core error");
|
||
|
}
|
||
|
|
||
|
public BaseAdapter(ApiClient apiClient, Activity activity) {
|
||
|
this.a = new WeakReference<>(apiClient);
|
||
|
this.b = new WeakReference<>(activity);
|
||
|
if (activity == null) {
|
||
|
HMSLog.w("BaseAdapter", "BaseAdapter constructor activity is null");
|
||
|
return;
|
||
|
}
|
||
|
this.i = activity.getApplicationContext();
|
||
|
StringBuilder sb = new StringBuilder("In constructor, activityWeakReference is ");
|
||
|
sb.append(this.b);
|
||
|
sb.append(", activity is ");
|
||
|
sb.append(this.b.get());
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public boolean b(Intent intent, BaseCallBack baseCallBack) {
|
||
|
if (!intent.hasExtra(KpmsConstant.KIT_UPDATE_RESULT)) {
|
||
|
return false;
|
||
|
}
|
||
|
int intExtra = intent.getIntExtra(KpmsConstant.KIT_UPDATE_RESULT, 0);
|
||
|
HMSLog.i("BaseAdapter", "kit_update_result is ".concat(String.valueOf(intExtra)));
|
||
|
if (intExtra == 1) {
|
||
|
HMSLog.e("BaseAdapter", "kit update success,replay request");
|
||
|
h();
|
||
|
} else {
|
||
|
HMSLog.e("BaseAdapter", "kit update failed");
|
||
|
baseCallBack.onError(a(-10, a(intExtra)).toJson());
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void c(Intent intent, BaseCallBack baseCallBack) {
|
||
|
long j;
|
||
|
String stringExtra = intent.getStringExtra(CommonCode.MapKey.JSON_HEADER);
|
||
|
String stringExtra2 = intent.getStringExtra(CommonCode.MapKey.JSON_BODY);
|
||
|
Object infoFromJsonobject = JsonUtil.getInfoFromJsonobject(stringExtra, "status_code");
|
||
|
Object infoFromJsonobject2 = JsonUtil.getInfoFromJsonobject(stringExtra, "error_code");
|
||
|
if (intent.hasExtra(CommonCode.MapKey.HMS_FOREGROUND_RES_UI)) {
|
||
|
Object infoFromJsonobject3 = JsonUtil.getInfoFromJsonobject(intent.getStringExtra(CommonCode.MapKey.HMS_FOREGROUND_RES_UI), "uiDuration");
|
||
|
if (infoFromJsonobject3 instanceof Long) {
|
||
|
j = ((Long) infoFromJsonobject3).longValue();
|
||
|
if (!(infoFromJsonobject instanceof Integer) && (infoFromJsonobject2 instanceof Integer)) {
|
||
|
int intValue = ((Integer) infoFromJsonobject).intValue();
|
||
|
b(((Integer) infoFromJsonobject2).intValue());
|
||
|
this.k.setStatusCode(intValue);
|
||
|
a(this.i, this.k, j);
|
||
|
} else {
|
||
|
b(-8);
|
||
|
a(this.i, this.k, j);
|
||
|
}
|
||
|
baseCallBack.onComplete(stringExtra, stringExtra2, null);
|
||
|
}
|
||
|
}
|
||
|
j = 0;
|
||
|
if (!(infoFromJsonobject instanceof Integer)) {
|
||
|
}
|
||
|
b(-8);
|
||
|
a(this.i, this.k, j);
|
||
|
baseCallBack.onComplete(stringExtra, stringExtra2, null);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void a(Activity activity, Parcelable parcelable, CoreBaseResponse coreBaseResponse) {
|
||
|
HMSLog.i("BaseAdapter", "startResolution");
|
||
|
RequestHeader requestHeader = this.j;
|
||
|
if (requestHeader != null) {
|
||
|
b(this.i, requestHeader);
|
||
|
}
|
||
|
if (this.l == null) {
|
||
|
g();
|
||
|
}
|
||
|
SystemManager.getSystemNotifier().registerObserver(this.l);
|
||
|
if (Build.VERSION.SDK_INT >= 29) {
|
||
|
a(coreBaseResponse);
|
||
|
}
|
||
|
Intent intentStartBridgeActivity = BridgeActivity.getIntentStartBridgeActivity(activity, BaseResolutionAdapter.class.getName());
|
||
|
Bundle bundle = new Bundle();
|
||
|
bundle.putParcelable(CommonCode.MapKey.HAS_RESOLUTION, parcelable);
|
||
|
intentStartBridgeActivity.putExtras(bundle);
|
||
|
intentStartBridgeActivity.putExtra(CommonCode.MapKey.TRANSACTION_ID, this.h);
|
||
|
long time = new Timestamp(System.currentTimeMillis()).getTime();
|
||
|
intentStartBridgeActivity.putExtra(CommonCode.MapKey.RESOLUTION_FLAG, time);
|
||
|
ResolutionFlagUtil.getInstance().saveResolutionFlag(this.h, time);
|
||
|
activity.startActivity(intentStartBridgeActivity);
|
||
|
}
|
||
|
|
||
|
private void a(CoreBaseResponse coreBaseResponse) {
|
||
|
HMSLog.i("BaseAdapter", "postResolutionTimeoutHandle");
|
||
|
ApkResolutionFailedManager.getInstance().postTask(this.h, new Runnable(this, coreBaseResponse) { // from class: com.huawei.hms.adapter.BaseAdapter.1
|
||
|
final CoreBaseResponse a;
|
||
|
final BaseAdapter b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
this.a = coreBaseResponse;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public void run() {
|
||
|
HMSLog.i("BaseAdapter", "postResolutionTimeoutHandle handle");
|
||
|
SystemManager.getSystemNotifier().unRegisterObserver(this.b.l);
|
||
|
ApkResolutionFailedManager.getInstance().removeValueOnly(this.b.h);
|
||
|
BaseCallBack b = this.b.b();
|
||
|
if (b != null) {
|
||
|
this.b.a(b, this.a);
|
||
|
} else {
|
||
|
HMSLog.e("BaseAdapter", "timeoutRunnable callBack is null");
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
private void a(Context context, RequestHeader requestHeader) {
|
||
|
Map<String, String> mapFromRequestHeader = HiAnalyticsUtil.getInstance().getMapFromRequestHeader(requestHeader);
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_DIRECTION, HiAnalyticsConstant.Direction.REQUEST);
|
||
|
mapFromRequestHeader.put("version", HiAnalyticsUtil.versionCodeToName(String.valueOf(requestHeader.getKitSdkVersion())));
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_PHONETYPE, Util.getSystemProperties("ro.logsystem.usertype", ""));
|
||
|
HiAnalyticsUtil.getInstance().onNewEvent(context, HiAnalyticsConstant.HMS_SDK_BASE_CALL_AIDL, mapFromRequestHeader);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void a(Context context, ResponseHeader responseHeader) {
|
||
|
HiAnalyticsUtil.getInstance();
|
||
|
Map<String, String> mapFromRequestHeader = HiAnalyticsUtil.getMapFromRequestHeader(responseHeader);
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_DIRECTION, HiAnalyticsConstant.Direction.RESPONSE);
|
||
|
mapFromRequestHeader.put("version", HiAnalyticsUtil.versionCodeToName(String.valueOf(this.j.getKitSdkVersion())));
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_PHONETYPE, Util.getSystemProperties("ro.logsystem.usertype", ""));
|
||
|
HiAnalyticsUtil.getInstance().onNewEvent(context, HiAnalyticsConstant.HMS_SDK_BASE_CALL_AIDL, mapFromRequestHeader);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void a(Context context, ResponseHeader responseHeader, long j) {
|
||
|
HiAnalyticsUtil.getInstance();
|
||
|
Map<String, String> mapFromRequestHeader = HiAnalyticsUtil.getMapFromRequestHeader(responseHeader);
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_DIRECTION, HiAnalyticsConstant.Direction.RESPONSE);
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_WAITTIME, String.valueOf(j));
|
||
|
mapFromRequestHeader.put("version", HiAnalyticsUtil.versionCodeToName(String.valueOf(this.j.getKitSdkVersion())));
|
||
|
mapFromRequestHeader.put(HiAnalyticsConstant.HaKey.BI_KEY_PHONETYPE, Util.getSystemProperties("ro.logsystem.usertype", ""));
|
||
|
HiAnalyticsUtil.getInstance().onNewEvent(context, HiAnalyticsConstant.HMS_SDK_BASE_START_RESOLUTION, mapFromRequestHeader);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public ResponseWrap a(int i, String str) {
|
||
|
c(i);
|
||
|
ResponseWrap responseWrap = new ResponseWrap(this.k);
|
||
|
responseWrap.setBody(str);
|
||
|
return responseWrap;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public String a(int i) {
|
||
|
JSONObject jSONObject = new JSONObject();
|
||
|
try {
|
||
|
jSONObject.put("errorCode", i);
|
||
|
} catch (JSONException e) {
|
||
|
StringBuilder sb = new StringBuilder("buildBodyStr failed: ");
|
||
|
sb.append(e.getMessage());
|
||
|
HMSLog.e("BaseAdapter", sb.toString());
|
||
|
}
|
||
|
return jSONObject.toString();
|
||
|
}
|
||
|
|
||
|
private void a(String str, String str2, Parcelable parcelable, BaseCallBack baseCallBack) {
|
||
|
a(str);
|
||
|
b(str2);
|
||
|
a(parcelable);
|
||
|
a(baseCallBack);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public boolean a(Intent intent, BaseCallBack baseCallBack) {
|
||
|
if (!intent.hasExtra(CommonCode.MapKey.PRIVACY_STATEMENT_CONFIRM_RESULT)) {
|
||
|
return false;
|
||
|
}
|
||
|
int intExtra = intent.getIntExtra(CommonCode.MapKey.PRIVACY_STATEMENT_CONFIRM_RESULT, 1001);
|
||
|
if (intExtra == 1001) {
|
||
|
StringBuilder sb = new StringBuilder("privacy_statement_confirm_result agreed: ");
|
||
|
sb.append(intExtra);
|
||
|
sb.append(", replay request");
|
||
|
HMSLog.i("BaseAdapter", sb.toString());
|
||
|
h();
|
||
|
return true;
|
||
|
}
|
||
|
HMSLog.i("BaseAdapter", "privacy_statement_confirm_result rejected: ".concat(String.valueOf(intExtra)));
|
||
|
baseCallBack.onError(a(CommonCode.BusInterceptor.PRIVACY_CNCEL_ERROR_CODE, a(CommonCode.BusInterceptor.PRIVACY_CNCEL_ERROR_CODE)).toJson());
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private Parcelable f() {
|
||
|
return this.f;
|
||
|
}
|
||
|
|
||
|
private String e() {
|
||
|
return this.e;
|
||
|
}
|
||
|
|
||
|
private String d() {
|
||
|
return this.d;
|
||
|
}
|
||
|
|
||
|
private void b(String str) {
|
||
|
this.e = str;
|
||
|
}
|
||
|
|
||
|
private void a(String str) {
|
||
|
this.d = str;
|
||
|
}
|
||
|
|
||
|
private void a(BaseCallBack baseCallBack) {
|
||
|
this.g = baseCallBack;
|
||
|
}
|
||
|
|
||
|
private void a(Parcelable parcelable) {
|
||
|
this.f = parcelable;
|
||
|
}
|
||
|
|
||
|
private BaseCallBack a() {
|
||
|
return this.g;
|
||
|
}
|
||
|
}
|