Merge branch 'refs/heads/for_master_0829_体积优化' into 6.8.2
# Conflicts: # common/build.gradle # lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java # main/src/main/res/mipmap-xxxhdpi/login_twitter.png
@@ -2,6 +2,7 @@ package com.shayu.phonelive.activity;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
@@ -12,17 +13,20 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
@@ -50,14 +54,12 @@ import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DownloadUtil;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.views.LauncherAdViewHolder;
|
||||
import com.yunbao.main.activity.EntryActivity;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
@@ -68,9 +70,15 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import myname.pdlive.shayu.R;
|
||||
|
||||
@@ -145,16 +153,217 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
}
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
try {
|
||||
LogUtil.uploadErrorLog(AppContext.sInstance);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
|
||||
|
||||
if(CommonAppConfig.IS_GOOGLE_PLAY != 0){
|
||||
//渠道包
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
}else {
|
||||
//链接包 下载so库
|
||||
checkFaceUnitySOFile();
|
||||
checkAgoraSOFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkFaceUnitySOFile() {
|
||||
File outputDir = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), Constants.DOWNLOAD_FaceUnity_SO);
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
if (!outputDir.exists()) {
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
File fileSo = new File(outputDir, Constants.FaceUnity_SO_Name);
|
||||
File fileSoList = new File(outputDir, cpuAbi);
|
||||
//解压后的文件数量必须要有2个
|
||||
//如果文件存在,解压后 文件数量一致,直接进入下一步
|
||||
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 2){
|
||||
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);
|
||||
|
||||
if (!fileSo.exists()) {
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
|
||||
}else if (fileSo.exists() && getFileCount(outputDir.getAbsolutePath()) < 3) {
|
||||
fileSo.delete();
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAgoraSOFile() {
|
||||
//存储路径 //检查是否下载过
|
||||
File outputDir = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), Constants.DOWNLOAD_Agora_SO);
|
||||
Log.i("downLoad", "outputDir.getAbsolutePath() = " + outputDir.getAbsolutePath());
|
||||
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
|
||||
if (!outputDir.exists()) {
|
||||
Log.e("downLoad", "outputDir:>>>" + outputDir.exists());
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
File fileSo = new File(outputDir, Constants.Agora_SO_Name);
|
||||
Log.i("downLoad", "fileSo.getAbsolutePath() = " + fileSo.getAbsolutePath());
|
||||
|
||||
File fileSoList = new File(outputDir, cpuAbi);
|
||||
Log.i("downLoad", "fileSoList.getAbsolutePath() = " + fileSoList.getAbsolutePath());
|
||||
|
||||
//解压后的文件数量必须要有22个
|
||||
//如果文件存在,解压后 文件数量一致,直接进入下一步
|
||||
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 22){
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
return;
|
||||
}
|
||||
Log.i("download", cpuAbi);
|
||||
//如果沒下載,需要清楚之前的登錄信息,這樣用戶就有時間去下載so庫 ,
|
||||
//根據手機cup 架構類型去下載支持不同類型的so 庫
|
||||
|
||||
//2开始下载
|
||||
//检查压缩包是否已经下载过
|
||||
|
||||
String soUrl = String.format("https://downs.yaoulive.com/androidLibs/t1/agora-so-%s.zip", cpuAbi);
|
||||
// https://downs.yaoulive.com/androidLibs/t1/agora-so-arm64-v8a.zip
|
||||
Log.i("download", soUrl);
|
||||
|
||||
if (!fileSo.exists()) {
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.Agora_SO_Name,true);
|
||||
}else if (fileSo.exists() && getFileCount(outputDir.getAbsolutePath()) < 23) {
|
||||
fileSo.delete();
|
||||
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.Agora_SO_Name,true);
|
||||
}
|
||||
}
|
||||
|
||||
Dialog progressDialog;
|
||||
public ProgressBar progressBar;
|
||||
public TextView tvProgress;
|
||||
|
||||
private void showDialog(Activity context) {
|
||||
progressDialog = new Dialog(context, com.yunbao.common.R.style.dialog);
|
||||
View view = LayoutInflater.from(context).inflate(com.yunbao.common.R.layout.dialog_progress, null);
|
||||
tvProgress = view.findViewById(com.yunbao.common.R.id.tvProgress);
|
||||
TextView tvDialogTitle = view.findViewById(com.yunbao.common.R.id.tvDialogTitle);
|
||||
tvDialogTitle.setText("首次安装,请等待");
|
||||
progressBar = view.findViewById(com.yunbao.common.R.id.progressBar);
|
||||
progressDialog.setContentView(view);
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
int width = display.getWidth();
|
||||
Window window = progressDialog.getWindow();// 这部分是设置dialog宽高的,宽高是我从sharedpreferences里面获取到的。之前程序启动的时候有获取
|
||||
window.getDecorView().setPadding(0, 0, 0, 0);
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.width = width / 4 * 3;
|
||||
window.setAttributes(lp);
|
||||
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
public void downloadSo(String outputDir, String downloadUrl,String fileName,boolean isShowDialog) {
|
||||
DownloadUtil downloadUtil = new DownloadUtil();
|
||||
if(isShowDialog){
|
||||
showDialog(LauncherActivity.this);
|
||||
}
|
||||
downloadUtil.download("so", outputDir, fileName, downloadUrl, new DownloadUtil.Callback() {
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
if (isShowDialog){
|
||||
progressDialog.dismiss();
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 20);
|
||||
}
|
||||
File fileSo = new File(outputDir, fileName);
|
||||
try {
|
||||
unzip(fileSo.getAbsolutePath(), outputDir);
|
||||
} catch (Exception e) {
|
||||
Log.e("ZipCheck", "Error reading ZIP file", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
if (isShowDialog){
|
||||
progressBar.setProgress(progress);
|
||||
}
|
||||
Log.i("downLoad", "progress:>>>" + progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
//资源下载失败
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压 .zip 文件到目标目录
|
||||
*/
|
||||
public void unzip(String zipFilePath, String destDirectory) throws IOException {
|
||||
File destDir = new File(destDirectory);
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs();
|
||||
}
|
||||
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
|
||||
ZipEntry entry = zipIn.getNextEntry();
|
||||
while (entry != null) {
|
||||
|
||||
String filePath = destDirectory + File.separator + sanitizePath(entry.getName());
|
||||
Log.d("Unzip", "Extracting: " + filePath);
|
||||
if (!entry.isDirectory()) {
|
||||
extractFile(zipIn, filePath);
|
||||
} else {
|
||||
new File(filePath).mkdirs();
|
||||
}
|
||||
zipIn.closeEntry();
|
||||
entry = zipIn.getNextEntry();
|
||||
}
|
||||
zipIn.close();
|
||||
}
|
||||
|
||||
private String sanitizePath(String path) {
|
||||
return path.replaceAll("[^a-zA-Z0-9./_-]", "_");
|
||||
}
|
||||
|
||||
private void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
|
||||
byte[] bytesIn = new byte[4096];
|
||||
int read = 0;
|
||||
while ((read = zipIn.read(bytesIn)) != -1) {
|
||||
bos.write(bytesIn, 0, read);
|
||||
}
|
||||
bos.close();
|
||||
}
|
||||
|
||||
public int getFileCount(String directoryPath) {
|
||||
File directory = new File(directoryPath);
|
||||
if (!directory.exists() || !directory.isDirectory()) {
|
||||
// 目录不存在或不是目录
|
||||
return -1;
|
||||
}
|
||||
|
||||
File[] files = directory.listFiles();
|
||||
if (files == null) {
|
||||
// 无法列出目录内容
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fileCount = 0;
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
fileCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return fileCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片倒计时
|
||||
*/
|
||||
@@ -200,6 +409,9 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
CommonAppConfig.getInstance().setAnchorPkTime(bean.getPkTime());
|
||||
if (!TextUtils.isEmpty(bean.getTxVideoUgcLicenceUrl()) && !TextUtils.isEmpty(bean.getTxVideoUgcKey()))
|
||||
Log.i("tvv", bean.getTxVideoUgcLicenceUrl() + "是" + bean.getTxVideoUgcKey());
|
||||
|
||||
//sdk接口动态加载so TXLiveBase.setLibraryPath(); https://brands.cnblogs.com/tencentcloud/p/6137
|
||||
|
||||
TXLiveBase.getInstance().setLicence(LauncherActivity.this, bean.getTxVideoUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
TXUGCBase.getInstance().setLicence(LauncherActivity.this, bean.getTxPlayUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 586 KiB After Width: | Height: | Size: 497 KiB |