From ee52a6c28cc18646a49225fd969d8020300c54f0 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Sun, 9 Feb 2025 13:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BA=94=E7=94=A8=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbase/build.properties | 4 +- libappbase/build.properties | 4 +- .../studio/libappbase/CrashHandler.java | 43 +++++++++---------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/appbase/build.properties b/appbase/build.properties index cfc2012..1d6a716 100644 --- a/appbase/build.properties +++ b/appbase/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sun Feb 09 11:41:02 HKT 2025 +#Sun Feb 09 05:07:18 GMT 2025 stageCount=2 libraryProject=libappbase baseVersion=1.2 publishVersion=1.2.1 -buildCount=0 +buildCount=30 baseBetaVersion=1.2.2 diff --git a/libappbase/build.properties b/libappbase/build.properties index b91d876..1d6a716 100644 --- a/libappbase/build.properties +++ b/libappbase/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sun Feb 09 11:40:48 HKT 2025 +#Sun Feb 09 05:07:18 GMT 2025 stageCount=2 libraryProject=libappbase baseVersion=1.2 publishVersion=1.2.1 -buildCount=0 +buildCount=30 baseBetaVersion=1.2.2 diff --git a/libappbase/src/main/java/cc/winboll/studio/libappbase/CrashHandler.java b/libappbase/src/main/java/cc/winboll/studio/libappbase/CrashHandler.java index 55871fb..32ed2fe 100644 --- a/libappbase/src/main/java/cc/winboll/studio/libappbase/CrashHandler.java +++ b/libappbase/src/main/java/cc/winboll/studio/libappbase/CrashHandler.java @@ -50,11 +50,11 @@ import java.util.Locale; public final class CrashHandler { public static final String TAG = "CrashHandler"; - + public static final String TITTLE = "CrashReport"; private static final String EXTRA_CRASH_INFO = "crashInfo"; - + final static String PREFS = CrashHandler.class.getName() + "PREFS"; final static String PREFS_CRASHHANDLER_ISCRASHHAPPEN = "PREFS_CRASHHANDLER_ISCRASHHAPPEN"; @@ -130,7 +130,6 @@ public final class CrashHandler { LogUtils.d(TAG, "gotoCrashActiviy: "); if (AppCrashSafetyWire.getInstance().isAppCrashSafetyWireOK()) { LogUtils.d(TAG, "gotoCrashActiviy: isAppCrashSafetyWireOK"); - AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(app); intent.setClass(app, GlobalCrashActiviy.class); intent.putExtra(EXTRA_CRASH_INFO, errorLog); // 如果发生了 CrashHandler 内部崩溃, 就调用基础的应用崩溃显示类 @@ -141,10 +140,9 @@ public final class CrashHandler { // 正常状态调用进阶的应用崩溃显示页 intent.setClass(app, CrashActiviy.class); intent.putExtra(EXTRA_CRASH_INFO, errorLog); - AppCrashSafetyWire.getInstance().resumeToMaximumImmediately(); } - + // intent.setClass(app, CrashActiviy.class); // intent.putExtra(CrashActiviy.EXTRA_CRASH_INFO, errorLog); @@ -330,23 +328,19 @@ public final class CrashHandler { new Handler(Looper.getMainLooper()).postDelayed(new Runnable(){ @Override public void run() { - // 进程持续运行时,恢复保险丝熔断值 - //Resume to maximum - resumeToMaximumImmediately(); -// LogUtils.d(TAG, "postCrashSafetyWire Resume to maximum"); -// while (resumeToMaximum(currentSafetyLevel + 1)) { -// try { -// Thread.sleep(1000); -// } catch (InterruptedException e) { -// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); -// } -// } + LogUtils.d(TAG, "Handler run()"); + if (!AppCrashSafetyWire.getInstance().isSafetyWireWorking(currentSafetyLevel - 1)) { + // 如果下一次应用崩溃时,保险丝熔断,则先恢复保险丝满能状态 + // 进程持续运行时,恢复保险丝熔断值 + //Resume to maximum + AppCrashSafetyWire.getInstance().resumeToMaximumImmediately(); + LogUtils.d(TAG, "postResumeCrashSafetyWireHandler"); + } } - }, 1000); + }, 500); } - } - + public static String getAppName(Context context) { PackageManager packageManager = context.getPackageManager(); try { @@ -368,7 +362,8 @@ public final class CrashHandler { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext()); + mLog = getIntent().getStringExtra(EXTRA_CRASH_INFO); setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar); setContentView: { @@ -388,7 +383,7 @@ public final class CrashHandler { contentView.addView(hw, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setContentView(contentView); getActionBar().setTitle(TITTLE); - getActionBar().setSubtitle("GlobalCrashActiviy Error"); + getActionBar().setSubtitle(GlobalApplication.class.getSimpleName() + " Error"); } } @@ -457,6 +452,8 @@ public final class CrashHandler { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext()); + mLog = getIntent().getStringExtra(EXTRA_CRASH_INFO); setTheme(android.R.style.Theme_DeviceDefault_NoActionBar); // TypedArray a = obtainStyledAttributes(attrs, R.styleable.ASupportToolbar, R.attr.aSupportToolbar, 0); @@ -466,7 +463,7 @@ public final class CrashHandler { // mEndColor = a.getColor(R.styleable.ASupportToolbar_attrASupportToolbarEndColor, Color.YELLOW); // // 返回一个绑定资源结束的信号给资源 // a.recycle(); - + setContentView: { // LinearLayout contentView = new LinearLayout(this); // contentView.setOrientation(LinearLayout.VERTICAL); @@ -518,7 +515,7 @@ public final class CrashHandler { // } // } // }); - + getActionBar().setTitle(TITTLE); getActionBar().setSubtitle(getAppName(getApplicationContext())); }