fix 修复PK过程中挂后台导致摄像头关闭问题

This commit is contained in:
2023-09-25 09:54:39 +08:00
parent 4b3b47b65f
commit b40abb9bc0
5 changed files with 79 additions and 21 deletions

View File

@@ -158,7 +158,7 @@ public class LogUtil {
public static void shareFile(Context context) {
try {
/* try {
IMLoginModel bean = IMLoginManager.get(context).getUserInfo();
boolean isAnchor=false;
if(bean!=null){
@@ -170,7 +170,7 @@ public class LogUtil {
}
} catch (Exception e) {
return;
}
}*/
/* if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
return;

View File

@@ -49,17 +49,17 @@ public class PluginManager {
}
public boolean isDownloadApk() {
if(!CommonAppConfig.IS_PLUGIN_MODEL){
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
return true;
}
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk").exists();
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists();
}
/**
* 加载主播插件
*/
public void loadAnchorPlugin(DialogInterface.OnDismissListener dismissListener) {
if(!CommonAppConfig.IS_PLUGIN_MODEL){
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
dismissListener.onDismiss(null);
return;
}
@@ -73,7 +73,8 @@ public class PluginManager {
e.printStackTrace();
}
File sdk = new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk");
if (!sdk.exists()) {
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists() || !sdk.exists()) {
Log.i(TAG, "loadAnchorPlugin: 插件未下载");
if (StringUtil.isEmpty(anchorPluginDownloadUrl)) {
Log.e(TAG, "主播下载地址为空");
return;
@@ -97,8 +98,12 @@ public class PluginManager {
* @param outDir 解压路径
*/
private void loadFaceSo(File plugin, String outDir) {
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"lib").exists()) {
unzip(plugin.getAbsolutePath(), outDir, ".so");
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").exists()) {
Log.i(TAG, "loadFaceSo: lib插件未解压");
if (unzip(plugin.getAbsolutePath(), outDir, ".so")) {
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").mkdirs();
Log.i(TAG, "loadFaceSo: lib插件解压");
}
}
String[] abis = Build.SUPPORTED_ABIS;
String abi = Arrays.asList(abis).contains("arm64-v8a") ? "arm64-v8a" : "armeabi-v7a";
@@ -108,8 +113,8 @@ public class PluginManager {
try {
Field field = Class.forName("com.faceunity.wrapper.faceunity$LoadConfig").getDeclaredField("sLoadedLibrary");
field.setAccessible(true);
field.set(null,true);
}catch (Exception e){
field.set(null, true);
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -121,8 +126,12 @@ public class PluginManager {
* @param outDir 解压路径
*/
private void loadFaceBundle(File plugin, String outDir) {
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"assets").exists()) {
unzip(plugin.getAbsolutePath(), outDir, ".bundle");
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").exists()) {
Log.i(TAG, "loadFaceBundle: bundle未解压");
if (unzip(plugin.getAbsolutePath(), outDir, ".bundle")) {
Log.i(TAG, "loadFaceBundle: bundle解压");
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").mkdirs();
}
}
try {
Object BUNDLE_AI_FACE = Class.forName("com.yunbao.faceunity.utils.FURenderer").getField("BUNDLE_AI_FACE").get(null);
@@ -131,6 +140,7 @@ public class PluginManager {
Class.forName("com.yunbao.faceunity.utils.FaceUnityConfig").getField("BUNDLE_FACE_BEAUTIFICATION").set(null, outDir + File.separator + "assets" + File.separator + BUNDLE_FACE_BEAUTIFICATION);
} catch (Exception e) {
e.printStackTrace();
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").delete();
}
}
@@ -148,6 +158,7 @@ public class PluginManager {
Log.d(TAG, "加载成功 " + dir + File.separator + file);
} else {
Log.e(TAG, "不存在 " + dir + File.separator + file);
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").delete();
}
}
@@ -160,6 +171,7 @@ public class PluginManager {
@Override
public void onSuccess(File file) {
Log.d(TAG, "下载成功 " + file);
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").mkdirs();
loadAnchorPlugin(dismissListener);
}
@@ -170,7 +182,7 @@ public class PluginManager {
@Override
public void onError(Throwable e) {
downloadAnchorSdk(dismissListener);
}
});
}
@@ -187,13 +199,14 @@ public class PluginManager {
FileOutputStream out;
byte buffer[] = new byte[1024];
try {
Log.i(TAG, "unzip: " + outDir);
ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
ZipEntry entry = zis.getNextEntry();
while (entry != null) {
String name = entry.getName();
if (entry.isDirectory()) {
File newDir = new File(outDir + entry.getName());
newDir.mkdir();
newDir.mkdirs();
} else if (name.endsWith(suffix)) {
File outputFile = new File(outDir + File.separator + name);
String outputPath = outputFile.getCanonicalPath();
@@ -206,7 +219,7 @@ public class PluginManager {
outputFile = new File(outputPath, name);
outputFile.createNewFile();
out = new FileOutputStream(outputFile);
Log.i(TAG, "unzip: >>" + outputFile.getAbsolutePath());
int tmp = 0;
while ((tmp = zis.read(buffer)) > 0) {
out.write(buffer, 0, tmp);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 22 KiB