Skip to content

Commit afd105b

Browse files
author
qinpengcheng
committed
Merge branch '2.10.1_report' into 'dev_2.10.1'
2.10.1 report See merge request Mobile/VideoOS-Android-SDK!35
2 parents e84cabe + 3fbc7e1 commit afd105b

File tree

8 files changed

+77
-25
lines changed

8 files changed

+77
-25
lines changed

VideoOS/LuaViewSDK/src/cn/com/venvy/lua/plugin/LVReportPlugin.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.luaj.vm2.Varargs;
99
import org.luaj.vm2.lib.VarArgFunction;
1010

11+
import cn.com.venvy.common.report.Report;
12+
import cn.com.venvy.common.utils.VenvyLog;
1113
import cn.com.venvy.lua.binder.VenvyLVLibBinder;
1214

1315
/**
@@ -18,29 +20,42 @@
1820
public class LVReportPlugin {
1921

2022
private static LuaReport sLuaReport;
23+
private static final String TAG = "LVReportPlugin";
2124

2225
public static void install(VenvyLVLibBinder venvyLVLibBinder) {
23-
venvyLVLibBinder.set("report", sLuaReport == null ? sLuaReport = new LuaReport() : sLuaReport);
26+
venvyLVLibBinder.set("logReport", sLuaReport == null ? sLuaReport = new LuaReport() : sLuaReport);
2427
}
2528

2629
private static class LuaReport extends VarArgFunction {
2730
@Override
2831
public Varargs invoke(Varargs args) {
2932
int fixIndex = VenvyLVLibBinder.fixIndex(args);
3033
if (args.narg() > fixIndex) {
31-
32-
switch (LuaUtil.getString(args, fixIndex + 1)) {
33-
case "0":
34-
break;
35-
case "1":
36-
break;
37-
case "2":
38-
break;
39-
case "3":
34+
LuaValue messageValue = args.arg(fixIndex + 1);//key
35+
String message = VenvyLVLibBinder.luaValueToString(messageValue);
36+
if (TextUtils.isEmpty(message)) {
37+
return LuaValue.NIL;
38+
}
39+
int level = LuaUtil.getInt(args, fixIndex + 2) == null ? 0 : LuaUtil.getInt(args, fixIndex + 2);
40+
boolean needReport = LuaUtil.getBoolean(args, fixIndex + 3) == null ? true : false;
41+
switch (level) {
42+
case 0:
43+
VenvyLog.i(message);
44+
if (true) {
45+
Report.report(Report.ReportLevel.i, TAG, message);
46+
}
4047
break;
41-
case "4":
48+
case 1:
49+
VenvyLog.i(message);
50+
if (needReport) {
51+
Report.report(Report.ReportLevel.w, TAG, message);
52+
}
4253
break;
4354
default:
55+
VenvyLog.i(message);
56+
if (true) {
57+
Report.report(Report.ReportLevel.i, TAG, message);
58+
}
4459
break;
4560
}
4661
}

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Platform(PlatformInfo platformInfo) {
7171
mPlatformInfo = platformInfo;
7272
}
7373
TrackHelper.init(this);
74-
// Report.initReport(this);
74+
Report.initReport(this);
7575
}
7676

7777
public void setContentViewGroup(ViewGroup contentViewGroup) {

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/PreloadLuaUpdate.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.support.annotation.Nullable;
55
import android.text.TextUtils;
66

7-
import org.json.JSONArray;
87
import java.io.File;
98
import java.util.ArrayList;
109
import java.util.HashMap;
@@ -18,6 +17,7 @@
1817
import cn.com.venvy.common.download.DownloadTask;
1918
import cn.com.venvy.common.download.DownloadTaskRunner;
2019
import cn.com.venvy.common.download.TaskListener;
20+
import cn.com.venvy.common.report.Report;
2121
import cn.com.venvy.common.statistics.VenvyStatisticsManager;
2222
import cn.com.venvy.common.utils.VenvyAsyncTaskUtil;
2323
import cn.com.venvy.common.utils.VenvyFileUtil;
@@ -75,7 +75,7 @@ public void startDownloadLuaFile(List<LuaFileInfo> listOfLuaInfo) {
7575
builder.append(info.getMiniAppId());
7676
}
7777
setTaskTag(builder.toString());
78-
checkUpdateLuaInfos(listOfLuaInfo,getTaskTag());
78+
checkUpdateLuaInfos(listOfLuaInfo, getTaskTag());
7979
}
8080

8181
/***
@@ -155,12 +155,12 @@ private void startDownloadLuaFile(Map<String, Set<LuaFileInfo.LuaListBean>> mapI
155155

156156
ArrayList<DownloadTask> arrayList = new ArrayList<>();
157157

158-
while(entries.hasNext()){
158+
while (entries.hasNext()) {
159159
Map.Entry<String, Set<LuaFileInfo.LuaListBean>> entry = entries.next();
160160
String key = entry.getKey();
161161
Set<LuaFileInfo.LuaListBean> value = entry.getValue();
162-
for (LuaFileInfo.LuaListBean luaBean:value){
163-
String downUrl=luaBean.getLuaFileUrl();
162+
for (LuaFileInfo.LuaListBean luaBean : value) {
163+
String downUrl = luaBean.getLuaFileUrl();
164164
String downPath = TextUtils.isEmpty(key) ? VenvyFileUtil.getCachePath(App.getContext()) + LUA_CACHE_PATH + File.separator + Uri.parse(downUrl).getLastPathSegment() : VenvyFileUtil.getCachePath(App.getContext()) + LUA_CACHE_PATH + File.separator + key + File.separator + Uri.parse(downUrl).getLastPathSegment();
165165
DownloadTask task = new DownloadTask(App.getContext(), downUrl, downPath, true);
166166
arrayList.add(task);
@@ -199,6 +199,7 @@ public void onTasksComplete(@Nullable List<DownloadTask> successfulTasks, @Nulla
199199
if (callback != null) {
200200
if (failedTasks != null && failedTasks.size() > 0) {
201201
callback.updateError(new Exception("update Lua error,because down urls is failed"));
202+
Report.report(Report.ReportLevel.w, PreloadLuaUpdate.class.getName(), buildReportString(failedTasks));
202203
} else {
203204
callback.updateComplete(true);
204205
}
@@ -230,4 +231,18 @@ private String getFileLuaEncoderByMd5(String fileName, String miniAppId) {
230231
}
231232
return VenvyMD5Util.EncoderByMd5(new File(VenvyFileUtil.getCachePath(App.getContext()) + LUA_CACHE_PATH + File.separator + fileName));
232233
}
234+
235+
private static String buildReportString(List<DownloadTask> failedTasks) {
236+
237+
StringBuilder builder = new StringBuilder();
238+
builder.append("[download lua failed],");
239+
builder.append("\\n");
240+
if (failedTasks != null) {
241+
for (DownloadTask downloadTask : failedTasks) {
242+
builder.append("url = ").append(downloadTask.getDownloadUrl());
243+
builder.append("\\n");
244+
}
245+
}
246+
return builder.toString();
247+
}
233248
}

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/PreloadZipUpdate.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import cn.com.venvy.common.download.DownloadTask;
1717
import cn.com.venvy.common.download.DownloadTaskRunner;
1818
import cn.com.venvy.common.download.TaskListener;
19+
import cn.com.venvy.common.report.Report;
1920
import cn.com.venvy.common.statistics.VenvyStatisticsManager;
2021
import cn.com.venvy.common.utils.VenvyAsyncTaskUtil;
2122
import cn.com.venvy.common.utils.VenvyFileUtil;
@@ -289,6 +290,7 @@ public void onTasksComplete(@Nullable List<DownloadTask> successfulTasks, @Nulla
289290
CacheZipUpdateCallback callback = getCacheLuaUpdateCallback();
290291
if (callback != null) {
291292
callback.updateError(new Exception("update error,because downloadTask error"));
293+
Report.report(Report.ReportLevel.w, PreloadZipUpdate.class.getName(), buildReportString(failedTasks));
292294
}
293295
return;
294296
}
@@ -353,4 +355,17 @@ private String getZipAbsolutePath() {
353355
private String getUnZipAbsolutePath() {
354356
return VenvyFileUtil.getCachePath(App.getContext()) + UN_ZIP_PATH;
355357
}
358+
private static String buildReportString(List<DownloadTask> failedTasks) {
359+
360+
StringBuilder builder = new StringBuilder();
361+
builder.append("[download zip failed],");
362+
builder.append("\\n");
363+
if (failedTasks != null) {
364+
for (DownloadTask downloadTask : failedTasks) {
365+
builder.append("url = ").append(downloadTask.getDownloadUrl());
366+
builder.append("\\n");
367+
}
368+
}
369+
return builder.toString();
370+
}
356371
}

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/debug/DebugDialogView.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import android.widget.CompoundButton;
99
import android.widget.FrameLayout;
1010
import android.widget.LinearLayout;
11+
12+
import cn.com.venvy.common.report.Report;
1113
import cn.com.venvy.common.utils.VenvyLog;
1214
import cn.com.venvy.common.utils.VenvyUIUtil;
1315

@@ -141,6 +143,11 @@ void updateCheckBoxTxt(DebugStatus.EnvironmentStatus environmentStatus) {
141143
mPreCheckoutBox.setText(openPreTxt);
142144
break;
143145
}
146+
if (Report.isReportAble()) {
147+
mReportCheckBox.setText("是否关闭日志上报功能?");
148+
} else {
149+
mReportCheckBox.setText("是否打开日志上报功能?");
150+
}
144151
}
145152

146153
private class PositiveClickListener implements DialogInterface.OnClickListener {
@@ -163,7 +170,7 @@ public void onClick(DialogInterface dialog, int which) {
163170

164171
DebugStatus.changeEnvironmentStatus(status);
165172
if (mReportCheckBox.isChecked()) {
166-
173+
Report.setReportAble(!Report.isReportAble());
167174
}
168175

169176
//根据选中与否来决定是否打开LOG

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/http/base/BaseRequestConnect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,6 @@ private void startReportErrorLog(Request request, Exception e) {
521521
}
522522
}
523523
}
524-
// Report.report(Report.ReportLevel.w, BaseRequestConnect.TAG, builder.toString());
524+
Report.report(Report.ReportLevel.w, BaseRequestConnect.TAG, builder.toString());
525525
}
526526
}

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/image/ImageLoadResultAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void loadFailure(@Nullable WeakReference<? extends IImageView> imageView,
3131
if (mImageLoaderResult != null) {
3232
mImageLoaderResult.loadFailure(imageView, url, e);
3333
}
34-
// Report.report(Report.ReportLevel.w, ImageLoadResultAdapter.class.getName(), buildReportString(e, url));
34+
Report.report(Report.ReportLevel.w, ImageLoadResultAdapter.class.getName(), buildReportString(e, url));
3535
}
3636

3737
private static String buildReportString(Exception exception, String url) {

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/report/ReportHelper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ReportHelper {
4848
private static final String REPORT_AES_IV = "lx7eZhVoBEnKXELF";
4949
private static final String REPORT_SERVER_KEY = "info";
5050
private static final String KEY_ASYNC_TASK = "Report_report";
51-
private static final String REPORT_URL = "https://log.videojj.com/api/log";
51+
private static final String REPORT_URL = "https://os-saas.videojj.com/os-report-log/api/log";
5252

5353
//最大缓存条数
5454
private static final int MAX_CACHE_NUM = 5;
@@ -74,7 +74,7 @@ class ReportHelper {
7474
}
7575

7676
boolean isEnable() {
77-
return DebugStatus.isRelease() && enable;
77+
return !DebugStatus.isPreView() && enable;
7878
}
7979

8080
public void report(@NonNull final ReportInfo reportInfo) {
@@ -122,7 +122,7 @@ public Void doAsyncTask(Void... strings) throws Exception {
122122
HashMap<String, String> params = new HashMap<>();
123123
String signParams = VenvyAesUtil.encrypt(REPORT_AES_KEY, REPORT_AES_IV, gzipString);
124124
params.put(REPORT_SERVER_KEY, signParams);
125-
Request request = HttpRequest.put(REPORT_URL, params);
125+
Request request = HttpRequest.post(REPORT_URL, params);
126126
request.setPriority(Priority.LOW);
127127
mConnect.connect(request, new IRequestHandler() {
128128
@Override
@@ -136,8 +136,8 @@ public void requestFinish(Request request, IResponse response) {
136136
return;
137137
}
138138
JSONObject jsonObject = new JSONObject(body);
139-
if (jsonObject.has("logReport")) {
140-
int reportNum = jsonObject.optInt("logReport");
139+
if (jsonObject.has("data")) {
140+
int reportNum = jsonObject.optInt("data");
141141
Report.ReportLevel.buildLevelAble(reportNum);
142142
}
143143
} catch (Exception e) {

0 commit comments

Comments
 (0)