Skip to content

Commit aa85fc6

Browse files
committed
Fix bugs in Android 16 and HyperOS 3
Upgraded dependencies. Fix icon normalization hook for HyperOS 3. Fix IconProvider.getIcon hook for Android 16.
1 parent c96c809 commit aa85fc6

5 files changed

Lines changed: 37 additions & 32 deletions

File tree

app/src/main/java/com/gswxxn/restoresplashscreen/hook/NewSystemUIHooker.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.highcapable.yukihookapi.hook.factory.constructor
1212
import com.highcapable.yukihookapi.hook.factory.method
1313
import com.highcapable.yukihookapi.hook.log.YLog
1414
import com.highcapable.yukihookapi.hook.type.android.ActivityInfoClass
15+
import com.highcapable.yukihookapi.hook.type.android.ComponentInfoClass
1516
import com.highcapable.yukihookapi.hook.type.android.DrawableClass
1617
import com.highcapable.yukihookapi.hook.type.java.FloatType
1718
import com.highcapable.yukihookapi.hook.type.java.IntType
@@ -54,7 +55,7 @@ object NewSystemUIHooker: YukiBaseHooker() {
5455
"com.android.launcher3.icons.IconProvider".toClass().method {
5556
name = "getIcon"
5657
paramCount(2)
57-
param { IntType in it && ActivityInfoClass in it }
58+
param { IntType in it && (ActivityInfoClass in it || ComponentInfoClass in it) }
5859
}.give()!!
5960
}
6061
val normalizeAndWrapToAdaptiveIcon = HookManager {

app/src/main/java/com/gswxxn/restoresplashscreen/hook/systemui/IconHookHandler.kt

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,30 @@ object IconHookHandler : BaseHookHandler() {
173173

174174
// 不使用自带的图标缩放, 防止在 MIUI 上出现图标白边及图标错位
175175
NewSystemUIHooker.Members.normalizeAndWrapToAdaptiveIcon.addBeforeHook {
176-
val scale = instance.current()
177-
.method { name = "getNormalizer"; superClass() }.call()!!.current()
178-
.method { name = "getScale"; paramCount(4); superClass() }
179-
.invoke<Float>(
180-
args.first { it is Drawable },
181-
args.first { it is RectF },
182-
null,
183-
null
184-
)!!
185-
args(args.indexOfFirst { it is FloatArray }).cast<FloatArray>()!![0] = scale
186-
187-
val oriDrawable = args.first { it is Drawable } as Drawable
188-
val returnType = NewSystemUIHooker.Members.normalizeAndWrapToAdaptiveIcon.returnType
189-
190-
printLog("normalizeAndWrapToAdaptiveIcon(): avoid shrink icon by system ui")
191-
result = if (returnType == AdaptiveIconDrawable::class.java)
192-
TransparentAdaptiveIconDrawable(oriDrawable)
193-
else
194-
oriDrawable
176+
if (Thread.currentThread().stackTrace.any { it.methodName == "makeSplashScreenContentView" }) {
177+
printLog("normalizeAndWrapToAdaptiveIcon(): avoid shrink icon by system ui")
178+
val boolShrinkNonAdaptiveIconsIndex = args.indexOfFirst { it is Boolean }
179+
if (boolShrinkNonAdaptiveIconsIndex != -1) {
180+
args(boolShrinkNonAdaptiveIconsIndex).setFalse()
181+
} else {
182+
val scale = instance.current(ignored = true)
183+
.method { name = "getNormalizer"; superClass() }.call()?.current()
184+
?.method { name = "getScale"; paramCount(4); superClass() }
185+
?.invoke<Float>(
186+
args.first { it is Drawable },
187+
args.first { it is RectF },
188+
null,
189+
null
190+
) ?: 0.92f
191+
args(args.indexOfFirst { it is FloatArray }).cast<FloatArray>()!![0] = scale
192+
val oriDrawable = args.first { it is Drawable } as Drawable
193+
val returnType = NewSystemUIHooker.Members.normalizeAndWrapToAdaptiveIcon.returnType
194+
result = if (returnType == AdaptiveIconDrawable::class.java)
195+
TransparentAdaptiveIconDrawable(oriDrawable)
196+
else
197+
oriDrawable
198+
}
199+
}
195200
}
196201
NewSystemUIHooker.Members.createIconBitmap_BaseIconFactory.addBeforeHook {
197202
args(0).cast<Drawable>()?.let { drawable ->

app/src/main/java/com/gswxxn/restoresplashscreen/ui/ConfigAppsActivity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.gswxxn.restoresplashscreen.ui
22

3-
import android.content.Context
43
import android.content.Intent
54
import android.content.res.Configuration
65
import android.text.Editable
@@ -130,11 +129,11 @@ class ConfigAppsActivity : BaseActivity<ActivityConfigAppsBinding>(), CoroutineS
130129
binding.searchEditText.apply {
131130
// 焦点事件
132131
setOnFocusChangeListener { v, hasFocus ->
133-
val imm = v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
132+
val imm = v.context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
134133
if (hasFocus) {
135134
showView(false, binding.appListTitle, binding.configDescription, binding.configTitleFilter, binding.overallSettings)
136135
// 弹出软键盘
137-
imm.showSoftInput(binding.searchEditText, InputMethodManager.SHOW_FORCED)
136+
imm.showSoftInput(binding.searchEditText, 0)
138137
} else {
139138
// 隐藏软键盘
140139
imm.hideSoftInputFromWindow(this.windowToken, 0)
@@ -162,7 +161,7 @@ class ConfigAppsActivity : BaseActivity<ActivityConfigAppsBinding>(), CoroutineS
162161
cView = holder.root
163162
cView.tag = holder
164163
} else {
165-
holder = cView?.tag as AdapterConfigBinding
164+
holder = cView.tag as AdapterConfigBinding
166165
}
167166
getItem(position).also { item ->
168167
// 设置图标

gradle/sweet-dependency/sweet-dependency-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ repositories:
2222

2323
plugins:
2424
com.android.application:
25-
version: 8.7.3
25+
version: 8.13.0
2626
org.jetbrains.kotlin.android:
27-
version: 2.1.0
27+
version: 2.1.21
2828
org.jetbrains.kotlin.plugin.serialization:
29-
version: 2.1.0
29+
version: 2.1.21
3030
com.google.devtools.ksp:
31-
version: 2.1.0-1.0.29
31+
version: 2.1.21-2.0.2
3232

3333
libraries:
3434
de.robv.android.xposed:
@@ -44,12 +44,12 @@ libraries:
4444
version: 1.0.0
4545
androidx.compose.material3:
4646
material3:
47-
version: 1.3.1
47+
version: 1.4.0
4848
org.jetbrains.kotlinx:
4949
kotlinx-coroutines-android:
50-
version: 1.9.0
50+
version: 1.10.2
5151
kotlinx-serialization-json:
52-
version: 1.7.3
52+
version: 1.9.0
5353
androidx.annotation:
5454
annotation:
5555
version: 1.9.1

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)