Skip to content

Commit cf05d3b

Browse files
author
lucas
committed
Merge branch 'dev_2.4.3' into dev_2.5.0
2 parents 91be2a4 + 0ff038c commit cf05d3b

File tree

6 files changed

+131
-19
lines changed

6 files changed

+131
-19
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
import org.luaj.vm2.Varargs;
1010
import org.luaj.vm2.lib.VarArgFunction;
1111

12+
import cn.com.venvy.App;
1213
import cn.com.venvy.Config;
1314
import cn.com.venvy.Platform;
1415
import cn.com.venvy.common.bean.VideoFrameSize;
1516
import cn.com.venvy.common.bean.VideoPlayerSize;
1617
import cn.com.venvy.common.debug.DebugStatus;
1718
import cn.com.venvy.common.interf.ScreenStatus;
1819
import cn.com.venvy.common.interf.VideoType;
20+
import cn.com.venvy.common.utils.VenvyDeviceUtil;
1921
import cn.com.venvy.common.utils.VenvyLog;
2022
import cn.com.venvy.lua.binder.VenvyLVLibBinder;
2123

@@ -40,6 +42,7 @@ public static void install(VenvyLVLibBinder venvyLVLibBinder, Platform platform)
4042
venvyLVLibBinder.set("getVideoCategory", new GetCategory(platform));
4143
venvyLVLibBinder.set("getConfigExtendJSONString", new GetExtendJSONString(platform));
4244
venvyLVLibBinder.set("osType", new OsType(platform));
45+
venvyLVLibBinder.set("isPhone", new IsPhone());
4346

4447
}
4548

@@ -308,4 +311,20 @@ public Varargs invoke(Varargs args) {
308311
return LuaValue.valueOf(value);
309312
}
310313
}
314+
315+
316+
/**
317+
* 判断是否是手机设备
318+
*
319+
* 支持sim card 且 屏幕尺寸小于20则认为是手机设备
320+
*/
321+
private static class IsPhone extends VarArgFunction {
322+
@Override
323+
public LuaValue invoke(Varargs args) {
324+
boolean isPhone = VenvyDeviceUtil.isSupportSimCard(App.getContext()) && VenvyDeviceUtil.getScreenDimension(App.getContext()) < 20.0;
325+
326+
return LuaValue.valueOf(isPhone);
327+
}
328+
}
329+
311330
}
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/VenvyLibrary/src/main/java/cn/com/venvy/common/utils/VenvyDeviceUtil.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import android.support.annotation.Nullable;
1111
import android.telephony.TelephonyManager;
1212
import android.text.TextUtils;
13+
import android.util.DisplayMetrics;
14+
import android.view.Display;
15+
import android.view.WindowManager;
1316

1417
import org.json.JSONObject;
1518

@@ -23,6 +26,7 @@
2326
import java.net.NetworkInterface;
2427
import java.net.URL;
2528
import java.net.URLEncoder;
29+
import java.text.DecimalFormat;
2630
import java.util.Enumeration;
2731
import java.util.UUID;
2832

@@ -364,4 +368,35 @@ public static boolean existSDcard() {
364368
}
365369
return MEDIA_MOUNTED.equals(externalStorageState);
366370
}
371+
372+
/**
373+
* 是否支持sim卡
374+
*
375+
* @param context
376+
* @return
377+
*/
378+
public static boolean isSupportSimCard(Context context) {
379+
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
380+
return telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
381+
}
382+
383+
384+
/**
385+
* 获取屏幕物理尺寸
386+
*
387+
* @return
388+
*/
389+
public static double getScreenDimension(Context context) {
390+
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
391+
Display display = windowManager.getDefaultDisplay();
392+
DisplayMetrics dm = new DisplayMetrics();
393+
display.getMetrics(dm);
394+
395+
double x = Math.pow(dm.widthPixels / dm.xdpi, 2);
396+
double y = Math.pow(dm.heightPixels / dm.ydpi, 2);
397+
398+
DecimalFormat df = new DecimalFormat("#.##");
399+
return Double.parseDouble(df.format(Math.sqrt(x + y)));
400+
}
401+
367402
}

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

Lines changed: 31 additions & 14 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;
@@ -32,6 +33,8 @@ public abstract class VideoPlusView<T extends VideoPlusController> extends Frame
3233

3334
private VideoPlusViewHelper plusViewHelper;
3435

36+
private VideoPlusAdapter adapter;
37+
3538
public VideoPlusView(Context context) {
3639
super(context);
3740
init();
@@ -73,10 +76,8 @@ private void init() {
7376

7477
programViewA = createTypeAProgram();
7578
programViewB = createTypeBProgram();
76-
programViewDesktop = createDesktopProgram();
7779
addView(programViewA);
7880
addView(programViewB);
79-
addView(programViewDesktop);
8081
programViewB.setClickable(false);
8182
}
8283

@@ -99,8 +100,8 @@ private VideoProgramTypeBView createTypeBProgram() {
99100
return new VideoProgramTypeBView(getContext());
100101
}
101102

102-
private VideoProgramView createDesktopProgram(){
103-
return new VideoProgramView(getContext());
103+
private VideoProgramView createDesktopProgram() {
104+
return new VideoProgramView(getContext());
104105
}
105106

106107
/**
@@ -119,9 +120,9 @@ public void clearAllVisionProgram() {
119120
* @param msg
120121
* @param needRetry
121122
*/
122-
public void showExceptionLogic(String msg, boolean needRetry,String data) {
123+
public void showExceptionLogic(String msg, boolean needRetry, String data) {
123124
if (programViewB != null) {
124-
programViewB.showExceptionLogic(msg, needRetry,data);
125+
programViewB.showExceptionLogic(msg, needRetry, data);
125126
}
126127

127128
}
@@ -169,9 +170,7 @@ public void setVideoOSAdapter(VideoPlusAdapter adapter) {
169170
if (programViewB != null) {
170171
programViewB.setVideoOSAdapter(adapter);
171172
}
172-
if(programViewDesktop != null){
173-
programViewDesktop.setVideoOSAdapter(adapter);
174-
}
173+
this.adapter = adapter;
175174
}
176175

177176
public void start() {
@@ -220,8 +219,16 @@ public void launchH5VisionProgram(String url) {
220219
}
221220

222221

223-
public void launchDesktopProgram(String targetName){
224-
if(programViewDesktop != null && !TextUtils.isEmpty(targetName)) {
222+
public void launchDesktopProgram(String targetName) {
223+
// 桌面存在则不需要重复加载桌面
224+
if(programViewDesktop != null) return;
225+
226+
programViewDesktop = createDesktopProgram();
227+
if(adapter != null){
228+
programViewDesktop.setVideoOSAdapter(adapter);
229+
}
230+
addView(programViewDesktop);
231+
if (!TextUtils.isEmpty(targetName)) {
225232
programViewDesktop.setVisibility(VISIBLE);
226233
Uri uri = Uri.parse("LuaView://desktopLuaView?template=" + targetName + "&id=" + targetName.substring(0, targetName.lastIndexOf(".")));
227234
programViewDesktop.navigation(uri, new HashMap<String, String>(), null);
@@ -265,11 +272,21 @@ public void stopService(ServiceType serviceType) {
265272
programViewA.stopService(serviceType);
266273
}
267274

268-
if(serviceType == ServiceType.ServiceTypeVideoMode){
269-
// 如果是关闭视联网模式,则隐藏视联网桌面
270-
if(programViewDesktop != null){
275+
if (serviceType == ServiceType.ServiceTypeVideoMode) {
276+
// 如果是关闭视联网模式,则移除视联网桌面
277+
if (programViewDesktop != null) {
271278
programViewDesktop.setVisibility(GONE);
279+
removeView(programViewDesktop);
280+
programViewDesktop = null;
272281
}
273282
}
274283
}
284+
285+
/**
286+
* 开发者模式开关
287+
* @param isDevMode
288+
*/
289+
public void setDevMode(boolean isDevMode){
290+
App.setIsDevMode(isDevMode);
291+
}
275292
}

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)