1
1
package app.revanced.manager.patcher.runtime.process
2
2
3
+ import android.annotation.SuppressLint
3
4
import android.app.ActivityThread
4
5
import android.content.Context
5
6
import android.content.Intent
7
+ import android.os.Build
6
8
import android.os.Bundle
7
9
import android.os.Looper
8
10
import app.revanced.manager.BuildConfig
@@ -95,6 +97,10 @@ class PatcherProcess(private val context: Context) : IPatcherProcess.Stub() {
95
97
}
96
98
97
99
companion object {
100
+ private val longArrayClass = LongArray ::class .java
101
+ private val emptyLongArray = LongArray (0 )
102
+
103
+ @SuppressLint(" PrivateApi" )
98
104
@JvmStatic
99
105
fun main (args : Array <String >) {
100
106
Looper .prepare()
@@ -105,6 +111,15 @@ class PatcherProcess(private val context: Context) : IPatcherProcess.Stub() {
105
111
val systemContext = ActivityThread .systemMain().systemContext as Context
106
112
val appContext = systemContext.createPackageContext(managerPackageName, 0 )
107
113
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
+
108
123
val ipcInterface = PatcherProcess (appContext)
109
124
110
125
appContext.sendBroadcast(Intent ().apply {
0 commit comments