fix: Allow building on SystemUI

This commit is contained in:
Pun Butrach
2025-11-16 19:43:46 +07:00
parent 6f9db8c769
commit 3b3a49eebf
3 changed files with 15 additions and 23 deletions

View File

@@ -19,7 +19,6 @@ import android.graphics.Paint
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.view.forEach
import com.android.app.tracing.traceSection
import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener
import java.lang.ref.WeakReference
@@ -34,30 +33,22 @@ class DisableSubpixelTextTransitionListener(private val rootView: ViewGroup?) :
override fun onTransitionStarted() {
isTransitionInProgress = true
traceSection("subpixelFlagSetForTextView") {
traceSection("subpixelFlagTraverseHierarchy") {
getAllChildTextView(rootView, childrenTextViews)
}
traceSection("subpixelFlagDisableForTextView") {
childrenTextViews.forEach { child ->
val childTextView = child.get() ?: return@forEach
childTextView.paintFlags = childTextView.paintFlags or Paint.SUBPIXEL_TEXT_FLAG
}
}
getAllChildTextView(rootView, childrenTextViews)
childrenTextViews.forEach { child ->
val childTextView = child.get() ?: return@forEach
childTextView.paintFlags = childTextView.paintFlags or Paint.SUBPIXEL_TEXT_FLAG
}
}
override fun onTransitionFinished() {
if (!isTransitionInProgress) return
isTransitionInProgress = false
traceSection("subpixelFlagEnableForTextView") {
childrenTextViews.forEach { child ->
val childTextView = child.get() ?: return@forEach
childTextView.paintFlags =
childTextView.paintFlags and Paint.SUBPIXEL_TEXT_FLAG.inv()
}
childrenTextViews.clear()
childrenTextViews.forEach { child ->
val childTextView = child.get() ?: return@forEach
childTextView.paintFlags =
childTextView.paintFlags and Paint.SUBPIXEL_TEXT_FLAG.inv()
}
childrenTextViews.clear()
}
/**

View File

@@ -28,13 +28,13 @@ class UncaughtExceptionPreHandlerManager @Inject constructor() {
* Verifies that the global handler is set in Thread. If not, sets is up.
*/
private fun checkGlobalHandlerSetup() {
val currentHandler = Thread.getUncaughtExceptionPreHandler()
val currentHandler = Thread.getDefaultUncaughtExceptionHandler()
if (currentHandler != globalUncaughtExceptionPreHandler) {
if (currentHandler is GlobalUncaughtExceptionHandler) {
throw IllegalStateException("Two UncaughtExceptionPreHandlerManagers created")
}
currentHandler?.let { addHandler(it) }
Thread.setUncaughtExceptionPreHandler(globalUncaughtExceptionPreHandler)
Thread.setDefaultUncaughtExceptionHandler(globalUncaughtExceptionPreHandler)
}
}
@@ -68,4 +68,4 @@ class UncaughtExceptionPreHandlerManager @Inject constructor() {
handleUncaughtException(thread, throwable)
}
}
}
}

View File

@@ -18,7 +18,7 @@ import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
import android.os.Process
import com.android.systemui.dagger.qualifiers.Application
//import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dagger.qualifiers.UiBackground
import com.android.systemui.unfold.config.ResourceUnfoldTransitionConfig
@@ -98,7 +98,8 @@ abstract class SystemUnfoldSharedModule {
@Singleton
fun unfoldTrackingContext(
@UnfoldSingleThreadBg singleThreadBgExecutor: Executor,
@Application applicationScope: CoroutineScope,
// @Application
applicationScope: CoroutineScope,
): CoroutineScope {
// tracking depends on being executed on a single thread so when changing it, ensure all
// consumers are not accessing shared state