1、声网jar + 下载so开发 基本完成
This commit is contained in:
parent
f5d8b7fed1
commit
09395b152e
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
@ -316,6 +316,6 @@ public class Constants {
|
||||
public static int firstInto = 0;//
|
||||
|
||||
// 声网so
|
||||
public static final String DOWNLOAD_SO = "agora-lib";
|
||||
public static final String DOWNLOAD_SO = "agora_lib";
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.opengl.EGLSurface;
|
||||
import android.opengl.GLES20;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.TextureView;
|
||||
@ -117,8 +118,11 @@ public class SWAuManager extends BaseCacheManager {
|
||||
|
||||
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
|
||||
//链接包,声网加载下载的 So文件
|
||||
File file = new File(mContext.getApplicationInfo().dataDir, com.yunbao.common.Constants.DOWNLOAD_SO);
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_SO + File.separator + cpuAbi);
|
||||
config.mNativeLibPath = file.getAbsolutePath();
|
||||
Log.i("downLoad", "config.mNativeLibPath 1 = " + config.mNativeLibPath);
|
||||
}
|
||||
|
||||
// 创建并初始化 RtcEngine
|
||||
@ -143,6 +147,14 @@ public class SWAuManager extends BaseCacheManager {
|
||||
config.mContext = mContext;
|
||||
config.mAppId = CommonAppConfig.getSwAppId();
|
||||
config.mEventHandler = mEventHandler;
|
||||
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
|
||||
//链接包,声网加载下载的 So文件
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_SO + File.separator + cpuAbi);
|
||||
config.mNativeLibPath = file.getAbsolutePath();
|
||||
Log.i("downLoad", "config.mNativeLibPath 2 = " + config.mNativeLibPath);
|
||||
}
|
||||
// 创建并初始化 RtcEngine
|
||||
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@ -128,6 +130,16 @@ public class SWManager extends BaseCacheManager {
|
||||
config.mContext = mContext;
|
||||
config.mAppId = CommonAppConfig.getSwAppId();
|
||||
config.mEventHandler = mRtcEventHandler;
|
||||
|
||||
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
|
||||
//链接包,声网加载下载的 So文件
|
||||
String cpuAbi = "";
|
||||
cpuAbi = Build.CPU_ABI;
|
||||
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_SO + File.separator + cpuAbi);
|
||||
config.mNativeLibPath = file.getAbsolutePath();
|
||||
Log.i("downLoad", "config.mNativeLibPath 2 = " + config.mNativeLibPath);
|
||||
}
|
||||
|
||||
// 创建并初始化 RtcEngine
|
||||
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
|
||||
}
|
||||
|
@ -239,6 +239,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
"测试文本:"+getString(R.string.hot)
|
||||
);
|
||||
ToastUtil.showDebug("打包时间:"+CommonAppConfig.BUILD_TIME+"\n系统语言:"+IMLoginManager.get(CommonAppContext.sInstance).getLocaleLanguage());
|
||||
|
||||
//初始化声网
|
||||
SWAuManager.get().initRtcEngine(this);
|
||||
ActivityCompat.postponeEnterTransition(this);
|
||||
|
Loading…
Reference in New Issue
Block a user