1、相心美颜So文件静默加载增加下载失败、解压失败重试机制和多次失败后的提示
This commit is contained in:
parent
e69796e158
commit
2e84e799d4
@ -186,19 +186,17 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
//解压后的文件数量必须要有2个
|
||||
//如果文件存在,解压后 文件数量一致,直接进入下一步
|
||||
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 2){
|
||||
MainActivity.faceSDKIsLoadSuceness = true;
|
||||
CommonAppConfig.faceSDKIsLoadSuceness = true;
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
return;
|
||||
}
|
||||
// https://downs.yaoulive.com/androidLibs/t3/faceunity2-so-arm64-v8a.zip
|
||||
String soUrl = String.format("https://downs.yaoulive.com/androidLibs/t3/faceunity2-so-%s.zip", cpuAbi);
|
||||
Log.i("download", soUrl);
|
||||
|
||||
downLoadFaceSDK_OutputDir = outputDir.getAbsolutePath();
|
||||
if (!fileSo.exists()) {
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
|
||||
downloadSo(downLoadFaceSDK_OutputDir, downLoadFaceSDK_downloadUrl,Constants.FaceUnity_SO_Name,false);
|
||||
}else if (fileSo.exists() && getFileCount(outputDir.getAbsolutePath()) < 3) {
|
||||
fileSo.delete();
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
|
||||
downloadSo(outputDir.getAbsolutePath(), downLoadFaceSDK_downloadUrl,Constants.FaceUnity_SO_Name,false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,9 +242,13 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
}
|
||||
}
|
||||
|
||||
Dialog progressDialog;
|
||||
private Dialog progressDialog;
|
||||
public ProgressBar progressBar;
|
||||
public TextView tvProgress;
|
||||
private int downLoadFaceSDKCount = 0;
|
||||
private int unZipFaceSDKCount = 0;
|
||||
private String downLoadFaceSDK_OutputDir;
|
||||
private String downLoadFaceSDK_downloadUrl = String.format("https://downs.yaoulive.com/androidLibs/t3/faceunity2-so-%s.zip", Build.CPU_ABI);
|
||||
|
||||
private void showDialog(Activity context) {
|
||||
progressDialog = new Dialog(context, com.yunbao.common.R.style.dialog);
|
||||
@ -268,6 +270,9 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void downloadSo(String outputDir, String downloadUrl,String fileName,boolean isShowDialog) {
|
||||
DownloadUtil downloadUtil = new DownloadUtil();
|
||||
if(isShowDialog){
|
||||
@ -280,17 +285,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
progressDialog.dismiss();
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 20);
|
||||
}
|
||||
File fileSo = new File(outputDir, fileName);
|
||||
try {
|
||||
unzip(fileSo.getAbsolutePath(), outputDir);
|
||||
MainActivity.faceSDKIsLoadSuceness = true;
|
||||
if (BuildConfig.DEBUG){
|
||||
ToastUtil.showDebug("美颜SDK加载成功...");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("ZipCheck", "Error reading ZIP file", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
unZipFaceSDK(outputDir, fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -304,12 +299,36 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
//资源下载失败
|
||||
|
||||
downLoadFaceSDKCount++;
|
||||
if (downLoadFaceSDKCount < 3) {
|
||||
downloadSo(downLoadFaceSDK_OutputDir, downLoadFaceSDK_downloadUrl,Constants.FaceUnity_SO_Name,false);
|
||||
} else {
|
||||
CommonAppConfig.faceSDKDownLoadOrUnZipFailed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void unZipFaceSDK(String outputDir, String fileName) {
|
||||
File fileSo = new File(outputDir, fileName);
|
||||
try {
|
||||
unzip(fileSo.getAbsolutePath(), outputDir);
|
||||
} catch (Exception e) {
|
||||
Log.e("ZipCheck", "Error reading ZIP file", e);
|
||||
unZipFaceSDKCount++;
|
||||
if (unZipFaceSDKCount < 3) {
|
||||
unZipFaceSDK(outputDir, fileName);
|
||||
} else {
|
||||
CommonAppConfig.faceSDKDownLoadOrUnZipFailed = true;
|
||||
}
|
||||
}
|
||||
CommonAppConfig.faceSDKIsLoadSuceness = true;
|
||||
if (BuildConfig.DEBUG){
|
||||
ToastUtil.showDebug("美颜SDK加载成功...");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压 .zip 文件到目标目录
|
||||
*/
|
||||
|
@ -145,6 +145,10 @@ public class CommonAppConfig {
|
||||
private int mAppIconRes;
|
||||
private String mAppName;
|
||||
private Boolean mTiBeautyEnable;//是否使用萌颜 true使用萌颜 false 使用基础美颜
|
||||
// 美颜SDK是否已经加载成功
|
||||
public static boolean faceSDKIsLoadSuceness;
|
||||
// 美颜SDK是否下载失败或者解压失败(自动试3次)
|
||||
public static boolean faceSDKDownLoadOrUnZipFailed = false;
|
||||
|
||||
public String getUid() {
|
||||
if (TextUtils.isEmpty(mUid)) {
|
||||
|
@ -827,6 +827,7 @@
|
||||
|
||||
<string name="only_open_anchor">暫時只對主播開放</string>
|
||||
<string name="wait_face_sdk_load">請稍等,美顏SDK加載中</string>
|
||||
<string name="face_sdk_load_failed">美顏SDK加載失敗,請重啟App</string>
|
||||
|
||||
<string name="facebook_app_id">2011402032399020</string>
|
||||
<string name="facebook_client_token">959584e054a33614996361f0044e5253</string>
|
||||
|
@ -787,6 +787,7 @@
|
||||
|
||||
<string name="only_open_anchor">For the time being, it is only open to the anchor</string>
|
||||
<string name="wait_face_sdk_load">Please wait, the beauty SDK is loading.</string>
|
||||
<string name="face_sdk_load_failed">Beauty SDK failed to load, please restart the App</string>
|
||||
|
||||
<string name="facebook_app_id">2011402032399020</string>
|
||||
<string name="facebook_client_token">959584e054a33614996361f0044e5253</string>
|
||||
|
@ -215,14 +215,14 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
super.main();
|
||||
Bus.getOn(this);
|
||||
Intent intent = getIntent();
|
||||
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
|
||||
/* if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
|
||||
// 美颜SO设置
|
||||
File file_FaceUnity = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_FaceUnity_SO + File.separator + Build.CPU_ABI);
|
||||
faceunity.LoadConfig.loadLibrary(file_FaceUnity.getAbsolutePath());
|
||||
Log.i("downLoad", "美颜SO Path = " + file_FaceUnity.getAbsolutePath());
|
||||
}
|
||||
}*/
|
||||
|
||||
initFaceManager();
|
||||
// initFaceManager();
|
||||
leave_img = findViewById(R.id.leave_img);
|
||||
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
|
||||
if (mLiveSDK == Constants.LIVE_SDK_SW) {
|
||||
|
@ -205,10 +205,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
|
||||
private View floatWarOrder;//战令浮窗
|
||||
private List<AnchorStartLiveBean> startListNotifyList = new ArrayList<>();
|
||||
private String[] libNameList = new String[]{"agora-core", "agora-ffmpeg", "agora-fdkaac", "agora-soundtouch","agora-rtc-sdk"};
|
||||
// 美颜SDK是否已经加载成功
|
||||
public static boolean faceSDKIsLoadSuceness = false;
|
||||
|
||||
// private String[] libNameList = new String[]{"agora-core", "agora-ffmpeg", "agora-fdkaac", "agora-soundtouch","agora-rtc-sdk"};
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
|
@ -168,11 +168,18 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O
|
||||
public void onLiveClick() {
|
||||
boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
|
||||
if (isAnchor) {
|
||||
if (CommonAppConfig.faceSDKDownLoadOrUnZipFailed){
|
||||
// 美颜SDK下载或解压失败并且重试三次还是失败,提示用户重启
|
||||
ToastUtil.show(getString(R.string.face_sdk_load_failed));
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断美颜SDK是否加载成功
|
||||
if (!MainActivity.faceSDKIsLoadSuceness){
|
||||
if (!CommonAppConfig.faceSDKIsLoadSuceness){
|
||||
ToastUtil.show(getString(R.string.wait_face_sdk_load));
|
||||
return;
|
||||
}
|
||||
|
||||
String[] permissions;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
permissions = new String[]{
|
||||
|
Loading…
Reference in New Issue
Block a user