mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +08:00
Modify optimize the way of TaiChi activation in YukiHookFactory
This commit is contained in:
@@ -36,7 +36,6 @@ import android.content.res.Configuration
|
|||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@@ -189,23 +188,14 @@ fun Context.applyModuleTheme(@StyleRes theme: Int, configuration: Configuration?
|
|||||||
*/
|
*/
|
||||||
internal val Context.isTaiChiModuleActive: Boolean
|
internal val Context.isTaiChiModuleActive: Boolean
|
||||||
get() {
|
get() {
|
||||||
var isModuleActive = false
|
/**
|
||||||
runCatching {
|
* 获取模块是否激活
|
||||||
var result: Bundle? = null
|
* @return [Boolean] or null
|
||||||
Uri.parse("content://me.weishu.exposed.CP/").also { uri ->
|
*/
|
||||||
runCatching {
|
fun isModuleActive() =
|
||||||
result = contentResolver.call(uri, "active", null, null)
|
contentResolver?.call(Uri.parse("content://me.weishu.exposed.CP/"), "active", null, null)?.getBoolean("active", false)
|
||||||
}.onFailure {
|
return runCatching { isModuleActive() }.getOrNull() ?: runCatching {
|
||||||
// TaiChi is killed, try invoke
|
startActivity(Intent("me.weishu.exp.ACTION_ACTIVE").apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
|
||||||
runCatching {
|
isModuleActive()
|
||||||
startActivity(Intent("me.weishu.exp.ACTION_ACTIVE").apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) })
|
}.getOrNull() ?: false
|
||||||
}.onFailure { return false }
|
|
||||||
}
|
|
||||||
if (result == null)
|
|
||||||
result = contentResolver.call(Uri.parse("content://me.weishu.exposed.CP/"), "active", null, null)
|
|
||||||
if (result == null) return false
|
|
||||||
}
|
|
||||||
isModuleActive = result?.getBoolean("active", false) == true
|
|
||||||
}
|
|
||||||
return isModuleActive
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user