6.7.0 - Alpha7 - 修复 ErrorDialogActivity 可能无法正常启动或短时间自动消失的问题

This commit is contained in:
SuperMonster003
2025-10-23 23:17:49 +08:00
parent 2c8fddb295
commit 759234ebc8
7 changed files with 46 additions and 94 deletions

View File

@@ -31,7 +31,7 @@
"打包应用无法正常使用 Paddle OCR 与 Rapid OCR 功能的问题", "打包应用无法正常使用 Paddle OCR 与 Rapid OCR 功能的问题",
"版本历史页面部分系统因字体差别导致统计数据显示不完整的问题", "版本历史页面部分系统因字体差别导致统计数据显示不完整的问题",
"部分设备无法正常初始化 MLKit Google OCR 的问题 (试修) _[`issue #8`](http://issues.autojs6.com/8#issuecomment-3117061768)_", "部分设备无法正常初始化 MLKit Google OCR 的问题 (试修) _[`issue #8`](http://issues.autojs6.com/8#issuecomment-3117061768)_",
"ErrorDialogActivity 可能无法正常启动的问题 _[`issue #414`](http://issues.autojs6.com/414)_ _[`issue #340`](http://issues.autojs6.com/340#issuecomment-2973485826)_", "ErrorDialogActivity 可能无法正常启动或短时间自动消失的问题 _[`issue #414`](http://issues.autojs6.com/414)_ _[`issue #340`](http://issues.autojs6.com/340#issuecomment-2973485826)_",
"崩溃报告页面复制详细信息功能失效的问题", "崩溃报告页面复制详细信息功能失效的问题",
"APK 文件类型信息对话框可能无法获取应用名称及 SDK 信息的问题", "APK 文件类型信息对话框可能无法获取应用名称及 SDK 信息的问题",
"构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题" "构建工具启用 isCleanup[Paddle/Rapid]Ocr 配置选项时无法正常完成 Rebuild Project 任务的问题"

View File

@@ -223,11 +223,8 @@
android:targetActivity="org.autojs.autojs.ui.splash.SplashActivity"> android:targetActivity="org.autojs.autojs.ui.splash.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="${intentCategory}" /> <category android:name="${intentCategory}" />
</intent-filter> </intent-filter>
<meta-data <meta-data
@@ -244,11 +241,8 @@
android:targetActivity="org.autojs.autojs.ui.splash.SplashActivity"> android:targetActivity="org.autojs.autojs.ui.splash.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="${intentCategory}" /> <category android:name="${intentCategory}" />
</intent-filter> </intent-filter>
<meta-data <meta-data
@@ -281,11 +275,8 @@
android:taskAffinity="org.autojs.autojs.external.shortcut.ShortcutActivity" android:taskAffinity="org.autojs.autojs.external.shortcut.ShortcutActivity"
android:theme="@android:style/Theme.NoDisplay"> android:theme="@android:style/Theme.NoDisplay">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -321,8 +312,18 @@
android:name="org.autojs.autojs.ui.settings.DeveloperOptionsActivity" android:name="org.autojs.autojs.ui.settings.DeveloperOptionsActivity"
android:theme="@style/AppTheme.Settings" /> android:theme="@style/AppTheme.Settings" />
<!-- <activity android:name="org.autojs.autojs.ui.error.CrashReportActivity" android:process=":crash_report"/> --> <activity
<activity android:name="org.autojs.autojs.ui.error.CrashReportActivity" /> android:name="org.autojs.autojs.ui.error.CrashReportActivity"
android:process=":crash_report"
android:exported="false"
android:launchMode="singleTask"
android:taskAffinity="${applicationId}.crash_report"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity <activity
android:name="org.autojs.autojs.external.tasker.TaskerScriptEditActivity" android:name="org.autojs.autojs.external.tasker.TaskerScriptEditActivity"
@@ -378,11 +379,8 @@
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" /> <action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -449,73 +447,41 @@
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.TIME_SET" /> <action android:name="android.intent.action.TIME_SET" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" /> <action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.UID_REMOVED" /> <action android:name="android.intent.action.UID_REMOVED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /> <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
<action android:name="android.intent.action.ACTION_SHUTDOWN" /> <action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.intent.action.ACTION_BATTERY_CHANGED" /> <action android:name="android.intent.action.ACTION_BATTERY_CHANGED" />
<action android:name="android.intent.action.DATE_CHANGED" /> <action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="android.intent.action.DREAMING_STARTED" /> <action android:name="android.intent.action.DREAMING_STARTED" />
<action android:name="android.intent.action.DREAMING_STOPPED" /> <action android:name="android.intent.action.DREAMING_STOPPED" />
<action android:name="android.intent.action.HEADSET_PLUG" /> <action android:name="android.intent.action.HEADSET_PLUG" />
<action android:name="android.intent.action.INPUT_METHOD_CHANGED" /> <action android:name="android.intent.action.INPUT_METHOD_CHANGED" />
<action android:name="android.intent.action.LOCALE_CHANGED" /> <action android:name="android.intent.action.LOCALE_CHANGED" />
<action android:name="android.intent.action.MEDIA_BUTTON" /> <action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.intent.action.MEDIA_CHECKING" /> <action android:name="android.intent.action.MEDIA_CHECKING" />
<action android:name="android.intent.action.MEDIA_MOUNTED" /> <action android:name="android.intent.action.MEDIA_MOUNTED" />
<action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" /> <action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
<action android:name="android.intent.action.PROVIDER_CHANGED" /> <action android:name="android.intent.action.PROVIDER_CHANGED" />
<action android:name="android.intent.action.WALLPAPER_CHANGED" /> <action android:name="android.intent.action.WALLPAPER_CHANGED" />
<action android:name="android.intent.action.USER_UNLOCKED" /> <action android:name="android.intent.action.USER_UNLOCKED" />
<action android:name="android.intent.action.USER_PRESENT" /> <action android:name="android.intent.action.USER_PRESENT" />
<action <action
android:name="android.net.conn.CONNECTIVITY_CHANGE" android:name="android.net.conn.CONNECTIVITY_CHANGE"
tools:ignore="BatteryLife" /> tools:ignore="BatteryLife" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" /> <action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED" /> <action android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" /> <action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_RESTARTED" /> <action android:name="android.intent.action.PACKAGE_RESTARTED" />
<data android:scheme="package" /> <data android:scheme="package" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@@ -539,23 +505,14 @@
android:exported="true" android:exported="true"
android:label="@string/text_edit_script"> android:label="@string/text_edit_script">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:scheme="content" /> <data android:scheme="content" />
<data android:mimeType="application/x-javascript" /> <data android:mimeType="application/x-javascript" />
<data android:mimeType="text/plain" /> <data android:mimeType="text/plain" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -566,23 +523,14 @@
android:taskAffinity="org.autojs.autojs.external.open.RunIntentActivity" android:taskAffinity="org.autojs.autojs.external.open.RunIntentActivity"
android:theme="@android:style/Theme.NoDisplay"> android:theme="@android:style/Theme.NoDisplay">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:scheme="content" /> <data android:scheme="content" />
<data android:mimeType="application/x-javascript" /> <data android:mimeType="application/x-javascript" />
<data android:mimeType="text/plain" /> <data android:mimeType="text/plain" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -592,23 +540,14 @@
android:label="@string/text_import_script" android:label="@string/text_import_script"
android:theme="@style/AppTheme.Transparent"> android:theme="@style/AppTheme.Transparent">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:scheme="content" /> <data android:scheme="content" />
<data android:mimeType="application/x-javascript" /> <data android:mimeType="application/x-javascript" />
<data android:mimeType="text/plain" /> <data android:mimeType="text/plain" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@@ -82,7 +82,6 @@ abstract class AbstractAutoJs protected constructor(val application: Application
addAccessibilityServiceDelegates() addAccessibilityServiceDelegates()
registerActivityLifecycleCallbacks() registerActivityLifecycleCallbacks()
WrappedShizuku.onCreate() WrappedShizuku.onCreate()
ThemeColorManager.init()
} }
private fun initContextFactory() { private fun initContextFactory() {

View File

@@ -29,6 +29,7 @@ import org.autojs.autojs.external.receiver.DynamicBroadcastReceivers
import org.autojs.autojs.ipc.InAppEventBus import org.autojs.autojs.ipc.InAppEventBus
import org.autojs.autojs.leakcanary.LeakCanarySetup import org.autojs.autojs.leakcanary.LeakCanarySetup
import org.autojs.autojs.pluginclient.DevPluginService import org.autojs.autojs.pluginclient.DevPluginService
import org.autojs.autojs.theme.ThemeColorManager
import org.autojs.autojs.timing.TimedTaskManager import org.autojs.autojs.timing.TimedTaskManager
import org.autojs.autojs.timing.TimedTaskScheduler import org.autojs.autojs.timing.TimedTaskScheduler
import org.autojs.autojs.tool.CrashHandler import org.autojs.autojs.tool.CrashHandler
@@ -58,21 +59,31 @@ class App : MultiDexApplication() {
GlobalAppContext.set(this) GlobalAppContext.set(this)
instance = WeakReference(this) instance = WeakReference(this)
devPluginService = DevPluginService(this)
setUpStaticsTool() when {
setUpDebugEnvironment() ":crash_report".matchesProcessNameSuffix() -> {
setUpLeakCanary() ThemeColorManager.init()
setUpDefaultNightMode()
}
else /* Main process. */ -> {
devPluginService = DevPluginService(this)
AutoJs.initInstance(this) setUpStaticsTool()
GlobalKeyObserver.initIfNeeded(applicationContext) setUpDebugEnvironment()
setupDrawableImageLoader() setUpLeakCanary()
TimedTaskScheduler.init(this)
initDynamicBroadcastReceivers()
initMlKitContext()
Toaster.init(this)
setUpDefaultNightMode() AutoJs.initInstance(this)
GlobalKeyObserver.initIfNeeded(applicationContext)
setupDrawableImageLoader()
TimedTaskScheduler.init(this)
initDynamicBroadcastReceivers()
initMlKitContext()
Toaster.init(this)
ThemeColorManager.init()
setUpDefaultNightMode()
}
}
} }
override fun attachBaseContext(base: Context) { override fun attachBaseContext(base: Context) {
@@ -263,6 +274,10 @@ class App : MultiDexApplication() {
val app: App val app: App
get() = instance.get()!! get() = instance.get()!!
private fun String.matchesProcessNameSuffix(): Boolean {
return getProcessNameCompat().endsWith(this)
}
fun getProcessNameCompat(): String { fun getProcessNameCompat(): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) getProcessName() else { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) getProcessName() else {
try { try {

View File

@@ -9,7 +9,6 @@ import com.tencent.bugly.crashreport.CrashReport.CrashHandleCallback
import org.autojs.autojs.app.GlobalAppContext import org.autojs.autojs.app.GlobalAppContext
import org.autojs.autojs.core.accessibility.AccessibilityService import org.autojs.autojs.core.accessibility.AccessibilityService
import org.autojs.autojs.runtime.ScriptRuntime import org.autojs.autojs.runtime.ScriptRuntime
import org.autojs.autojs.util.ClipboardUtils
import org.autojs.autojs6.BuildConfig import org.autojs.autojs6.BuildConfig
import org.mozilla.javascript.RhinoException import org.mozilla.javascript.RhinoException
import java.lang.Thread.UncaughtExceptionHandler import java.lang.Thread.UncaughtExceptionHandler
@@ -46,12 +45,13 @@ class CrashHandler(private val errorReportClass: Class<*>) : CrashHandleCallback
override fun uncaughtException(thread: Thread, ex: Throwable) { override fun uncaughtException(thread: Thread, ex: Throwable) {
Log.e(TAG, "Uncaught Exception", ex) Log.e(TAG, "Uncaught Exception", ex)
ScriptRuntime.popException(ex.message ?: "Uncaught Exception") // ScriptRuntime.popException(ex.message ?: "Uncaught Exception")
val latestMessage = ex.message ?: "[ No error message ]" val latestMessage = ex.message ?: "[ No error message ]"
if (mCachedExceptionMessage.size > 4) { if (mCachedExceptionMessage.size > 4) {
if (mCachedExceptionMessage.all { it.get()?.message == latestMessage } || mCachedExceptionMessage.size > 20) { if (mCachedExceptionMessage.all { it.get()?.message == latestMessage } || mCachedExceptionMessage.size > 20) {
ScriptRuntime.popException(latestMessage) ScriptRuntime.popException(latestMessage)
ClipboardUtils.setClip(GlobalAppContext.get(), ex.stackTraceToString()) // ClipboardUtils.setClip(GlobalAppContext.get(), ex.stackTraceToString())
startCrashReportActivity("Uncaught Exception", ex.stackTraceToString())
exitProcess(1) exitProcess(1)
} }
} }

View File

@@ -55,7 +55,7 @@ class CrashReportActivity : BaseActivity() {
binding.restart.setOnClickListener { restart() } binding.restart.setOnClickListener { restart() }
binding.exit.setOnClickListener { exit() } binding.exit.setOnClickListener { exit() }
savedInstanceState ?: copy() // savedInstanceState ?: copy()
} }
@Deprecated("Deprecated in Java") @Deprecated("Deprecated in Java")

View File

@@ -38,10 +38,9 @@ public class ErrorDialogActivity extends BaseActivity {
.content(message) .content(message)
.positiveText(positiveButtonText) .positiveText(positiveButtonText)
.positiveColorRes(R.color.dialog_button_default) .positiveColorRes(R.color.dialog_button_default)
.cancelable(true) .cancelable(false)
.canceledOnTouchOutside(true) .canceledOnTouchOutside(false)
.onPositive((dialog, which) -> finish()) .onPositive((dialog, which) -> finish())
.dismissListener(dialog -> finish())
.show(); .show();
MaterialDialogExtensions.makeTextCopyable(materialDialog, materialDialog.getContentView()); MaterialDialogExtensions.makeTextCopyable(materialDialog, materialDialog.getContentView());