package com.bytedance.router.net;

import X.0HH;
import X.AnonymousClass9EH;
import X.C30738n2;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.dynamic.RouterConfig;
import com.bytedance.router.dynamic.ServerParam;
import java.util.HashMap;
import java.util.Map;

public class SmartRouterApi {
    public static Map<String, String> sCommonParams;

    public static class ApiResult<T> {
        public int errorCode = -1;
        public T result;

        static {
            Covode.recordClassIndex(37245);
        }
    }

    static {
        Covode.recordClassIndex(37244);
    }

    public static boolean reportRouterConfig(Context context, ServerParam serverParam, RouterConfig routerConfig) {
        return false;
    }

    public static Map<String, String> getCommonParams(Context context) {
        Map<String, String> map = sCommonParams;
        if (map != null) {
            return map;
        }
        sCommonParams = new HashMap();
        try {
            sCommonParams.put("version_code", String.valueOf(INVOKEVIRTUAL_com_bytedance_router_net_SmartRouterApi_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getPackageInfo(context.getPackageManager(), context.getPackageName(), 128).versionCode));
            Bundle bundle = INVOKEVIRTUAL_com_bytedance_router_net_SmartRouterApi_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getApplicationInfo(context.getPackageManager(), context.getPackageName(), 128).metaData;
            if (bundle != null) {
                sCommonParams.put("update_version_code", String.valueOf(bundle.getInt("UPDATE_VERSION_CODE")));
            }
            sCommonParams.put("device_platform", "android");
            sCommonParams.put("os_api", String.valueOf(Build.VERSION.SDK_INT));
        } catch (Exception e) {
            sCommonParams = null;
            0HH.LIZ(e);
        }
        return sCommonParams;
    }

    public static String getRouterConfigTag(Context context) {
        Map<String, String> commonParams = getCommonParams(context);
        String str = "";
        if (commonParams == null) {
            return str;
        }
        String str2 = sCommonParams.get("version_code");
        String str3 = sCommonParams.get("update_version_code");
        if (!TextUtils.isEmpty(str2)) {
            str = str + str2;
        }
        if (TextUtils.isEmpty(str3)) {
            return str;
        }
        return str + "_" + str2;
    }

    public static ApiResult<RouterConfig> requestConfig(Context context, ServerParam serverParam) {
        return new ApiResult<>();
    }

    public static ApplicationInfo INVOKEVIRTUAL_com_bytedance_router_net_SmartRouterApi_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getApplicationInfo(PackageManager packageManager, String str, int i) {
        Context LIZ = AnonymousClass9EH.LJJIFFI.LIZ();
        if (C30738n2.LJIIIZ && TextUtils.equals(str, LIZ.getPackageName()) && i == 128) {
            if (C30738n2.LIZ == null) {
                C30738n2.LIZ = packageManager.getApplicationInfo(str, i);
            }
            return C30738n2.LIZ;
        } else if (!C30738n2.LJIIIZ || !TextUtils.equals(str, LIZ.getPackageName()) || i != 0) {
            return packageManager.getApplicationInfo(str, i);
        } else {
            if (C30738n2.LIZJ == null) {
                C30738n2.LIZJ = packageManager.getApplicationInfo(str, i);
            }
            return C30738n2.LIZJ;
        }
    }

    public static PackageInfo INVOKEVIRTUAL_com_bytedance_router_net_SmartRouterApi_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getPackageInfo(PackageManager packageManager, String str, int i) {
        Context LIZ = AnonymousClass9EH.LJJIFFI.LIZ();
        if (C30738n2.LJIIIZ && TextUtils.equals(str, LIZ.getPackageName()) && i == 128) {
            if (C30738n2.LIZIZ == null) {
                C30738n2.LIZIZ = packageManager.getPackageInfo(str, i);
            }
            return C30738n2.LIZIZ;
        } else if (C30738n2.LJIIIZ && TextUtils.equals(str, LIZ.getPackageName()) && i == 0) {
            if (C30738n2.LIZLLL == null) {
                C30738n2.LIZLLL = packageManager.getPackageInfo(str, i);
            }
            return C30738n2.LIZLLL;
        } else if (C30738n2.LJIIIZ && TextUtils.equals(str, LIZ.getPackageName()) && i == 64) {
            if (C30738n2.LJ == null) {
                C30738n2.LJ = packageManager.getPackageInfo(str, i);
            }
            return C30738n2.LJ;
        } else if (!C30738n2.LJIIIZ || !TextUtils.equals(str, LIZ.getPackageName()) || i != 8) {
            return packageManager.getPackageInfo(str, i);
        } else {
            if (C30738n2.LJFF == null) {
                C30738n2.LJFF = packageManager.getPackageInfo(str, i);
            }
            return C30738n2.LJFF;
        }
    }
}
