package com.huawei.hms.support.hianalytics; import android.content.Context; import android.text.TextUtils; import com.huawei.hms.android.SystemUtils; import com.huawei.hms.common.internal.RequestHeader; import com.huawei.hms.common.internal.ResponseHeader; import com.huawei.hms.common.internal.TransactionIdCreater; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import com.huawei.hms.support.log.HMSLog; import com.huawei.hms.utils.Util; import java.util.HashMap; import java.util.Map; /* loaded from: classes2.dex */ public class HiAnalyticsUtil { private static final Object a = new Object(); private static HiAnalyticsUtil b; private static HiAnalyticsUtils c; private String a(Context context, String str) { String packageName = context.getPackageName(); StringBuilder sb = new StringBuilder("01||"); sb.append(packageName); sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR); sb.append(Util.getAppId(context)); sb.append("|61100302|"); sb.append(str); return sb.toString(); } public static HiAnalyticsUtil getInstance() { HiAnalyticsUtil hiAnalyticsUtil; synchronized (a) { if (b == null) { b = new HiAnalyticsUtil(); c = HiAnalyticsUtils.getInstance(); } hiAnalyticsUtil = b; } return hiAnalyticsUtil; } public static Map getMapFromForegroundResponseHeader(ResponseHeader responseHeader) { HashMap hashMap = new HashMap(); if (responseHeader == null) { return hashMap; } hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_TRANSID, responseHeader.getTransactionId()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, responseHeader.getActualAppID()); hashMap.put("service", responseHeader.getSrvName()); hashMap.put("apiName", responseHeader.getApiName()); hashMap.put("package", responseHeader.getPkgName()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_RESULT, String.valueOf(responseHeader.getStatusCode())); hashMap.put("result", String.valueOf(responseHeader.getErrorCode())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_ERRORREASON, responseHeader.getErrorReason()); hashMap.put("callTime", String.valueOf(System.currentTimeMillis())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_BASE_VERSION, "6.11.0.302"); return hashMap; } public static Map getMapFromRequestHeader(ResponseHeader responseHeader) { HashMap hashMap = new HashMap(); if (responseHeader == null) { return hashMap; } hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_TRANSID, responseHeader.getTransactionId()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, responseHeader.getActualAppID()); hashMap.put("service", responseHeader.getSrvName()); String apiName = responseHeader.getApiName(); if (!TextUtils.isEmpty(apiName)) { String[] split = apiName.split("\\."); if (split.length >= 2) { hashMap.put("apiName", split[1]); } } hashMap.put("package", responseHeader.getPkgName()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_RESULT, String.valueOf(responseHeader.getStatusCode())); hashMap.put("result", String.valueOf(responseHeader.getErrorCode())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_ERRORREASON, responseHeader.getErrorReason()); hashMap.put("callTime", String.valueOf(System.currentTimeMillis())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_BASE_VERSION, "6.11.0.302"); return hashMap; } public static String versionCodeToName(String str) { return HiAnalyticsUtils.versionCodeToName(str); } @Deprecated public Map getMapForBi(Context context, String str) { HashMap hashMap = new HashMap(); String[] split = str.split("\\."); if (split.length >= 2) { String str2 = split[0]; String str3 = split[1]; String appId = Util.getAppId(context); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_TRANSID, TransactionIdCreater.getId(appId, str)); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, appId); hashMap.put("service", str2); hashMap.put("apiName", str3); if (context != null) { hashMap.put("package", context.getPackageName()); } hashMap.put("version", "6.11.0.302"); hashMap.put("callTime", String.valueOf(System.currentTimeMillis())); } return hashMap; } public Map getMapFromForegroundRequestHeader(RequestHeader requestHeader) { HashMap hashMap = new HashMap(); if (requestHeader == null) { return hashMap; } hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_TRANSID, requestHeader.getTransactionId()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, requestHeader.getActualAppID()); hashMap.put("service", requestHeader.getSrvName()); hashMap.put("apiName", requestHeader.getApiName()); hashMap.put("package", requestHeader.getPkgName()); hashMap.put("callTime", String.valueOf(System.currentTimeMillis())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_BASE_VERSION, "6.11.0.302"); return hashMap; } @Deprecated public boolean hasError() { if (SystemUtils.isChinaROM()) { return false; } HMSLog.i("HiAnalyticsUtil", "not ChinaROM "); return true; } public void onBuoyEvent(Context context, String str, String str2) { c.onBuoyEvent(context, str, str2); } public void onEvent(Context context, String str, Map map) { c.onEvent(context, str, map); } public void onEvent2(Context context, String str, String str2) { c.onEvent2(context, str, str2); } public void onNewEvent(Context context, String str, Map map) { c.onNewEvent(context, str, map); } public void onEvent(Context context, String str, String str2) { if (context != null) { onEvent2(context, str, a(context, str2)); } } public boolean hasError(Context context) { return c.hasError(context); } public Map getMapFromRequestHeader(RequestHeader requestHeader) { HashMap hashMap = new HashMap(); if (requestHeader == null) { return hashMap; } hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_TRANSID, requestHeader.getTransactionId()); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_APPID, requestHeader.getActualAppID()); hashMap.put("service", requestHeader.getSrvName()); String apiName = requestHeader.getApiName(); if (!TextUtils.isEmpty(apiName)) { String[] split = apiName.split("\\."); if (split.length >= 2) { hashMap.put("apiName", split[1]); } } hashMap.put("package", requestHeader.getPkgName()); hashMap.put("callTime", String.valueOf(System.currentTimeMillis())); hashMap.put(HiAnalyticsConstant.HaKey.BI_KEY_BASE_VERSION, "6.11.0.302"); return hashMap; } }