mirror of
https://github.com/KitsunePie/AppErrorsTracking.git
synced 2025-09-04 18:25:19 +08:00
Revert "Make FrameworkHooker singleton"
This reverts commit ee4b3896ef
.
This commit is contained in:
@@ -35,5 +35,5 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
isDebug = false
|
isDebug = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onHook() = encase { loadSystem(FrameworkHooker) }
|
override fun onHook() = encase { loadSystem(FrameworkHooker()) }
|
||||||
}
|
}
|
@@ -48,21 +48,23 @@ import com.highcapable.yukihookapi.hook.factory.method
|
|||||||
import com.highcapable.yukihookapi.hook.log.loggerE
|
import com.highcapable.yukihookapi.hook.log.loggerE
|
||||||
import com.highcapable.yukihookapi.hook.type.android.MessageClass
|
import com.highcapable.yukihookapi.hook.type.android.MessageClass
|
||||||
|
|
||||||
object FrameworkHooker : YukiBaseHooker() {
|
class FrameworkHooker : YukiBaseHooker() {
|
||||||
|
|
||||||
private const val AppErrorsClass = "com.android.server.am.AppErrors"
|
companion object {
|
||||||
|
|
||||||
private const val AppErrorResultClass = "com.android.server.am.AppErrorResult"
|
private const val AppErrorsClass = "com.android.server.am.AppErrors"
|
||||||
|
|
||||||
private const val AppErrorDialog_DataClass = "com.android.server.am.AppErrorDialog\$Data"
|
private const val AppErrorResultClass = "com.android.server.am.AppErrorResult"
|
||||||
|
|
||||||
private const val ProcessRecordClass = "com.android.server.am.ProcessRecord"
|
private const val AppErrorDialog_DataClass = "com.android.server.am.AppErrorDialog\$Data"
|
||||||
|
|
||||||
private val ErrorDialogControllerClass = VariousClass(
|
private const val ProcessRecordClass = "com.android.server.am.ProcessRecord"
|
||||||
"com.android.server.am.ProcessRecord\$ErrorDialogController",
|
|
||||||
"com.android.server.am.ErrorDialogController"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
private val ErrorDialogControllerClass = VariousClass(
|
||||||
|
"com.android.server.am.ProcessRecord\$ErrorDialogController",
|
||||||
|
"com.android.server.am.ErrorDialogController"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建对话框按钮
|
* 创建对话框按钮
|
||||||
@@ -72,29 +74,18 @@ object FrameworkHooker : YukiBaseHooker() {
|
|||||||
* @param it 点击事件回调
|
* @param it 点击事件回调
|
||||||
* @return [LinearLayout]
|
* @return [LinearLayout]
|
||||||
*/
|
*/
|
||||||
private fun createButtonItem(
|
private fun createButtonItem(context: Context, drawableId: Int, content: String, it: () -> Unit) =
|
||||||
context: Context,
|
|
||||||
drawableId: Int,
|
|
||||||
content: String,
|
|
||||||
it: () -> Unit
|
|
||||||
) =
|
|
||||||
LinearLayout(context).apply {
|
LinearLayout(context).apply {
|
||||||
background = DrawableBuilder().rounded().cornerRadius(15.dp(context)).ripple()
|
background = DrawableBuilder().rounded().cornerRadius(15.dp(context)).ripple().rippleColor(0xFFAAAAAA.toInt()).build()
|
||||||
.rippleColor(0xFFAAAAAA.toInt()).build()
|
|
||||||
gravity = Gravity.CENTER or Gravity.START
|
gravity = Gravity.CENTER or Gravity.START
|
||||||
layoutParams =
|
layoutParams =
|
||||||
ViewGroup.LayoutParams(
|
ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
addView(ImageView(context).apply {
|
addView(ImageView(context).apply {
|
||||||
setImageDrawable(moduleAppResources.getDrawable(drawableId))
|
setImageDrawable(moduleAppResources.getDrawable(drawableId))
|
||||||
layoutParams = ViewGroup.LayoutParams(25.dp(context), 25.dp(context))
|
layoutParams = ViewGroup.LayoutParams(25.dp(context), 25.dp(context))
|
||||||
setColorFilter(if (context.isSystemInDarkMode) Color.WHITE else Color.BLACK)
|
setColorFilter(if (context.isSystemInDarkMode) Color.WHITE else Color.BLACK)
|
||||||
})
|
})
|
||||||
addView(View(context).apply {
|
addView(View(context).apply { layoutParams = ViewGroup.LayoutParams(15.dp(context), 0) })
|
||||||
layoutParams = ViewGroup.LayoutParams(15.dp(context), 0)
|
|
||||||
})
|
|
||||||
addView(TextView(context).apply {
|
addView(TextView(context).apply {
|
||||||
text = content
|
text = content
|
||||||
textSize = 16f
|
textSize = 16f
|
||||||
@@ -131,8 +122,7 @@ object FrameworkHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
afterHook {
|
afterHook {
|
||||||
/** 当前实例 */
|
/** 当前实例 */
|
||||||
val context = field { name = "mContext" }.get(instance).cast<Context>()
|
val context = field { name = "mContext" }.get(instance).cast<Context>() ?: return@afterHook
|
||||||
?: return@afterHook
|
|
||||||
|
|
||||||
/** 错误数据 */
|
/** 错误数据 */
|
||||||
val errData = args().first().cast<Message>()?.obj
|
val errData = args().first().cast<Message>()?.obj
|
||||||
@@ -151,9 +141,7 @@ object FrameworkHooker : YukiBaseHooker() {
|
|||||||
.get(errData).any()).cast<ApplicationInfo>() ?: ApplicationInfo()
|
.get(errData).any()).cast<ApplicationInfo>() ?: ApplicationInfo()
|
||||||
|
|
||||||
/** 是否短时内重复错误 */
|
/** 是否短时内重复错误 */
|
||||||
val isRepeating =
|
val isRepeating = AppErrorDialog_DataClass.clazz.field { name = "repeating" }.get(errData).boolean()
|
||||||
AppErrorDialog_DataClass.clazz.field { name = "repeating" }.get(errData)
|
|
||||||
.boolean()
|
|
||||||
/** 判断在后台就不显示对话框 */
|
/** 判断在后台就不显示对话框 */
|
||||||
if (errResult == -2) return@afterHook
|
if (errResult == -2) return@afterHook
|
||||||
/** 创建自定义对话框 */
|
/** 创建自定义对话框 */
|
||||||
@@ -165,39 +153,19 @@ object FrameworkHooker : YukiBaseHooker() {
|
|||||||
setTitle("${appInfo.loadLabel(context.packageManager)} ${if (isRepeating) "屡次停止运行" else "已停止运行"}")
|
setTitle("${appInfo.loadLabel(context.packageManager)} ${if (isRepeating) "屡次停止运行" else "已停止运行"}")
|
||||||
setView(LinearLayout(context).apply {
|
setView(LinearLayout(context).apply {
|
||||||
orientation = LinearLayout.VERTICAL
|
orientation = LinearLayout.VERTICAL
|
||||||
addView(
|
addView(createButtonItem(context, R.drawable.ic_baseline_info, content = "应用信息") {
|
||||||
createButtonItem(
|
cancel()
|
||||||
context,
|
context.openSelfSetting(packageName = appInfo.packageName)
|
||||||
R.drawable.ic_baseline_info,
|
})
|
||||||
content = "应用信息"
|
|
||||||
) {
|
|
||||||
cancel()
|
|
||||||
context.openSelfSetting(packageName = appInfo.packageName)
|
|
||||||
})
|
|
||||||
if (isRepeating)
|
if (isRepeating)
|
||||||
addView(
|
addView(createButtonItem(context, R.drawable.ic_baseline_close, content = "关闭应用") { cancel() })
|
||||||
createButtonItem(
|
else addView(createButtonItem(context, R.drawable.ic_baseline_refresh, content = "重新打开") {
|
||||||
context,
|
cancel()
|
||||||
R.drawable.ic_baseline_close,
|
context.openApp(appInfo.packageName)
|
||||||
content = "关闭应用"
|
})
|
||||||
) { cancel() })
|
addView(createButtonItem(context, R.drawable.ic_baseline_bug_report, content = "错误详情") {
|
||||||
else addView(
|
// TODO 待开发
|
||||||
createButtonItem(
|
})
|
||||||
context,
|
|
||||||
R.drawable.ic_baseline_refresh,
|
|
||||||
content = "重新打开"
|
|
||||||
) {
|
|
||||||
cancel()
|
|
||||||
context.openApp(appInfo.packageName)
|
|
||||||
})
|
|
||||||
addView(
|
|
||||||
createButtonItem(
|
|
||||||
context,
|
|
||||||
R.drawable.ic_baseline_bug_report,
|
|
||||||
content = "错误详情"
|
|
||||||
) {
|
|
||||||
// TODO 待开发
|
|
||||||
})
|
|
||||||
setPadding(6.dp(context), 15.dp(context), 6.dp(context), 6.dp(context))
|
setPadding(6.dp(context), 15.dp(context), 6.dp(context), 6.dp(context))
|
||||||
})
|
})
|
||||||
/** 只有 SystemUid 才能响应系统级别的对话框 */
|
/** 只有 SystemUid 才能响应系统级别的对话框 */
|
||||||
|
Reference in New Issue
Block a user