Commit 0d19e527 0d19e52783a0764ff4babf0d5c14f8571b77b4f0 by 胡波

新增烽火盒子stb协议

1 parent 42a1199e
Showing 21 changed files with 357 additions and 15 deletions
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
4 <selectionStates> 4 <selectionStates>
5 <SelectionState runConfigName="app"> 5 <SelectionState runConfigName="app">
6 <option name="selectionMode" value="DROPDOWN" /> 6 <option name="selectionMode" value="DROPDOWN" />
7 <DropdownSelection timestamp="2024-10-12T05:40:06.328823Z">
8 <Target type="DEFAULT_BOOT">
9 <handle>
10 <DeviceId pluginId="Default" identifier="serial=0123456789;connection=725ee2fc" />
11 </handle>
12 </Target>
13 </DropdownSelection>
14 <DialogSelection />
7 </SelectionState> 15 </SelectionState>
8 </selectionStates> 16 </selectionStates>
9 </component> 17 </component>
......
...@@ -8,7 +8,7 @@ android { ...@@ -8,7 +8,7 @@ android {
8 8
9 defaultConfig { 9 defaultConfig {
10 applicationId "com.topdraw.iptvlaunchertest" 10 applicationId "com.topdraw.iptvlaunchertest"
11 minSdk 21 11 minSdk 19
12 targetSdk 34 12 targetSdk 34
13 versionCode 1 13 versionCode 1
14 versionName "1.0" 14 versionName "1.0"
...@@ -30,6 +30,7 @@ android { ...@@ -30,6 +30,7 @@ android {
30 buildFeatures{ 30 buildFeatures{
31 buildConfig true 31 buildConfig true
32 } 32 }
33
33 flavorDimensions 'APP' 34 flavorDimensions 'APP'
34 productFlavors{ 35 productFlavors{
35 chongqing{ 36 chongqing{
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
4 4
5 <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> 5 <uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
6 <uses-permission android:name="android.permission.DELETE_PACKAGES"/> 6 <uses-permission android:name="android.permission.DELETE_PACKAGES"/>
7 <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
7 <uses-permission android:name="android.permission.INTERNET"/> 8 <uses-permission android:name="android.permission.INTERNET"/>
9 <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
8 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 10 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
9 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 11 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
10 12
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest;
2 2
3 import android.Manifest; 3 import android.Manifest;
4 import android.content.pm.PermissionInfo;
5 import android.os.Build; 4 import android.os.Build;
6 import android.os.Bundle; 5 import android.os.Bundle;
7 import android.webkit.WebSettings; 6 import android.webkit.WebSettings;
...@@ -13,11 +12,9 @@ import androidx.core.graphics.Insets; ...@@ -13,11 +12,9 @@ import androidx.core.graphics.Insets;
13 import androidx.core.view.ViewCompat; 12 import androidx.core.view.ViewCompat;
14 import androidx.core.view.WindowInsetsCompat; 13 import androidx.core.view.WindowInsetsCompat;
15 14
16 import java.security.acl.Permission;
17
18 public class MainActivity extends AppCompatActivity { 15 public class MainActivity extends AppCompatActivity {
19 private WebView webView; 16 private WebView webView;
20 private STBAppManager stbAppManager; 17
21 private String[] permissions = new String[]{ 18 private String[] permissions = new String[]{
22 Manifest.permission.WRITE_EXTERNAL_STORAGE, 19 Manifest.permission.WRITE_EXTERNAL_STORAGE,
23 Manifest.permission.READ_EXTERNAL_STORAGE, 20 Manifest.permission.READ_EXTERNAL_STORAGE,
...@@ -52,8 +49,12 @@ public class MainActivity extends AppCompatActivity { ...@@ -52,8 +49,12 @@ public class MainActivity extends AppCompatActivity {
52 settings.setAllowUniversalAccessFromFileURLs(true); 49 settings.setAllowUniversalAccessFromFileURLs(true);
53 } 50 }
54 51
52 //注册接口
55 private void initObject(){ 53 private void initObject(){
56 this.stbAppManager = new STBAppManager(this); 54 if(TestConfig.testDist==TestConfig.Skyworth){
57 webView.addJavascriptInterface(this.stbAppManager,"STBAppManager"); 55 webView.addJavascriptInterface(new com.topdraw.iptvlaunchertest.sky.STBAppManager(this),"STBAppManager");
56 }else if(TestConfig.testDist==TestConfig.FiberHome){
57 webView.addJavascriptInterface(new com.topdraw.iptvlaunchertest.fh.STBAppManager(this),"STBAppManager");
58 }
58 } 59 }
59 } 60 }
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.topdraw.iptvlaunchertest;
2
3 public class TestConfig {
4 //创维盒子
5 public static final int Skyworth = 0;
6 //烽火盒子
7 public static final int FiberHome = 1;
8
9 public static int testDist = FiberHome;
10 }
1 package com.topdraw.iptvlaunchertest.fh;
2
3 import android.content.Context;
4 import android.content.pm.PackageInfo;
5 import android.text.TextUtils;
6 import android.util.Log;
7
8 public class FHActivityUtil {
9 public static String parseAppFile(Context context, String appName) {
10 String pkgName = null;
11 Log.d("FHActivityUtil", "parseAppFile appName = " + appName);
12 if((TextUtils.isEmpty(appName)) || context == null) {
13 return null;
14 }
15
16 try {
17 PackageInfo pkgInfo = context.getPackageManager().getPackageArchiveInfo(appName, 0);
18 if(pkgInfo != null) {
19 pkgName = pkgInfo.packageName;
20 }
21
22 Log.d("FHActivityUtil", "parseAppFile pkgName = " + pkgName);
23 }
24 catch(Exception e) {
25 e.printStackTrace();
26 }
27
28 return pkgName;
29 }
30 }
1 package com.topdraw.iptvlaunchertest.fh;
2
3 import android.os.Bundle;
4 import android.text.TextUtils;
5 import android.util.Log;
6
7 import org.json.JSONArray;
8 import org.json.JSONObject;
9
10 import java.util.HashMap;
11 import java.util.Iterator;
12 import java.util.Map;
13
14 /**
15 * 烽火盒子启动参数解析工具
16 */
17 public class FHJsonUtil {
18 private static final String TAG = "FHJsonUtil";
19
20 public static JSONArray getArray(String str) {
21 JSONArray jSONArray = null;
22 if (TextUtils.isEmpty(str)) {
23 Log.d(TAG, "getArray arrStr is null.");
24 jSONArray = null;
25 } else {
26 try {
27 jSONArray = new JSONArray(str);
28 } catch (Exception e) {
29 }
30 }
31 return jSONArray;
32 }
33
34 public static JSONArray getArrayParam(JSONObject jSONObject, String str) {
35 JSONArray jSONArray = null;
36 if (jSONObject == null || TextUtils.isEmpty(str)) {
37 Log.d(TAG, "getArrayParam jsonObj/name is null.");
38 jSONArray = null;
39 } else {
40 try {
41 jSONArray = jSONObject.getJSONArray(str);
42 } catch (Exception e) {
43 }
44 }
45 return jSONArray;
46 }
47
48 public static int getIntParam(JSONObject jSONObject, String str) {
49 int i = -1;
50 if (jSONObject == null || TextUtils.isEmpty(str)) {
51 Log.d(TAG, "getIntParam jsonObj/name is null.");
52 i = -1;
53 } else {
54 try {
55 i = jSONObject.getInt(str);
56 } catch (Exception e) {
57 }
58 Log.d(TAG, "getIntParam name = " + str + ", value = " + i);
59 }
60 return i;
61 }
62
63 public static int getIntParamFromString(String str, String str2) {
64 int i = -1;
65 if (TextUtils.isEmpty(str2)) {
66 Log.d(TAG, "getIntParamFromString name is null.");
67 i = -1;
68 } else {
69 JSONObject jsonObj = getJsonObj(str);
70 if (jsonObj == null) {
71 Log.d(TAG, "getIntParamFromString jsonObj null.");
72 i = -1;
73 } else {
74 try {
75 i = jsonObj.getInt(str2);
76 } catch (Exception e) {
77 }
78 Log.d(TAG, "getIntParamFromString name = " + str2 + ", value = " + i);
79 }
80 }
81 return i;
82 }
83
84 public static JSONObject getJsonObj(String str) {
85 JSONObject jSONObject;
86 if (TextUtils.isEmpty(str)) {
87 Log.d(TAG, "getJsonObj jsonStr is null.");
88 jSONObject = null;
89 } else {
90 try {
91 jSONObject = new JSONObject(str);
92 } catch (Exception e) {
93 jSONObject = null;
94 }
95 }
96 return jSONObject;
97 }
98
99 public static JSONObject getJsonObjFromArray(JSONArray jSONArray, int i) {
100 JSONObject jSONObject = null;
101 if (jSONArray == null) {
102 Log.d(TAG, "getJsonObjFromArray jsonArray is null.");
103 jSONObject = null;
104 } else {
105 try {
106 jSONObject = jSONArray.getJSONObject(i);
107 } catch (Exception e) {
108 }
109 }
110 return jSONObject;
111 }
112
113 public static JSONObject getJsonObjFromString(String str, int i) {
114 JSONObject jSONObject = null;
115 if (TextUtils.isEmpty(str)) {
116 Log.d(TAG, "getJsonObjFromString jsonStr is null.");
117 jSONObject = null;
118 } else {
119 try {
120 jSONObject = new JSONArray(str).getJSONObject(i);
121 } catch (Exception e) {
122 }
123 }
124 return jSONObject;
125 }
126
127 public static String getStrParam(JSONObject jSONObject, String str) {
128 String str2;
129 if (jSONObject == null || TextUtils.isEmpty(str)) {
130 Log.d(TAG, "getStrParam jsonObj/name is null.");
131 str2 = "";
132 } else {
133 str2 = "";
134 try {
135 if (jSONObject.has(str)) {
136 str2 = jSONObject.getString(str);
137 }
138 } catch (Exception e) {
139 str2 = "";
140 }
141 Log.d(TAG, "getStrParam value = " + str2);
142 }
143 return str2;
144 }
145
146 public static String getStrParamFromString(String str, String str2) {
147 String str3;
148 if (TextUtils.isEmpty(str2)) {
149 Log.d(TAG, "getStrParamFromString name is null.");
150 str3 = "";
151 } else {
152 JSONObject jsonObj = getJsonObj(str);
153 if (jsonObj == null) {
154 Log.d(TAG, "getStrParamFromString jsonObj is null.");
155 str3 = "";
156 } else {
157 str3 = "";
158 try {
159 if (jsonObj.has(str2)) {
160 str3 = jsonObj.getString(str2);
161 }
162 } catch (Exception e) {
163 str3 = "";
164 }
165 Log.d(TAG, "getStrParamFromString value = " + str3);
166 }
167 }
168 return str3;
169 }
170
171 public static Bundle jsonStringToBundle(String str) {
172 Bundle bundle = new Bundle();
173 if (TextUtils.isEmpty(str)) {
174 Log.d(TAG, "jsonStringToBundle jsonStr is null.");
175 } else {
176 try {
177 JSONObject jSONObject = new JSONObject(str);
178 Iterator<String> keys = jSONObject.keys();
179 while (keys.hasNext()) {
180 String next = keys.next();
181 Object obj = jSONObject.get(next);
182 if (obj instanceof Integer) {
183 bundle.putInt(next, ((Integer) obj).intValue());
184 } else if (obj instanceof Long) {
185 bundle.putLong(next, ((Long) obj).longValue());
186 } else if (obj instanceof Double) {
187 bundle.putDouble(next, ((Double) obj).doubleValue());
188 } else if (obj instanceof String) {
189 bundle.putString(next, (String) obj);
190 }
191 }
192 } catch (Exception e) {
193 e.printStackTrace();
194 }
195 }
196 return bundle;
197 }
198
199 public static Map jsonToMap(String str) {
200 HashMap hashMap = new HashMap();
201 if (TextUtils.isEmpty(str)) {
202 Log.d(TAG, "jsonToMap jsonString is null.");
203 } else {
204 try {
205 JSONObject jSONObject = new JSONObject(str);
206 Iterator<String> keys = jSONObject.keys();
207 while (keys.hasNext()) {
208 String next = keys.next();
209 if (!TextUtils.isEmpty(next)) {
210 hashMap.put(next, jSONObject.getString(next));
211 }
212 }
213 } catch (Exception e) {
214 }
215 }
216 return hashMap;
217 }
218
219 public static void putStrParam(JSONObject jSONObject, String str, String str2) {
220 if (jSONObject == null || TextUtils.isEmpty(str)) {
221 Log.d(TAG, "putStrParam jsonObj/name is null.");
222 return;
223 }
224 try {
225 jSONObject.put(str, str2);
226 } catch (Exception e) {
227 }
228 }
229 }
1 package com.topdraw.iptvlaunchertest.fh;
2
3 public interface IDownLoadListener {
4 void OnDownloadStateChange(int i, String str, int i2);
5 }
1 package com.topdraw.iptvlaunchertest.fh;
2
3 public interface IProgressDialogListener {
4 void onDialogProgressChange(long j);
5
6 void onDismissProgressDialog();
7
8 void onShowProgressDialog(String str, long j);
9 }
1 package com.topdraw.iptvlaunchertest.fh;
2
3 public class Util {
4 public static String byte2Hex(byte[] bArr) {
5 String str;
6 String str2 = "";
7 if (bArr == null || bArr.length == 0) {
8 str = null;
9 } else {
10 for (int i = 0; i < bArr.length; i++) {
11 String hexString = Integer.toHexString(bArr[i] & 255);
12 String str3 = hexString.length() == 1 ? str2 + "0" + hexString : str2 + hexString;
13 str2 = str3;
14 if (i < bArr.length - 1) {
15 str2 = str3 + "";
16 }
17 }
18 str = str2.toUpperCase();
19 }
20 return str;
21 }
22
23 public static String strLeftPad(String str, int i, char c) {
24 String str2;
25 if (str == null) {
26 str2 = null;
27 } else {
28 int length = i - str.length();
29 str2 = str;
30 if (length > 0) {
31 char[] cArr = new char[length];
32 for (int i2 = 0; i2 < cArr.length; i2++) {
33 cArr[i2] = c;
34 }
35 str2 = new String(cArr).concat(str);
36 }
37 }
38 return str2;
39 }
40 }
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.content.pm.PackageInfo; 4 import android.content.pm.PackageInfo;
5 import android.content.pm.PackageManager; 5 import android.content.pm.PackageManager;
6 import android.os.Build; 6 import android.os.Build;
7 import android.util.Log; 7 import android.util.Log;
8
9 import com.topdraw.iptvlaunchertest.App;
10 import com.topdraw.iptvlaunchertest.BuildConfig;
11
8 import java.io.BufferedReader; 12 import java.io.BufferedReader;
9 import java.io.IOException; 13 import java.io.IOException;
10 import java.io.InputStream; 14 import java.io.InputStream;
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.annotation.TargetApi; 3 import android.annotation.TargetApi;
4 import android.app.PendingIntent; 4 import android.app.PendingIntent;
5 import android.content.Intent; 5 import android.content.Intent;
6 import android.content.pm.PackageInstaller; 6 import android.content.pm.PackageInstaller;
7
8 import com.topdraw.iptvlaunchertest.App;
9
7 import java.io.File; 10 import java.io.File;
8 import java.io.FileInputStream; 11 import java.io.FileInputStream;
9 import java.io.IOException; 12 import java.io.IOException;
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 import java.io.Closeable; 2 import java.io.Closeable;
3 import java.io.IOException; 3 import java.io.IOException;
4 4
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.util.Log; 3 import android.util.Log;
4 4
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.content.BroadcastReceiver; 3 import android.content.BroadcastReceiver;
4 import android.content.Context; 4 import android.content.Context;
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.content.Intent; 4 import android.content.Intent;
......
1 package com.topdraw.iptvlaunchertest; 1 package com.topdraw.iptvlaunchertest.sky;
2 2
3 import android.os.Handler; 3 import android.os.Handler;
4 import android.os.Looper; 4 import android.os.Looper;
......
...@@ -3,7 +3,7 @@ agp = "8.6.1" ...@@ -3,7 +3,7 @@ agp = "8.6.1"
3 junit = "4.13.2" 3 junit = "4.13.2"
4 junitVersion = "1.2.1" 4 junitVersion = "1.2.1"
5 espressoCore = "3.6.1" 5 espressoCore = "3.6.1"
6 appcompat = "1.7.0" 6 appcompat = "1.2.0"
7 material = "1.12.0" 7 material = "1.12.0"
8 activity = "1.9.1" 8 activity = "1.9.1"
9 constraintlayout = "2.1.4" 9 constraintlayout = "2.1.4"
......