java: config: Limit clear keystore workaround for few affected apps
- To avoid side affects caused to unwanted apps that are added to target.txt Signed-off-by: Dakkshesh <beakthoven@gmail.com>
This commit is contained in:
@@ -41,7 +41,7 @@ private fun initializeInterceptors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearKeyStore() {
|
private fun clearKeyStore() {
|
||||||
val targetUIDs = PkgConfig.getTargetPackageUids()
|
val targetUIDs = PkgConfig.getKSClearPackageUids()
|
||||||
Logger.i("Clearing keystore for ${targetUIDs.size} target packages")
|
Logger.i("Clearing keystore for ${targetUIDs.size} target packages")
|
||||||
|
|
||||||
targetUIDs.forEach { uid ->
|
targetUIDs.forEach { uid ->
|
||||||
|
|||||||
@@ -180,17 +180,25 @@ object PkgConfig {
|
|||||||
return (hackPackages + generatePackages + packageModes.keys).toSet()
|
return (hackPackages + generatePackages + packageModes.keys).toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTargetPackageUids(): Set<Int> {
|
fun getKSClearPackageUids(): Set<Int> {
|
||||||
val result = mutableSetOf<Int>()
|
val uids = mutableSetOf<Int>()
|
||||||
val pm = getPm() ?: return emptySet()
|
val pm = getPm() ?: return emptySet()
|
||||||
val flags = if (Build.VERSION.SDK_INT >= 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
|
val userId = Process.myUid() / 100000
|
||||||
|
|
||||||
getTargetPackages().forEach { pkg ->
|
val detectorPackages = setOf(
|
||||||
|
"io.github.vvb2060.keyattestation",
|
||||||
|
"io.github.vvb2060.mahoshojo",
|
||||||
|
"io.github.qwq233.keyattestation"
|
||||||
|
)
|
||||||
|
|
||||||
|
val KeyStoreClearPackages = getTargetPackages().intersect(detectorPackages)
|
||||||
|
|
||||||
|
KeyStoreClearPackages.forEach { pkg ->
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
val appInfo = pm.getApplicationInfo(pkg, flags, userId)
|
val appInfo = pm.getApplicationInfo(pkg, flags, userId)
|
||||||
if (appInfo != null) {
|
if (appInfo != null) {
|
||||||
result.add(appInfo.uid)
|
uids.add(appInfo.uid)
|
||||||
Logger.d("Got UID ${appInfo.uid} for package: $pkg")
|
Logger.d("Got UID ${appInfo.uid} for package: $pkg")
|
||||||
} else {
|
} else {
|
||||||
Logger.e("ApplicationInfo is null for package: $pkg")
|
Logger.e("ApplicationInfo is null for package: $pkg")
|
||||||
@@ -200,7 +208,7 @@ object PkgConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return uids
|
||||||
}
|
}
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
|
|||||||
Reference in New Issue
Block a user