package com.huawei.hms.common.api; import com.huawei.hms.api.Api; import com.huawei.hms.api.ConnectionResult; import com.huawei.hms.api.HuaweiApiAvailability; import com.huawei.hms.common.HuaweiApi; import com.huawei.hms.support.log.HMSLog; /* loaded from: classes2.dex */ public class AvailabilityException extends Exception { private static final String TAG = "AvailabilityException"; private String message = null; private ConnectionResult generateConnectionResult(int i) { HMSLog.i(TAG, "The availability check result is: ".concat(String.valueOf(i))); setMessage(i); return new ConnectionResult(i); } public ConnectionResult getConnectionResult(HuaweiApiCallable huaweiApiCallable) { if (huaweiApiCallable != null && huaweiApiCallable.getHuaweiApi() != null) { return generateConnectionResult(HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(huaweiApiCallable.getHuaweiApi().getContext(), 30000000)); } HMSLog.e(TAG, "The huaweiApi is null."); return generateConnectionResult(8); } public ConnectionResult getConnectionResult(HuaweiApi huaweiApi) { if (huaweiApi == null) { HMSLog.e(TAG, "The huaweiApi is null."); return generateConnectionResult(8); } return generateConnectionResult(HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(huaweiApi.getContext(), 30000000)); } @Override // java.lang.Throwable public String getMessage() { return this.message; } private void setMessage(int i) { String str; if (i == 21) { str = "ANDROID_VERSION_UNSUPPORT"; } else if (i == 0) { str = "success"; } else if (i == 1) { str = "SERVICE_MISSING"; } else if (i != 2) { str = i != 3 ? "INTERNAL_ERROR" : "SERVICE_DISABLED"; } else { str = "SERVICE_VERSION_UPDATE_REQUIRED"; } this.message = str; } }