Commit 0d19e527 0d19e52783a0764ff4babf0d5c14f8571b77b4f0 by 胡波

新增烽火盒子stb协议

1 parent 42a1199e
Showing 21 changed files with 357 additions and 15 deletions
......@@ -4,6 +4,14 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-10-12T05:40:06.328823Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="Default" identifier="serial=0123456789;connection=725ee2fc" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
......
......@@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.topdraw.iptvlaunchertest"
minSdk 21
minSdk 19
targetSdk 34
versionCode 1
versionName "1.0"
......@@ -30,6 +30,7 @@ android {
buildFeatures{
buildConfig true
}
flavorDimensions 'APP'
productFlavors{
chongqing{
......
......@@ -4,7 +4,9 @@
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
......
package com.topdraw.iptvlaunchertest;
import android.Manifest;
import android.content.pm.PermissionInfo;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebSettings;
......@@ -13,11 +12,9 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.security.acl.Permission;
public class MainActivity extends AppCompatActivity {
private WebView webView;
private STBAppManager stbAppManager;
private String[] permissions = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
......@@ -52,8 +49,12 @@ public class MainActivity extends AppCompatActivity {
settings.setAllowUniversalAccessFromFileURLs(true);
}
//注册接口
private void initObject(){
this.stbAppManager = new STBAppManager(this);
webView.addJavascriptInterface(this.stbAppManager,"STBAppManager");
if(TestConfig.testDist==TestConfig.Skyworth){
webView.addJavascriptInterface(new com.topdraw.iptvlaunchertest.sky.STBAppManager(this),"STBAppManager");
}else if(TestConfig.testDist==TestConfig.FiberHome){
webView.addJavascriptInterface(new com.topdraw.iptvlaunchertest.fh.STBAppManager(this),"STBAppManager");
}
}
}
\ No newline at end of file
......
package com.topdraw.iptvlaunchertest;
public class TestConfig {
//创维盒子
public static final int Skyworth = 0;
//烽火盒子
public static final int FiberHome = 1;
public static int testDist = FiberHome;
}
package com.topdraw.iptvlaunchertest.fh;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.text.TextUtils;
import android.util.Log;
public class FHActivityUtil {
public static String parseAppFile(Context context, String appName) {
String pkgName = null;
Log.d("FHActivityUtil", "parseAppFile appName = " + appName);
if((TextUtils.isEmpty(appName)) || context == null) {
return null;
}
try {
PackageInfo pkgInfo = context.getPackageManager().getPackageArchiveInfo(appName, 0);
if(pkgInfo != null) {
pkgName = pkgInfo.packageName;
}
Log.d("FHActivityUtil", "parseAppFile pkgName = " + pkgName);
}
catch(Exception e) {
e.printStackTrace();
}
return pkgName;
}
}
package com.topdraw.iptvlaunchertest.fh;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* 烽火盒子启动参数解析工具
*/
public class FHJsonUtil {
private static final String TAG = "FHJsonUtil";
public static JSONArray getArray(String str) {
JSONArray jSONArray = null;
if (TextUtils.isEmpty(str)) {
Log.d(TAG, "getArray arrStr is null.");
jSONArray = null;
} else {
try {
jSONArray = new JSONArray(str);
} catch (Exception e) {
}
}
return jSONArray;
}
public static JSONArray getArrayParam(JSONObject jSONObject, String str) {
JSONArray jSONArray = null;
if (jSONObject == null || TextUtils.isEmpty(str)) {
Log.d(TAG, "getArrayParam jsonObj/name is null.");
jSONArray = null;
} else {
try {
jSONArray = jSONObject.getJSONArray(str);
} catch (Exception e) {
}
}
return jSONArray;
}
public static int getIntParam(JSONObject jSONObject, String str) {
int i = -1;
if (jSONObject == null || TextUtils.isEmpty(str)) {
Log.d(TAG, "getIntParam jsonObj/name is null.");
i = -1;
} else {
try {
i = jSONObject.getInt(str);
} catch (Exception e) {
}
Log.d(TAG, "getIntParam name = " + str + ", value = " + i);
}
return i;
}
public static int getIntParamFromString(String str, String str2) {
int i = -1;
if (TextUtils.isEmpty(str2)) {
Log.d(TAG, "getIntParamFromString name is null.");
i = -1;
} else {
JSONObject jsonObj = getJsonObj(str);
if (jsonObj == null) {
Log.d(TAG, "getIntParamFromString jsonObj null.");
i = -1;
} else {
try {
i = jsonObj.getInt(str2);
} catch (Exception e) {
}
Log.d(TAG, "getIntParamFromString name = " + str2 + ", value = " + i);
}
}
return i;
}
public static JSONObject getJsonObj(String str) {
JSONObject jSONObject;
if (TextUtils.isEmpty(str)) {
Log.d(TAG, "getJsonObj jsonStr is null.");
jSONObject = null;
} else {
try {
jSONObject = new JSONObject(str);
} catch (Exception e) {
jSONObject = null;
}
}
return jSONObject;
}
public static JSONObject getJsonObjFromArray(JSONArray jSONArray, int i) {
JSONObject jSONObject = null;
if (jSONArray == null) {
Log.d(TAG, "getJsonObjFromArray jsonArray is null.");
jSONObject = null;
} else {
try {
jSONObject = jSONArray.getJSONObject(i);
} catch (Exception e) {
}
}
return jSONObject;
}
public static JSONObject getJsonObjFromString(String str, int i) {
JSONObject jSONObject = null;
if (TextUtils.isEmpty(str)) {
Log.d(TAG, "getJsonObjFromString jsonStr is null.");
jSONObject = null;
} else {
try {
jSONObject = new JSONArray(str).getJSONObject(i);
} catch (Exception e) {
}
}
return jSONObject;
}
public static String getStrParam(JSONObject jSONObject, String str) {
String str2;
if (jSONObject == null || TextUtils.isEmpty(str)) {
Log.d(TAG, "getStrParam jsonObj/name is null.");
str2 = "";
} else {
str2 = "";
try {
if (jSONObject.has(str)) {
str2 = jSONObject.getString(str);
}
} catch (Exception e) {
str2 = "";
}
Log.d(TAG, "getStrParam value = " + str2);
}
return str2;
}
public static String getStrParamFromString(String str, String str2) {
String str3;
if (TextUtils.isEmpty(str2)) {
Log.d(TAG, "getStrParamFromString name is null.");
str3 = "";
} else {
JSONObject jsonObj = getJsonObj(str);
if (jsonObj == null) {
Log.d(TAG, "getStrParamFromString jsonObj is null.");
str3 = "";
} else {
str3 = "";
try {
if (jsonObj.has(str2)) {
str3 = jsonObj.getString(str2);
}
} catch (Exception e) {
str3 = "";
}
Log.d(TAG, "getStrParamFromString value = " + str3);
}
}
return str3;
}
public static Bundle jsonStringToBundle(String str) {
Bundle bundle = new Bundle();
if (TextUtils.isEmpty(str)) {
Log.d(TAG, "jsonStringToBundle jsonStr is null.");
} else {
try {
JSONObject jSONObject = new JSONObject(str);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
Object obj = jSONObject.get(next);
if (obj instanceof Integer) {
bundle.putInt(next, ((Integer) obj).intValue());
} else if (obj instanceof Long) {
bundle.putLong(next, ((Long) obj).longValue());
} else if (obj instanceof Double) {
bundle.putDouble(next, ((Double) obj).doubleValue());
} else if (obj instanceof String) {
bundle.putString(next, (String) obj);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return bundle;
}
public static Map jsonToMap(String str) {
HashMap hashMap = new HashMap();
if (TextUtils.isEmpty(str)) {
Log.d(TAG, "jsonToMap jsonString is null.");
} else {
try {
JSONObject jSONObject = new JSONObject(str);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
if (!TextUtils.isEmpty(next)) {
hashMap.put(next, jSONObject.getString(next));
}
}
} catch (Exception e) {
}
}
return hashMap;
}
public static void putStrParam(JSONObject jSONObject, String str, String str2) {
if (jSONObject == null || TextUtils.isEmpty(str)) {
Log.d(TAG, "putStrParam jsonObj/name is null.");
return;
}
try {
jSONObject.put(str, str2);
} catch (Exception e) {
}
}
}
package com.topdraw.iptvlaunchertest.fh;
public interface IDownLoadListener {
void OnDownloadStateChange(int i, String str, int i2);
}
package com.topdraw.iptvlaunchertest.fh;
public interface IProgressDialogListener {
void onDialogProgressChange(long j);
void onDismissProgressDialog();
void onShowProgressDialog(String str, long j);
}
package com.topdraw.iptvlaunchertest.fh;
public class Util {
public static String byte2Hex(byte[] bArr) {
String str;
String str2 = "";
if (bArr == null || bArr.length == 0) {
str = null;
} else {
for (int i = 0; i < bArr.length; i++) {
String hexString = Integer.toHexString(bArr[i] & 255);
String str3 = hexString.length() == 1 ? str2 + "0" + hexString : str2 + hexString;
str2 = str3;
if (i < bArr.length - 1) {
str2 = str3 + "";
}
}
str = str2.toUpperCase();
}
return str;
}
public static String strLeftPad(String str, int i, char c) {
String str2;
if (str == null) {
str2 = null;
} else {
int length = i - str.length();
str2 = str;
if (length > 0) {
char[] cArr = new char[length];
for (int i2 = 0; i2 < cArr.length; i2++) {
cArr[i2] = c;
}
str2 = new String(cArr).concat(str);
}
}
return str2;
}
}
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import com.topdraw.iptvlaunchertest.App;
import com.topdraw.iptvlaunchertest.BuildConfig;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.pm.PackageInstaller;
import com.topdraw.iptvlaunchertest.App;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import java.io.Closeable;
import java.io.IOException;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.util.Log;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.content.BroadcastReceiver;
import android.content.Context;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.content.Context;
import android.content.Intent;
......
package com.topdraw.iptvlaunchertest;
package com.topdraw.iptvlaunchertest.sky;
import android.os.Handler;
import android.os.Looper;
......
......@@ -3,7 +3,7 @@ agp = "8.6.1"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
appcompat = "1.7.0"
appcompat = "1.2.0"
material = "1.12.0"
activity = "1.9.1"
constraintlayout = "2.1.4"
......