智慧城市 v1.2.1版本的 MD5 值为:d4aeacb5153a2710d0b6882be5dd2b15
以下内容为反编译后的 LogEntity.java 源代码,内容仅作参考
package io.rong.common.dlog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import io.rong.common.dlog.DLog;
import io.rong.common.rlog.RLogConfig;
import io.rong.imlib.common.RongLibConst;
import io.rong.imlib.common.SavePathUtils;
import java.io.File;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class LogEntity {
public static final String CrashLogFileName = "rong_sdk_crash.log";
private static final String LOG_DIR = "rong_log";
public static final String LogFileName = "rong_sdk.log";
private static final String Log_Default_Url = "https://feedback.cn.ronghub.com";
public static final int MODE_DEBUG = 1;
public static final int MODE_RELEASE = 0;
public static final int MODE_TEST = 2;
private static final String SP_APP_KEY = "APP_KEY";
private static final String SP_MONITOR_LEVEL = "MONITOR_LEVEL";
private static final String SP_MONITOR_TYPE = "MONITOR_TYPE";
private static final String SP_NAME = "FwLog";
private static final String SP_OFFLINE_LOG_SERVER = "OFFLINE_LOG_SERVER";
private static final String SP_ONLINE_LOG_SERVER = "ONLINE_LOG_SERVER";
private static final String SP_SDK_VER = "SDK_VER";
private static final String SP_START_LOG_TIME = "START_LOG_TIME";
private static final String SP_TOKEN = "TOKEN";
private static final String SP_UPLOAD_CACHE_LIST = "UPLOAD_CACHE_LIST";
private static final String SP_USER_ID = "USER_ID";
private static LogEntity instance;
private String appKey;
private int consoleLogLevel;
private boolean isDebugMode;
private String logDir;
private DLog.ILogListener logListener;
private int monitorLevel;
private int monitorType;
private String offlineLogServer = null;
private String onlineLogServer = null;
private String sdkVer;
private SharedPreferences sharedPreferences;
private long startLogTime;
private String token;
private String userId;
public static void init(Context context) {
if (instance == null) {
instance = new LogEntity(context);
}
}
private LogEntity(Context context) {
File file = null;
ApplicationInfo applicationInfo = context.getApplicationInfo();
this.isDebugMode = (applicationInfo == null || (applicationInfo.flags & 2) == 0) ? false : true;
this.sharedPreferences = context.getSharedPreferences(SP_NAME, 0);
if (!SavePathUtils.isSavePathEmpty()) {
this.logDir = SavePathUtils.getSavePath() + File.separator + LOG_DIR;
File file2 = new File(this.logDir);
if (file2.exists()) {
return;
}
file2.mkdirs();
return;
}
try {
file = context.getExternalFilesDir(LOG_DIR);
} catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
}
if (file != null) {
this.logDir = file.getAbsolutePath();
return;
}
try {
this.logDir = context.getFilesDir().getAbsoluteFile() + File.separator + LOG_DIR;
} catch (Exception e2) {
DLog.write(1, 512, DLog.LogTag.L_CRASH_MAIN_EPT_E.getTag(), "stacks", DLog.stackToString(e2));
}
}
public static LogEntity getInstance() {
LogEntity logEntity = instance;
if (logEntity != null) {
return logEntity;
}
throw new RuntimeException("LogEntity.init() has not been called.");
}
public String getLogDir() {
return this.logDir;
}
public String getSdkVer() {
if (this.sdkVer == null) {
this.sdkVer = this.sharedPreferences.getString(SP_SDK_VER, null);
}
return this.sdkVer;
}
public void setSdkVer(String str) {
this.sharedPreferences.edit().putString(SP_SDK_VER, str).apply();
this.sdkVer = str;
}
public String getAppKey() {
if (this.appKey == null) {
this.appKey = this.sharedPreferences.getString(SP_APP_KEY, null);
}
return this.appKey;
}
public void setAppKey(String str) {
this.sharedPreferences.edit().putString(SP_APP_KEY, str).apply();
this.appKey = str;
}
public String getUserId() {
if (this.userId == null) {
this.userId = this.sharedPreferences.getString(SP_USER_ID, null);
}
return this.userId;
}
public void setUserId(String str) {
this.sharedPreferences.edit().putString(SP_USER_ID, str).apply();
this.userId = str;
}
public String getToken() {
if (this.token == null) {
this.token = this.sharedPreferences.getString(SP_TOKEN, null);
}
return this.token;
}
public void setToken(String str) {
this.sharedPreferences.edit().putString(SP_TOKEN, str).apply();
this.token = str;
}
public void setOfflineLogServer(String str) {
this.sharedPreferences.edit().putString(SP_OFFLINE_LOG_SERVER, str).apply();
this.offlineLogServer = str;
}
String getOfflineLogServer() {
if (this.offlineLogServer == null) {
this.offlineLogServer = this.sharedPreferences.getString(SP_OFFLINE_LOG_SERVER, Log_Default_Url);
}
return this.offlineLogServer;
}
public void setOnlineLogServer(String str) {
this.sharedPreferences.edit().putString(SP_ONLINE_LOG_SERVER, str).apply();
this.onlineLogServer = str;
}
public String getOnlineLogServer() {
if (this.onlineLogServer == null) {
this.onlineLogServer = this.sharedPreferences.getString(SP_ONLINE_LOG_SERVER, "");
}
return this.onlineLogServer;
}
public long getStartLogTime() {
if (this.startLogTime == 0) {
this.startLogTime = this.sharedPreferences.getLong(SP_START_LOG_TIME, 0L);
}
return this.startLogTime;
}
public void setStartLogTime(long j) {
this.sharedPreferences.edit().putLong(SP_START_LOG_TIME, j).apply();
this.startLogTime = j;
}
public int getMonitorLevel() {
if (this.monitorLevel == 0) {
this.monitorLevel = this.sharedPreferences.getInt(SP_MONITOR_LEVEL, 0);
}
return this.monitorLevel;
}
public void setMonitorLevel(int i) {
if (getLogMode() == 2) {
i = 6;
}
this.sharedPreferences.edit().putInt(SP_MONITOR_LEVEL, i).apply();
this.monitorLevel = i;
}
public int getMonitorType() {
if (this.monitorType == 0) {
this.monitorType = this.sharedPreferences.getInt(SP_MONITOR_TYPE, 0);
}
return this.monitorType;
}
public void setMonitorType(int i) {
if (getLogMode() == 2) {
i = 268435455;
}
this.sharedPreferences.edit().putInt(SP_MONITOR_TYPE, i).apply();
this.monitorType = i;
}
public JSONArray getUploadCacheList() {
JSONArray jSONArray;
String string = this.sharedPreferences.getString(SP_UPLOAD_CACHE_LIST, null);
try {
if (string == null) {
jSONArray = new JSONArray();
} else {
jSONArray = new JSONArray(string);
}
return jSONArray;
} catch (JSONException e) {
DLog.write(1, 512, DLog.LogTag.G_GET_UPLOAD_CACHE_E.getTag(), "cache", string);
e.printStackTrace();
return new JSONArray();
}
}
void setUploadCacheList(JSONArray jSONArray) {
synchronized (this.sharedPreferences) {
if (jSONArray != null) {
this.sharedPreferences.edit().putString(SP_UPLOAD_CACHE_LIST, jSONArray.toString()).apply();
}
}
}
public void deleteUploadCacheList(int i) {
synchronized (this.sharedPreferences) {
JSONArray uploadCacheList = getUploadCacheList();
if (uploadCacheList != null) {
if (Build.VERSION.SDK_INT >= 19) {
uploadCacheList.remove(i);
}
this.sharedPreferences.edit().putString(SP_UPLOAD_CACHE_LIST, uploadCacheList.toString()).apply();
}
}
}
public void addLogStamp(String str) {
JSONArray uploadCacheList = getUploadCacheList();
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("filename", str);
jSONObject.put("sdkVer", getInstance().getSdkVer());
jSONObject.put("appKey", getInstance().getAppKey());
jSONObject.put("userId", getInstance().getUserId());
jSONObject.put(RongLibConst.KEY_TOKEN, getInstance().getToken());
uploadCacheList.put(jSONObject);
} catch (JSONException e) {
DLog.write(1, 512, DLog.LogTag.G_CRASH_E.getTag(), "stacks", DLog.stackToString(e));
e.printStackTrace();
}
setUploadCacheList(uploadCacheList);
}
public int getLogMode() {
return this.isDebugMode ? 1 : 0;
}
public void setConsoleLogLevel(int i) {
this.consoleLogLevel = i;
}
public int getConsoleLogLevel() {
return this.consoleLogLevel;
}
public void setLogListener(DLog.ILogListener iLogListener) {
this.logListener = iLogListener;
}
public DLog.ILogListener getLogListener() {
return this.logListener;
}
public String getUploadUrl() {
return getOfflineLogServer();
}
public long getUploadTimeInterval() {
return getLogMode() == 2 ? 120000L : 1200000L;
}
public long getOutDateTime() {
return getLogMode() == 2 ? 300000L : 259200000L;
}
public long getFileMaxSize() {
if (getLogMode() == 2) {
return 51200L;
}
return RLogConfig.DEFAULT_MAX_SIZE;
}
}