智慧城市 v1.2.1版本的 MD5 值为:d4aeacb5153a2710d0b6882be5dd2b15

以下内容为反编译后的 NavigationCacheHelper.java 源代码,内容仅作参考


package io.rong.imlib.navigation;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import io.rong.common.RLog;
import io.rong.common.fwlog.FwLog;
import io.rong.imlib.CMPStrategy;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.common.SharedPreferencesUtils;
import io.rong.imlib.filetransfer.FtConst;
import io.rong.imlib.filetransfer.upload.FilePlatformInfo;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class NavigationCacheHelper {
    private static final String ALGORITHM = "alg";
    private static final String APP_KEY = "appKey";
    private static final String BACKUP_SERVER = "bs";
    private static final String BAI_DU_MEDIA_SERVER = "bosAddr";
    private static final String CACHED_TIME = "cached_time";
    private static final String CLIENT_IP = "clientIp";
    private static final String CMP_SERVER = "server";
    private static final String CODE = "code";
    private static final String COMPLEX_CONNECTION = "complexConnection";
    private static final String CONN_POLICY = "connPolicy";
    private static final String CRYPTO = "crypto";
    private static final int DEFAULT_GIF_SIZE = 2048;
    private static final String DEFAULT_MEDIA_SERVER_HOST_BAIDU = "gz.bcebos.com";
    private static final String DEFAULT_VIDEO_TIME = "300";
    private static final String EXCLUDE_LOG_TAG = "excludeLogTag";
    private static final String EXT_KIT_SWITCH = "extkitSwitch";
    private static final String GET_CHATROOM_HISTORY_SERVICE = "chatroomMsg";
    private static final String GET_GROUP_MESSAGE_LIMIT = "grpMsgLimit";
    private static final String GET_REMOTE_SERVICE = "historyMsg";
    private static final String GIF_SIZE = "gifSize";
    private static final String GROUP_READ_RECEIPT_VERSION = "grpRRVer";
    private static final String JOIN_MULTI_CHATROOM = "joinMChrm";
    private static final String KEY_E = "e";
    private static final String KEY_N = "n";
    private static final String KV_STORAGE = "kvStorage";
    private static final String LAST_SUCCESS_NAVI = "lastSuccessNavi";
    private static final String LOCATION_CONFIG = "location";
    private static final String LOG_MONITOR = "monitor";
    private static final String MEDIA_SERVER = "uploadServer";
    private static final String MEDIA_SERVER_CONFIG = "ossConfig";
    private static final String NAVIGATION_IP_PREFERENCE = "RongNavigationIp";
    private static final String NAVIGATION_PREFERENCE = "RongNavigation";
    private static final String OFFLINE_LOG_SERVER = "offlinelogserver";
    private static final String ONLINE_LOG_SERVER = "onlinelogserver";
    private static final String OPEN_ANTI = "openAnti";
    private static final String OPEN_DNS = "openHttpDNS";
    private static final String OPEN_MP = "openMp";
    private static final String OPEN_TLS = "openTLS";
    private static final String OPEN_US = "openUS";
    private static final String PRIME_G = "g";
    private static final String PRIME_P = "p";
    private static final String RANDOM_R = "r";
    private static final String REPAIR_MSG = "repairHisMsg";
    private static final String SITE = "site";
    private static final String TAG = "NavigationCacheHelper";
    private static final long TIME_OUT = 7200000;
    private static final String TIMING_UPLOAD_LOG_CONFIG = "logPolicy";
    private static final String TIMING_UPLOAD_LOG_SWITCH = "logSwitch";
    private static final String TOKEN = "token";
    private static final String TYPE = "type";
    private static final int USERID_MAX_LENGTH = 64;
    private static final String USER_ID = "userId";
    private static final String VIDEO_TIMES = "videoTimes";
    private static final String VOIP_CALL_INFO = "voipCallInfo";
    private static Object lock = new Object();
    private static long sCacheTime = 0;
    private static boolean userPolicy = false;

    public static boolean isCacheValid(Context context, String str, String str2, String str3) {
        if (getConnectionCmpList(context).size() == 0) {
            return false;
        }
        SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
        String string = sharedPreferences.getString("appKey", null);
        String string2 = sharedPreferences.getString("token", null);
        String string3 = sharedPreferences.getString("userId", null);
        String lastSuccessNaviDomainList = getLastSuccessNaviDomainList(context);
        sCacheTime = sharedPreferences.getLong(CACHED_TIME, 0L);
        long currentTimeMillis = System.currentTimeMillis() - TimeZone.getDefault().getRawOffset();
        boolean z = string != null && string.equals(str) && string2 != null && string2.equals(str2) && currentTimeMillis - sCacheTime <= TIME_OUT && !TextUtils.isEmpty(string3) && isNaviUrlsValid(lastSuccessNaviDomainList, str3);
        FwLog.write(3, 1, FwLog.LogTag.L_GET_NAVI_S.getTag(), "cache_valid|delta_time", Boolean.valueOf(z), Long.valueOf(currentTimeMillis - sCacheTime));
        return z;
    }

    private static boolean isNaviUrlsValid(String str, String str2) {
        if (TextUtils.isEmpty(str2) || TextUtils.isEmpty(str)) {
            return false;
        }
        return str2.equals(str);
    }

    public static boolean isUSOpened(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(OPEN_US, false);
    }

    public static boolean isMPOpened(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(OPEN_MP, true);
    }

    public static boolean isCacheTimeout(Context context) {
        long j = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getLong(CACHED_TIME, 0L);
        return j != 0 && (System.currentTimeMillis() - ((long) TimeZone.getDefault().getRawOffset())) - j > TIME_OUT;
    }

    public static long getCachedTime() {
        return sCacheTime;
    }

    public static void clearCache(Context context) {
        SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit().clear().commit();
    }

    public static void clearNaviCache(Context context) {
        SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0).edit().clear().commit();
    }

    public static List<String> getConnectionCmpList(Context context) {
        String[] split;
        SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
        String string = sharedPreferences.getString(CMP_SERVER, null);
        String string2 = sharedPreferences.getString(BACKUP_SERVER, null);
        ArrayList arrayList = new ArrayList();
        if (!TextUtils.isEmpty(string)) {
            arrayList.add(string);
        }
        if (!TextUtils.isEmpty(string2)) {
            for (String str : string2.split(",")) {
                if (!TextUtils.isEmpty(str)) {
                    arrayList.add(str);
                }
            }
        }
        return arrayList;
    }

    public static void clearComplexConnectionEntries(Context context) {
        SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit().remove(COMPLEX_CONNECTION).commit();
    }

    public static String getToken(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString("token", "");
    }

    public static String getAppKey(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString("appKey", "");
    }

    public static void updateTime(Context context, long j) {
        SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
        edit.putLong(CACHED_TIME, j);
        edit.commit();
    }

    public static void cacheLastSuccessNaviDomainList(Context context, String str) {
        SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0).edit();
        edit.putString(LAST_SUCCESS_NAVI, str);
        edit.commit();
    }

    private static String getLastSuccessNaviDomainList(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0).getString(LAST_SUCCESS_NAVI, null);
    }

    public static String getVoIPCallInfo(Context context) {
        String string;
        synchronized (lock) {
            string = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(VOIP_CALL_INFO, null);
        }
        return string;
    }

    public static void updateVoIPCallInfo(Context context, String str) {
        synchronized (lock) {
            SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
            edit.putString(VOIP_CALL_INFO, str);
            edit.commit();
        }
    }

    public static String getMediaServer(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(MEDIA_SERVER, null);
    }

    static String getBaiDuMediaServer(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(BAI_DU_MEDIA_SERVER, DEFAULT_MEDIA_SERVER_HOST_BAIDU);
    }

    public static boolean isGetRemoteEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(GET_REMOTE_SERVICE, false);
    }

    public static int getGroupMessageLimit(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(GET_GROUP_MESSAGE_LIMIT, 1000);
    }

    @Deprecated
    public static String getOfflineLogServer(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(OFFLINE_LOG_SERVER, "https://feedback.cn.ronghub.com");
    }

    @Deprecated
    public static String getOnlineLogServer(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(ONLINE_LOG_SERVER, null);
    }

    public static boolean isChatroomHistoryEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(GET_CHATROOM_HISTORY_SERVICE, false);
    }

    public static boolean isJoinMChatroomEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(JOIN_MULTI_CHATROOM, false);
    }

    public static boolean isPhraseEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(EXT_KIT_SWITCH, false);
    }

    public static boolean isDnsEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(OPEN_DNS, false);
    }

    public static boolean isRepairMsgEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(REPAIR_MSG, false);
    }

    public static LocationConfig getLocationConfig(Context context) {
        String string = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(LOCATION_CONFIG, null);
        if (!TextUtils.isEmpty(string)) {
            try {
                LocationConfig locationConfig = new LocationConfig();
                JSONObject jSONObject = new JSONObject(string);
                locationConfig.setConfigure(jSONObject.optBoolean("configure"));
                if (jSONObject.has("conversationTypes")) {
                    JSONArray optJSONArray = jSONObject.optJSONArray("conversationTypes");
                    int[] iArr = new int[optJSONArray.length()];
                    for (int i = 0; i < optJSONArray.length(); i++) {
                        iArr[i] = optJSONArray.optInt(i);
                    }
                    locationConfig.setConversationTypes(iArr);
                }
                locationConfig.setMaxParticipant(jSONObject.optInt("maxParticipant"));
                locationConfig.setDistanceFilter(jSONObject.optInt("distanceFilter"));
                locationConfig.setRefreshInterval(jSONObject.optInt("refreshInterval"));
                return locationConfig;
            } catch (JSONException e) {
                RLog.e(TAG, "getLocationConfig ", e);
            }
        }
        return null;
    }

    public static int getLogMonitor(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(LOG_MONITOR, 0);
    }

    public static String getUserId(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString("userId", null);
    }

    public static void saveUserId(Context context, String str) {
        SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
        edit.putString("userId", str);
        edit.apply();
    }

    public static void clearUserId(Context context) {
        SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit().remove("userId").commit();
    }

    public static boolean isKvStorageEnabled(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(KV_STORAGE, false);
    }

    public static String getExcludeLogTag(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(EXCLUDE_LOG_TAG, "");
    }

    public static String getRealTimeLogConfig(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(TIMING_UPLOAD_LOG_CONFIG, null);
    }

    public static void cacheRequest(Context context, String str, String str2) {
        SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
        edit.putLong(CACHED_TIME, System.currentTimeMillis() - TimeZone.getDefault().getRawOffset());
        edit.putString("appKey", str);
        edit.putString("token", str2);
        edit.commit();
    }

    public static int decode2File(Context context, String str, int i) {
        if (TextUtils.isEmpty(str)) {
            RLog.e(TAG, "[connect] decode2File: navi data is empty.");
            return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!jSONObject.has("code")) {
                return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
            }
            int optInt = jSONObject.optInt("code");
            if (optInt != 200) {
                RLog.e(TAG, "[connect] decode2File: code & httpCode " + optInt + "-" + i);
                if ((optInt == 401 && i == 403) || (optInt == 403 && i == 401)) {
                    return IRongCoreEnum.CoreErrorCode.RC_CONN_USER_OR_PASSWD_ERROR.getValue();
                }
                return IRongCoreEnum.CoreErrorCode.RC_NAVI_RESOURCE_ERROR.getValue();
            }
            SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
            String optString = jSONObject.optString("userId");
            if (!TextUtils.isEmpty(optString) && optString.getBytes().length <= 64) {
                edit.putString("userId", optString);
                String optString2 = jSONObject.optString(CMP_SERVER);
                String optString3 = jSONObject.optString(BACKUP_SERVER);
                if (TextUtils.isEmpty(optString2) && TextUtils.isEmpty(optString3)) {
                    RLog.e(TAG, "[connect] decode2File: cmp is invalid, " + str);
                    return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
                }
                edit.putString(CMP_SERVER, optString2);
                edit.putString(BACKUP_SERVER, optString3);
                edit.putString(MEDIA_SERVER, jSONObject.optString(MEDIA_SERVER));
                edit.putString(MEDIA_SERVER_CONFIG, jSONObject.optString(MEDIA_SERVER_CONFIG));
                edit.putString(LOCATION_CONFIG, jSONObject.optString(LOCATION_CONFIG));
                edit.putString(VOIP_CALL_INFO, jSONObject.optString(VOIP_CALL_INFO));
                edit.putBoolean(GET_REMOTE_SERVICE, jSONObject.optBoolean(GET_REMOTE_SERVICE));
                edit.putBoolean(GET_CHATROOM_HISTORY_SERVICE, jSONObject.optBoolean(GET_CHATROOM_HISTORY_SERVICE));
                if (jSONObject.has(GET_GROUP_MESSAGE_LIMIT)) {
                    edit.putInt(GET_GROUP_MESSAGE_LIMIT, jSONObject.optInt(GET_GROUP_MESSAGE_LIMIT));
                }
                edit.putBoolean(JOIN_MULTI_CHATROOM, jSONObject.optBoolean(JOIN_MULTI_CHATROOM));
                boolean z = true;
                edit.putBoolean(OPEN_MP, jSONObject.optInt(OPEN_MP) == 1);
                edit.putBoolean(OPEN_US, jSONObject.optInt(OPEN_US) == 1);
                if (jSONObject.has(LOG_MONITOR)) {
                    edit.putInt(LOG_MONITOR, jSONObject.optInt(LOG_MONITOR));
                }
                edit.putBoolean(TYPE, jSONObject.optInt(TYPE) == 1);
                if (jSONObject.has(CONN_POLICY)) {
                    edit.putInt(CONN_POLICY, jSONObject.optInt(CONN_POLICY));
                }
                if (jSONObject.has(VIDEO_TIMES)) {
                    edit.putInt(VIDEO_TIMES, jSONObject.optInt(VIDEO_TIMES));
                }
                edit.putString(OFFLINE_LOG_SERVER, jSONObject.optString(OFFLINE_LOG_SERVER));
                edit.putString(ONLINE_LOG_SERVER, jSONObject.optString(ONLINE_LOG_SERVER));
                edit.putBoolean(EXT_KIT_SWITCH, jSONObject.optInt(EXT_KIT_SWITCH) == 1);
                edit.putBoolean(KV_STORAGE, jSONObject.optInt(KV_STORAGE) == 1);
                if (jSONObject.has(GIF_SIZE)) {
                    edit.putInt(GIF_SIZE, jSONObject.optInt(GIF_SIZE));
                }
                edit.putBoolean(OPEN_DNS, jSONObject.optInt(OPEN_DNS) == 1);
                if (jSONObject.has(BAI_DU_MEDIA_SERVER)) {
                    edit.putString(BAI_DU_MEDIA_SERVER, jSONObject.optString(BAI_DU_MEDIA_SERVER));
                }
                if (jSONObject.optInt(TIMING_UPLOAD_LOG_SWITCH) == 1) {
                    String optString4 = jSONObject.optString(TIMING_UPLOAD_LOG_CONFIG);
                    if (!TextUtils.isEmpty(optString4)) {
                        edit.putString(TIMING_UPLOAD_LOG_CONFIG, optString4.replaceAll("&quot;", "\""));
                    } else {
                        edit.putString(TIMING_UPLOAD_LOG_CONFIG, "");
                    }
                } else {
                    edit.putString(TIMING_UPLOAD_LOG_CONFIG, "");
                }
                if (jSONObject.has(EXCLUDE_LOG_TAG)) {
                    edit.putString(EXCLUDE_LOG_TAG, jSONObject.optString(EXCLUDE_LOG_TAG));
                }
                if (jSONObject.has(CRYPTO)) {
                    String optString5 = jSONObject.isNull(CRYPTO) ? null : jSONObject.optString(CRYPTO);
                    if (!TextUtils.isEmpty(optString5)) {
                        JSONObject jSONObject2 = new JSONObject(optString5);
                        edit.putString(PRIME_P, jSONObject2.optString(PRIME_P));
                        edit.putString(PRIME_G, jSONObject2.optString(PRIME_G));
                        edit.putString(KEY_N, jSONObject2.optString(KEY_N));
                        edit.putString(KEY_E, jSONObject2.optString(KEY_E));
                        edit.putString(SITE, jSONObject2.optString(SITE));
                        edit.putLong(RANDOM_R, jSONObject2.optLong(RANDOM_R));
                        edit.putInt(ALGORITHM, jSONObject2.optInt(ALGORITHM));
                    }
                }
                if (jSONObject.has(REPAIR_MSG)) {
                    edit.putBoolean(REPAIR_MSG, jSONObject.optInt(REPAIR_MSG) == 1);
                }
                edit.putInt(GROUP_READ_RECEIPT_VERSION, jSONObject.optInt(GROUP_READ_RECEIPT_VERSION));
                if (jSONObject.has(OPEN_TLS)) {
                    edit.putBoolean(OPEN_TLS, jSONObject.optInt(OPEN_TLS) == 1);
                }
                if (jSONObject.has(OPEN_ANTI)) {
                    if (jSONObject.optInt(OPEN_ANTI) != 1) {
                        z = false;
                    }
                    edit.putBoolean(OPEN_ANTI, z);
                }
                edit.commit();
                return 0;
            }
            RLog.e(TAG, "[connect] decode2File: no user_id." + str);
            return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
        } catch (JSONException unused) {
            return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
        }
    }

    public static int getVideoLimitTime(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(VIDEO_TIMES, Integer.valueOf(DEFAULT_VIDEO_TIME).intValue());
    }

    public static boolean isCMPValid(String str) {
        return CMPStrategy.getInstance().isCMPValid(str);
    }

    public static boolean getPrivateCloudConfig(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(TYPE, false);
    }

    public static boolean isConnPolicyEnable(Context context) {
        boolean z = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(CONN_POLICY, 0) == 1;
        RLog.i(TAG, "isConnPolicyEnable, userPolicy = " + userPolicy + ", naviPolicy = " + z);
        if (z) {
            return true;
        }
        return userPolicy;
    }

    public static void setUserPolicy(boolean z) {
        RLog.i(TAG, "setUserPolicy, userPolicy = " + z);
        userPolicy = z;
    }

    private static String decode(String str, String str2, String str3) {
        int indexOf;
        int indexOf2;
        if (str == null || (indexOf = str.indexOf(str2) + str2.length()) >= (indexOf2 = str.indexOf(str3)) || indexOf2 == 0) {
            return null;
        }
        return str.substring(indexOf, indexOf2);
    }

    public static String queryRequestIP(String str) {
        DNSResolve dNSResolve = new DNSResolve(str);
        dNSResolve.resolveHost();
        return dNSResolve.getIP();
    }

    public static int getGifSizeLimit(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(GIF_SIZE, 2048);
    }

    public static void updateClientIp(Context context, String str) {
        SharedPreferences.Editor edit = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).edit();
        edit.putString(CLIENT_IP, str);
        edit.commit();
    }

    public static String getClientIp(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(CLIENT_IP, "");
    }

    public static String getPrimeP(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(PRIME_P, "");
    }

    public static String getPrimeG(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(PRIME_G, "");
    }

    public static String getKeyE(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(KEY_E, "");
    }

    public static String getKeyN(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(KEY_N, "");
    }

    public static long getRandomR(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getLong(RANDOM_R, 0L);
    }

    public static int getAlgorithm(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(ALGORITHM, 0);
    }

    public static String getSite(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(SITE, "");
    }

    public static boolean getOpenTls(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(OPEN_TLS, false);
    }

    public static boolean getOpenAnti(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getBoolean(OPEN_ANTI, false);
    }

    public static List<FilePlatformInfo> getMediaServerCache(Context context) {
        try {
            SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
            List<FilePlatformInfo> mediaServerConfig = sharedPreferences.contains(MEDIA_SERVER_CONFIG) ? getMediaServerConfig(sharedPreferences) : null;
            if (mediaServerConfig != null && mediaServerConfig.size() != 0) {
                return mediaServerConfig;
            }
            return getOldMediaServerConfig(sharedPreferences);
        } catch (Exception e) {
            e.printStackTrace();
            RLog.e(TAG, " getMediaServerCache ", e);
            return null;
        }
    }

    private static List<FilePlatformInfo> getOldMediaServerConfig(SharedPreferences sharedPreferences) {
        ArrayList arrayList = new ArrayList();
        try {
            String string = sharedPreferences.getString(MEDIA_SERVER, null);
            String string2 = sharedPreferences.getString(BAI_DU_MEDIA_SERVER, DEFAULT_MEDIA_SERVER_HOST_BAIDU);
            if (!TextUtils.isEmpty(string)) {
                arrayList.add(new FilePlatformInfo(string, FtConst.ServiceType.QI_NIU.getPriority(), FtConst.ServiceType.QI_NIU));
            }
            if (!TextUtils.isEmpty(string2)) {
                arrayList.add(new FilePlatformInfo(string2, FtConst.ServiceType.BAI_DU.getPriority(), FtConst.ServiceType.BAI_DU));
            }
            Collections.sort(arrayList);
        } catch (Exception e) {
            e.printStackTrace();
            RLog.e(TAG, " getOldMediaServerConfig ", e);
            arrayList.clear();
        }
        return arrayList;
    }

    private static List<FilePlatformInfo> getMediaServerConfig(SharedPreferences sharedPreferences) {
        ArrayList arrayList = new ArrayList();
        String string = sharedPreferences.getString(MEDIA_SERVER_CONFIG, null);
        RLog.d(TAG, "getMediaServerConfig mediaServerConfigJson=" + string);
        if (TextUtils.isEmpty(string)) {
            RLog.i(TAG, "getMediaServerConfig: mediaServerConfigJson is empty.");
            return arrayList;
        }
        try {
            Iterator<JsonElement> it = new JsonParser().parse(string).getAsJsonArray().iterator();
            while (it.hasNext()) {
                JsonElement next = it.next();
                String str = "";
                FtConst.ServiceType serviceType = null;
                String str2 = null;
                for (String str3 : next.getAsJsonObject().keySet()) {
                    if (TextUtils.equals(str3, FtConst.ServiceType.QI_NIU.getName())) {
                        serviceType = FtConst.ServiceType.reverse(str3);
                        str2 = next.getAsJsonObject().get(str3).getAsString();
                    } else if (TextUtils.equals(str3, FtConst.ServiceType.BAI_DU.getName())) {
                        serviceType = FtConst.ServiceType.reverse(str3);
                        str2 = next.getAsJsonObject().get(str3).getAsString();
                        if (TextUtils.isEmpty(str2)) {
                            str2 = DEFAULT_MEDIA_SERVER_HOST_BAIDU;
                        }
                    } else if (TextUtils.equals(str3, FtConst.ServiceType.ALI_OSS.getName())) {
                        serviceType = FtConst.ServiceType.reverse(str3);
                        str2 = next.getAsJsonObject().get(str3).getAsString();
                    } else if (TextUtils.equals(str3, FtConst.ServiceType.AWS_S3.getName())) {
                        serviceType = FtConst.ServiceType.reverse(str3);
                        str2 = next.getAsJsonObject().get(str3).getAsString();
                    } else if (TextUtils.equals(str3, FtConst.ServiceType.STC.getName())) {
                        serviceType = FtConst.ServiceType.reverse(str3);
                        str2 = next.getAsJsonObject().get(str3).getAsString();
                    } else if (TextUtils.equals(str3, PRIME_P)) {
                        str = next.getAsJsonObject().get(str3).getAsString();
                    }
                }
                if (serviceType != null) {
                    arrayList.add(new FilePlatformInfo(str2, str, serviceType));
                }
            }
            Collections.sort(arrayList);
        } catch (Exception e) {
            FwLog.write(2, 1, "L-check_ossconfig_data-S", "value", string);
            e.printStackTrace();
            RLog.e(TAG, " getMediaServerConfig ", e);
            arrayList.clear();
        }
        return arrayList;
    }

    public static int getCachedReadReceiptVersion(Context context) {
        return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getInt(GROUP_READ_RECEIPT_VERSION, 0);
    }
}