39 lines
954 B
Kotlin
39 lines
954 B
Kotlin
|
|
package com.hikoncont.util.adaptation
|
||
|
|
|
||
|
|
import com.hikoncont.util.DeviceDetector.DeviceBrand
|
||
|
|
import com.hikoncont.util.DeviceDetector.KeepAlivePolicy
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Device runtime fingerprint used by adaptation strategies.
|
||
|
|
*/
|
||
|
|
data class DeviceRuntimeInfo(
|
||
|
|
val brand: DeviceBrand,
|
||
|
|
val sdkInt: Int,
|
||
|
|
val brandRaw: String,
|
||
|
|
val manufacturerRaw: String,
|
||
|
|
val modelRaw: String,
|
||
|
|
val deviceRaw: String,
|
||
|
|
val productRaw: String
|
||
|
|
)
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Strategy interface for per-device adaptation.
|
||
|
|
*
|
||
|
|
* Keep this interface focused and stable so new ROM/model behavior can be
|
||
|
|
* plugged in by adding a strategy class instead of editing many call sites.
|
||
|
|
*/
|
||
|
|
interface DeviceAdaptationStrategy {
|
||
|
|
val id: String
|
||
|
|
val priority: Int
|
||
|
|
|
||
|
|
fun matches(info: DeviceRuntimeInfo): Boolean
|
||
|
|
|
||
|
|
fun keepAlivePolicy(info: DeviceRuntimeInfo): KeepAlivePolicy
|
||
|
|
}
|
||
|
|
|
||
|
|
data class StrategyResolution(
|
||
|
|
val strategyId: String,
|
||
|
|
val keepAlivePolicy: KeepAlivePolicy
|
||
|
|
)
|
||
|
|
|