diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 6d42c5495..d9ccd9be5 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -6,6 +6,7 @@ import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.net.http.HttpResponseCache; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -61,6 +62,7 @@ import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import io.rong.imkit.config.RongConfigCenter; @@ -274,7 +276,6 @@ public class AppContext extends CommonAppContext { configSPApp(); //初始化美颜SDK // FaceManager.initFaceUnity(this); - } /** @@ -350,5 +351,17 @@ public class AppContext extends CommonAppContext { return; } 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()); + } } } diff --git a/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java b/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java index 5fadf48e3..c97ea4a90 100644 --- a/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java @@ -11,6 +11,7 @@ import com.yunbao.common.R; import org.json.JSONObject; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; import java.util.Timer; import java.util.TimerTask; @@ -44,7 +45,7 @@ public class GoogleUtils { public boolean getGoogleService() { - boolean flag =false; + boolean flag = false; try { Class clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleBillingManage"); googlePay = clz.getConstructor(Activity.class).newInstance(mActivity); @@ -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) { Timer timer = new Timer(); TimerTask task = new TimerTask() { diff --git a/lib_google/build.gradle b/lib_google/build.gradle index c68945254..262c095e4 100644 --- a/lib_google/build.gradle +++ b/lib_google/build.gradle @@ -35,4 +35,11 @@ dependencies { api 'com.google.android.gms:play-services-ads-identifier:15.0.1' api 'com.google.firebase:firebase-messaging:23.0.6' 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' + } \ No newline at end of file diff --git a/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java b/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java index 6408a27bb..91605b530 100644 --- a/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java +++ b/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java @@ -2,13 +2,16 @@ package com.shayu.lib_google.utils; import android.app.Activity; import android.content.Context; +import android.os.Build; import android.util.Log; +import android.widget.Toast; import androidx.annotation.NonNull; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.FirebaseApp; +import com.google.firebase.crashlytics.FirebaseCrashlytics; import com.google.firebase.messaging.FirebaseMessaging; import io.rong.push.PushManager; @@ -53,4 +56,27 @@ public class FirebaseManage { public void initializeApp() { 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); + } }