修复bug上报问题

This commit is contained in:
hch 2024-02-16 10:34:10 +08:00
parent aa9bc7326c
commit 08e009e5f9
4 changed files with 63 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.net.http.HttpResponseCache; import android.net.http.HttpResponseCache;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
@ -61,6 +62,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import io.rong.imkit.config.RongConfigCenter; import io.rong.imkit.config.RongConfigCenter;
@ -274,7 +276,6 @@ public class AppContext extends CommonAppContext {
configSPApp(); configSPApp();
//初始化美颜SDK //初始化美颜SDK
// FaceManager.initFaceUnity(this); // FaceManager.initFaceUnity(this);
} }
/** /**
@ -350,5 +351,17 @@ public class AppContext extends CommonAppContext {
return; return;
} }
String uid = CommonAppConfig.getInstance().getUid(); String uid = CommonAppConfig.getInstance().getUid();
if (CommonAppConfig.IS_GOOGLE_PLAY != 2) {
GoogleUtils.newInstance(sInstance).setFirebaseCrashData(
uid,
SpUtil.getInstance().getStringValue(SpUtil.USER_INFO),
String.valueOf(CommonAppConfig.IS_GOOGLE_PLAY),
Arrays.toString(Build.SUPPORTED_ABIS),
String.valueOf(CrashSaveBean.getInstance().getStartTime()),
String.valueOf(CrashSaveBean.getInstance().getEnterRoom()),
String.valueOf(CrashSaveBean.getInstance().getSlidingRoom()),
String.valueOf(CrashSaveBean.getInstance().getPlaySvga()), CrashSaveBean.getInstance().getActivitySize());
}
} }
} }

View File

@ -11,6 +11,7 @@ import com.yunbao.common.R;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -227,6 +228,20 @@ public class GoogleUtils {
} }
} }
public void setFirebaseCrashData(String uid, String userData, String isGoogle, String cpu, String runTime, String enterRoom, String slidingRoom, String playSvga, String ActivitySize) {
try {
Class<?> clz = mContext.getClassLoader().loadClass("com.shayu.lib_google.utils.FirebaseManage");
googlePay= clz.getConstructor(Context.class).newInstance(mContext);
googlePay.getClass()
.getMethod("setFirebaseCrashData", String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class)
.invoke(googlePay, uid, userData, isGoogle, cpu, runTime, enterRoom, slidingRoom, playSvga, ActivitySize);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void setQueryPurchaseListener(Activity activity, QueryPurchasesListener queryPurchasesListener) { public void setQueryPurchaseListener(Activity activity, QueryPurchasesListener queryPurchasesListener) {
Timer timer = new Timer(); Timer timer = new Timer();
TimerTask task = new TimerTask() { TimerTask task = new TimerTask() {

View File

@ -35,4 +35,11 @@ dependencies {
api 'com.google.android.gms:play-services-ads-identifier:15.0.1' api 'com.google.android.gms:play-services-ads-identifier:15.0.1'
api 'com.google.firebase:firebase-messaging:23.0.6' api 'com.google.firebase:firebase-messaging:23.0.6'
api 'cn.rongcloud.sdk:sight:5.2.5.4' api 'cn.rongcloud.sdk:sight:5.2.5.4'
implementation platform('com.google.firebase:firebase-bom:30.5.0')
implementation 'com.google.firebase:firebase-crashlytics'
//implementation platform('com.google.firebase:firebase-bom:30.5.0')
//implementation 'com.google.firebase:firebase-crashlytics'
} }

View File

@ -2,13 +2,16 @@ package com.shayu.lib_google.utils;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseApp;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.firebase.messaging.FirebaseMessaging; import com.google.firebase.messaging.FirebaseMessaging;
import io.rong.push.PushManager; import io.rong.push.PushManager;
@ -53,4 +56,27 @@ public class FirebaseManage {
public void initializeApp() { public void initializeApp() {
FirebaseApp.initializeApp(mContext); FirebaseApp.initializeApp(mContext);
} }
public void setFirebaseCrashData(String uid, String userData, String isGoogle, String cpu, String runTime, String enterRoom, String slidingRoom, String playSvga, String ActivitySize) {
FirebaseCrashlytics.getInstance().setUserId(uid);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if (uid != null && !uid.isEmpty()) {
FirebaseCrashlytics.getInstance().setCustomKey("uid", uid);
} else {
FirebaseCrashlytics.getInstance().setCustomKey("uid", "uid is null");
}
}
FirebaseCrashlytics.getInstance().setCustomKey("userData", userData);
FirebaseCrashlytics.getInstance().setCustomKey("isGoogle", isGoogle);
FirebaseCrashlytics.getInstance().setCustomKey("PhoneName", Build.BRAND);
FirebaseCrashlytics.getInstance().setCustomKey("Phone", Build.MODEL);
FirebaseCrashlytics.getInstance().setCustomKey("CPU", cpu);
FirebaseCrashlytics.getInstance().setCustomKey("RunTime", (System.currentTimeMillis() - Long.parseLong(runTime)));
FirebaseCrashlytics.getInstance().setCustomKey("enterRoom", enterRoom);
FirebaseCrashlytics.getInstance().setCustomKey("slidingRoom", slidingRoom);
FirebaseCrashlytics.getInstance().setCustomKey("playSvga", playSvga);
FirebaseCrashlytics.getInstance().setCustomKey("ActivitySize", ActivitySize);
}
} }