Skip to content

Commit 0ff038c

Browse files
author
lucas
committed
提供视联网模式开关API
1 parent e3a28b9 commit 0ff038c

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"miniAppId":"1231231",
3+
"display":{
4+
"navTitle":"视频桌面"
5+
},
6+
"h5Url":"",
7+
"luaList":[
8+
{
9+
"url":"os_desktop_hotspot.lua"
10+
},
11+
{
12+
"url":"wwwwww.lua"
13+
}
14+
],
15+
"template":"os_desktop_hotspot.lua"
16+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
public class App {
1010

1111
private static Context sAppContext = null;
12+
// 是否打开开发者模式
13+
private static boolean isDevMode = false;
1214

1315
public static Context getContext() {
1416
return sAppContext;
@@ -19,4 +21,12 @@ public static void setContext(Context context) {
1921
sAppContext = context.getApplicationContext();
2022
}
2123
}
24+
25+
public static void setIsDevMode(boolean isDevMode) {
26+
App.isDevMode = isDevMode;
27+
}
28+
29+
public static boolean isIsDevMode() {
30+
return isDevMode;
31+
}
2232
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoPlusView.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import java.util.HashMap;
1212

13+
import cn.com.venvy.App;
1314
import cn.com.venvy.common.interf.IServiceCallback;
1415
import cn.com.venvy.common.interf.ServiceType;
1516
import cn.com.venvy.common.router.IRouterCallback;
@@ -280,4 +281,12 @@ public void stopService(ServiceType serviceType) {
280281
}
281282
}
282283
}
284+
285+
/**
286+
* 开发者模式开关
287+
* @param isDevMode
288+
*/
289+
public void setDevMode(boolean isDevMode){
290+
App.setIsDevMode(isDevMode);
291+
}
283292
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VisionProgramConfigModel.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.HashMap;
1212
import java.util.Map;
1313

14+
import cn.com.venvy.App;
1415
import cn.com.venvy.AppSecret;
1516
import cn.com.venvy.Config;
1617
import cn.com.venvy.Platform;
@@ -105,7 +106,17 @@ public void requestFinish(Request request, IResponse response) {
105106
}
106107
return;
107108
}
108-
final JSONObject decryptData = new JSONObject(VenvyAesUtil.decrypt(encryptData, AppSecret.getAppSecret(getPlatform()), AppSecret.getAppSecret(getPlatform())));
109+
110+
String jsonStr = "";
111+
if (App.isIsDevMode()) {
112+
VenvyLog.d("devMode is open");
113+
// jsonStr = VenvyAssetsUtil.readFileAssets("dev_config.json",App.getContext());
114+
} else {
115+
VenvyLog.d("devMode is close");
116+
jsonStr = VenvyAesUtil.decrypt(encryptData, AppSecret.getAppSecret(getPlatform()), AppSecret.getAppSecret(getPlatform()));
117+
}
118+
119+
final JSONObject decryptData = new JSONObject(jsonStr);
109120

110121
if (isH5Type) {
111122
final String h5Url = decryptData.optString("h5Url");
@@ -120,10 +131,11 @@ public void requestFinish(Request request, IResponse response) {
120131

121132
return;
122133
}
123-
124-
JSONArray fileListArray = decryptData.optJSONArray("luaList");// lua文件列表 sample : [{url:xxx, md5:xxx}, {url:xxx, md5:xxx} , ...]
134+
// lua文件列表 sample : [{url:xxx, md5:xxx}, {url:xxx, md5:xxx} , ...]
135+
// 开发者模式下 则是:[{url:本地filePath}, {url:本地filePath} , ...]
136+
JSONArray fileListArray = decryptData.optJSONArray("luaList");
125137
final String template = decryptData.optString("template"); // 入口lua文件名称
126-
String resCode = decryptData.optString("resCode"); // 应答码 00-成功 01-失败
138+
String resCode = App.isIsDevMode() ? "-1" : decryptData.optString("resCode"); // 应答码 00-成功 01-失败
127139
JSONObject displayObj = decryptData.optJSONObject("display");
128140

129141
if (displayObj != null) {
@@ -163,7 +175,10 @@ public void updateError(Throwable t) {
163175
VenvyResourceUtil.getStringId(getContext(), "errorDesc")));
164176
bundle.putBoolean(CONSTANT_NEED_RETRY, false);
165177
ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_SHOW_VISION_ERROR_LOGIC, bundle);
166-
} else {
178+
} else if(resCode.equalsIgnoreCase("-1")){
179+
// 开发者模式
180+
181+
}else {
167182
VenvyLog.e(decryptData.optString("resMsg")); // 应答信息
168183
}
169184

0 commit comments

Comments
 (0)