Skip to content

Commit 9efc6fc

Browse files
committed
open report
1 parent ecff455 commit 9efc6fc

File tree

6 files changed

+64
-21
lines changed

6 files changed

+64
-21
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import android.support.annotation.Nullable;
44
import android.view.ViewGroup;
55

6-
import org.json.JSONArray;
7-
86
import java.io.File;
97
import java.io.Serializable;
108
import java.lang.reflect.Method;
@@ -72,7 +70,7 @@ public Platform(PlatformInfo platformInfo) {
7270
mPlatformInfo = platformInfo;
7371
}
7472
TrackHelper.init(this);
75-
// Report.initReport(this);
73+
Report.initReport(this);
7674
}
7775

7876
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/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) {

0 commit comments

Comments
 (0)