修复:部分用户无法上麦问题
优化:日志上报逻辑
This commit is contained in:
parent
8b46c57482
commit
07f8f46f1f
@ -1,11 +1,9 @@
|
|||||||
package com.yunbao.common.utils;
|
package com.yunbao.common.utils;
|
||||||
|
|
||||||
import static android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION;
|
import static android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION;
|
||||||
import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED;
|
|
||||||
import static java.text.DateFormat.DEFAULT;
|
import static java.text.DateFormat.DEFAULT;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.app.Dialog;
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -14,10 +12,10 @@ import android.os.Environment;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.content.PermissionChecker;
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
import com.lzy.okgo.callback.StringCallback;
|
import com.lzy.okgo.callback.StringCallback;
|
||||||
import com.lzy.okgo.model.Progress;
|
import com.lzy.okgo.model.Progress;
|
||||||
@ -31,7 +29,6 @@ import com.yunbao.common.CommonAppConfig;
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -42,11 +39,20 @@ import java.nio.file.Files;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cxf on 2019/6/20.
|
* Created by cxf on 2019/6/20.
|
||||||
*/
|
*/
|
||||||
@ -157,10 +163,10 @@ public class LogUtil {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
|
/* if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
String title = "[PDLIVE]" + CommonAppConfig.getInstance().getUid() + "_";
|
String title = "[PDLIVE]" + CommonAppConfig.getInstance().getUid() + "_";
|
||||||
String today = title + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date());
|
String today = title + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date());
|
||||||
File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator);
|
File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator);
|
||||||
@ -188,6 +194,17 @@ public class LogUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (zip.exists()) {
|
if (zip.exists()) {
|
||||||
|
DialogUitl.showSimpleDialog(context, "上报日志", new DialogUitl.SimpleCallback() {
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
uploadLog(zip);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
dialog.dismiss();
|
||||||
|
ToastUtil.show("OK");
|
||||||
Intent share = new Intent(Intent.ACTION_SEND);
|
Intent share = new Intent(Intent.ACTION_SEND);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
Uri contentUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", zip);
|
Uri contentUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", zip);
|
||||||
@ -215,6 +232,52 @@ public class LogUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static String TAG="Upload";
|
||||||
|
private static void uploadLog(File log) {
|
||||||
|
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
|
||||||
|
MultipartBody requestBody = new MultipartBody.Builder()
|
||||||
|
.addFormDataPart("uid", CommonAppConfig.getInstance().getUid())
|
||||||
|
.addFormDataPart("time", new SimpleDateFormat("yyyy-DD-mm HH:mm:ss", Locale.getDefault()).format(new Date()))
|
||||||
|
.addFormDataPart("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY+"")
|
||||||
|
.addFormDataPart("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||||
|
.addFormDataPart("file","file", RequestBody.create(MediaType.parse("application/octet-stream"),log)) //上报日志文件
|
||||||
|
.build();
|
||||||
|
|
||||||
|
body.put("uid", CommonAppConfig.getInstance().getUid());
|
||||||
|
body.put("time", new SimpleDateFormat("yyyy-DD-mm HH:mm:ss", Locale.getDefault()).format(new Date()));
|
||||||
|
body.put("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY);
|
||||||
|
body.put("appVersion", CommonAppConfig.getInstance().getVersion());
|
||||||
|
|
||||||
|
OkHttpClient client = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(3, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
//.url("https://newht.yaoulive.com/index.php/api/error_log/report") //无法接受文件
|
||||||
|
.url("https://tools.yutou233.cn/public/file/request.do")//临时上报地址,可接受文件
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
client.newCall(request)
|
||||||
|
.enqueue(new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||||
|
Log.e(TAG, "error",e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call call, okhttp3.Response response) throws IOException {
|
||||||
|
String body = response.body().string();
|
||||||
|
Log.i(TAG, "onResponse: "+body);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -732,6 +732,19 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
Log.e("ry", "下麦成功");
|
Log.e("ry", "下麦成功");
|
||||||
// 该用户切换为观众成功,可以以观众身份进行音视频
|
// 该用户切换为观众成功,可以以观众身份进行音视频
|
||||||
//退出rtc播放
|
//退出rtc播放
|
||||||
|
leaveRoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当切换失败且不影响当前角色继续音视频时回调
|
||||||
|
* @param errorCode 失败错误码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
|
Log.e("ry", "下麦失败" + errorCode);
|
||||||
|
leaveRoom();
|
||||||
|
}
|
||||||
|
private void leaveRoom(){
|
||||||
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
|
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
@ -761,21 +774,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailed(RTCErrorCode errorCode) {
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
Log.e("ry", errorCode + "退出多人房间成功");
|
Log.e("ry", errorCode + "退出多人房间成功");
|
||||||
|
userJoinLinkMic = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 当切换失败且不影响当前角色继续音视频时回调
|
|
||||||
* @param errorCode 失败错误码
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onFailed(RTCErrorCode errorCode) {
|
|
||||||
Log.e("ry", "下麦失败" + errorCode);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if ("Debug".equals(str)) {
|
} else if ("Debug".equals(str)) {
|
||||||
@ -938,7 +941,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
public void run() {
|
public void run() {
|
||||||
RCRTCEngine.getInstance().enableSpeaker(true);
|
RCRTCEngine.getInstance().enableSpeaker(true);
|
||||||
//遍历远端用户发布的资源列表
|
//遍历远端用户发布的资源列表
|
||||||
|
Log.i(TAG, "软件资源数量:"+data.getLiveStreams().size());
|
||||||
for (RCRTCInputStream stream : data.getLiveStreams()) {
|
for (RCRTCInputStream stream : data.getLiveStreams()) {
|
||||||
|
Log.i(TAG, "资源流 type: "+stream.getMediaType());
|
||||||
if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
|
if (stream.getMediaType() == RCRTCMediaType.VIDEO) {
|
||||||
//暂停播放
|
//暂停播放
|
||||||
mPlayer.stop();
|
mPlayer.stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user