Refine code style
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user