米游社.apk(点击下载) / 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 com.xiaomi.mipush.sdk.Constants;
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.Map;
import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class NavigationCacheHelper {
private static final String AI_ADDRESS = "aiAddr";
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 JWT = "jwt";
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_SPEECH = "openSpeech";
private static final String OPEN_TLS = "openTLS";
private static final String OPEN_TRANSLATION = "openTranslation";
private static final String OPEN_ULTRA_GROUP = "ugMsg";
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 void cacheLastSuccessNaviDomainList(Context context, String str) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(LAST_SUCCESS_NAVI, str);
edit.commit();
}
}
public static void cacheRequest(Context context, String str, String str2) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putLong(CACHED_TIME, System.currentTimeMillis() - ((long) TimeZone.getDefault().getRawOffset()));
edit.putString("appKey", str);
edit.putString("token", str2);
edit.commit();
}
}
public static void clearCache(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
sharedPreferences.edit().clear().commit();
}
}
public static void clearComplexConnectionEntries(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
sharedPreferences.edit().remove(COMPLEX_CONNECTION).commit();
}
}
public static void clearNaviCache(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0);
if (sharedPreferences != null) {
sharedPreferences.edit().clear().commit();
}
}
public static void clearUserId(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
sharedPreferences.edit().remove("userId").commit();
}
}
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 int decode2File(Context context, String str, int i10) {
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 + Constants.ACCEPT_TIME_SEPARATOR_SERVER + i10);
if ((optInt == 401 && i10 == 403) || (optInt == 403 && i10 == 401)) {
return IRongCoreEnum.CoreErrorCode.RC_CONN_USER_OR_PASSWD_ERROR.getValue();
}
return IRongCoreEnum.CoreErrorCode.RC_NAVI_RESOURCE_ERROR.getValue();
}
String optString = jSONObject.optString("userId");
if (!TextUtils.isEmpty(optString)) {
if (optString.getBytes().length <= 64) {
String optString2 = jSONObject.optString(CMP_SERVER);
String optString3 = jSONObject.optString(BACKUP_SERVER);
if (!TextUtils.isEmpty(optString2) || !TextUtils.isEmpty(optString3)) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.clear().commit();
edit.putString("userId", optString);
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", jSONObject.optString("location"));
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 z10 = 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(""", "\""));
} 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("p", jSONObject2.optString("p"));
edit.putString("g", jSONObject2.optString("g"));
edit.putString("n", jSONObject2.optString("n"));
edit.putString("e", jSONObject2.optString("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);
}
if (jSONObject.has(OPEN_ULTRA_GROUP)) {
edit.putBoolean(OPEN_ULTRA_GROUP, jSONObject.optInt(OPEN_ULTRA_GROUP) == 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)) {
edit.putBoolean(OPEN_ANTI, jSONObject.optInt(OPEN_ANTI) == 1);
}
if (jSONObject.has(OPEN_TRANSLATION)) {
edit.putBoolean(OPEN_TRANSLATION, jSONObject.optInt(OPEN_TRANSLATION) == 1);
}
if (jSONObject.has(OPEN_SPEECH)) {
if (jSONObject.optInt(OPEN_SPEECH) != 1) {
z10 = false;
}
edit.putBoolean(OPEN_SPEECH, z10);
}
if (jSONObject.has(AI_ADDRESS)) {
edit.putString(AI_ADDRESS, jSONObject.optString(AI_ADDRESS));
}
edit.putString(JWT, jSONObject.optString(JWT));
edit.commit();
return 0;
}
RLog.e(TAG, "[connect] decode2File: cmp is invalid, " + str);
return IRongCoreEnum.CoreErrorCode.RC_NODE_NOT_FOUND.getValue();
}
}
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 String getAIAddress(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString(AI_ADDRESS, "");
}
public static int getAlgorithm(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 0;
}
return sharedPreferences.getInt(ALGORITHM, 0);
}
public static String getAppKey(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("appKey", "");
}
public static String getBaiDuMediaServer(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return DEFAULT_MEDIA_SERVER_HOST_BAIDU;
}
return sharedPreferences.getString(BAI_DU_MEDIA_SERVER, DEFAULT_MEDIA_SERVER_HOST_BAIDU);
}
public static int getCachedReadReceiptVersion(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 0;
}
return sharedPreferences.getInt(GROUP_READ_RECEIPT_VERSION, 0);
}
public static long getCachedTime() {
return sCacheTime;
}
public static String getClientIp(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString(CLIENT_IP, "");
}
public static List<String> getConnectionCmpList(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
String str = null;
if (sharedPreferences != null) {
str = sharedPreferences.getString(CMP_SERVER, null);
}
String str2 = "";
if (sharedPreferences != null) {
str2 = sharedPreferences.getString(BACKUP_SERVER, str2);
}
ArrayList arrayList = new ArrayList();
if (!TextUtils.isEmpty(str)) {
arrayList.add(str);
}
if (!TextUtils.isEmpty(str2)) {
String[] split = str2.split(",");
for (String str3 : split) {
if (!TextUtils.isEmpty(str3)) {
arrayList.add(str3);
}
}
}
return arrayList;
}
public static String getExcludeLogTag(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString(EXCLUDE_LOG_TAG, "");
}
public static int getGifSizeLimit(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 2048;
}
return sharedPreferences.getInt(GIF_SIZE, 2048);
}
public static int getGroupMessageLimit(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 1000;
}
return sharedPreferences.getInt(GET_GROUP_MESSAGE_LIMIT, 1000);
}
public static String getJWT(Context context) {
return SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getString(JWT, "");
}
public static String getKeyE(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("e", "");
}
public static String getKeyN(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("n", "");
}
private static String getLastSuccessNaviDomainList(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_IP_PREFERENCE, 0);
if (sharedPreferences == null) {
return null;
}
return sharedPreferences.getString(LAST_SUCCESS_NAVI, null);
}
public static LocationConfig getLocationConfig(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
String string = sharedPreferences == null ? null : sharedPreferences.getString("location", 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 i10 = 0; i10 < optJSONArray.length(); i10++) {
iArr[i10] = optJSONArray.optInt(i10);
}
locationConfig.setConversationTypes(iArr);
}
locationConfig.setMaxParticipant(jSONObject.optInt("maxParticipant"));
locationConfig.setDistanceFilter(jSONObject.optInt("distanceFilter"));
locationConfig.setRefreshInterval(jSONObject.optInt("refreshInterval"));
return locationConfig;
} catch (JSONException e10) {
RLog.e(TAG, "getLocationConfig ", e10);
}
}
return null;
}
public static int getLogMonitor(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 0;
}
return sharedPreferences.getInt(LOG_MONITOR, 0);
}
public static String getMediaServer(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return null;
}
return sharedPreferences.getString(MEDIA_SERVER, null);
}
public static List<FilePlatformInfo> getMediaServerCache(Context context) {
try {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
List<FilePlatformInfo> mediaServerConfig = (sharedPreferences == null || !sharedPreferences.contains(MEDIA_SERVER_CONFIG)) ? null : getMediaServerConfig(sharedPreferences);
if (mediaServerConfig != null) {
if (!mediaServerConfig.isEmpty()) {
return mediaServerConfig;
}
}
return getOldMediaServerConfig(sharedPreferences);
} catch (Exception e10) {
e10.printStackTrace();
RLog.e(TAG, " getMediaServerCache ", e10);
return null;
}
}
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> it2 = new JsonParser().parse(string).getAsJsonArray().iterator();
while (it2.hasNext()) {
JsonElement next = it2.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, "p")) {
str = next.getAsJsonObject().get(str3).getAsString();
}
}
if (serviceType != null) {
arrayList.add(new FilePlatformInfo(str2, str, serviceType));
}
}
Collections.sort(arrayList);
} catch (Exception e10) {
FwLog.write(2, 1, "L-check_ossconfig_data-S", "value", string);
e10.printStackTrace();
RLog.e(TAG, " getMediaServerConfig ", e10);
arrayList.clear();
}
return arrayList;
}
public static String getNavigationPreferenceValue(Context context, String str) {
Object obj;
Map<String, ?> all = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0).getAll();
if (all == null || all.isEmpty() || (obj = all.get(str)) == null) {
return "";
}
return obj.toString();
}
@Deprecated
public static String getOfflineLogServer(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "https://feedback.cn.ronghub.com";
}
return sharedPreferences.getString(OFFLINE_LOG_SERVER, "https://feedback.cn.ronghub.com");
}
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)) {
FtConst.ServiceType serviceType = FtConst.ServiceType.QI_NIU;
arrayList.add(new FilePlatformInfo(string, serviceType.getPriority(), serviceType));
}
if (!TextUtils.isEmpty(string2)) {
FtConst.ServiceType serviceType2 = FtConst.ServiceType.BAI_DU;
arrayList.add(new FilePlatformInfo(string2, serviceType2.getPriority(), serviceType2));
}
Collections.sort(arrayList);
} catch (Exception e10) {
e10.printStackTrace();
RLog.e(TAG, " getOldMediaServerConfig ", e10);
arrayList.clear();
}
return arrayList;
}
@Deprecated
public static String getOnlineLogServer(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return null;
}
return sharedPreferences.getString(ONLINE_LOG_SERVER, null);
}
public static boolean getOpenAnti(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_ANTI, false)) {
return false;
}
return true;
}
public static boolean getOpenTls(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_TLS, false)) {
return false;
}
return true;
}
public static String getPrimeG(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("g", "");
}
public static String getPrimeP(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("p", "");
}
public static boolean getPrivateCloudConfig(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean("type", false)) {
return false;
}
return true;
}
public static long getRandomR(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return 0;
}
return sharedPreferences.getLong(RANDOM_R, 0);
}
public static String getRealTimeLogConfig(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return null;
}
return sharedPreferences.getString(TIMING_UPLOAD_LOG_CONFIG, null);
}
public static String getSite(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("site", "");
}
public static String getToken(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return "";
}
return sharedPreferences.getString("token", "");
}
public static String getUserId(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return null;
}
return sharedPreferences.getString("userId", null);
}
public static int getVideoLimitTime(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return Integer.parseInt(DEFAULT_VIDEO_TIME);
}
return sharedPreferences.getInt(VIDEO_TIMES, Integer.parseInt(DEFAULT_VIDEO_TIME));
}
public static String getVoIPCallInfo(Context context) {
String str;
synchronized (lock) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
str = null;
if (sharedPreferences != null) {
str = sharedPreferences.getString(VOIP_CALL_INFO, null);
}
}
return str;
}
public static boolean isCMPValid(String str) {
return CMPStrategy.getInstance().isCMPValid(str);
}
public static boolean isCacheTimeout(Context context) {
long j10;
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
j10 = 0;
} else {
j10 = sharedPreferences.getLong(CACHED_TIME, 0);
}
long currentTimeMillis = System.currentTimeMillis() - ((long) TimeZone.getDefault().getRawOffset());
if (j10 == 0 || currentTimeMillis - j10 <= 7200000) {
return false;
}
return true;
}
public static boolean isCacheValid(Context context, String str, String str2, String str3) {
String str4;
String str5;
if (getConnectionCmpList(context).isEmpty()) {
return false;
}
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
String str6 = null;
if (sharedPreferences == null) {
str4 = null;
} else {
str4 = sharedPreferences.getString("appKey", null);
}
if (sharedPreferences == null) {
str5 = null;
} else {
str5 = sharedPreferences.getString("token", null);
}
if (sharedPreferences != null) {
str6 = sharedPreferences.getString("userId", null);
}
String lastSuccessNaviDomainList = getLastSuccessNaviDomainList(context);
long j10 = 0;
if (sharedPreferences != null) {
j10 = sharedPreferences.getLong(CACHED_TIME, 0);
}
sCacheTime = j10;
long currentTimeMillis = System.currentTimeMillis() - ((long) TimeZone.getDefault().getRawOffset());
boolean z10 = str4 != null && str4.equals(str) && str5 != null && str5.equals(str2) && currentTimeMillis - sCacheTime <= 7200000 && !TextUtils.isEmpty(str6) && isNaviUrlsValid(lastSuccessNaviDomainList, str3);
FwLog.write(3, 1, FwLog.LogTag.L_GET_NAVI_S.getTag(), "cache_valid|delta_time", Boolean.valueOf(z10), Long.valueOf(currentTimeMillis - sCacheTime));
return z10;
}
public static boolean isChatroomHistoryEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(GET_CHATROOM_HISTORY_SERVICE, false)) {
return false;
}
return true;
}
public static boolean isConnPolicyEnable(Context context) {
boolean z10 = false;
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null && sharedPreferences.getInt(CONN_POLICY, 0) == 1) {
z10 = true;
}
RLog.i(TAG, "isConnPolicyEnable, userPolicy = " + userPolicy + ", naviPolicy = " + z10);
if (z10) {
return true;
}
return userPolicy;
}
public static boolean isDnsEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_DNS, false)) {
return false;
}
return true;
}
public static boolean isGetRemoteEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null) {
return false;
}
return sharedPreferences.getBoolean(GET_REMOTE_SERVICE, false);
}
public static boolean isJoinMChatroomEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(JOIN_MULTI_CHATROOM, false)) {
return false;
}
return true;
}
public static boolean isKvStorageEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(KV_STORAGE, false)) {
return false;
}
return true;
}
public static boolean isMPOpened(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
return sharedPreferences == null || sharedPreferences.getBoolean(OPEN_MP, true);
}
private static boolean isNaviUrlsValid(String str, String str2) {
if (TextUtils.isEmpty(str2) || TextUtils.isEmpty(str)) {
return false;
}
return str2.equals(str);
}
public static boolean isPhraseEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(EXT_KIT_SWITCH, false)) {
return false;
}
return true;
}
public static boolean isRepairMsgEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(REPAIR_MSG, false)) {
return false;
}
return true;
}
public static boolean isSpeechEnable(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_SPEECH, false)) {
return false;
}
return true;
}
public static boolean isTranslationEnable(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_TRANSLATION, false)) {
return false;
}
return true;
}
public static boolean isUSOpened(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_US, false)) {
return false;
}
return true;
}
public static boolean isUltraGroupEnabled(Context context) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences == null || !sharedPreferences.getBoolean(OPEN_ULTRA_GROUP, false)) {
return false;
}
return true;
}
public static String queryRequestIP(String str) {
return DNSResolve.getIP(str);
}
public static void saveUserId(Context context, String str) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString("userId", str);
edit.apply();
}
}
public static void setUserPolicy(boolean z10) {
RLog.i(TAG, "setUserPolicy, userPolicy = " + z10);
userPolicy = z10;
}
public static void updateClientIp(Context context, String str) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(CLIENT_IP, str);
edit.commit();
}
}
public static void updateTime(Context context, long j10) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putLong(CACHED_TIME, j10);
edit.commit();
}
}
public static void updateVoIPCallInfo(Context context, String str) {
synchronized (lock) {
SharedPreferences sharedPreferences = SharedPreferencesUtils.get(context, NAVIGATION_PREFERENCE, 0);
if (sharedPreferences != null) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(VOIP_CALL_INFO, str);
edit.commit();
}
}
}
}