Fix crash on Android R beta 1

This commit is contained in:
Mygod
2020-03-02 09:58:58 +08:00
parent dfd4911597
commit 418618eecb

View File

@@ -37,16 +37,19 @@ class TetherTimeoutMonitor(private val context: Context, private val handler: Ha
private val enabled get() = Settings.Global.getInt(app.contentResolver, SOFT_AP_TIMEOUT_ENABLED, 1) == 1 private val enabled get() = Settings.Global.getInt(app.contentResolver, SOFT_AP_TIMEOUT_ENABLED, 1) == 1
private val timeout by lazy { private val timeout by lazy {
val delay = try {
app.resources.getInteger(Resources.getSystem().getIdentifier( app.resources.getInteger(Resources.getSystem().getIdentifier(
"config_wifi_framework_soft_ap_timeout_delay", "integer", "android")).let { delay -> "config_wifi_framework_soft_ap_timeout_delay", "integer", "android"))
} catch (e: Resources.NotFoundException) {
Timber.w(e)
MIN_SOFT_AP_TIMEOUT_DELAY_MS
}
if (delay < MIN_SOFT_AP_TIMEOUT_DELAY_MS) { if (delay < MIN_SOFT_AP_TIMEOUT_DELAY_MS) {
Timber.w( Timber.w("Overriding timeout delay with minimum limit value: $delay < $MIN_SOFT_AP_TIMEOUT_DELAY_MS")
"Overriding timeout delay with minimum limit value: $delay < $MIN_SOFT_AP_TIMEOUT_DELAY_MS")
MIN_SOFT_AP_TIMEOUT_DELAY_MS MIN_SOFT_AP_TIMEOUT_DELAY_MS
} else delay } else delay
} }
} }
}
private var charging = when (context.registerReceiver(null, intentFilter(Intent.ACTION_BATTERY_CHANGED)) private var charging = when (context.registerReceiver(null, intentFilter(Intent.ACTION_BATTERY_CHANGED))
?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)) { ?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)) {