diff --git a/.idea/misc.xml b/.idea/misc.xml index 991a888..cdbd289 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/java/io/github/beakthoven/TrickyStoreOSS/config/Config.kt b/app/src/main/java/io/github/beakthoven/TrickyStoreOSS/config/Config.kt index 3d66492..127359e 100644 --- a/app/src/main/java/io/github/beakthoven/TrickyStoreOSS/config/Config.kt +++ b/app/src/main/java/io/github/beakthoven/TrickyStoreOSS/config/Config.kt @@ -6,6 +6,7 @@ package io.github.beakthoven.TrickyStoreOSS.config import android.content.pm.IPackageManager +import android.os.Build import android.os.FileObserver import android.os.IBinder import android.os.IInterface @@ -182,7 +183,7 @@ object PkgConfig { fun getTargetPackageUids(): Set { val result = mutableSetOf() val pm = getPm() ?: return emptySet() - val flags = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) 0L else 0 + val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) 0L else 0 val userId = Process.myUid() / 100000 getTargetPackages().forEach { pkg -> @@ -240,15 +241,21 @@ object PkgConfig { } private fun waitAndGetSystemService(name: String): IBinder? { - var tryCount = 0 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + return ServiceManager.waitForService(name) + } + var tryCount = 0 while (tryCount++ < 70) { val service = ServiceManager.getService(name) - if (service != null) return service - Logger.e("Package manager is null, waiting for 500ms") + if (service != null) { + Logger.d("Got $name service after $tryCount tries") + return service + } Thread.sleep(500) } + Logger.e("Failed to get $name service") return null } } diff --git a/stub/src/main/java/android/os/ServiceManager.java b/stub/src/main/java/android/os/ServiceManager.java index ede73ea..1465e76 100644 --- a/stub/src/main/java/android/os/ServiceManager.java +++ b/stub/src/main/java/android/os/ServiceManager.java @@ -7,18 +7,22 @@ package android.os; public class ServiceManager { public static IBinder getService(String name) { - throw new UnsupportedOperationException("STUB!"); + throw new UnsupportedOperationException(""); + } + + public static IBinder waitForService(String name) { + throw new UnsupportedOperationException(""); } public static void addService(String name, IBinder binder) { - throw new UnsupportedOperationException("STUB!"); + throw new UnsupportedOperationException(""); } public static IBinder checkService(String name) { - throw new UnsupportedOperationException("STUB!"); + throw new UnsupportedOperationException(""); } public static String[] listServices() { - throw new UnsupportedOperationException("STUB!"); + throw new UnsupportedOperationException(""); } }