Refine code style

This commit is contained in:
Mygod
2021-05-05 19:25:10 -04:00
parent 6f9225b9cc
commit cd2fdba3cd

View File

@@ -180,15 +180,13 @@ object TetheringManager {
service service
} }
private fun resolveSystemService(action: String): ResolveInfo? {
val result = app.packageManager.queryIntentServices(Intent(action), PackageManager.MATCH_SYSTEM_ONLY)
check(result.size <= 1) { "Multiple system services handle $action: ${result.joinToString()}" }
return result.firstOrNull()
}
@get:RequiresApi(30) @get:RequiresApi(30)
val resolvedService get() = sequence { val resolvedService get() = sequence {
resolveSystemService(TETHERING_CONNECTOR_CLASS + IN_PROCESS_SUFFIX)?.let { yield(it) } for (action in arrayOf(TETHERING_CONNECTOR_CLASS + IN_PROCESS_SUFFIX, TETHERING_CONNECTOR_CLASS)) {
resolveSystemService(TETHERING_CONNECTOR_CLASS)?.let { yield(it) } val result = app.packageManager.queryIntentServices(Intent(action), PackageManager.MATCH_SYSTEM_ONLY)
check(result.size <= 1) { "Multiple system services handle $action: ${result.joinToString()}" }
result.firstOrNull()?.let { yield(it) }
}
}.first() }.first()
@get:RequiresApi(24) @get:RequiresApi(24)