1、声网jar + 下载so开发 基本完成
This commit is contained in:
@@ -11,10 +11,12 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
@@ -41,6 +43,7 @@ import androidx.core.content.ContextCompat;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.phonelive.AppContext;
|
||||
import com.tencent.rtmp.ITXLivePlayListener;
|
||||
import com.tencent.rtmp.TXLiveBase;
|
||||
@@ -175,67 +178,44 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
}else {
|
||||
//链接包 下载so库
|
||||
String permission1 = Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
String permission2 = Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
|
||||
int isPermission1 = ContextCompat.checkSelfPermission(mContext, permission1);
|
||||
int isPermission2 = ContextCompat.checkSelfPermission(mContext, permission2);
|
||||
if (isPermission1 == PackageManager.PERMISSION_GRANTED && isPermission2 == PackageManager.PERMISSION_GRANTED) {
|
||||
downLoadSo();
|
||||
} else {
|
||||
//申请权限
|
||||
ActivityCompat.requestPermissions(LauncherActivity.this, new String[]{permission1,
|
||||
permission2}, PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
|
||||
downLoadSo();
|
||||
Log.e("downLoad", "outputDir:>>>" + grantResults[0]);
|
||||
Log.e("downLoad", "grantResults[0]:>>>" + grantResults[1]);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
Toast.makeText(this, "需要您的手機存儲權限!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
downLoadSo();
|
||||
}
|
||||
}
|
||||
|
||||
private void downLoadSo() {
|
||||
//存储路径 //检查是否下载过
|
||||
File outputDir = new File(getApplicationInfo().dataDir, Constants.DOWNLOAD_SO);
|
||||
File outputDir = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), Constants.DOWNLOAD_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, "soKuZip.zip");
|
||||
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(outputDir.getAbsolutePath()) == 23){
|
||||
if (fileSo.exists() && getFileCount(fileSoList.getAbsolutePath()) == 22){
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Log.i("download", cpuAbi);
|
||||
//如果沒下載,需要清楚之前的登錄信息,這樣用戶就有時間去下載so庫 ,
|
||||
//根據手機cup 架構類型去下載支持不同類型的so 庫
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
Log.i("download", cpuAbi);
|
||||
|
||||
//2开始下载
|
||||
//检查压缩包是否已经下载过
|
||||
|
||||
Log.i("download", "permission WRITE_EXTERNAL_STORAGE.." + ContextCompat.checkSelfPermission(LauncherActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE));
|
||||
Log.i("download", "permission READ_EXTERNAL_STORAGE .." + ContextCompat.checkSelfPermission(LauncherActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE));
|
||||
String soUrl = String.format("https://downs.yaoulive.com/%s.zip", cpuAbi);
|
||||
String soUrl = String.format("https://downs.yaoulive.com/so-%s.zip", cpuAbi);
|
||||
Log.i("download", soUrl);
|
||||
|
||||
if (!fileSo.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user