Created
November 7, 2020 01:36
-
-
Save Elvis10ten/d22a0654328fd2a1094bd80b4993a53b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val isConnected = bondSteadyState == PeripheralBond.State.CONNECTED | |
val hasPriority = priority != NO_PRIORITY | |
private val maxPossibleConnectionAndInteractiveScore = 4 + 2 | |
// Any device with a higher priority should always rank higher. | |
private val priorityScore = (maxPossibleConnectionAndInteractiveScore + 1.0).pow(priority) | |
private val connectionScore: Int get() { | |
// Connection should contribute more if we can't stream | |
val trueValue = if(canStreamData) 2 else 4 | |
return if(isConnected) trueValue else 1 | |
} | |
private val interactiveScore = if(owner.isInteractive) 2 else 1 | |
private val timestampScore = log10(timestamp.toDouble()) | |
internal val rank = priorityScore + connectionScore + interactiveScore + timestampScore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment