11package app.revanced.manager.patcher.runtime.process
22
3+ import android.annotation.SuppressLint
34import android.app.ActivityThread
45import android.content.Context
56import android.content.Intent
7+ import android.os.Build
68import android.os.Bundle
79import android.os.Looper
810import app.revanced.manager.BuildConfig
@@ -95,6 +97,10 @@ class PatcherProcess(private val context: Context) : IPatcherProcess.Stub() {
9597 }
9698
9799 companion object {
100+ private val longArrayClass = LongArray ::class .java
101+ private val emptyLongArray = LongArray (0 )
102+
103+ @SuppressLint(" PrivateApi" )
98104 @JvmStatic
99105 fun main (args : Array <String >) {
100106 Looper .prepare()
@@ -105,6 +111,15 @@ class PatcherProcess(private val context: Context) : IPatcherProcess.Stub() {
105111 val systemContext = ActivityThread .systemMain().systemContext as Context
106112 val appContext = systemContext.createPackageContext(managerPackageName, 0 )
107113
114+ // Avoid annoying logs. See https://github.com/robolectric/robolectric/blob/ad0484c6b32c7d11176c711abeb3cb4a900f9258/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java#L376-L388
115+ Class .forName(" android.app.AppCompatCallbacks" ).apply {
116+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .VANILLA_ICE_CREAM ) {
117+ getDeclaredMethod(" install" , longArrayClass, longArrayClass).also { it.isAccessible = true }(null , emptyLongArray, emptyLongArray)
118+ } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
119+ getDeclaredMethod(" install" , longArrayClass).also { it.isAccessible = true }(null , emptyLongArray)
120+ }
121+ }
122+
108123 val ipcInterface = PatcherProcess (appContext)
109124
110125 appContext.sendBroadcast(Intent ().apply {
0 commit comments