@@ -24,9 +24,6 @@ import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.Utils ;
import com.facebook.appevents.AppEventsLogger ;
import com.fm.openinstall.OpenInstall ;
import com.google.firebase.FirebaseApp ;
import com.google.firebase.analytics.FirebaseAnalytics ;
import com.google.firebase.crashlytics.FirebaseCrashlytics ;
import com.shayu.phonelive.utils.LogUtils ;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo ;
import com.tencent.imsdk.v2.V2TIMManager ;
@@ -46,9 +43,9 @@ import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom ;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager ;
import com.yunbao.common.utils.AppManager ;
import com.yunbao.common.utils.GoogleUtils ;
import com.yunbao.common.utils.L ;
import com.yunbao.common.utils.SpUtil ;
import com.yunbao.common.utils.ToastUtil ;
import com.yunbao.live.socket.SocketReceiveBean ;
import com.yunbao.live.socket.SocketRyClient ;
import com.yunbao.live.utils.LiveImDeletUtil ;
@@ -145,7 +142,6 @@ public class AppContext extends CommonAppContext {
sInstance = this ;
L . setDeBug ( BuildConfig . DEBUG ) ;
AppEventsLogger . activateApp ( this ) ;
FirebaseAnalytics . getInstance ( this ) ;
File httpCacheDir = new File ( getCacheDir ( ) , " https " ) ;
try {
@@ -170,8 +166,7 @@ public class AppContext extends CommonAppContext {
//友盟正式初始化
UMConfigure . init ( getApplicationContext ( ) , " 64e40ee55488fe7b3afa2c96 " , " PDLive " , UMConfigure . DEVICE_TYPE_PHONE ,
" 64e40ee55488fe7b3afa2c96 " ) ;
UMConfigure . init ( getApplicationContext ( ) , " 64e40ee55488fe7b3afa2c96 " , " PDLive " , UMConfigure . DEVICE_TYPE_PHONE , " 64e40ee55488fe7b3afa2c96 " ) ;
//集成umeng-crash-vx.x.x.aar, 则需要关闭原有统计SDK异常捕获功能
MobclickAgent . setCatchUncaughtExceptions ( false ) ;
@@ -212,9 +207,7 @@ public class AppContext extends CommonAppContext {
if ( content . getContent ( ) . contains ( " _method_ " ) ) {
msg . obj = content . getContent ( ) ;
//观众页面
if ( SocketRyClient . mSocketHandler ! = null
& & ( TextUtils . equals ( " __system__ " , message . getTargetId ( ) )
| | ( " g " + PortraitLiveManager . liveID ) . contains ( message . getTargetId ( ) ) ) ) {
if ( SocketRyClient . mSocketHandler ! = null & & ( TextUtils . equals ( " __system__ " , message . getTargetId ( ) ) | | ( " g " + PortraitLiveManager . liveID ) . contains ( message . getTargetId ( ) ) ) ) {
SocketRyClient . mSocketHandler . sendMessage ( msg ) ;
} else if ( content . getContent ( ) . contains ( " LivePK_anchorStartLiveNotify " ) ) { //开播通知
SocketReceiveBean received = JSON . parseObject ( content . getContent ( ) , SocketReceiveBean . class ) ;
@@ -313,40 +306,37 @@ public class AppContext extends CommonAppContext {
* 注册全局异常捕获, 有需要时可以在onCreate调用
*/
private void registerError ( ) {
NeverCrashUtils . getInstance ( )
. setDebugMode ( BuildConfig . DEBUG )
. setMainCrashHandler ( ( t , e ) - > {
Log . e ( " ApplicationError " , " 主线程异常 " ) ; //此处log只是展示, 当debug为true时, 主类内部log会打印异常信息
e . printStackTrace ( ) ;
AppManager . runDebugCode ( ( ) - > {
//闪退后finish所有Activity并且杀死进程
for ( WeakReference < Activity > activity : activities ) {
if ( activity ! = null & & activity . get ( ) ! = null ) {
activity . get ( ) . finish ( ) ;
}
}
Process . killProcess ( Process . myPid ( ) ) ;
System . exit ( 0 ) ;
setFirebaseCrashData ( ) ;
new Handler ( Looper . getMainLooper ( ) ) . postDelayed ( ( ) - > {
throw new RuntimeException ( e ) ;
} , 100 ) ;
} ) ;
NeverCrashUtils . getInstance ( ) . setDebugMode ( BuildConfig . DEBUG ) . setMainCrashHandler ( ( t , e ) - > {
Log . e ( " ApplicationError " , " 主线程异常 " ) ; //此处log只是展示, 当debug为true时, 主类内部log会打印异常信息
e . printStackTrace ( ) ;
AppManager . runDebugCode ( ( ) - > {
//闪退后finish所有Activity并且杀死进程
for ( WeakReference < Activity > activity : activities ) {
if ( activity ! = null & & activity . get ( ) ! = null ) {
activity . get ( ) . finish ( ) ;
}
}
Process . killProcess ( Process . myPid ( ) ) ;
System . exit ( 0 ) ;
setFirebaseCrashData ( ) ;
new Handler ( Looper . getMainLooper ( ) ) . postDelayed ( ( ) - > {
throw new RuntimeException ( e ) ;
} , 100 ) ;
} ) ;
} )
. setUncaughtCrashHandler ( ( t , e ) - > {
Log . e ( " ApplicationError " , " 子线程异常 " ) ; //此处log只是展示, 当debug为true时, 主类内部log会打印异常信息
e . printStackTrace ( ) ;
} )
. register ( this ) ;
} ). setUncaughtCrashHandler ( ( t , e ) - > {
Log . e ( " ApplicationError " , " 子线程异常 " ) ; //此处log只是展示, 当debug为true时, 主类内部log会打印异常信息
e . printStackTrace ( ) ;
} ) . register ( this ) ;
}
public void registerFirebaseCrash ( ) {
if ( ! CommonAppConfig . IS_UPLOAD_ERROR_LOG ) {
return ;
}
FirebaseAnalytics . getInstance ( this ) ;
FirebaseApp . initializeApp ( this ) ;
if ( CommonAppConfig . IS_GOOGLE_PLAY = = 1 ) {
GoogleUtils . newInstance ( this ) . initializeApp ( this ) ;
}
}
@@ -355,21 +345,5 @@ public class AppContext extends CommonAppContext {
return ;
}
String uid = CommonAppConfig . getInstance ( ) . getUid ( ) ;
FirebaseCrashlytics . getInstance ( ) . setUserId ( CommonAppConfig . getInstance ( ) . getUid ( ) ) ;
if ( uid ! = null & & ! uid . isEmpty ( ) ) {
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " uid " , uid ) ;
} else {
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " uid " , " uid is null " ) ;
}
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " userData " , SpUtil . getInstance ( ) . getStringValue ( SpUtil . USER_INFO ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " isGoogle " , CommonAppConfig . IS_GOOGLE_PLAY ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " PhoneName " , Build . BRAND ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " Phone " , Build . MODEL ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " CPU " , Arrays . toString ( Build . SUPPORTED_ABIS ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " RunTime " , ( System . currentTimeMillis ( ) - CrashSaveBean . getInstance ( ) . getStartTime ( ) ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " enterRoom " , CrashSaveBean . getInstance ( ) . getEnterRoom ( ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " slidingRoom " , CrashSaveBean . getInstance ( ) . getSlidingRoom ( ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " playSvga " , CrashSaveBean . getInstance ( ) . getPlaySvga ( ) ) ;
FirebaseCrashlytics . getInstance ( ) . setCustomKey ( " ActivitySize " , CrashSaveBean . getInstance ( ) . getActivitySize ( ) ) ;
}
}